add comments at top of idmap-test.sh
authoraburford <andrew.burford@stonybrook.edu>
Sun, 15 May 2022 00:33:55 +0000 (20:33 -0400)
committeraburford <andrew.burford@stonybrook.edu>
Sun, 15 May 2022 00:33:55 +0000 (20:33 -0400)
idmap-tests/idmap-test.sh

index 40359fb28477ecd376d7e896c6899a1fd2b74654..1f40db8e8ae737617fd4bd820d37f6c591c6dc3a 100755 (executable)
@@ -1,10 +1,21 @@
 #!/bin/sh
-# XXX: fill in
+#
+# This script creates an idmapped mount of an ext4 file system and tries to
+# stack wrapfs on top of it. It creates a third user called luser if they do
+# not exist and sets the following idmap:
+#      root -> ubuntu
+#      ubuntu -> luser
+#      luser -> root
+# Files are created belonging to each user on the original mount of the ext4
+# filesystem. They should show up as different users on the id mapped mount and
+# also on the wrapfs mount if wrapfs correctly supports idmapped mounts on the
+# lower fs.
 
 SCRATCH_DEV=/dev/sdb
 SCRATCH_DIR=/n/scratch
 LOWER_DIR=/n/lower
 TMP_DIR=/n/tmp
+TMP_DIR=/n/tmp
 FS_TYPE=ext4
 
 function runcmd
@@ -19,6 +30,10 @@ function runcmd
     fi
 }
 
+if ! id luser &>/dev/null; then
+       runcmd adduser --disabled-password -q --gecos luser luser
+fi
+
 dirs="$TMP_DIR $LOWER_DIR $SCRATCH_DIR"
 for d in $dirs; do
        echo checking dir $d
@@ -37,7 +52,10 @@ runcmd touch $SCRATCH_DIR/luser
 runcmd chown luser $SCRATCH_DIR/luser
 ls1=$(ls -l $SCRATCH_DIR)
 
-runcmd ./mount-idmapped --map-mount b:0:1000:1 --map-mount b:1000:1001:1 --map-mount b:1001:0:1 $SCRATCH_DIR $LOWER_DIR
+ubuntu=$(id -u ubuntu)
+luser=$(id -u luser)
+
+runcmd ./mount-idmapped --map-mount b:0:$ubuntu:1 --map-mount b:$ubuntu:$luser:1 --map-mount b:$luser:0:1 $SCRATCH_DIR $LOWER_DIR
 runcmd mount -t wrapfs $LOWER_DIR $TMP_DIR
 if test $ret != 32; then
        echo wrapfs returned unexpected error: $ret