]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_send / zfs_send_encrypted.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
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
8 # 1.0 of the CDDL.
9 #
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.
13 #
14 # CDDL HEADER END
15 #
16
17 #
18 # Copyright (c) 2017, Datto, Inc. All rights reserved.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 # ZFS should perform unencrypted sends of encrypted datasets, unless the '-p'
26 # or '-R' options are specified.
27 #
28 # STRATEGY:
29 # 1. Create an encrypted dataset
30 # 6. Create a child encryption root
31 # 2. Snapshot the dataset
32 # 3. Attempt a send
33 # 4. Attempt a send with properties
34 # 5. Attempt a replication send
35 # 7. Unmount the parent and unload its key
36 # 8. Attempt a send of the parent dataset
37 # 9. Attempt a send of the child encryption root
38 #
39
40 verify_runnable "both"
41
42 function cleanup
43 {
44     datasetexists $TESTPOOL/$TESTFS1 && \
45         log_must zfs destroy -r $TESTPOOL/$TESTFS1
46 }
47
48 log_onexit cleanup
49
50 log_assert "ZFS should perform unencrypted sends of encrypted datasets, " \
51         "unless the '-p' or '-R' options are specified"
52
53 typeset passphrase="password"
54 typeset passphrase1="password1"
55 typeset snap="$TESTPOOL/$TESTFS1@snap"
56
57 log_must eval "echo $passphrase | zfs create -o encryption=on" \
58         "-o keyformat=passphrase $TESTPOOL/$TESTFS1"
59
60 log_must eval "echo $passphrase1 | zfs create -o encryption=on" \
61         "-o keyformat=passphrase $TESTPOOL/$TESTFS1/child"
62
63 log_must zfs snapshot -r $snap
64
65 log_must eval "zfs send $snap > /dev/null"
66 log_mustnot eval "zfs send -p $snap > /dev/null"
67 log_mustnot eval "zfs send -R $snap > /dev/null"
68
69 log_must zfs unmount $TESTPOOL/$TESTFS1
70 log_must zfs unload-key $TESTPOOL/$TESTFS1
71
72 log_mustnot eval "zfs send $snap > /dev/null"
73 log_must eval "zfs send $TESTPOOL/$TESTFS1/child@snap > /dev/null"
74
75 log_pass "ZFS performs unencrypted sends of encrypted datasets, unless the" \
76         "'-p' or '-R' options are specified"