diff options
author | Timo Teras <timo.teras@iki.fi> | 2008-04-22 08:16:26 +0000 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2008-04-22 08:16:26 +0000 |
commit | 219a1b2ee8f4c3c2caf57e79bcb9780e32da7155 (patch) | |
tree | 0a4d20d18de572e5eba37138ca5176fee051d981 /src/package.c | |
parent | 384c2f1d94282ff5564a5f6c5ab9e51c975f83a6 (diff) | |
download | apk-tools-219a1b2ee8f4c3c2caf57e79bcb9780e32da7155.tar.gz apk-tools-219a1b2ee8f4c3c2caf57e79bcb9780e32da7155.tar.bz2 apk-tools-219a1b2ee8f4c3c2caf57e79bcb9780e32da7155.tar.xz apk-tools-219a1b2ee8f4c3c2caf57e79bcb9780e32da7155.zip |
Overwriting of bb files, apk_create (from old apk-tools), chdir changes,
other stuff.
Diffstat (limited to 'src/package.c')
-rw-r--r-- | src/package.c | 16 |
1 files changed, 10 insertions, 6 deletions
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; |