summaryrefslogtreecommitdiff
path: root/src/app_add.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app_add.c')
-rw-r--r--src/app_add.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/app_add.c b/src/app_add.c
index 8b0ed1a..f5edae0 100644
--- a/src/app_add.c
+++ b/src/app_add.c
@@ -20,6 +20,7 @@
struct add_ctx {
const char *virtpkg;
unsigned short solver_flags;
+ unsigned short extract_flags;
};
static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int optch, const char *optarg)
@@ -30,6 +31,9 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt
case 0x10000:
dbopts->open_flags |= APK_OPENF_CREATE;
break;
+ case 0x10001:
+ actx->extract_flags |= APK_EXTRACTF_NO_CHOWN;
+ break;
case 'u':
actx->solver_flags |= APK_SOLVERF_UPGRADE;
break;
@@ -47,6 +51,7 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt
static const struct apk_option options_applet[] = {
{ 0x10000, "initdb" },
+ { 0x10001, "no-chown" },
{ 'u', "upgrade" },
{ 'l', "latest" },
{ 't', "virtual", required_argument, "NAME" },
@@ -118,6 +123,9 @@ static int add_main(void *ctx, struct apk_database *db, struct apk_string_array
apk_dependency_array_copy(&world, db->world);
+ if (getuid() != 0 || (actx->extract_flags & APK_EXTRACTF_NO_CHOWN))
+ db->extract_flags |= APK_EXTRACTF_NO_CHOWN;
+
if (actx->virtpkg) {
apk_blob_t b = APK_BLOB_STR(actx->virtpkg);
apk_blob_pull_dep(&b, db, &virtdep);