Imported from pacman-2.9.7.tar.gz
This commit is contained in:
parent
de98f7004e
commit
1bcc87c3fe
1 changed files with 27 additions and 7 deletions
28
src/pacman.c
28
src/pacman.c
|
@ -110,6 +110,7 @@ PMList *pm_targets = NULL;
|
||||||
FILE *logfd = NULL;
|
FILE *logfd = NULL;
|
||||||
char *lckfile = "/tmp/pacman.lck";
|
char *lckfile = "/tmp/pacman.lck";
|
||||||
char *workfile = NULL;
|
char *workfile = NULL;
|
||||||
|
char *chrootbin = NULL;
|
||||||
enum {READ_ONLY, READ_WRITE} pm_access;
|
enum {READ_ONLY, READ_WRITE} pm_access;
|
||||||
int maxcols = 80;
|
int maxcols = 80;
|
||||||
int neednl = 0; /* for cleaner message output */
|
int neednl = 0; /* for cleaner message output */
|
||||||
|
@ -150,6 +151,21 @@ int main(int argc, char *argv[])
|
||||||
return(ret);
|
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 */
|
/* see if we're root or not */
|
||||||
myuid = geteuid();
|
myuid = geteuid();
|
||||||
if(!myuid && getenv("FAKEROOTKEY")) {
|
if(!myuid && getenv("FAKEROOTKEY")) {
|
||||||
|
@ -3361,6 +3377,10 @@ int runscriptlet(char *installfn, char *script, char *ver, char *oldver)
|
||||||
/* not found */
|
/* not found */
|
||||||
return(0);
|
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")) {
|
if(!strcmp(script, "pre_upgrade") || !strcmp(script, "pre_install")) {
|
||||||
snprintf(tmpdir, PATH_MAX, "%stmp/", pmo_root);
|
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);
|
vprint("Executing %s script...\n", script);
|
||||||
if(oldver) {
|
if(oldver) {
|
||||||
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | /usr/sbin/chroot %s /bin/bash",
|
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | %s %s /bin/bash",
|
||||||
scriptpath, script, ver, oldver, pmo_root);
|
scriptpath, script, ver, oldver, chrootbin, pmo_root);
|
||||||
} else {
|
} else {
|
||||||
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s\" | /usr/sbin/chroot %s /bin/bash",
|
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s\" | %s %s /bin/bash",
|
||||||
scriptpath, script, ver, pmo_root);
|
scriptpath, script, ver, chrootbin, pmo_root);
|
||||||
}
|
}
|
||||||
vprint("%s\n", cmdline);
|
vprint("%s\n", cmdline);
|
||||||
system(cmdline);
|
system(cmdline);
|
||||||
|
|
Loading…
Add table
Reference in a new issue