#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2016 Google, Inc. All Rights Reserved.
+#
# FS QA Test generic/397
#
# Test accessing encrypted files and directories, both with and without the
# need to run all the xfstests with encryption enabled. Access without the
# encryption key, on the other hand, should result in some particular behaviors.
#
-#-----------------------------------------------------------------------
-# Copyright (c) 2016 Google, Inc. All Rights Reserved.
-#
-# Author: Eric Biggers <ebiggers@google.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#-----------------------------------------------------------------------
-#
-
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
# real QA test starts here
_supported_fs generic
_supported_os Linux
+_require_symlinks
_require_scratch_encryption
-_require_xfs_io_command "set_encpolicy"
_require_command "$KEYCTL_PROG" keyctl
_new_session_keyring
_scratch_mount
mkdir $SCRATCH_MNT/edir $SCRATCH_MNT/ref_dir
-keydesc=$(_generate_encryption_key)
-$XFS_IO_PROG -c "set_encpolicy $keydesc" $SCRATCH_MNT/edir
+keydesc=$(_generate_session_encryption_key)
+_set_encpolicy $SCRATCH_MNT/edir $keydesc
for dir in $SCRATCH_MNT/edir $SCRATCH_MNT/ref_dir; do
touch $dir/empty > /dev/null
$XFS_IO_PROG -t -f -c "pwrite 0 4k" $dir/a > /dev/null
-e 's/Operation not permitted/Required key not available/'
}
-_unlink_encryption_key $keydesc
+_unlink_session_encryption_key $keydesc
_scratch_cycle_mount
# Check that unencrypted names aren't there