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 an unencrypted stream from an encrypted dataset
28 # 1. Create an unencrypted dataset
29 # 2. Create an encrypted dataset
30 # 3. Create and checksum a file on the encrypted dataset
31 # 4. Snapshot the encrypted dataset
32 # 5. Attempt to receive the snapshot into an unencrypted child
33 # 6. Verify encryption is not enabled
34 # 7. Verify the checksum of the file is the same as the original
35 # 8. Attempt to receive the snapshot into an encrypted child
36 # 9. Verify the checksum of the file is the same as the original
39 verify_runnable "both"
43 datasetexists $TESTPOOL/$TESTFS1 && \
44 log_must zfs destroy -r $TESTPOOL/$TESTFS1
46 datasetexists $TESTPOOL/$TESTFS2 && \
47 log_must zfs destroy -r $TESTPOOL/$TESTFS2
52 log_assert "ZFS should receive an unencrypted stream from an encrypted dataset"
54 typeset passphrase="password"
55 typeset snap="$TESTPOOL/$TESTFS2@snap"
57 log_must zfs create $TESTPOOL/$TESTFS1
58 log_must eval "echo $passphrase | zfs create -o encryption=on" \
59 "-o keyformat=passphrase $TESTPOOL/$TESTFS2"
61 log_must mkfile 1M /$TESTPOOL/$TESTFS2/$TESTFILE0
62 typeset checksum=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0)
64 log_must zfs snapshot $snap
66 log_note "Verify ZFS can receive into an unencrypted child"
67 log_must eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS1/c1"
69 crypt=$(get_prop encryption $TESTPOOL/$TESTFS1/c1)
70 [[ "$crypt" == "off" ]] || log_fail "Received unencrypted stream as encrypted"
72 typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS1/c1/$TESTFILE0)
73 [[ "$cksum1" == "$checksum" ]] || \
74 log_fail "Checksums differ ($cksum1 != $checksum)"
76 log_note "Verify ZFS can receive into an encrypted child"
77 log_must eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS2/c1"
79 typeset cksum2=$(md5digest /$TESTPOOL/$TESTFS2/c1/$TESTFILE0)
80 [[ "$cksum2" == "$checksum" ]] || \
81 log_fail "Checksums differ ($cksum2 != $checksum)"
83 log_pass "ZFS can receive an unencrypted stream from an encrypted dataset"