From 8a4371ccd73e8f8672466881bd3b782de919cd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Tue, 4 Sep 2012 10:38:13 +0300 Subject: [PATCH] db: remove AT_SYMLINK_NOFOLLOW for directory permissions fchmodat does not support this flag - symlinks do not have permissions. Sysadmin probably does not expect us to not follow symlinks either: if /var -> /mnt/foo/var, we should be making sure the permissions and ownership is correct on the target directory, not on the symlink. Since fchmodat never returned ENOENT with AT_SYMLINK_NOFOLLOW, this also fixes directory re-creation if it does not exist. fixes #1348. --- src/database.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database.c b/src/database.c index efff29f..d1a8f1a 100644 --- a/src/database.c +++ b/src/database.c @@ -229,11 +229,11 @@ static void apk_db_dir_mkdir(struct apk_database *db, struct apk_db_dir *dir) return; if ((dir->refs == 1) || - (fchmodat(db->root_fd, dir->name, dir->mode, AT_SYMLINK_NOFOLLOW) != 0 && + (fchmodat(db->root_fd, dir->name, dir->mode, 0) != 0 && errno == ENOENT)) if ((mkdirat(db->root_fd, dir->name, dir->mode) != 0 && errno == EEXIST)) - if (fchmodat(db->root_fd, dir->name, dir->mode, AT_SYMLINK_NOFOLLOW) != 0) + if (fchmodat(db->root_fd, dir->name, dir->mode, 0) != 0) ; if (fchownat(db->root_fd, dir->name, dir->uid, dir->gid, 0) != 0) -- 1.7.12