diff options
author | Paul Spooren <mail@aparcar.org> | 2021-12-18 17:42:13 +0100 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-12-29 09:50:50 +0200 |
commit | f2a595913960a5a68806d4e32f1b849bfdce6933 (patch) | |
tree | e792233983fddbabf9e1b73f133542bcfb4e91f9 /src/database.c | |
parent | 2da3f347d8851f6344ea6dba47676e488084debf (diff) | |
download | apk-tools-f2a595913960a5a68806d4e32f1b849bfdce6933.tar.gz apk-tools-f2a595913960a5a68806d4e32f1b849bfdce6933.tar.bz2 apk-tools-f2a595913960a5a68806d4e32f1b849bfdce6933.tar.xz apk-tools-f2a595913960a5a68806d4e32f1b849bfdce6933.zip |
apk: add --preserve-env option
This options is useful for (post)install scripts to run with the same
environment variables as apk is executed.
[TT: minor stylistic changes]
Signed-off-by: Paul Spooren <mail@aparcar.org>
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c index be7a0a1..b0c00aa 100644 --- a/src/database.c +++ b/src/database.c @@ -1873,7 +1873,7 @@ int apk_db_run_script(struct apk_database *db, char *fn, char **argv) struct apk_out *out = &db->ctx->out; int status; pid_t pid; - static char * const environment[] = { + static char * const clean_environment[] = { "PATH=/usr/sbin:/usr/bin:/sbin:/bin", NULL }; @@ -1896,7 +1896,7 @@ int apk_db_run_script(struct apk_database *db, char *fn, char **argv) exit(127); } - execve(fn, argv, environment); + execve(fn, argv, (db->ctx->flags & APK_PRESERVE_ENV) ? environ : clean_environment); exit(127); /* should not get here */ } while (waitpid(pid, &status, 0) < 0 && errno == EINTR); |