All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 08/11] btrfs-progs: utils: Fallback to open without O_NOATIME flag in find_mount_root():
Date: Fri, 11 May 2018 16:29:46 +0900	[thread overview]
Message-ID: <20180511072949.15269-9-misono.tomohiro@jp.fujitsu.com> (raw)
In-Reply-To: <20180511072949.15269-1-misono.tomohiro@jp.fujitsu.com>

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: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
---
 utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/utils.c b/utils.c
index d81d4980..84b81311 100644
--- a/utils.c
+++ b/utils.c
@@ -2048,6 +2048,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;
 	close(fd);
-- 
2.14.3



  parent reply	other threads:[~2018-05-11  7:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11  7:29 [PATCH 00/11] btrfs-progs: Rework of "subvolume list/show" and relax the root privileges of them Tomohiro Misono
2018-05-11  7:29 ` [PATCH 01/11] btrfs-progs: ioctl/libbtrfsutil: Add 3 definitions of new unprivileged ioctl Tomohiro Misono
2018-05-11  7:29 ` [PATCH 02/11] btrfs-progs: libbtrfsutil: Factor out btrfs_util_subvolume_info_fd() Tomohiro Misono
2018-05-11  7:29 ` [PATCH 03/11] btrfs-porgs: libbtrfsutil: Relax the privileges of util_subvolume_info() Tomohiro Misono
2018-05-11  7:29 ` [PATCH 04/11] btrfs-progs: libbtrfsuitl: Factor out btrfs_util_subvolume_iterator_next() Tomohiro Misono
2018-05-11  7:29 ` [PATCH 05/11] btrfs-progs: libbtrfsutil: Update the behavior of subvolume iterator and relax the privileges Tomohiro Misono
2018-05-11  7:29 ` [PATCH 06/11] btrfs-progs: sub list: Use libbtrfsuitl for subvolume list Tomohiro Misono
2018-05-11  7:29 ` [PATCH 07/11] btrfs-progs: sub list: Change the default behavior of "subvolume list" and allow non-privileged user to call it Tomohiro Misono
2018-05-11  7:29 ` Tomohiro Misono [this message]
2018-05-11  7:29 ` [PATCH 09/11] btrfs-progs: sub show: Allow non-privileged user to call "subvolume show" Tomohiro Misono
2018-05-11  7:29 ` [PATCH 10/11] btrfs-progs: test: Add helper function to check if test user exists Tomohiro Misono
2018-05-11  7:29 ` [PATCH 11/11] btrfs-porgs: test: Add cli-test/009 to check subvolume list for both root and normal user Tomohiro Misono

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180511072949.15269-9-misono.tomohiro@jp.fujitsu.com \
    --to=misono.tomohiro@jp.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.