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) 2019 Datto, Inc. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22 23# 24# DESCRIPTION: 25# zfs receive -d should create the expected encryption hierarchy. 26# 27# STRATEGY: 28# 1. Create an encrypted dataset and a inheriting child 29# 2. Snapshot the child dataset 30# 2. Create a recursive raw send file from the snapshot 31# 3. Destroy the original child filesystem 32# 4. Receive the snapshot as a child of the second dataset with '-d' 33# 5. Verify the new child can be mounted 34# 35 36verify_runnable "both" 37 38function cleanup 39{ 40 datasetexists $TESTPOOL/$TESTFS1 && \ 41 destroy_dataset $TESTPOOL/$TESTFS1 -r 42 rm -f $sendfile 43} 44 45log_onexit cleanup 46 47log_assert "zfs receive -d should create the expected encryption hierarchy" 48 49typeset passphrase="password1" 50 51sendfile=$TEST_BASE_DIR/sendfile.$$ 52 53log_must eval "echo $passphrase | zfs create -o encryption=on" \ 54 "-o keyformat=passphrase $TESTPOOL/$TESTFS1" 55log_must zfs create $TESTPOOL/$TESTFS1/child 56log_must zfs snapshot $TESTPOOL/$TESTFS1/child@snap 57log_must eval "zfs send -Rw $TESTPOOL/$TESTFS1/child@snap > $sendfile" 58log_must zfs destroy -r $TESTPOOL/$TESTFS1/child 59log_must zfs receive -Fd $TESTPOOL < $sendfile 60log_must eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS1/child" 61 62log_pass "zfs receive -d creates the expected encryption hierarchy" 63