From f2e41a488e51a973015719625947183416056e26 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Fri, 10 Feb 2012 15:58:35 +0200 Subject: db: fix directory permissions recalculation --- src/database.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/database.c b/src/database.c index cb7428f..1ced84f 100644 --- a/src/database.c +++ b/src/database.c @@ -239,24 +239,27 @@ static void apk_db_dir_unref(struct apk_database *db, struct apk_db_dir *dir, if (dir->refs > 0) { if (allow_rmdir) { dir->flags |= APK_DBDIRF_RECALC_MODE; + dir->mode = 0; + dir->uid = (uid_t) -1; + dir->gid = (gid_t) -1; } return; } - if ((allow_rmdir == APK_DISALLOW_RMDIR) && - (dir->flags & APK_DBDIRF_RECALC_MODE)) { - apk_db_dir_mkdir(db, dir); - } - db->installed.stats.dirs--; if (allow_rmdir) { + /* The final instance of this directory was removed, + * so this directory gets deleted in reality too. */ dir->flags &= ~APK_DBDIRF_RECALC_MODE; dir->mode = 0; dir->uid = (uid_t) -1; dir->gid = (gid_t) -1; unlinkat(db->root_fd, dir->name, AT_REMOVEDIR); + } else if (dir->flags & APK_DBDIRF_RECALC_MODE) { + /* Directory permissions need a reset. */ + apk_db_dir_mkdir(db, dir); } if (dir->parent != NULL) -- cgit v1.2.3-70-g09d2