aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-10-04 16:56:07 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-10-04 16:56:07 +0300
commit8f0938a056b3ccfc5b6971d9637e2188e639d8a3 (patch)
tree707805178715845165ac989d97538c07e6262d9f /src
parent806a476190fb78135769e8a8ef217082ee724255 (diff)
package: remove package script after use (fixes #7974)
this is a regression introduced in commit 349c61c9 ("add support for pre and post commit hooks")
Diffstat (limited to 'src')
-rw-r--r--src/package.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/package.c b/src/package.c
index 4582b10..be7f269 100644
--- a/src/package.c
+++ b/src/package.c
@@ -1018,21 +1018,24 @@ void apk_ipkg_run_script(struct apk_installed_package *ipkg,
if (fd < 0) {
mkdirat(root_fd, "var/cache/misc", 0755);
fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0755);
- if (fd < 0)
- goto error;
+ if (fd < 0) goto err_log;
}
if (write(fd, ipkg->script[type].ptr, ipkg->script[type].len) < 0) {
close(fd);
- goto error;
+ goto err_log;
}
close(fd);
if (apk_db_run_script(db, fn, argv) < 0)
- ipkg->broken_script = 1;
- return;
-error:
+ goto err;
+ goto cleanup;
+
+err_log:
apk_error("%s: failed to execute: %s", &fn[15], apk_error_str(errno));
+err:
ipkg->broken_script = 1;
+cleanup:
+ unlinkat(root_fd, fn, 0);
}
static int parse_index_line(void *ctx, apk_blob_t line)