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 2020 Joyent, Inc. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib 23. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib 24 25# 26# DESCRIPTION: 27# Try to change an encrypted dataset key via a ZFS channel program 28 29verify_runnable "both" 30 31function cleanup 32{ 33 datasetexists $TESTPOOL/$TESTFS1 && \ 34 log_must zfs destroy -f $TESTPOOL/$TESTFS1 35} 36log_onexit cleanup 37 38log_assert "zfs.sync.change_key should change key material" 39 40log_must eval "echo $HEXKEY | zfs create -o encryption=on" \ 41 "-o keyformat=hex -o keylocation=prompt $TESTPOOL/$TESTFS1" 42 43log_must $ZCP_ROOT/synctask_core/change_key.exe $TESTPOOL/$TESTFS1 $HEXKEY1 44 45# Key shouldn't appear in zpool history when using change_key.exe 46log_mustnot eval "zfs history -il $TESTPOOL | grep $HEXKEY1" 47 48log_must zfs unmount $TESTPOOL/$TESTFS1 49log_must zfs unload-key $TESTPOOL/$TESTFS1 50 51log_mustnot eval "echo $HEXKEY | zfs load-key $TESTPOOL/$TESTFS1" 52log_must key_unavailable $TESTPOOL/$TESTFS1 53 54log_must eval "echo $HEXKEY1 | zfs load-key $TESTPOOL/$TESTFS1" 55 56log_pass "zfs.sync.change_key should change key material" 57