[5/8] btrfs-progs: utils: Fallback to open without O_NOATIME flag in find_mount_root():
diff mbox series

Message ID 97ed64c94563e960eb3443bcbc164ce167662e2e.1543294426.git.misono.tomohiro@jp.fujitsu.com
State New
Headers show
  • btrfs-progs: sub: Relax the privileges of "subvolume list/show"
Related show

Commit Message

Misono Tomohiro Nov. 27, 2018, 5:24 a.m. UTC
O_NOATIME flag requires effective UID of process matches file's owner
or has CAP_FOWNER capabilities. Fallback to open without O_NOATIME flag
so that non-privileged user can also call find_mount_root().

This is a preparation work to allow non-privileged user to call
"subvolume show".

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
 utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff mbox series

diff --git a/utils.c b/utils.c
index 3a4bc92a..8ce8417d 100644
--- a/utils.c
+++ b/utils.c
@@ -2054,6 +2054,9 @@  int find_mount_root(const char *path, char **mount_root)
 	char *longest_match = NULL;
 	fd = open(path, O_RDONLY | O_NOATIME);
+	if (fd < 0 && errno == EPERM)
+		fd = open(path, O_RDONLY);
 	if (fd < 0)
 		return -errno;