zcp: get_prop: fix encryptionroot and encryption

It was reported that channel programs' zfs.get_prop doesn't work for
dataset properties encryption and encryptionroot.

They are handled in get_special_prop due to the need to call
dsl_dataset_crypt_stats to load those dsl props.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
Co-authored-by: Graham Christensen <graham@grahamc.com>
Closes #17280
This commit is contained in:
Pavel Snajdr
2025-05-28 02:04:37 +02:00
committed by GitHub
parent 06fa8f3f69
commit 8487945034
7 changed files with 104 additions and 9 deletions
+2
View File
@@ -106,6 +106,7 @@ nobase_dist_datadir_zfs_tests_tests_DATA += \
functional/channel_program/lua_core/tst.args_to_lua.zcp \
functional/channel_program/lua_core/tst.divide_by_zero.err \
functional/channel_program/lua_core/tst.divide_by_zero.zcp \
functional/channel_program/lua_core/tst.encryption.zcp \
functional/channel_program/lua_core/tst.exists.zcp \
functional/channel_program/lua_core/tst.large_prog.out \
functional/channel_program/lua_core/tst.large_prog.zcp \
@@ -544,6 +545,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/channel_program/lua_core/setup.ksh \
functional/channel_program/lua_core/tst.args_to_lua.ksh \
functional/channel_program/lua_core/tst.divide_by_zero.ksh \
functional/channel_program/lua_core/tst.encryption.ksh \
functional/channel_program/lua_core/tst.exists.ksh \
functional/channel_program/lua_core/tst.integer_illegal.ksh \
functional/channel_program/lua_core/tst.integer_overflow.ksh \
@@ -0,0 +1,43 @@
#!/bin/ksh -p
# SPDX-License-Identifier: CDDL-1.0
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2021 by Determinate Systems. All rights reserved.
#
. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib
#
# DESCRIPTION:
# zfs.exists should accurately report whether a dataset exists, and
# report an error if a dataset is in another pool.
verify_runnable "global"
function cleanup
{
datasetexists $TESTPOOL/$TESTDATASET && \
log_must zfs destroy -R $TESTPOOL/$TESTDATASET
}
log_onexit cleanup
TESTDATASET="channelprogramencryption"
passphrase="password"
log_must eval "echo "$passphrase" | zfs create -o encryption=aes-256-ccm " \
"-o keyformat=passphrase $TESTPOOL/$TESTDATASET"
log_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.encryption.zcp \
$TESTPOOL/$TESTDATASET
log_pass "zfs.get_prop(dataset, ...) on \"encryption\" and \"encryptionroot\" gives correct results"
@@ -0,0 +1,23 @@
-- SPDX-License-Identifier: CDDL-1.0
--
-- This file and its contents are supplied under the terms of the
-- Common Development and Distribution License ("CDDL"), version 1.0.
-- You may only use this file in accordance with the terms of version
-- 1.0 of the CDDL.
--
-- A full copy of the text of the CDDL should have accompanied this
-- source. A copy of the CDDL is also available via the Internet at
-- http://www.illumos.org/license/CDDL.
--
--
-- Copyright (c) 2021 by Determinate Systems. All rights reserved.
--
-- ensure zfs.get_prop returns the correct values for "encryption"
-- and "encryptionroot"
args = ...
argv = args['argv']
assert(zfs.get_prop(argv[1], "encryption") == "aes-256-ccm")
assert(zfs.get_prop(argv[1], "encryptionroot") == argv[1])
@@ -24,15 +24,16 @@
verify_runnable "global"
# create $TESTSNAP and $TESTCLONE
create_snapshot
create_clone
function cleanup
{
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R
}
log_onexit cleanup
# create $TESTSNAP and $TESTCLONE
create_snapshot
create_clone
log_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.exists.zcp \
$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS@$TESTSNAP \