From 219a1b2ee8f4c3c2caf57e79bcb9780e32da7155 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Tue, 22 Apr 2008 08:16:26 +0000 Subject: Overwriting of bb files, apk_create (from old apk-tools), chdir changes, other stuff. --- src/package.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/package.c') diff --git a/src/package.c b/src/package.c index 04ec2be..5cde906 100644 --- a/src/package.c +++ b/src/package.c @@ -320,15 +320,20 @@ int apk_pkg_add_script(struct apk_package *pkg, int fd, return r; } -int apk_pkg_run_script(struct apk_package *pkg, const char *root, +int apk_pkg_run_script(struct apk_package *pkg, int root_fd, unsigned int type) { + static const char * const environment[] = { + "PATH=/usr/sbin:/usr/bin:/sbin:/bin", + NULL + }; struct apk_script *script; struct hlist_node *c; int fd, status; pid_t pid; char fn[1024]; + fchdir(root_fd); hlist_for_each_entry(script, c, &pkg->scripts, script_list) { if (script->type != type) continue; @@ -349,14 +354,13 @@ int apk_pkg_run_script(struct apk_package *pkg, const char *root, if (pid == -1) return -1; if (pid == 0) { - chroot(root); - fn[2] = '.'; - execl(&fn[2], script_types[script->type], - pkg->version, "", NULL); + chroot("."); + execle(fn, script_types[script->type], + pkg->version, "", NULL, environment); exit(1); } waitpid(pid, &status, 0); - unlink(fn); + //unlink(fn); if (WIFEXITED(status)) return WEXITSTATUS(status); return -1; -- cgit v1.2.3-60-g2f50