alpm: Don't chroot() to "/"
chroot() requires CAP_SYS_CHROOT. If the caller has put us in the right root directory already, don't call chroot(). This allows running pacman in a containerized environment without CAP_SYS_CHROOT.
This commit is contained in:
parent
917b67f5d1
commit
e9b385a636
1 changed files with 3 additions and 1 deletions
|
@ -655,7 +655,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use fprintf instead of _alpm_log to send output through the parent */
|
/* use fprintf instead of _alpm_log to send output through the parent */
|
||||||
if(chroot(handle->root) != 0) {
|
/* don't chroot() to "/": this allows running with less caps when the
|
||||||
|
* caller puts us in the right root */
|
||||||
|
if(strcmp(handle->root, "/") != 0 && chroot(handle->root) != 0) {
|
||||||
fprintf(stderr, _("could not change the root directory (%s)\n"), strerror(errno));
|
fprintf(stderr, _("could not change the root directory (%s)\n"), strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue