mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
zdb: add decryption support
The approach is straightforward: for dataset ops, if a key was offered, find the encryption root and the various encryption parameters, derive a wrapping key if necessary, and then unlock the encryption root. After that all the regular dataset ops will return unencrypted data, and that's kinda the whole thing. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #11551 Closes #12707 Closes #14503
This commit is contained in:
@@ -126,9 +126,9 @@ tags = ['functional', 'clean_mirror']
|
||||
tests = ['zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', 'zdb_005_pos',
|
||||
'zdb_006_pos', 'zdb_args_neg', 'zdb_args_pos',
|
||||
'zdb_block_size_histogram', 'zdb_checksum', 'zdb_decompress',
|
||||
'zdb_display_block', 'zdb_label_checksum', 'zdb_object_range_neg',
|
||||
'zdb_object_range_pos', 'zdb_objset_id', 'zdb_decompress_zstd',
|
||||
'zdb_recover', 'zdb_recover_2']
|
||||
'zdb_display_block', 'zdb_encrypted', 'zdb_label_checksum',
|
||||
'zdb_object_range_neg', 'zdb_object_range_pos', 'zdb_objset_id',
|
||||
'zdb_decompress_zstd', 'zdb_recover', 'zdb_recover_2']
|
||||
pre =
|
||||
post =
|
||||
tags = ['functional', 'cli_root', 'zdb']
|
||||
|
||||
@@ -573,6 +573,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/cli_root/zdb/zdb_decompress.ksh \
|
||||
functional/cli_root/zdb/zdb_decompress_zstd.ksh \
|
||||
functional/cli_root/zdb/zdb_display_block.ksh \
|
||||
functional/cli_root/zdb/zdb_encrypted.ksh \
|
||||
functional/cli_root/zdb/zdb_label_checksum.ksh \
|
||||
functional/cli_root/zdb/zdb_object_range_neg.ksh \
|
||||
functional/cli_root/zdb/zdb_object_range_pos.ksh \
|
||||
|
||||
@@ -57,7 +57,7 @@ set -A args "create" "add" "destroy" "import fakepool" \
|
||||
"add raidz1 fakepool" "add raidz2 fakepool" \
|
||||
"setvprop" "blah blah" "-%" "--?" "-*" "-=" \
|
||||
"-a" "-f" "-g" "-j" "-n" "-o" "-p" "-p /tmp" \
|
||||
"-t" "-w" "-z" "-E" "-H" "-I" "-J" "-K" \
|
||||
"-t" "-w" "-z" "-E" "-H" "-I" "-J" \
|
||||
"-Q" "-R" "-T" "-W"
|
||||
|
||||
log_assert "Execute zdb using invalid parameters."
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2017, Datto, Inc. All rights reserved.
|
||||
# Copyright (c) 2023, Rob Norris <robn@despairlabs.com>
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# 'zdb -K ...' should enable reading from an encrypt dataset
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create an encrypted dataset
|
||||
# 2. Write some data to a file
|
||||
# 3. Run zdb -dddd on the file, confirm it can't be read
|
||||
# 4. Run zdb -K ... -ddddd on the file, confirm it can be read
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
dataset="$TESTPOOL/$TESTFS2"
|
||||
file="$TESTDIR2/somefile"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $dataset && destroy_dataset $dataset -f
|
||||
default_cleanup_noexit
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must default_setup_noexit $DISKS
|
||||
|
||||
log_assert "'zdb -K' should enable reading from an encrypted dataset"
|
||||
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o mountpoint=$TESTDIR2" \
|
||||
"-o encryption=on -o keyformat=passphrase $dataset"
|
||||
|
||||
echo 'my great encrypted text' > $file
|
||||
|
||||
obj="$(ls -i $file | cut -d' ' -f1)"
|
||||
size="$(wc -c < $file)"
|
||||
|
||||
log_note "test file $file is objid $obj, size $size"
|
||||
|
||||
sync_pool $TESTPOOL true
|
||||
|
||||
log_must eval "zdb -dddd $dataset $obj | grep -q 'object encrypted'"
|
||||
|
||||
log_must eval "zdb -K $PASSPHRASE -dddd $dataset $obj | grep -q 'size\s$size$'"
|
||||
|
||||
log_pass "'zdb -K' enables reading from an encrypted dataset"
|
||||
Reference in New Issue
Block a user