summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-04-22 08:16:26 +0000
committerTimo Teras <timo.teras@iki.fi>2008-04-22 08:16:26 +0000
commit219a1b2ee8f4c3c2caf57e79bcb9780e32da7155 (patch)
tree0a4d20d18de572e5eba37138ca5176fee051d981 /src/package.c
parent384c2f1d94282ff5564a5f6c5ab9e51c975f83a6 (diff)
downloadapk-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.c16
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;