Commit 5d19789a authored by Timo Teräs's avatar Timo Teräs

pkg, db: execute scripts from /var/cache/misc (fixes #129)

parent 1011c4e3
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment