1c03c5b1cSMartin Matuska#!/bin/ksh -p
2c03c5b1cSMartin Matuska#
3c03c5b1cSMartin Matuska# CDDL HEADER START
4c03c5b1cSMartin Matuska#
5c03c5b1cSMartin Matuska# The contents of this file are subject to the terms of the
6c03c5b1cSMartin Matuska# Common Development and Distribution License (the "License").
7c03c5b1cSMartin Matuska# You may not use this file except in compliance with the License.
8c03c5b1cSMartin Matuska#
9c03c5b1cSMartin Matuska# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*271171e0SMartin Matuska# or https://opensource.org/licenses/CDDL-1.0.
11c03c5b1cSMartin Matuska# See the License for the specific language governing permissions
12c03c5b1cSMartin Matuska# and limitations under the License.
13c03c5b1cSMartin Matuska#
14c03c5b1cSMartin Matuska# When distributing Covered Code, include this CDDL HEADER in each
15c03c5b1cSMartin Matuska# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16c03c5b1cSMartin Matuska# If applicable, add the following below this CDDL HEADER, with the
17c03c5b1cSMartin Matuska# fields enclosed by brackets "[]" replaced with your own identifying
18c03c5b1cSMartin Matuska# information: Portions Copyright [yyyy] [name of copyright owner]
19c03c5b1cSMartin Matuska#
20c03c5b1cSMartin Matuska# CDDL HEADER END
21c03c5b1cSMartin Matuska#
22c03c5b1cSMartin Matuska
23c03c5b1cSMartin Matuska#
24c03c5b1cSMartin Matuska# Copyright (c) 2022 by Attila Fülöp <attila@fueloep.org>
25c03c5b1cSMartin Matuska#
26c03c5b1cSMartin Matuska
27c03c5b1cSMartin Matuska. $STF_SUITE/include/libtest.shlib
28c03c5b1cSMartin Matuska
29c03c5b1cSMartin Matuska#
30c03c5b1cSMartin Matuska# DESCRIPTION:
31c03c5b1cSMartin Matuska#      ZFS should receive a raw send of a mix of unencrypted and encrypted
32c03c5b1cSMartin Matuska#      child datasets
33c03c5b1cSMartin Matuska#
34c03c5b1cSMartin Matuska#      The layout of the datasets is:  enc/unenc/enc/unenc
35c03c5b1cSMartin Matuska#
36c03c5b1cSMartin Matuska# STRATEGY:
37c03c5b1cSMartin Matuska# 1. Create the dataset hierarchy
38c03c5b1cSMartin Matuska# 2. Snapshot the dataset hierarchy
39c03c5b1cSMartin Matuska# 3. Send -Rw the dataset hierarchy and receive into a top-level dataset
40c03c5b1cSMartin Matuska# 4. Check the encryption property of the received datasets
41c03c5b1cSMartin Matuska
42c03c5b1cSMartin Matuskaverify_runnable "both"
43c03c5b1cSMartin Matuska
44c03c5b1cSMartin Matuskafunction cleanup
45c03c5b1cSMartin Matuska{
46c03c5b1cSMartin Matuska	datasetexists "$TESTPOOL/$TESTFS1" && \
47c03c5b1cSMartin Matuska		destroy_dataset "$TESTPOOL/$TESTFS1" -r
48c03c5b1cSMartin Matuska
49c03c5b1cSMartin Matuska	datasetexists "$TESTPOOL/$TESTFS2" && \
50c03c5b1cSMartin Matuska		destroy_dataset "$TESTPOOL/$TESTFS2" -r
51c03c5b1cSMartin Matuska}
52c03c5b1cSMartin Matuska
53c03c5b1cSMartin Matuskalog_onexit cleanup
54c03c5b1cSMartin Matuska
55c03c5b1cSMartin Matuskalog_assert "ZFS should receive a mix of un/encrypted childs"
56c03c5b1cSMartin Matuska
57c03c5b1cSMartin Matuskatypeset src="$TESTPOOL/$TESTFS1"
58c03c5b1cSMartin Matuskatypeset dst="$TESTPOOL/$TESTFS2"
59c03c5b1cSMartin Matuskatypeset snap="snap"
60c03c5b1cSMartin Matuska
61c03c5b1cSMartin Matuskaecho "password" | \
62c03c5b1cSMartin Matuska	create_dataset "$src" -o encryption=on -o keyformat=passphrase
63c03c5b1cSMartin Matuskacreate_dataset "$src/u" "-o encryption=off"
64c03c5b1cSMartin Matuskaecho "password" | \
65c03c5b1cSMartin Matuska	create_dataset "$src/u/e" -o encryption=on -o keyformat=passphrase
66c03c5b1cSMartin Matuskacreate_dataset "$src/u/e/u" -o encryption=off
67c03c5b1cSMartin Matuska
68c03c5b1cSMartin Matuskalog_must zfs snapshot -r "$src@$snap"
69c03c5b1cSMartin Matuskalog_must eval "zfs send -Rw $src@$snap | zfs receive -u $dst"
70c03c5b1cSMartin Matuskalog_must test "$(get_prop 'encryption' $dst)" != "off"
71c03c5b1cSMartin Matuskalog_must test "$(get_prop 'encryption' $dst/u)" == "off"
72c03c5b1cSMartin Matuskalog_must test "$(get_prop 'encryption' $dst/u/e)" != "off"
73c03c5b1cSMartin Matuskalog_must test "$(get_prop 'encryption' $dst/u/e/u)" == "off"
74c03c5b1cSMartin Matuska
75c03c5b1cSMartin Matuskalog_pass "ZFS can receive a mix of un/encrypted childs"
76