1*eb633035STom Caputi#!/bin/ksh -p 2*eb633035STom Caputi# 3*eb633035STom Caputi# CDDL HEADER START 4*eb633035STom Caputi# 5*eb633035STom Caputi# This file and its contents are supplied under the terms of the 6*eb633035STom Caputi# Common Development and Distribution License ("CDDL"), version 1.0. 7*eb633035STom Caputi# You may only use this file in accordance with the terms of version 8*eb633035STom Caputi# 1.0 of the CDDL. 9*eb633035STom Caputi# 10*eb633035STom Caputi# A full copy of the text of the CDDL should have accompanied this 11*eb633035STom Caputi# source. A copy of the CDDL is also available via the Internet at 12*eb633035STom Caputi# http://www.illumos.org/license/CDDL. 13*eb633035STom Caputi# 14*eb633035STom Caputi# CDDL HEADER END 15*eb633035STom Caputi# 16*eb633035STom Caputi 17*eb633035STom Caputi# 18*eb633035STom Caputi# Copyright (c) 2017 Datto, Inc. All rights reserved. 19*eb633035STom Caputi# 20*eb633035STom Caputi 21*eb633035STom Caputi. $STF_SUITE/include/libtest.shlib 22*eb633035STom Caputi 23*eb633035STom Caputi# 24*eb633035STom Caputi# DESCRIPTION: 25*eb633035STom Caputi# ZFS should receive streams from raw sends. 26*eb633035STom Caputi# 27*eb633035STom Caputi# STRATEGY: 28*eb633035STom Caputi# 1. Create an encrypted dataset 29*eb633035STom Caputi# 2. Create a file and get its checksum 30*eb633035STom Caputi# 3. Snapshot the dataset 31*eb633035STom Caputi# 4. Attempt to receive a raw send stream as a child of an unencrypted dataset 32*eb633035STom Caputi# 5. Verify the key is unavailable 33*eb633035STom Caputi# 6. Attempt to load the key and mount the dataset 34*eb633035STom Caputi# 7. Verify the cheksum of the file is the same as the original 35*eb633035STom Caputi# 8. Attempt to receive a raw send stream as a child of an encrypted dataset 36*eb633035STom Caputi# 9. Verify the key is unavailable 37*eb633035STom Caputi# 10. Attempt to load the key and mount the dataset 38*eb633035STom Caputi# 11. Verify the cheksum of the file is the same as the original 39*eb633035STom Caputi# 40*eb633035STom Caputi 41*eb633035STom Caputiverify_runnable "both" 42*eb633035STom Caputi 43*eb633035STom Caputifunction cleanup 44*eb633035STom Caputi{ 45*eb633035STom Caputi datasetexists $TESTPOOL/$TESTFS1 && \ 46*eb633035STom Caputi log_must zfs destroy -r $TESTPOOL/$TESTFS1 47*eb633035STom Caputi 48*eb633035STom Caputi datasetexists $TESTPOOL/$TESTFS2 && \ 49*eb633035STom Caputi log_must zfs destroy -r $TESTPOOL/$TESTFS2 50*eb633035STom Caputi} 51*eb633035STom Caputi 52*eb633035STom Caputilog_onexit cleanup 53*eb633035STom Caputi 54*eb633035STom Caputilog_assert "ZFS should receive streams from raw sends" 55*eb633035STom Caputi 56*eb633035STom Caputitypeset passphrase="password" 57*eb633035STom Caputitypeset snap="$TESTPOOL/$TESTFS1@snap" 58*eb633035STom Caputi 59*eb633035STom Caputilog_must eval "echo $passphrase | zfs create -o encryption=on" \ 60*eb633035STom Caputi "-o keyformat=passphrase $TESTPOOL/$TESTFS1" 61*eb633035STom Caputi 62*eb633035STom Caputilog_must mkfile 1M /$TESTPOOL/$TESTFS1/$TESTFILE0 63*eb633035STom Caputitypeset checksum=$(md5sum /$TESTPOOL/$TESTFS1/$TESTFILE0 | \ 64*eb633035STom Caputi awk '{ print $1 }') 65*eb633035STom Caputi 66*eb633035STom Caputilog_must zfs snapshot $snap 67*eb633035STom Caputi 68*eb633035STom Caputilog_note "Verify ZFS can receive a raw send stream from an encrypted dataset" 69*eb633035STom Caputilog_must eval "zfs send -w $snap | zfs receive $TESTPOOL/$TESTFS2" 70*eb633035STom Caputi 71*eb633035STom Caputikeystatus=$(get_prop keystatus $TESTPOOL/$TESTFS2) 72*eb633035STom Caputi[[ "$keystatus" == "unavailable" ]] || \ 73*eb633035STom Caputi log_fail "Expected keystatus unavailable, got $keystatus" 74*eb633035STom Caputi 75*eb633035STom Caputilog_must eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS2" 76*eb633035STom Caputi 77*eb633035STom Caputitypeset cksum1=$(md5sum /$TESTPOOL/$TESTFS2/$TESTFILE0 | awk '{ print $1 }') 78*eb633035STom Caputi[[ "$cksum1" == "$checksum" ]] || \ 79*eb633035STom Caputi log_fail "Checksums differ ($cksum1 != $checksum)" 80*eb633035STom Caputi 81*eb633035STom Caputilog_must eval "zfs send -w $snap | zfs receive $TESTPOOL/$TESTFS1/c1" 82*eb633035STom Caputi 83*eb633035STom Caputikeystatus=$(get_prop keystatus $TESTPOOL/$TESTFS1/c1) 84*eb633035STom Caputi[[ "$keystatus" == "unavailable" ]] || \ 85*eb633035STom Caputi log_fail "Expected keystatus unavailable, got $keystatus" 86*eb633035STom Caputi 87*eb633035STom Caputilog_must eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS1/c1" 88*eb633035STom Caputitypeset cksum2=$(md5sum /$TESTPOOL/$TESTFS1/c1/$TESTFILE0 | \ 89*eb633035STom Caputi awk '{ print $1 }') 90*eb633035STom Caputi[[ "$cksum2" == "$checksum" ]] || \ 91*eb633035STom Caputi log_fail "Checksums differ ($cksum2 != $checksum)" 92*eb633035STom Caputi 93*eb633035STom Caputilog_pass "ZFS can receive streams from raw sends" 94