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 must promote clones of an encryption root. 27# 28# STRATEGY: 29# 1. Create an encrypted dataset 30# 2. Clone the encryption root 31# 3. Clone the clone 32# 4. Add children to each of these three datasets 33# 4. Verify the encryption root of all datasets is the origin 34# 5. Promote the clone of the clone 35# 6. Verify the encryption root of all datasets is still the origin 36# 7. Promote the dataset again, so it is now the encryption root 37# 8. Verify the encryption root of all datasets is the promoted dataset 38# 39 40verify_runnable "both" 41 42function cleanup 43{ 44 datasetexists $TESTPOOL/$TESTFS1 && \ 45 destroy_dataset $TESTPOOL/$TESTFS1 -Rf 46 datasetexists $TESTPOOL/clone1 && \ 47 destroy_dataset $TESTPOOL/clone1 -Rf 48 datasetexists $TESTPOOL/clone2 && \ 49 destroy_dataset $TESTPOOL/clone2 -Rf 50} 51log_onexit cleanup 52 53log_assert "ZFS must promote clones of an encryption root" 54 55passphrase="password" 56snaproot="$TESTPOOL/$TESTFS1@snap1" 57snapclone="$TESTPOOL/clone1@snap2" 58 59log_must eval "echo $passphrase | zfs create -o encryption=on" \ 60 "-o keyformat=passphrase $TESTPOOL/$TESTFS1" 61 62log_must zfs snap $snaproot 63log_must zfs clone $snaproot $TESTPOOL/clone1 64log_must zfs snap $snapclone 65log_must zfs clone $snapclone $TESTPOOL/clone2 66log_must zfs create $TESTPOOL/$TESTFS1/child0 67log_must zfs create $TESTPOOL/clone1/child1 68log_must zfs create $TESTPOOL/clone2/child2 69 70log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1 71log_must verify_encryption_root $TESTPOOL/clone1 $TESTPOOL/$TESTFS1 72log_must verify_encryption_root $TESTPOOL/clone2 $TESTPOOL/$TESTFS1 73log_must verify_encryption_root $TESTPOOL/$TESTFS1/child0 $TESTPOOL/$TESTFS1 74log_must verify_encryption_root $TESTPOOL/clone1/child1 $TESTPOOL/$TESTFS1 75log_must verify_encryption_root $TESTPOOL/clone2/child2 $TESTPOOL/$TESTFS1 76 77log_must zfs promote $TESTPOOL/clone2 78log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1 79log_must verify_encryption_root $TESTPOOL/clone1 $TESTPOOL/$TESTFS1 80log_must verify_encryption_root $TESTPOOL/clone2 $TESTPOOL/$TESTFS1 81log_must verify_encryption_root $TESTPOOL/$TESTFS1/child0 $TESTPOOL/$TESTFS1 82log_must verify_encryption_root $TESTPOOL/clone1/child1 $TESTPOOL/$TESTFS1 83log_must verify_encryption_root $TESTPOOL/clone2/child2 $TESTPOOL/$TESTFS1 84 85log_must zfs promote $TESTPOOL/clone2 86log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/clone2 87log_must verify_encryption_root $TESTPOOL/clone1 $TESTPOOL/clone2 88log_must verify_encryption_root $TESTPOOL/clone2 $TESTPOOL/clone2 89log_must verify_encryption_root $TESTPOOL/$TESTFS1/child0 $TESTPOOL/clone2 90log_must verify_encryption_root $TESTPOOL/clone1/child1 $TESTPOOL/clone2 91log_must verify_encryption_root $TESTPOOL/clone2/child2 $TESTPOOL/clone2 92 93log_pass "ZFS promotes clones of an encryption root" 94