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. Verify the encryption root of all three datasets is the origin 33# 5. Promote the clone of the clone 34# 6. Verify the encryption root of all three datasets is still the origin 35# 7. Promote the clone of the original encryption root 36# 8. Verify the encryption root of all three datasets is the promoted dataset 37# 38 39verify_runnable "both" 40 41function cleanup 42{ 43 datasetexists $TESTPOOL/$TESTFS1 && \ 44 log_must zfs destroy -Rf $TESTPOOL/$TESTFS1 45 datasetexists $TESTPOOL/clone1 && \ 46 log_must zfs destroy -Rf $TESTPOOL/clone1 47 datasetexists $TESTPOOL/clone2 && \ 48 log_must zfs destroy -Rf $TESTPOOL/clone2 49} 50log_onexit cleanup 51 52log_assert "ZFS must promote clones of an encryption root" 53 54passphrase="password" 55snaproot="$TESTPOOL/$TESTFS1@snap1" 56snapclone="$TESTPOOL/clone1@snap2" 57 58log_must eval "echo $passphrase | zfs create -o encryption=on" \ 59 "-o keyformat=passphrase $TESTPOOL/$TESTFS1" 60 61log_must zfs snap $snaproot 62log_must zfs clone $snaproot $TESTPOOL/clone1 63log_must zfs snap $snapclone 64log_must zfs clone $snapclone $TESTPOOL/clone2 65 66log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1 67log_must verify_encryption_root $TESTPOOL/clone1 $TESTPOOL/$TESTFS1 68log_must verify_encryption_root $TESTPOOL/clone2 $TESTPOOL/$TESTFS1 69 70log_must zfs promote $TESTPOOL/clone2 71log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1 72log_must verify_encryption_root $TESTPOOL/clone1 $TESTPOOL/$TESTFS1 73log_must verify_encryption_root $TESTPOOL/clone2 $TESTPOOL/$TESTFS1 74 75log_must zfs promote $TESTPOOL/clone2 76log_must verify_encryption_root $TESTPOOL/$TESTFS1 $TESTPOOL/clone2 77log_must verify_encryption_root $TESTPOOL/clone1 $TESTPOOL/clone2 78log_must verify_encryption_root $TESTPOOL/clone2 $TESTPOOL/clone2 79 80log_pass "ZFS promotes clones of an encryption root" 81