1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# CDDL HEADER START 5# 6# The contents of this file are subject to the terms of the 7# Common Development and Distribution License (the "License"). 8# You may not use this file except in compliance with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or https://opensource.org/licenses/CDDL-1.0. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23 24. $STF_SUITE/include/libtest.shlib 25. $STF_SUITE/tests/functional/rsend/rsend.kshlib 26 27# 28# Description: 29# Incrementally receiving a snapshot to an encrypted filesystem succeeds. 30# 31# Strategy: 32# 1) Create a pool and an encrypted fs 33# 2) Create some files and snapshots 34# 3) Send the first snapshot to a second encrypted as well as an 35# unencrypted fs. 36# 4) Incrementally send the second snapshot to the unencrypted fs. 37# 5) Rollback the second encrypted fs to the first snapshot. 38# 6) Incrementally send the second snapshot from the unencrypted to the 39# second encrypted fs. 40# 7) Incrementally send the third snapshot from the first encrypted to the 41# unencrypted fs. 42# 8) Incrementally send the third snapshot from the unencrypted to the second 43# encrypted fs. 44# 45 46verify_runnable "both" 47 48log_assert "Incrementally receiving a snapshot to an encrypted filesystem succeeds" 49 50function cleanup 51{ 52 destroy_pool pool_lb 53 log_must rm -f $TESTDIR/vdev_a 54} 55 56log_onexit cleanup 57 58typeset passphrase="password" 59typeset passphrase2="password2" 60 61typeset file="/pool_lb/encryptme/$TESTFILE0" 62typeset file1="/pool_lb/encryptme/$TESTFILE1" 63typeset file2="/pool_lb/encryptme/$TESTFILE2" 64 65# Create pool 66truncate -s $MINVDEVSIZE $TESTDIR/vdev_a 67log_must zpool create -f pool_lb $TESTDIR/vdev_a 68log_must eval "echo $passphrase > /pool_lb/pwd" 69log_must eval "echo $passphrase2 > /pool_lb/pwd2" 70 71log_must zfs create -o encryption=on -o keyformat=passphrase \ 72 -o keylocation=file:///pool_lb/pwd pool_lb/encryptme 73log_must dd if=/dev/urandom of=$file bs=1024 count=1024 74log_must zfs snapshot pool_lb/encryptme@snap1 75log_must dd if=/dev/urandom of=$file1 bs=1024 count=1024 76log_must zfs snapshot pool_lb/encryptme@snap2 77log_must dd if=/dev/urandom of=$file2 bs=1024 count=1024 78log_must zfs snapshot pool_lb/encryptme@snap3 79log_must eval "zfs send -Lc pool_lb/encryptme@snap1 | zfs recv \ 80 -o encryption=on -o keyformat=passphrase -o keylocation=file:///pool_lb/pwd2 \ 81 pool_lb/encrypttwo" 82log_must eval "zfs send -Lc pool_lb/encryptme@snap1 | zfs recv \ 83 pool_lb/unencryptme" 84log_must eval "zfs send -Lc -i pool_lb/encryptme@{snap1,snap2} | zfs recv \ 85 pool_lb/unencryptme" 86log_must zfs rollback pool_lb/encrypttwo@snap1 87log_must eval "zfs send -Lc -i pool_lb/unencryptme@{snap1,snap2} | zfs recv \ 88 pool_lb/encrypttwo" 89log_must eval "zfs send -Lc -i pool_lb/encryptme@{snap2,snap3} | zfs recv \ 90 pool_lb/unencryptme" 91log_must eval "zfs send -Lc -i pool_lb/unencryptme@{snap2,snap3} | zfs recv \ 92 -F pool_lb/encrypttwo" 93 94log_pass "Incrementally receiving a snapshot to an encrypted filesystem succeeds" 95