mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Allow unencrypted children of encrypted datasets
When encryption was first added to ZFS, we made a decision to prevent users from creating unencrypted children of encrypted datasets. The idea was to prevent users from inadvertently leaving some of their data unencrypted. However, since the release of 0.8.0, some legitimate reasons have been brought up for this behavior to be allowed. This patch simply removes this limitation from all code paths that had checks for it and updates the tests accordingly. Reviewed-by: Jason King <jason.king@joyent.com> Reviewed-by: Sean Eric Fagan <sef@ixsystems.com> Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes #8737 Closes #8870
This commit is contained in:
@@ -51,10 +51,10 @@
|
||||
# yes unspec 0 1 no no keyformat specified
|
||||
# yes unspec 1 0 yes new encryption root, crypt inherited
|
||||
# yes unspec 1 1 yes new encryption root, crypt inherited
|
||||
# yes off 0 0 no unencrypted child of encrypted parent
|
||||
# yes off 0 1 no unencrypted child of encrypted parent
|
||||
# yes off 1 0 no unencrypted child of encrypted parent
|
||||
# yes off 1 1 no unencrypted child of encrypted parent
|
||||
# yes off 0 0 yes unencrypted child of encrypted parent
|
||||
# yes off 0 1 no keylocation given, but crypt off
|
||||
# yes off 1 0 no keyformat given, but crypt off
|
||||
# yes off 1 1 no keyformat given, but crypt off
|
||||
# yes on 0 0 yes inherited encryption, local crypt
|
||||
# yes on 0 1 no no keyformat specified for new key
|
||||
# yes on 1 0 yes new encryption root
|
||||
@@ -113,7 +113,9 @@ log_must eval "echo $PASSPHRASE | zfs create -o keyformat=passphrase" \
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o keyformat=passphrase" \
|
||||
"-o keylocation=prompt $TESTPOOL/$TESTFS2/c4"
|
||||
|
||||
log_mustnot zfs create -o encryption=off $TESTPOOL/$TESTFS2/c5
|
||||
log_must zfs create -o encryption=off $TESTPOOL/$TESTFS2/c5
|
||||
log_must test "$(get_prop 'encryption' $TESTPOOL/$TESTFS2/c5)" == "off"
|
||||
|
||||
log_mustnot zfs create -o encryption=off -o keylocation=prompt \
|
||||
$TESTPOOL/$TESTFS2/c5
|
||||
log_mustnot zfs create -o encryption=off -o keyformat=passphrase \
|
||||
@@ -122,13 +124,13 @@ log_mustnot zfs create -o encryption=off -o keyformat=passphrase \
|
||||
-o keylocation=prompt $TESTPOOL/$TESTFS2/c5
|
||||
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \
|
||||
"$TESTPOOL/$TESTFS2/c5"
|
||||
"$TESTPOOL/$TESTFS2/c6"
|
||||
log_mustnot zfs create -o encryption=on -o keylocation=prompt \
|
||||
$TESTPOOL/$TESTFS2/c6
|
||||
$TESTPOOL/$TESTFS2/c7
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \
|
||||
"-o keyformat=passphrase $TESTPOOL/$TESTFS2/c6"
|
||||
"-o keyformat=passphrase $TESTPOOL/$TESTFS2/c7"
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \
|
||||
"-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS2/c7"
|
||||
"-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS2/c8"
|
||||
|
||||
log_pass "ZFS creates datasets only if they have a valid combination of" \
|
||||
"encryption properties set."
|
||||
|
||||
@@ -46,7 +46,7 @@ function cleanup
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_assert "ZFS should receive to an encrypted child dataset"
|
||||
log_assert "ZFS should receive encrypted filesystems into child dataset"
|
||||
|
||||
typeset passphrase="password"
|
||||
typeset snap="$TESTPOOL/$TESTFS@snap"
|
||||
@@ -60,11 +60,13 @@ log_must eval "echo $passphrase | zfs create -o encryption=on" \
|
||||
log_note "Verifying ZFS will receive to an encrypted child"
|
||||
log_must eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS1/c1"
|
||||
|
||||
log_note "Verifying 'send -p' will not receive to an encrypted child"
|
||||
log_mustnot eval "zfs send -p $snap | zfs receive $TESTPOOL/$TESTFS1/c2"
|
||||
log_note "Verifying 'send -p' will receive to an encrypted child"
|
||||
log_must eval "zfs send -p $snap | zfs receive $TESTPOOL/$TESTFS1/c2"
|
||||
log_must test "$(get_prop 'encryption' $TESTPOOL/$TESTFS1/c2)" == "off"
|
||||
|
||||
log_note "Verifying 'send -R' will not receive to an encrypted child"
|
||||
log_mustnot eval "zfs send -R $snap | zfs receive $TESTPOOL/$TESTFS1/c3"
|
||||
log_note "Verifying 'send -R' will receive to an encrypted child"
|
||||
log_must eval "zfs send -R $snap | zfs receive $TESTPOOL/$TESTFS1/c3"
|
||||
log_must test "$(get_prop 'encryption' $TESTPOOL/$TESTFS1/c3)" == "off"
|
||||
|
||||
log_note "Verifying ZFS will not receive to an encrypted child when the" \
|
||||
"parent key is unloaded"
|
||||
@@ -72,4 +74,4 @@ log_must zfs unmount $TESTPOOL/$TESTFS1
|
||||
log_must zfs unload-key $TESTPOOL/$TESTFS1
|
||||
log_mustnot eval "zfs send $snap | zfs receive $TESTPOOL/$TESTFS1/c4"
|
||||
|
||||
log_pass "ZFS can receive to an encrypted child dataset"
|
||||
log_pass "ZFS can receive encrypted filesystems into child dataset"
|
||||
|
||||
@@ -23,12 +23,13 @@
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# 'zfs rename' should not rename an unencrypted dataset to a child
|
||||
# 'zfs rename' should be able to move an unencrypted dataset to a child
|
||||
# of an encrypted dataset
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create an encrypted dataset
|
||||
# 2. Attempt to rename the default dataset to a child of the encrypted dataset
|
||||
# 2. Rename the default dataset to a child of the encrypted dataset
|
||||
# 3. Confirm the child dataset doesn't have any encryption properties
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
@@ -36,16 +37,17 @@ verify_runnable "both"
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $TESTPOOL/$TESTFS2 && \
|
||||
log_must zfs destroy $TESTPOOL/$TESTFS2
|
||||
log_must zfs destroy -r $TESTPOOL/$TESTFS2
|
||||
}
|
||||
log_onexit cleanup
|
||||
|
||||
log_assert "'zfs rename' should not rename an unencrypted dataset to a" \
|
||||
log_assert "'zfs rename' should allow renaming an unencrypted dataset to a" \
|
||||
"child of an encrypted dataset"
|
||||
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \
|
||||
"-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS2"
|
||||
log_mustnot zfs rename $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS2/$TESTFS
|
||||
log_must zfs rename $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS2/$TESTFS
|
||||
log_must test "$(get_prop 'encryption' $TESTPOOL/$TESTFS2/$TESTFS)" == "off"
|
||||
|
||||
log_pass "'zfs rename' does not rename an unencrypted dataset to a child" \
|
||||
log_pass "'zfs rename' allows renaming an unencrypted dataset to a child" \
|
||||
"of an encrypted dataset"
|
||||
|
||||
Reference in New Issue
Block a user