mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
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>
This commit is contained in:
parent
0223a028e0
commit
693ebbd16b
@ -344,6 +344,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
|
||||
char scriptfn[PATH_MAX];
|
||||
char cmdline[PATH_MAX];
|
||||
char tmpdir[PATH_MAX];
|
||||
char *argv[] = { "sh", "-c", cmdline, NULL };
|
||||
char *scriptpath;
|
||||
int clean_tmpdir = 0;
|
||||
int retval = 0;
|
||||
@ -401,7 +402,9 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
|
||||
scriptpath, script, ver);
|
||||
}
|
||||
|
||||
retval = _alpm_run_chroot(root, cmdline);
|
||||
_alpm_log(PM_LOG_DEBUG, "executing \"%s\"\n", cmdline);
|
||||
|
||||
retval = _alpm_run_chroot(root, "/bin/sh", argv);
|
||||
|
||||
cleanup:
|
||||
if(clean_tmpdir && _alpm_rmrf(tmpdir)) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn)
|
||||
int _alpm_unpack(const char *archive, const char *prefix, alpm_list_t *list, int breakfirst);
|
||||
int _alpm_rmrf(const char *path);
|
||||
int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args);
|
||||
int _alpm_run_chroot(const char *root, const char *cmd);
|
||||
int _alpm_run_chroot(const char *root, const char *path, char *const argv[]);
|
||||
int _alpm_ldconfig(const char *root);
|
||||
int _alpm_str_cmp(const void *s1, const void *s2);
|
||||
char *_alpm_filecache_find(const char *filename);
|
||||
|
Loading…
Reference in New Issue
Block a user