Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
d987c5da
Unverified
Commit
d987c5da
authored
Dec 13, 2017
by
Stéphane Graber
Committed by
GitHub
Dec 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2022 from 3XX0/exec-run-script
conf: avoid spawning unnecessary subshells
parents
5875fa24
6d1a5f93
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
conf.c
src/lxc/conf.c
+6
-4
No files found.
src/lxc/conf.c
View file @
d987c5da
...
@@ -355,10 +355,11 @@ static int run_script_argv(const char *name, const char *section,
...
@@ -355,10 +355,11 @@ static int run_script_argv(const char *name, const char *section,
size
+=
strlen
(
hook
)
+
1
;
size
+=
strlen
(
hook
)
+
1
;
size
+=
strlen
(
"exec"
);
size
+=
strlen
(
script
);
size
+=
strlen
(
script
);
size
+=
strlen
(
name
);
size
+=
strlen
(
name
);
size
+=
strlen
(
section
);
size
+=
strlen
(
section
);
size
+=
3
;
size
+=
4
;
if
(
size
>
INT_MAX
)
if
(
size
>
INT_MAX
)
return
-
1
;
return
-
1
;
...
@@ -370,7 +371,7 @@ static int run_script_argv(const char *name, const char *section,
...
@@ -370,7 +371,7 @@ static int run_script_argv(const char *name, const char *section,
}
}
ret
=
ret
=
snprintf
(
buffer
,
size
,
"%s %s %s %s"
,
script
,
name
,
section
,
hook
);
snprintf
(
buffer
,
size
,
"
exec
%s %s %s %s"
,
script
,
name
,
section
,
hook
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
size
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
size
)
{
ERROR
(
"Script name too long."
);
ERROR
(
"Script name too long."
);
return
-
1
;
return
-
1
;
...
@@ -405,10 +406,11 @@ int run_script(const char *name, const char *section, const char *script, ...)
...
@@ -405,10 +406,11 @@ int run_script(const char *name, const char *section, const char *script, ...)
size
+=
strlen
(
p
)
+
1
;
size
+=
strlen
(
p
)
+
1
;
va_end
(
ap
);
va_end
(
ap
);
size
+=
strlen
(
"exec"
);
size
+=
strlen
(
script
);
size
+=
strlen
(
script
);
size
+=
strlen
(
name
);
size
+=
strlen
(
name
);
size
+=
strlen
(
section
);
size
+=
strlen
(
section
);
size
+=
3
;
size
+=
4
;
if
(
size
>
INT_MAX
)
if
(
size
>
INT_MAX
)
return
-
1
;
return
-
1
;
...
@@ -419,7 +421,7 @@ int run_script(const char *name, const char *section, const char *script, ...)
...
@@ -419,7 +421,7 @@ int run_script(const char *name, const char *section, const char *script, ...)
return
-
1
;
return
-
1
;
}
}
ret
=
snprintf
(
buffer
,
size
,
"%s %s %s"
,
script
,
name
,
section
);
ret
=
snprintf
(
buffer
,
size
,
"
exec
%s %s %s"
,
script
,
name
,
section
);
if
(
ret
<
0
||
ret
>=
size
)
{
if
(
ret
<
0
||
ret
>=
size
)
{
ERROR
(
"Script name too long."
);
ERROR
(
"Script name too long."
);
return
-
1
;
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment