diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-02-26 17:09:35 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-02-26 18:19:27 +1100 |
commit | b0b857d6ca842fb516b3330a11e0d6d78f35aded (patch) | |
tree | 0cf05ddaedb52df0211cbe2583298b86e745a1fd /lib | |
parent | 336ebeabad687dd81c87e0ac01e68853e15f27b1 (diff) | |
download | samba-b0b857d6ca842fb516b3330a11e0d6d78f35aded.tar.gz samba-b0b857d6ca842fb516b3330a11e0d6d78f35aded.tar.bz2 samba-b0b857d6ca842fb516b3330a11e0d6d78f35aded.zip |
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)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/util.h | 2 | ||||
-rw-r--r-- | lib/util/util_runcmd.c | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/util/util.h b/lib/util/util.h index 01831fc826..e1608a8ac4 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -890,7 +890,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, ...); #endif /* _SAMBA_UTIL_H_ */ 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; |