summaryrefslogtreecommitdiffstats
path: root/main/apk-tools/0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch
blob: f3554419b5f0e85afc19ff20f5a160d57dec01c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From 8a4371ccd73e8f8672466881bd3b782de919cd93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
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