]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: avoid spawning unnecessary subshells
authorJonathan Calmels <jcalmels@nvidia.com>
Mon, 11 Dec 2017 22:43:06 +0000 (14:43 -0800)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 12:34:55 +0000 (13:34 +0100)
Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
src/lxc/conf.c

index 2f0d05ed58da89e8095e07a6a4b151bd2b14abe9..f8084475c0637335c17d2e8a942dcf393a8b0046 100644 (file)
@@ -353,10 +353,11 @@ static int run_script_argv(const char *name, const char *section,
 
        size += strlen(hook) + 1;
 
+       size += strlen("exec");
        size += strlen(script);
        size += strlen(name);
        size += strlen(section);
-       size += 3;
+       size += 4;
 
        if (size > INT_MAX)
                return -1;
@@ -368,7 +369,7 @@ static int run_script_argv(const char *name, const char *section,
        }
 
        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) {
                ERROR("Script name too long.");
                return -1;
@@ -403,10 +404,11 @@ int run_script(const char *name, const char *section, const char *script, ...)
                size += strlen(p) + 1;
        va_end(ap);
 
+       size += strlen("exec");
        size += strlen(script);
        size += strlen(name);
        size += strlen(section);
-       size += 3;
+       size += 4;
 
        if (size > INT_MAX)
                return -1;
@@ -417,7 +419,7 @@ int run_script(const char *name, const char *section, const char *script, ...)
                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) {
                ERROR("Script name too long.");
                return -1;