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 mount -l' should accept a valid key as it mounts the filesystem. 27# 28# STRATEGY: 29# 1. Create an encrypted dataset 30# 2. Unmount and unload the dataset's key 31# 3. Verify the key is unloaded 32# 4. Attempt to mount all datasets in the pool 33# 5. Verify that no error code is produced 34# 6. Verify that the encrypted dataset is not mounted 35# 7. Attempt to load the key while mounting the dataset 36# 8. Verify the key is loaded 37# 9. Verify the dataset is mounted 38# 39 40verify_runnable "both" 41 42function cleanup 43{ 44 datasetexists $TESTPOOL/$TESTFS1 && \ 45 destroy_dataset $TESTPOOL/$TESTFS1 -f 46} 47 48log_onexit cleanup 49 50log_assert "'zfs mount -l' should properly load a valid wrapping key" 51 52log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \ 53 "-o keyformat=passphrase $TESTPOOL/$TESTFS1" 54 55log_must zfs unmount $TESTPOOL/$TESTFS1 56log_must zfs unload-key $TESTPOOL/$TESTFS1 57log_must key_unavailable $TESTPOOL/$TESTFS1 58 59log_must zfs mount -a 60unmounted $TESTPOOL/$TESTFS1 || \ 61 log_fail "Filesystem $TESTPOOL/$TESTFS1 is mounted" 62 63log_must eval "echo $PASSPHRASE | zfs mount -l $TESTPOOL/$TESTFS1" 64log_must key_available $TESTPOOL/$TESTFS1 65 66mounted $TESTPOOL/$TESTFS1 || \ 67 log_fail "Filesystem $TESTPOOL/$TESTFS1 is unmounted" 68 69log_pass "'zfs mount -l' properly loads a valid wrapping key" 70