tests: remove udf/101
[xfstests-dev.git] / tests / generic / 419
1 #! /bin/bash
2 # FS QA Test generic/419
3 #
4 # Try to rename files in an encrypted directory, without access to the
5 # encryption key.  This should fail with ENOKEY.  Test both a regular rename and
6 # a cross rename.  This is a regression test for:
7 #       173b8439e1ba ("ext4: don't allow encrypted operations without keys")
8 #       363fa4e078cb ("f2fs: don't allow encrypted operations without keys")
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2017 Google, Inc.  All Rights Reserved.
12 #
13 # Author: Eric Biggers <ebiggers@google.com>
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #-----------------------------------------------------------------------
28 #
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41         cd /
42         rm -f $tmp.*
43 }
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48 . ./common/encrypt
49 . ./common/renameat2
50
51 # remove previous $seqres.full before test
52 rm -f $seqres.full
53
54 # real QA test starts here
55 _supported_fs generic
56 _supported_os Linux
57 _require_scratch_encryption
58 _require_xfs_io_command "set_encpolicy"
59 _require_command "$KEYCTL_PROG" keyctl
60 _requires_renameat2
61
62 _new_session_keyring
63
64 _scratch_mkfs_encrypted &>> $seqres.full
65 _scratch_mount
66
67 mkdir $SCRATCH_MNT/edir
68 keydesc=$(_generate_encryption_key)
69 $XFS_IO_PROG -c "set_encpolicy $keydesc" $SCRATCH_MNT/edir
70 echo a > $SCRATCH_MNT/edir/a
71 echo b > $SCRATCH_MNT/edir/b
72 _unlink_encryption_key $keydesc
73 _scratch_cycle_mount
74
75 # Note that because encrypted filenames are unpredictable, this needs to be
76 # written in a way that does not assume any particular filenames.
77 efile1=$(find $SCRATCH_MNT/edir -maxdepth 1 -type f | head -1)
78 efile2=$(find $SCRATCH_MNT/edir -maxdepth 1 -type f | tail -1)
79 mv $efile1 $efile2 |& _filter_scratch | sed 's|edir/[a-zA-Z0-9+,_]\+|edir/FILENAME|g'
80 src/renameat2 -x $efile1 $efile2
81
82 # success, all done
83 status=0
84 exit