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
25 # ZFS should receive to an encrypted child dataset.
28 # 1. Snapshot the default dataset
29 # 2. Create an encrypted dataset
30 # 3. Attempt to receive a stream to an encrypted child
31 # 4. Attempt to receive a stream with properties to an encrypted child
32 # 5. Attempt to receive a replication stream to an encrypted child
33 # 6. Unmount and unload the encrypted dataset keys
34 # 7. Attempt to receive a snapshot stream to an encrypted child
37 verify_runnable "both"
41 snapexists $snap && log_must_busy zfs destroy -f $snap
43 datasetexists $TESTPOOL/$TESTFS1 && \
44 log_must zfs destroy -r $TESTPOOL/$TESTFS1
49 log_assert "ZFS should receive encrypted filesystems into child dataset"
51 typeset passphrase="password"
52 typeset snap="$TESTPOOL/$TESTFS@snap"
53 typeset testfile="testfile"
55 log_must zfs snapshot $snap
57 log_must eval "echo $passphrase | zfs create -o encryption=on" \
58 "-o keyformat=passphrase $TESTPOOL/$TESTFS1"
60 log_note "Verifying ZFS will receive to an encrypted child"
61 log_must eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS1/c1"
63 log_note "Verifying 'send -p' will receive to an encrypted child"
64 log_must eval "zfs send -p $snap | zfs receive $TESTPOOL/$TESTFS1/c2"
65 log_must test "$(get_prop 'encryption' $TESTPOOL/$TESTFS1/c2)" == "off"
67 log_note "Verifying 'send -R' will receive to an encrypted child"
68 log_must eval "zfs send -R $snap | zfs receive $TESTPOOL/$TESTFS1/c3"
69 log_must test "$(get_prop 'encryption' $TESTPOOL/$TESTFS1/c3)" == "off"
71 log_note "Verifying ZFS will not receive to an encrypted child when the" \
72 "parent key is unloaded"
73 log_must zfs unmount $TESTPOOL/$TESTFS1
74 log_must zfs unload-key $TESTPOOL/$TESTFS1
75 log_mustnot eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS1/c4"
77 log_pass "ZFS can receive encrypted filesystems into child dataset"