5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2017 Datto, Inc. All rights reserved.
21 . $STF_SUITE/include/libtest.shlib
22 . $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib
26 # 'zfs load-key -L' should override keylocation with provided value.
29 # 1. Create a key file
30 # 2. Copy the key file to another location
31 # 3. Create an encrypted dataset using the keyfile
32 # 4. Unmount the dataset and unload its key
33 # 5. Attempt to load the dataset specifying a keylocation of file
34 # 6. Verify the key is loaded
35 # 7. Verify the keylocation is the original key file
36 # 8. Unload the dataset's key
37 # 9. Attempt to load the dataset specifying a keylocation of prompt
38 # 10. Verify the key is loaded
39 # 11. Verify the keylocation is the original key file
42 verify_runnable "both"
46 datasetexists $TESTPOOL/$TESTFS1 && \
47 log_must zfs destroy $TESTPOOL/$TESTFS1
51 log_assert "'zfs load-key -L' should override keylocation with provided value"
53 typeset key_location="/$TESTPOOL/pkey1"
55 log_must eval "echo $PASSPHRASE > $key_location"
56 log_must cp $key_location /$TESTPOOL/pkey2
58 log_must zfs create -o encryption=on -o keyformat=passphrase \
59 -o keylocation=file://$key_location $TESTPOOL/$TESTFS1
61 log_must zfs unmount $TESTPOOL/$TESTFS1
62 log_must zfs unload-key $TESTPOOL/$TESTFS1
64 log_must zfs load-key -L file:///$TESTPOOL/pkey2 $TESTPOOL/$TESTFS1
65 log_must key_available $TESTPOOL/$TESTFS1
66 log_must verify_keylocation $TESTPOOL/$TESTFS1 "file://$key_location"
68 log_must zfs unload-key $TESTPOOL/$TESTFS1
69 log_must eval "echo $PASSPHRASE | zfs load-key -L prompt $TESTPOOL/$TESTFS1"
70 log_must key_available $TESTPOOL/$TESTFS1
71 log_must verify_keylocation $TESTPOOL/$TESTFS1 "file://$key_location"
73 log_pass "'zfs load-key -L' overrides keylocation with provided value"