diff options
author | Jonathan Conder <j@skurvy.no-ip.org> | 2010-08-19 00:07:21 +1200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-08-27 11:19:15 -0500 |
commit | 693ebbd16bc1560ec3ec166d9944e44583141259 (patch) | |
tree | e7359349ae7cf41c4d296b64208053ff1eafcb05 /lib/libalpm/util.c | |
parent | 0223a028e0835b6e09e2654e62ce5fd462370ffb (diff) | |
download | pacman-693ebbd16bc1560ec3ec166d9944e44583141259.tar.xz |
use execv to avoid using sh just to run ldconfig
Signed-off-by: Jonathan Conder <j@skurvy.no-ip.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r-- | lib/libalpm/util.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 46460f0b..8a1f3924 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -452,7 +452,7 @@ int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) return(ret); } -int _alpm_run_chroot(const char *root, const char *cmd) +int _alpm_run_chroot(const char *root, const char *path, char *const argv[]) { char cwd[PATH_MAX]; pid_t pid; @@ -475,7 +475,7 @@ int _alpm_run_chroot(const char *root, const char *cmd) goto cleanup; } - _alpm_log(PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n", cmd, root); + _alpm_log(PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n", path, root); /* Flush open fds before fork() to avoid cloning buffers */ fflush(NULL); @@ -513,8 +513,8 @@ int _alpm_run_chroot(const char *root, const char *cmd) exit(1); } umask(0022); - execl("/bin/sh", "sh", "-c", cmd, (char *) NULL); - fprintf(stderr, _("call to execl failed (%s)\n"), strerror(errno)); + execv(path, argv); + fprintf(stderr, _("call to execv failed (%s)\n"), strerror(errno)); exit(1); } else { /* this code runs for the parent only (wait on the child) */ @@ -578,7 +578,8 @@ int _alpm_ldconfig(const char *root) if(access(line, F_OK) == 0) { snprintf(line, PATH_MAX, "%ssbin/ldconfig", root); if(access(line, X_OK) == 0) { - _alpm_run_chroot(root, "/sbin/ldconfig"); + char *argv[] = { "ldconfig", NULL }; + _alpm_run_chroot(root, "/sbin/ldconfig", argv); } } |