From 20127e732c66897506449c38baff9ec1a893032c Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 15 Nov 2013 20:54:27 +1000 Subject: Close file descirptor before fork FreeBSD chroot(2) fails with EPERM when a directory file descriptor is open with either `kern.chroot_allow_open_directories` being 0, or when the process already is inside a chroot. This is exposed in alpm_run_chroot that uses opendir() to open a file descriptor to the current directory before doing the forking and chrooting. Since the file descriptor is not used in the forked process, we close it. Fixes FS#36161. Signed-off-by: Allan McRae --- lib/libalpm/util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index f9fdb018..40a5ebd7 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -542,6 +542,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) while(dup2(pipefd[1], 2) == -1 && errno == EINTR); close(pipefd[0]); close(pipefd[1]); + close(cwdfd); /* use fprintf instead of _alpm_log to send output through the parent */ if(chroot(handle->root) != 0) { -- cgit v1.2.3-24-g4f1b