4 # Check uid/gid to/from disk with a user namespace. A new file
5 # will be created from inside a userns. We check that the uid/gid
6 # is correct from both inside the userns and also from init_user_ns.
7 # We will then unmount and remount the file system and check the
8 # uid/gid from both inside the userns and from init_user_ns to show
9 # that the correct uid was flushed and brought back from disk.
11 #-----------------------------------------------------------------------
12 # Copyright (C) 2013 Oracle, Inc. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
40 _scratch_unmount >/dev/null 2>&1
42 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
49 file=$SCRATCH_MNT/file1
51 # real QA test starts here
53 # only Linux supports user namespace
56 [ -x $lstat64 ] || _notrun "$lstat64 executable not found"
64 qa_user_id=`grep $qa_user /etc/passwd |awk -F: '{print $3}'`
69 -e "s/$qa_user_id/qa_user/g" \
70 -e "s!$SCRATCH_MNT!\$SCRATCH_MNT!"
75 echo "From init_user_ns"
76 src/lstat64 $file |head -3 |_filter_output
79 src/nsexec -s -U -M "0 $qa_user_id 1000" -G "0 $qa_user_id 1000" src/lstat64 $file |head -3 |_filter_output
82 _scratch_unmount >/dev/null 2>&1
83 echo "*** MKFS ***" >>$seqres.full
84 echo "" >>$seqres.full
85 _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
86 _scratch_mount >>$seqres.full 2>&1 || _fail "mount failed"
87 chmod 777 $SCRATCH_MNT
89 # create $file as "root" in userns, which is $qa_user in parent namespace
90 src/nsexec -s -U -M "0 $qa_user_id 1000" -G "0 $qa_user_id 1000" touch $file
95 echo "*** Remounting ***"
98 _scratch_cycle_mount >>$seqres.full 2>&1 || _fail "remount failed"
102 _scratch_unmount >/dev/null 2>&1