diff options
author | Judd Vinet <judd@archlinux.org> | 2005-09-16 20:22:02 +0200 |
---|---|---|
committer | Judd Vinet <judd@archlinux.org> | 2005-09-16 20:22:02 +0200 |
commit | 1bcc87c3feb41dc8004c3d600e3a3501a4060b44 (patch) | |
tree | 8eae71e1b514045a317feec0742f3b0bfa6c3c42 | |
parent | de98f7004e712ae422af4a567c7df26c4579b0d6 (diff) | |
download | pacman-1bcc87c3feb41dc8004c3d600e3a3501a4060b44.tar.gz pacman-1bcc87c3feb41dc8004c3d600e3a3501a4060b44.tar.xz |
Imported from pacman-2.9.7.tar.gz
-rw-r--r-- | src/pacman.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/pacman.c b/src/pacman.c index acd70566..53c9d85c 100644 --- a/src/pacman.c +++ b/src/pacman.c @@ -107,9 +107,10 @@ PMList *pm_packages = NULL; /* list of targets specified on command line */ PMList *pm_targets = NULL; -FILE *logfd = NULL; -char *lckfile = "/tmp/pacman.lck"; -char *workfile = NULL; +FILE *logfd = NULL; +char *lckfile = "/tmp/pacman.lck"; +char *workfile = NULL; +char *chrootbin = NULL; enum {READ_ONLY, READ_WRITE} pm_access; int maxcols = 80; int neednl = 0; /* for cleaner message output */ @@ -150,6 +151,21 @@ int main(int argc, char *argv[]) return(ret); } + /* look for the chroot binary */ + if(!chrootbin) { + struct stat buf; + /* the install initrd (busybox) places chroot in /usr/bin, so + * have to accomodate. + */ + if(!stat("/usr/sbin/chroot", &buf)) { + chrootbin = strdup("/usr/sbin/chroot"); + } else if(!stat("/usr/bin/chroot", &buf)) { + chrootbin = strdup("/usr/bin/chroot"); + } else { + fprintf(stderr, "warning: cannot find chroot binary - unable to run scriptlets\n"); + } + } + /* see if we're root or not */ myuid = geteuid(); if(!myuid && getenv("FAKEROOTKEY")) { @@ -3361,6 +3377,10 @@ int runscriptlet(char *installfn, char *script, char *ver, char *oldver) /* not found */ return(0); } + if(!chrootbin) { + fprintf(stderr, "warning: cannot find chroot binary - unable to run scriptlet\n"); + return(0); + } if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) { snprintf(tmpdir, PATH_MAX, "%stmp/", pmo_root); @@ -3397,11 +3417,11 @@ int runscriptlet(char *installfn, char *script, char *ver, char *oldver) vprint("Executing %s script...\n", script); if(oldver) { - snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | /usr/sbin/chroot %s /bin/bash", - scriptpath, script, ver, oldver, pmo_root); + snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | %s %s /bin/bash", + scriptpath, script, ver, oldver, chrootbin, pmo_root); } else { - snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s\" | /usr/sbin/chroot %s /bin/bash", - scriptpath, script, ver, pmo_root); + snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s\" | %s %s /bin/bash", + scriptpath, script, ver, chrootbin, pmo_root); } vprint("%s\n", cmdline); system(cmdline); |