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. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib 23*eb633035STom Caputi 24*eb633035STom Caputi# 25*eb633035STom Caputi# DESCRIPTION: 26*eb633035STom Caputi# 'zfs rename' should not move an encrypted child dataset outside of its 27*eb633035STom Caputi# encryption root. 28*eb633035STom Caputi# 29*eb633035STom Caputi# STRATEGY: 30*eb633035STom Caputi# 1. Create two encryption roots, and a child and grandchild of the first 31*eb633035STom Caputi# encryption root 32*eb633035STom Caputi# 2. Attempt to rename the grandchild under an unencrypted parent 33*eb633035STom Caputi# 3. Attempt to rename the grandchild under a different encrypted parent 34*eb633035STom Caputi# 4. Attempt to rename the grandchild under the current parent 35*eb633035STom Caputi# 5. Verify the encryption root of the dataset 36*eb633035STom Caputi# 6. Attempt to rename the grandchild to a child 37*eb633035STom Caputi# 7. Verify the encryption root of the dataset 38*eb633035STom Caputi# 39*eb633035STom Caputi 40*eb633035STom Caputiverify_runnable "both" 41*eb633035STom Caputi 42*eb633035STom Caputifunction cleanup 43*eb633035STom Caputi{ 44*eb633035STom Caputi datasetexists $TESTPOOL/$TESTFS2 && \ 45*eb633035STom Caputi log_must zfs destroy -r $TESTPOOL/$TESTFS2 46*eb633035STom Caputi datasetexists $TESTPOOL/$TESTFS3 && \ 47*eb633035STom Caputi log_must zfs destroy -r $TESTPOOL/$TESTFS3 48*eb633035STom Caputi} 49*eb633035STom Caputilog_onexit cleanup 50*eb633035STom Caputi 51*eb633035STom Caputilog_assert "'zfs rename' should not move an encrypted child outside of its" \ 52*eb633035STom Caputi "encryption root" 53*eb633035STom Caputi 54*eb633035STom Caputilog_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \ 55*eb633035STom Caputi "-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS2" 56*eb633035STom Caputilog_must zfs create $TESTPOOL/$TESTFS2/child 57*eb633035STom Caputilog_must zfs create $TESTPOOL/$TESTFS2/child/grandchild 58*eb633035STom Caputilog_must eval "echo $PASSPHRASE1 | zfs create -o encryption=on" \ 59*eb633035STom Caputi "-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS3" 60*eb633035STom Caputi 61*eb633035STom Caputilog_mustnot zfs rename $TESTPOOL/$TESTFS2/child/grandchild \ 62*eb633035STom Caputi $TESTPOOL/grandchild 63*eb633035STom Caputi 64*eb633035STom Caputilog_mustnot zfs rename $TESTPOOL/$TESTFS2/child/grandchild \ 65*eb633035STom Caputi $TESTPOOL/$TESTFS3/grandchild 66*eb633035STom Caputi 67*eb633035STom Caputilog_must zfs rename $TESTPOOL/$TESTFS2/child/grandchild \ 68*eb633035STom Caputi $TESTPOOL/$TESTFS2/child/grandchild2 69*eb633035STom Caputilog_must verify_encryption_root $TESTPOOL/$TESTFS2/child/grandchild2 \ 70*eb633035STom Caputi $TESTPOOL/$TESTFS2 71*eb633035STom Caputi 72*eb633035STom Caputilog_must zfs rename $TESTPOOL/$TESTFS2/child/grandchild2 \ 73*eb633035STom Caputi $TESTPOOL/$TESTFS2/grandchild2 74*eb633035STom Caputilog_must verify_encryption_root $TESTPOOL/$TESTFS2/grandchild2 \ 75*eb633035STom Caputi $TESTPOOL/$TESTFS2 76*eb633035STom Caputi 77*eb633035STom Caputilog_pass "'zfs rename' does not move an encrypted child outside of its" \ 78*eb633035STom Caputi "encryption root" 79