diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-08-11 17:56:24 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-08-11 17:56:24 +0300 |
commit | 5d19789a3b29d70ebfdbe18ac9c363390ff9eda9 (patch) | |
tree | 30222b5f1c8f3d9c6a1b1f36f901b12c8fd824c1 /src/package.c | |
parent | 1011c4e3462ec1694af75d3a4d54730c7aa1e142 (diff) | |
download | apk-tools-5d19789a3b29d70ebfdbe18ac9c363390ff9eda9.tar.gz apk-tools-5d19789a3b29d70ebfdbe18ac9c363390ff9eda9.tar.bz2 apk-tools-5d19789a3b29d70ebfdbe18ac9c363390ff9eda9.tar.xz apk-tools-5d19789a3b29d70ebfdbe18ac9c363390ff9eda9.zip |
pkg, db: execute scripts from /var/cache/misc (fixes #129)
Diffstat (limited to 'src/package.c')
-rw-r--r-- | src/package.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/package.c b/src/package.c index 3123834..33d6519 100644 --- a/src/package.c +++ b/src/package.c @@ -847,17 +847,22 @@ int apk_pkg_run_script(struct apk_package *pkg, int root_fd, if (script->type != type) continue; - snprintf(fn, sizeof(fn), "tmp/%s-%s.%s", + /* Avoid /tmp as it can be mounted noexec */ + snprintf(fn, sizeof(fn), "var/cache/misc/%s-%s.%s", pkg->name->name, pkg->version, apk_script_types[type]); - fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC, 0777); - if (fd < 0) - return fd; + fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC, 0755); + if (fd < 0) { + mkdirat(root_fd, "var/cache/misc", 0755); + fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC, 0755); + if (fd < 0) + return -errno; + } write(fd, script->script, script->size); close(fd); - apk_message("Executing %s", &fn[4]); + apk_message("Executing %s", &fn[15]); pid = fork(); if (pid == -1) |