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 by Datto Inc. All rights reserved. 19# 20 21. $STF_SUITE/tests/functional/rsend/rsend.kshlib 22. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib 23 24# 25# DESCRIPTION: 26# Raw recursive sends preserve filesystem structure. 27# 28# STRATEGY: 29# 1. Create an encrypted filesystem with a clone and a child 30# 2. Snapshot and send the filesystem tree 31# 3. Verify that the filesystem structure was correctly received 32# 4. Change the child to an encryption root and promote the clone 33# 5. Snapshot and send the filesystem tree again 34# 6. Verify that the new structure is received correctly 35# 36 37verify_runnable "both" 38 39function cleanup 40{ 41 log_must cleanup_pool $POOL 42 log_must cleanup_pool $POOL2 43 log_must setup_test_model $POOL 44} 45 46log_assert "Raw recursive sends preserve filesystem structure." 47log_onexit cleanup 48 49# Create the filesystem hierarchy 50log_must cleanup_pool $POOL 51log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \ 52 "-o keyformat=passphrase $POOL/$FS" 53log_must zfs snapshot $POOL/$FS@snap 54log_must zfs clone $POOL/$FS@snap $POOL/clone 55log_must zfs create $POOL/$FS/child 56 57# Back up the tree and verify the structure 58log_must zfs snapshot -r $POOL@before 59log_must eval "zfs send -wR $POOL@before > $BACKDIR/fs-before-R" 60log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/fs-before-R" 61dstds=$(get_dst_ds $POOL/$FS $POOL2) 62log_must cmp_ds_subs $POOL/$FS $dstds 63 64log_must verify_encryption_root $POOL/$FS $POOL/$FS 65log_must verify_keylocation $POOL/$FS "prompt" 66log_must verify_origin $POOL/$FS "-" 67 68log_must verify_encryption_root $POOL/clone $POOL/$FS 69log_must verify_keylocation $POOL/clone "none" 70log_must verify_origin $POOL/clone "$POOL/$FS@snap" 71 72log_must verify_encryption_root $POOL/$FS/child $POOL/$FS 73log_must verify_keylocation $POOL/$FS/child "none" 74 75# Alter the hierarchy and re-send 76log_must eval "echo $PASSPHRASE1 | zfs change-key -o keyformat=passphrase" \ 77 "$POOL/$FS/child" 78log_must zfs promote $POOL/clone 79log_must zfs snapshot -r $POOL@after 80log_must eval "zfs send -wR -i $POOL@before $POOL@after >" \ 81 "$BACKDIR/fs-after-R" 82log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/fs-after-R" 83log_must cmp_ds_subs $POOL/$FS $dstds 84 85log_must verify_encryption_root $POOL/$FS $POOL/clone 86log_must verify_keylocation $POOL/$FS "none" 87log_must verify_origin $POOL/$FS "$POOL/clone@snap" 88 89log_must verify_encryption_root $POOL/clone $POOL/clone 90log_must verify_keylocation $POOL/clone "prompt" 91log_must verify_origin $POOL/clone "-" 92 93log_must verify_encryption_root $POOL/$FS/child $POOL/$FS/child 94log_must verify_keylocation $POOL/$FS/child "prompt" 95 96log_pass "Raw recursive sends preserve filesystem structure." 97