Commit 8a4371cc authored by Timo Teräs's avatar Timo Teräs

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.
parent 000dfd92
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment