diff options
author | Christian Brauner <brauner@kernel.org> | 2022-01-07 15:58:17 +0100 |
---|---|---|
committer | Eryu Guan <guaneryu@gmail.com> | 2022-01-16 12:20:03 +0800 |
commit | 7edd45acf142e11db0a5e2ac5d7794a14a7323b5 (patch) | |
tree | a37fde106ed81e82fa8689716ae7cbf3289ecb49 | |
parent | b3c31bd3ab60b630feb779fee454545dc47c7306 (diff) | |
download | xfstests-dev-7edd45acf142e11db0a5e2ac5d7794a14a7323b5.tar.gz |
idmapped-mounts: add more explanations to setgid tests
The explanations before were a bit thin and people not familiar with
setgid inheritance might get confused. Make it easier to understand the
tests.
Cc: Seth Forshee <sforshee@digitalocean.com>
Cc: Eryu Guan <guaneryu@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: fstests@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r-- | src/idmapped-mounts/idmapped-mounts.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c index 56b26b0ce2..c53e194207 100644 --- a/src/idmapped-mounts/idmapped-mounts.c +++ b/src/idmapped-mounts/idmapped-mounts.c @@ -8128,6 +8128,14 @@ static int setgid_create_idmapped_in_userns(void) if (wait_for_pid(pid)) goto out; + /* + * Below we verify that setgid inheritance for a newly created file or + * directory works correctly. As part of this we need to verify that + * newly created files or directories inherit their gid from their + * parent directory. So we change the parent directorie's gid to 1000 + * and create a file with fs{g,u}id 0 and verify that the newly created + * file and directory inherit gid 1000, not 0. + */ if (fchownat(t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) { log_stderr("failure: fchownat"); goto out; @@ -8172,12 +8180,19 @@ static int setgid_create_idmapped_in_userns(void) die("failure: is_setgid"); } - /* Files and directories created in setgid directories inherit - * the i_gid of the parent directory. + /* + * In setgid directories newly created files always inherit the + * gid from the parent directory. Verify that the file is owned + * by gid 1000, not by gid 0. */ if (!expected_uid_gid(open_tree_fd, FILE1, 0, 0, 1000)) die("failure: check ownership"); + /* + * In setgid directories newly created directories always + * inherit the gid from the parent directory. Verify that the + * directory is owned by gid 1000, not by gid 0. + */ if (!expected_uid_gid(open_tree_fd, DIR1, 0, 0, 1000)) die("failure: check ownership"); |