xbps_pkg_exec_buffer: chdir to rootdir before creating fd.

This commit is contained in:
Juan RP 2012-11-19 14:59:42 +01:00
parent 0edba07106
commit 4f9ff2746e

View File

@ -60,6 +60,12 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
fpath = strdup(".xbps-script-XXXXXX"); fpath = strdup(".xbps-script-XXXXXX");
} }
/* change cwd to rootdir to exec the script */
if (chdir(xhp->rootdir) == -1) {
rv = errno;
goto out;
}
/* Create temp file to run script */ /* Create temp file to run script */
if ((fd = mkstemp(fpath)) == -1) { if ((fd = mkstemp(fpath)) == -1) {
xbps_dbg_printf(xhp, "%s: mkstemp %s\n", xbps_dbg_printf(xhp, "%s: mkstemp %s\n",
@ -80,12 +86,6 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
fdatasync(fd); fdatasync(fd);
close(fd); close(fd);
/* change cwd to rootdir to exec the script */
if (chdir(xhp->rootdir) == -1) {
rv = errno;
goto out;
}
/* exec script */ /* exec script */
rv = xbps_file_exec(xhp, fpath, action, pkgname, version, rv = xbps_file_exec(xhp, fpath, action, pkgname, version,
update ? "yes" : "no", update ? "yes" : "no",