lib/: spdx license conversion
[xfstests-dev.git] / tests / generic / 396
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Google, Inc.  All Rights Reserved.
4 #
5 # FS QA Test generic/396
6 #
7 # Test that FS_IOC_SET_ENCRYPTION_POLICY correctly validates the fscrypt_policy
8 # structure that userspace passes to it.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/encrypt
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34 _supported_fs generic
35 _supported_os Linux
36 _require_scratch_encryption
37 _require_xfs_io_command "set_encpolicy"
38
39 _scratch_mkfs_encrypted &>> $seqres.full
40 _scratch_mount
41 dir=$SCRATCH_MNT/dir
42 mkdir $dir
43
44 echo -e "\n*** Invalid contents encryption mode ***"
45 $XFS_IO_PROG -c "set_encpolicy -c 0xFF" $dir |& _filter_scratch
46
47 echo -e "\n*** Invalid filenames encryption mode ***"
48 $XFS_IO_PROG -c "set_encpolicy -n 0xFF" $dir |& _filter_scratch
49
50 echo -e "\n*** Invalid flags ***"
51 $XFS_IO_PROG -c "set_encpolicy -f 0xFF" $dir |& _filter_scratch
52
53 echo -e "\n*** Invalid policy version ***"
54 $XFS_IO_PROG -c "set_encpolicy -v 0xFF" $dir |& _filter_scratch
55
56 # Currently, the only supported combination of modes is AES-256-XTS for contents
57 # and AES-256-CTS for filenames.  Nothing else should be accepted.
58 echo -e "\n*** Invalid combinations of modes ***"
59 $XFS_IO_PROG -c "set_encpolicy -c AES-256-CTS -n AES-256-CTS" $dir |& _filter_scratch
60 $XFS_IO_PROG -c "set_encpolicy -c AES-256-CTS -n AES-256-XTS" $dir |& _filter_scratch
61 $XFS_IO_PROG -c "set_encpolicy -c AES-256-XTS -n AES-256-XTS" $dir |& _filter_scratch
62
63 # success, all done
64 status=0
65 exit