From b0b857d6ca842fb516b3330a11e0d6d78f35aded Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 26 Feb 2010 17:09:35 +1100 Subject: s4-dns: use a loadparm list for samba_runcmd() commands This allows commands with multiple arguments and quoting to be used, while still avoiding running a shell (and this having shell expansion problems) --- lib/util/util_runcmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/util/util_runcmd.c') diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c index 80574c4400..dea3ff91b1 100644 --- a/lib/util/util_runcmd.c +++ b/lib/util/util_runcmd.c @@ -154,7 +154,7 @@ struct composite_context *samba_runcmd(struct tevent_context *ev, struct timeval timeout, int stdout_log_level, int stderr_log_level, - const char *arg0, ...) + const char **argv0, ...) { struct samba_runcmd *r; int p1[2], p2[2]; @@ -174,7 +174,7 @@ struct composite_context *samba_runcmd(struct tevent_context *ev, r->stdout_log_level = stdout_log_level; r->stderr_log_level = stderr_log_level; - r->arg0 = talloc_strdup(r, arg0); + r->arg0 = talloc_strdup(r, argv0[0]); if (composite_nomem(r->arg0, c)) return c; if (pipe(p1) != 0) { @@ -228,13 +228,13 @@ struct composite_context *samba_runcmd(struct tevent_context *ev, dup2(p1[1], 1); dup2(p2[1], 2); - argv = str_list_make_single(r, r->arg0); + argv = str_list_copy(r, argv0); if (!argv) { fprintf(stderr, "Out of memory in child\n"); _exit(255); } - va_start(ap, arg0); + va_start(ap, argv0); while (1) { char *arg = va_arg(ap, char *); if (arg == NULL) break; @@ -246,7 +246,7 @@ struct composite_context *samba_runcmd(struct tevent_context *ev, } va_end(ap); - ret = execv(arg0, argv); + ret = execv(r->arg0, argv); fprintf(stderr, "Failed to exec child - %s\n", strerror(errno)); _exit(255); return NULL; -- cgit