]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_clones.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_change-key / zfs_change-key_clones.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 . $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib
23
24 #
25 # DESCRIPTION:
26 # 'zfs change-key' should correctly update encryption roots with clones.
27 #
28 # STRATEGY:
29 # 1. Create an encrypted dataset
30 # 2. Create an encryption root child of the first dataset
31 # 3. Clone the child encryption root twice
32 # 4. Add inheriting children to the encryption root and each of the clones
33 # 5. Verify the encryption roots
34 # 6. Have the child encryption root inherit from its parent
35 # 7. Verify the encryption root for all datasets is now the parent dataset
36 #
37
38 verify_runnable "both"
39
40 function cleanup
41 {
42         datasetexists $TESTPOOL/$TESTFS1 && \
43                 log_must zfs destroy -Rf $TESTPOOL/$TESTFS1
44 }
45
46 log_onexit cleanup
47
48 log_assert "'zfs change-key' should correctly update encryption " \
49         "roots with clones"
50
51 log_must eval "echo $PASSPHRASE1 | zfs create -o encryption=on" \
52         "-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS1"
53 log_must eval "echo $PASSPHRASE2 | zfs create -o encryption=on" \
54         "-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS1/child"
55 log_must zfs snapshot $TESTPOOL/$TESTFS1/child@1
56 log_must zfs clone $TESTPOOL/$TESTFS1/child@1 $TESTPOOL/$TESTFS1/clone1
57 log_must zfs clone $TESTPOOL/$TESTFS1/child@1 $TESTPOOL/$TESTFS1/clone2
58 log_must zfs create $TESTPOOL/$TESTFS1/child/A
59 log_must zfs create $TESTPOOL/$TESTFS1/clone1/B
60 log_must zfs create $TESTPOOL/$TESTFS1/clone2/C
61
62 log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1
63 log_must verify_encryption_root $TESTPOOL/$TESTFS1/child $TESTPOOL/$TESTFS1/child
64 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone1 $TESTPOOL/$TESTFS1/child
65 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone2 $TESTPOOL/$TESTFS1/child
66 log_must verify_encryption_root $TESTPOOL/$TESTFS1/child/A $TESTPOOL/$TESTFS1/child
67 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone1/B $TESTPOOL/$TESTFS1/child
68 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone2/C $TESTPOOL/$TESTFS1/child
69
70 log_must zfs change-key -i $TESTPOOL/$TESTFS1/child
71
72 log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1
73 log_must verify_encryption_root $TESTPOOL/$TESTFS1/child $TESTPOOL/$TESTFS1
74 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone1 $TESTPOOL/$TESTFS1
75 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone2 $TESTPOOL/$TESTFS1
76 log_must verify_encryption_root $TESTPOOL/$TESTFS1/child/A $TESTPOOL/$TESTFS1
77 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone1/B $TESTPOOL/$TESTFS1
78 log_must verify_encryption_root $TESTPOOL/$TESTFS1/clone2/C $TESTPOOL/$TESTFS1
79
80 log_pass "'zfs change-key' correctly updates encryption roots with clones"