generic/402: Drop useless fail message
[xfstests-dev.git] / tests / generic / 317
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2013 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 317
6 #
7 # Check uid/gid to/from disk with a user namespace. A new file
8 # will be created from inside a userns. We check that the uid/gid
9 # is correct from both inside the userns and also from init_user_ns.
10 # We will then unmount and remount the file system and check the
11 # uid/gid from both inside the userns and from init_user_ns to show
12 # that the correct uid was flushed and brought back from disk.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21
22 _cleanup()
23 {
24     cd /
25     _scratch_unmount >/dev/null 2>&1
26 }
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/attr
33
34 file=$SCRATCH_MNT/file1
35
36 # real QA test starts here
37 _supported_fs generic
38 # only Linux supports user namespace
39
40 [ -x $lstat64 ] || _notrun "$lstat64 executable not found"
41
42 rm -f $seqres.full
43
44 _require_scratch
45 _require_user
46 _require_ugid_map
47 _require_userns
48 qa_user_id=`id -u $qa_user`
49
50 _filter_output()
51 {
52     sed \
53       -e "s/$qa_user_id/qa_user/g" \
54       -e "s!$SCRATCH_MNT!\$SCRATCH_MNT!"
55 }
56
57 _print_numeric_uid()
58 {
59     echo "From init_user_ns"
60     $here/src/lstat64 $file |head -3 |_filter_output
61
62     echo "From user_ns"
63     # don't use $here/src/lstat64, as we're running cmd(src/lstat64) in
64     # nsexec as a regular user, and $here may contain path component that
65     # a regular user doesn't have search permission
66     $here/src/nsexec -s -U -M "0 $qa_user_id 1000" -G "0 $qa_user_id 1000" src/lstat64 $file |head -3 |_filter_output
67 }
68
69 _scratch_unmount >/dev/null 2>&1
70 echo "*** MKFS ***" >>$seqres.full
71 echo ""             >>$seqres.full
72 _scratch_mkfs       >>$seqres.full 2>&1 || _fail "mkfs failed"
73 _scratch_mount
74 chmod 777 $SCRATCH_MNT
75
76 # create $file as "root" in userns, which is $qa_user in parent namespace
77 $here/src/nsexec -s -U -M "0 $qa_user_id 1000" -G "0 $qa_user_id 1000" touch $file
78
79 _print_numeric_uid
80
81 echo ""
82 echo "*** Remounting ***"
83 echo ""
84 sync
85 _scratch_cycle_mount      >>$seqres.full 2>&1 || _fail "remount failed"
86
87 _print_numeric_uid
88
89 _scratch_unmount >/dev/null 2>&1
90 status=0
91 exit