fix newuidmap testcase
sleep 2s before running newxidmap - it seems we were sometimes racing, causing newxidmap to fail. Make sure to remove /tmp/test-xidmap, for some reason they were sometimes still there, causing test to fail. Fix some irregular tabbing. Signed-off-by: Serge Hallyn <serge@hallyn.com>
This commit is contained in:
		@@ -25,22 +25,24 @@ sysctl -q kernel.unprivileged_userns_clone=1
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
echo -n "Create world writable tmp directory... "
 | 
			
		||||
rm -rf /tmp/test-gidmap
 | 
			
		||||
mkdir -m 0777 /tmp/test-gidmap
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
echo -n "setup gidmapping... "
 | 
			
		||||
base=$(id -g foo)
 | 
			
		||||
runuser foo -g foo -c "unshare -U sleep 10 & pid=\$!; \
 | 
			
		||||
        newgidmap \$pid 0 1000 1 1 1000000 1000; ret=\$?; \
 | 
			
		||||
	cat /proc/\$pid/gid_map >/tmp/test-gidmap/gid_map;
 | 
			
		||||
        sleep 2; newgidmap \$pid 0 $base 1 1 1000000 1000; ret=\$?; \
 | 
			
		||||
        cat /proc/\$pid/gid_map >/tmp/test-gidmap/gid_map;
 | 
			
		||||
        kill \$pid; exit \$ret"
 | 
			
		||||
../../common/compare_file.pl /tmp/test-gidmap/gid_map data/gid_map
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
echo -n "Try to setup gidmapping with different primary group... "
 | 
			
		||||
runuser foo -g bar -c "unshare -U sleep 10 & pid=\$!; \
 | 
			
		||||
        newgidmap \$pid 0 1001 1 1 1000000 1000 2>/tmp/test-gidmap/newgidmap.err; ret=\$?; \
 | 
			
		||||
        sleep 2; newgidmap \$pid 0 $base 1 1 1000000 1000 2>/tmp/test-gidmap/newgidmap.err; ret=\$?; \
 | 
			
		||||
        kill \$pid; exit \$ret" && exit 1 || {
 | 
			
		||||
	status=$?
 | 
			
		||||
        status=$?
 | 
			
		||||
}
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,21 +23,36 @@ change_config
 | 
			
		||||
sysctl -q kernel.unprivileged_userns_clone=1
 | 
			
		||||
 | 
			
		||||
echo -n "Create world writable tmp directory..."
 | 
			
		||||
rm -rf /tmp/test-gidmap
 | 
			
		||||
mkdir -m 0777 /tmp/test-gidmap
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
echo -n "setup gidmapping... "
 | 
			
		||||
base=$(id -g foo)
 | 
			
		||||
runuser foo -g foo -c "unshare -U sleep 10 & pid=\$!; \
 | 
			
		||||
        newgidmap \$pid 0 1000 1 1 1000000 1000; ret=\$?; \
 | 
			
		||||
	cat /proc/\$pid/gid_map >/tmp/test-gidmap/gid_map;
 | 
			
		||||
        sleep 2s; newgidmap \$pid 0 $base 1 1 1000000 1000; ret=\$?; \
 | 
			
		||||
        cat /proc/\$pid/gid_map >/tmp/test-gidmap/gid_map;
 | 
			
		||||
        kill \$pid; exit \$ret"
 | 
			
		||||
../../common/compare_file.pl /tmp/test-gidmap/gid_map data/gid_map
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
# This next test should fail if setgroups on the ns is not
 | 
			
		||||
# USERNS_SETGROUPS_ALLOWED ("allow")
 | 
			
		||||
# TODO let's figure out what to do about this.  For now skip
 | 
			
		||||
# that test.
 | 
			
		||||
log_status "$0" "SUCCESS"
 | 
			
		||||
 | 
			
		||||
sysctl -q kernel.unprivileged_userns_clone=$unpriv_userns
 | 
			
		||||
rm -rf /tmp/test-gidmap;
 | 
			
		||||
 | 
			
		||||
restore_config
 | 
			
		||||
trap '' 0
 | 
			
		||||
exit 0
 | 
			
		||||
 | 
			
		||||
echo -n "setup gidmapping with different primary group... "
 | 
			
		||||
runuser foo -g bar -c "unshare -U sleep 10 & pid=\$!; \
 | 
			
		||||
        newgidmap \$pid 0 1001 1 1 1000000 1000; ret=\$?; \
 | 
			
		||||
	cat /proc/\$pid/gid_map >/tmp/test-gidmap/gid_map;
 | 
			
		||||
        sleep 2s; newgidmap \$pid 0 $base 1 1 1000000 1000; ret=\$?; \
 | 
			
		||||
        cat /proc/\$pid/gid_map >/tmp/test-gidmap/gid_map;
 | 
			
		||||
        kill \$pid; exit \$ret"
 | 
			
		||||
../../common/compare_file.pl /tmp/test-gidmap/gid_map data/gid_map.bar
 | 
			
		||||
echo "OK"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user