FS/XFS testing framework
 help / color / mirror / Atom feed
From: Gabriel Niebler <gniebler@suse.com>
To: fstests@vger.kernel.org
Cc: Gabriel Niebler <gniebler@suse.com>
Subject: [PATCH] common: Do not chown ro mountpoint when creating idmapped mount
Date: Fri,  3 Feb 2023 15:35:45 +0100	[thread overview]
Message-ID: <20230203143545.23689-1-gniebler@suse.com> (raw)

The function _idmapped_mount tries to change the ownership of the mountpoint
for which it aims to create an idmapped mount, to ensure that the mapped UID
and GID can actually create objects within it. Some tests set up a read-only
mount, however, which lets the chown call fail. This patch fixes the
function to check whether the mount is read-only and skip the chown, if so.

Signed-off-by: Gabriel Niebler <gniebler@suse.com>
---
 common/rc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index 81ce1026..19ab8062 100644
--- a/common/rc
+++ b/common/rc
@@ -414,8 +414,11 @@ _idmapped_mount()
 
 	# We create an idmapped mount where {g,u}id 0 writes to disk as
 	# {g,u}id 10000000 and $(id -u fsgqa) + 10000000. We change ownership
-        # of $mnt so {g,u} id 0 can actually create objects in there.
-	chown 10000000:10000000 $mnt || return 1
+	# of $mnt, provided it's not read-only, so {g,u} id 0 can actually
+	# create objects in there.
+	if [[ "$mount_rec" != *"ro,"* && "$mount_rec" != *",ro"* ]]; then
+		chown 10000000:10000000 $mnt || return 1
+	fi
 	$here/src/vfs/mount-idmapped \
 		--map-mount b:10000000:0:100000000000 \
 		$mnt $tmp
-- 
2.39.1


             reply	other threads:[~2023-02-03 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 14:35 Gabriel Niebler [this message]
2023-02-03 17:54 ` [PATCH] common: Chown mount even if already idmapped to account for remounts Gabriel Niebler
2023-02-06 14:53   ` Christian Brauner
2023-02-06 14:51 ` [PATCH] common: Do not chown ro mountpoint when creating idmapped mount Christian Brauner

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=20230203143545.23689-1-gniebler@suse.com \
    --to=gniebler@suse.com \
    --cc=fstests@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox