summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/database.c2
-rw-r--r--src/package.c15
2 files changed, 12 insertions, 5 deletions
diff --git a/src/database.c b/src/database.c
index a6669c3..e66cbf8 100644
--- a/src/database.c
+++ b/src/database.c
@@ -862,6 +862,8 @@ static int apk_db_create(struct apk_database *db)
mkdirat(db->root_fd, "var", 0755);
mkdirat(db->root_fd, "var/lib", 0755);
mkdirat(db->root_fd, "var/lib/apk", 0755);
+ mkdirat(db->root_fd, "var/cache", 0755);
+ mkdirat(db->root_fd, "var/cache/misc", 0755);
fd = openat(db->root_fd, "var/lib/apk/world", O_CREAT|O_RDWR|O_TRUNC, 0644);
if (fd < 0)
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)