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 (c) 2017 Datto, Inc. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib 23 24# 25# DESCRIPTION: 26# 'zfs load-key -L' should override keylocation with provided value. 27# 28# STRATEGY: 29# 1. Create a key file 30# 2. Copy the key file to another location 31# 3. Create an encrypted dataset using the keyfile 32# 4. Unmount the dataset and unload its key 33# 5. Attempt to load the dataset specifying a keylocation of file 34# 6. Verify the key is loaded 35# 7. Verify the keylocation is the original key file 36# 8. Unload the dataset's key 37# 9. Attempt to load the dataset specifying a keylocation of prompt 38# 10. Verify the key is loaded 39# 11. Verify the keylocation is the original key file 40# 41 42verify_runnable "both" 43 44function cleanup 45{ 46 datasetexists $TESTPOOL/$TESTFS1 && \ 47 log_must zfs destroy $TESTPOOL/$TESTFS1 48} 49log_onexit cleanup 50 51log_assert "'zfs load-key -L' should override keylocation with provided value" 52 53typeset key_location="/$TESTPOOL/pkey1" 54 55log_must eval "echo $PASSPHRASE > $key_location" 56log_must cp $key_location /$TESTPOOL/pkey2 57 58log_must zfs create -o encryption=on -o keyformat=passphrase \ 59 -o keylocation=file://$key_location $TESTPOOL/$TESTFS1 60 61log_must zfs unmount $TESTPOOL/$TESTFS1 62log_must zfs unload-key $TESTPOOL/$TESTFS1 63 64log_must zfs load-key -L file:///$TESTPOOL/pkey2 $TESTPOOL/$TESTFS1 65log_must key_available $TESTPOOL/$TESTFS1 66log_must verify_keylocation $TESTPOOL/$TESTFS1 "file://$key_location" 67 68log_must zfs unload-key $TESTPOOL/$TESTFS1 69log_must eval "echo $PASSPHRASE | zfs load-key -L prompt $TESTPOOL/$TESTFS1" 70log_must key_available $TESTPOOL/$TESTFS1 71log_must verify_keylocation $TESTPOOL/$TESTFS1 "file://$key_location" 72 73log_pass "'zfs load-key -L' overrides keylocation with provided value" 74