[lxc-devel] [lxc/master] conf: avoid spwaning unnecessary subshells
3XX0 on Github
lxc-bot at linuxcontainers.org
Mon Dec 11 22:56:36 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 456 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171211/25d503b9/attachment.bin>
-------------- next part --------------
From 4e29a8bd996fbf32bc389ea4c5c2b9abf32a4c1e Mon Sep 17 00:00:00 2001
From: Jonathan Calmels <jcalmels at nvidia.com>
Date: Mon, 11 Dec 2017 14:43:06 -0800
Subject: [PATCH] conf: avoid spwaning unnecessary subshells
Signed-off-by: Jonathan Calmels <jcalmels at nvidia.com>
---
src/lxc/conf.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 6a452064b..db8282aa8 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -355,10 +355,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;
@@ -370,7 +371,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;
@@ -405,10 +406,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;
@@ -419,7 +421,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;
More information about the lxc-devel
mailing list