1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2019, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib 19 20# 21# DESCRIPTION: 22# 'zfs userspace' and 'zfs groupspace' can be used on encrypted datasets 23# 24# 25# STRATEGY: 26# 1. Create both un-encrypted and encrypted datasets 27# 2. Receive un-encrypted dataset in encrypted hierarchy 28# 3. Verify encrypted datasets support 'zfs userspace' and 'zfs groupspace' 29# 30 31function cleanup 32{ 33 destroy_pool $POOLNAME 34 rm -f $FILEDEV 35} 36 37function log_must_unsupported 38{ 39 log_must_retry "unsupported" 3 "$@" || log_fail 40} 41 42log_onexit cleanup 43 44FILEDEV="$TEST_BASE_DIR/userspace_encrypted" 45POOLNAME="testpool$$" 46typeset -a POOL_OPTS=('' # all pool features enabled 47 '-d' # all pool features disabled 48 '-d -o feature@userobj_accounting=enabled' # only userobj_accounting enabled 49 '-d -o feature@project_quota=enabled') # only project_quota enabled 50DATASET_ENCROOT="$POOLNAME/encroot" 51DATASET_SENDFS="$POOLNAME/sendfs" 52 53log_assert "'zfs user/groupspace' should work on encrypted datasets" 54 55for opts in "${POOL_OPTS[@]}"; do 56 # Setup 57 truncate -s $SPA_MINDEVSIZE $FILEDEV 58 log_must zpool create $opts -o feature@encryption=enabled $POOLNAME \ 59 $FILEDEV 60 61 # 1. Create both un-encrypted and encrypted datasets 62 log_must zfs create $DATASET_SENDFS 63 log_must eval "echo 'password' | zfs create -o encryption=on" \ 64 "-o keyformat=passphrase -o keylocation=prompt " \ 65 "$DATASET_ENCROOT" 66 log_must zfs create $DATASET_ENCROOT/fs 67 68 # 2. Receive un-encrypted dataset in encrypted hierarchy 69 log_must zfs snap $DATASET_SENDFS@snap 70 log_must eval "zfs send $DATASET_SENDFS@snap | zfs recv " \ 71 "$DATASET_ENCROOT/recvfs" 72 73 # 3. Verify encrypted datasets support 'zfs userspace' and 74 # 'zfs groupspace' 75 log_must zfs userspace $DATASET_ENCROOT/fs 76 log_must zfs groupspace $DATASET_ENCROOT/fs 77 log_must_unsupported zfs userspace $DATASET_ENCROOT/recvfs 78 log_must_unsupported zfs groupspace $DATASET_ENCROOT/recvfs 79 80 # Cleanup 81 cleanup 82done 83 84log_pass "'zfs user/groupspace' works on encrypted datasets" 85