5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2017 Datto, Inc. All rights reserved.
27 . $STF_SUITE/include/libtest.shlib
28 . $STF_SUITE/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib
29 . $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib
33 # "zfs unmount -u" should allow the user to unload their encryption
34 # keys while unmounting one or more datasets
37 # 1. Create a hierarchy of encrypted datasets
38 # 2. Test that 'zfs unmount -u' unloads keys as it unmounts a dataset
39 # 3. Test that 'zfs unmount -u' unloads keys as it unmounts multiple datasets
40 # 4. Test that 'zfs unmount -u' returns an error if the key is still in
44 verify_runnable "both"
48 datasetexists $TESTPOOL/$TESTFS2 && \
49 log_must zfs destroy -r $TESTPOOL/$TESTFS2
50 datasetexists $TESTPOOL/$TESTFS2/newroot && \
51 log_must zfs destroy -r $TESTPOOL/$TESTFS2/newroot
52 datasetexists $TESTPOOL/$TESTFS2/child && \
53 log_must zfs destroy -r $TESTPOOL/$TESTFS2/child
58 log_assert "'zfs unmount -u' should unload keys for datasets as they are unmounted"
59 log_must eval "echo 'password' | zfs create -o encryption=on -o keyformat=passphrase $TESTPOOL/$TESTFS2"
60 log_must eval "echo 'password' | zfs create -o encryption=on -o keyformat=passphrase $TESTPOOL/$TESTFS2/newroot"
61 log_must zfs create $TESTPOOL/$TESTFS2/child
63 log_must zfs umount -u $TESTPOOL/$TESTFS2/newroot
64 log_must key_unavailable $TESTPOOL/$TESTFS2/newroot
65 log_must eval "echo 'password' | zfs mount -l $TESTPOOL/$TESTFS2/newroot"
67 log_must zfs umount -u $TESTPOOL/$TESTFS2
68 log_must key_unavailable $TESTPOOL/$TESTFS2
69 log_must key_unavailable $TESTPOOL/$TESTFS2/newroot
70 log_must key_unavailable $TESTPOOL/$TESTFS2/child
71 log_must eval "echo 'password' | zfs mount -l $TESTPOOL/$TESTFS2/newroot"
73 log_must zfs snap $TESTPOOL/$TESTFS2/newroot@1
74 log_must zfs clone $TESTPOOL/$TESTFS2/newroot@1 $TESTPOOL/$TESTFS2/clone
75 log_mustnot zfs umount -u $TESTPOOL/$TESTFS2/newroot
76 log_must key_available $TESTPOOL/$TESTFS2/newroot
77 log_must mounted $TESTPOOL/$TESTFS2/newroot
79 log_pass "'zfs unmount -u' unloads keys for datasets as they are unmounted"