diff options
author | Timo Teräs <timo.teras@iki.fi> | 2012-02-10 16:40:01 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2012-02-10 16:40:01 +0200 |
commit | 9ac8d8710229315b2e481fb99cec3ebc1852ea4f (patch) | |
tree | 6834c58328909995222651b1fed9824ad93d7efd /src/fix.c | |
parent | f2e41a488e51a973015719625947183416056e26 (diff) | |
download | apk-tools-9ac8d8710229315b2e481fb99cec3ebc1852ea4f.tar.gz apk-tools-9ac8d8710229315b2e481fb99cec3ebc1852ea4f.tar.bz2 apk-tools-9ac8d8710229315b2e481fb99cec3ebc1852ea4f.tar.xz apk-tools-9ac8d8710229315b2e481fb99cec3ebc1852ea4f.zip |
db, fix: more secure way to choose effective directory permissions
And implement --directory-permissions for fix-applet to reset all
directory uid, gid and modes.
Diffstat (limited to 'src/fix.c')
-rw-r--r-- | src/fix.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -21,6 +21,7 @@ struct fix_ctx { unsigned short solver_flags; int fix_depends : 1; + int fix_directory_permissions : 1; }; static int fix_parse(void *pctx, struct apk_db_options *dbopts, @@ -37,12 +38,22 @@ static int fix_parse(void *pctx, struct apk_db_options *dbopts, case 'r': ctx->solver_flags |= APK_SOLVERF_REINSTALL; break; + case 0x10000: + ctx->fix_directory_permissions = 1; + break; default: return -1; } return 0; } +static int mark_recalculate(apk_hash_item item, void *ctx) +{ + struct apk_db_dir *dir = (struct apk_db_dir *) item; + dir->flags |= APK_DBDIRF_RECALC_MODE; + return 0; +} + static int fix_main(void *pctx, struct apk_database *db, int argc, char **argv) { struct fix_ctx *ctx = (struct fix_ctx *) pctx; @@ -53,6 +64,9 @@ static int fix_main(void *pctx, struct apk_database *db, int argc, char **argv) if (!ctx->solver_flags) ctx->solver_flags = APK_SOLVERF_REINSTALL; + if (ctx->fix_directory_permissions) + apk_hash_foreach(&db->installed.dirs, mark_recalculate, db); + for (i = 0; i < argc; i++) { pkg = NULL; if (strstr(argv[i], ".apk") != NULL) { @@ -95,6 +109,7 @@ static struct apk_option fix_options[] = { { 'd', "depends", "Fix all dependencies too" }, { 'u', "upgrade", "Upgrade package if possible" }, { 'r', "reinstall", "Reinstall the package" }, + { 0x10000, "directory-permissions", "Reset all directory permissions" }, }; static struct apk_applet apk_fix = { |