1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23. $STF_SUITE/tests/functional/idmap_mount/idmap_mount_common.kshlib 24 25# 26# 27# DESCRIPTION: 28# Test uid and gid of files in idmapped folder are mapped correctly 29# 30# 31# STRATEGY: 32# 1. Create files/folder owned by $UID1 and $GID1 under "idmap_test" 33# 2. Idmap the folder to "idmap_dest" 34# 3. Verify the owner of files/folder under "idmap_dest" 35# 36 37verify_runnable "global" 38 39export WORKDIR=$TESTDIR/idmap_test 40export IDMAPDIR=$TESTDIR/idmap_dest 41 42function cleanup 43{ 44 log_must rm -rf $WORKDIR 45 if mountpoint $IDMAPDIR; then 46 log_must umount $IDMAPDIR 47 fi 48 log_must rm -rf $IDMAPDIR 49} 50 51log_onexit cleanup 52 53if ! idmap_util -c $TESTDIR; then 54 log_unsupported "Idmap mount not supported." 55fi 56 57log_must mkdir -p $WORKDIR 58log_must mkdir -p $IDMAPDIR 59log_must touch $WORKDIR/file1 60log_must mkdir $WORKDIR/subdir 61log_must ln -s $WORKDIR/file1 $WORKDIR/file1_sym 62log_must ln $WORKDIR/file1 $WORKDIR/subdir/file1_hard 63log_must touch $WORKDIR/subdir/file2 64log_must chown -R $UID1:$GID1 $WORKDIR 65log_must chown $UID2:$GID2 $WORKDIR/subdir/file2 66 67log_must idmap_util -m "u:${UID1}:${UID2}:1" -m "g:${GID1}:${GID2}:1" $WORKDIR $IDMAPDIR 68 69log_must test "$UID2 $GID2" = "$(stat -c '%u %g' $IDMAPDIR/file1)" 70log_must test "$UID2 $GID2" = "$(stat -c '%u %g' $IDMAPDIR/file1_sym)" 71log_must test "$UID2 $GID2" = "$(stat -c '%u %g' $IDMAPDIR/subdir)" 72log_must test "$UID2 $GID2" = "$(stat -c '%u %g' $IDMAPDIR/subdir/file1_hard)" 73log_mustnot test "$UID2 $GID2" = "$(stat -c '%u %g' $IDMAPDIR/subdir/file2)" 74 75log_pass "Owner verification of entries under idmapped folder is successful." 76 77