-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement -f option to force inherit key with zfs change-key -if #15821
Draft
digitalsignalperson
wants to merge
1
commit into
openzfs:master
Choose a base branch
from
digitalsignalperson:change-key-force-inherit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_inherit-force.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/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. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# 'zfs change-key -if' should cause a dataset to inherit its parent key | ||
# without the key being loaded | ||
# | ||
# STRATEGY: | ||
# 1. Create a parent encrypted dataset | ||
# 2. Create a child dataset | ||
# 3. Create a copy of the parent dataset | ||
# 4. Send a copy of the child to the copy of the parent | ||
# 5. Attempt to force inherit the parent key without the keys being loaded | ||
# 6. Verify the key is inherited | ||
# 7. Load the parent key | ||
# 8. Verify the key is available for parent and child | ||
# 9. Attempt to mount the datasets | ||
# | ||
|
||
verify_runnable "both" | ||
|
||
function cleanup | ||
{ | ||
datasetexists $TESTPOOL/$TESTFS1 && \ | ||
destroy_dataset $TESTPOOL/$TESTFS1 -r | ||
|
||
datasetexists $TESTPOOL/$TESTFS2 && \ | ||
destroy_dataset $TESTPOOL/$TESTFS2 -r | ||
} | ||
|
||
log_onexit cleanup | ||
|
||
log_assert "'zfs change-key -if' should cause a dataset to inherit its" \ | ||
"parent key" | ||
|
||
log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \ | ||
"-o keyformat=passphrase -o keylocation=prompt $TESTPOOL/$TESTFS1" | ||
log_must eval "echo $PASSPHRASE1 | zfs create $TESTPOOL/$TESTFS1/child" | ||
log_must verify_encryption_root $TESTPOOL/$TESTFS1/child "$TESTPOOL/$TESTFS1" | ||
|
||
log_must zfs snapshot -r $TESTPOOL/$TESTFS1@snap | ||
|
||
log_must eval "zfs send -w $TESTPOOL/$TESTFS1@snap | zfs receive $TESTPOOL/$TESTFS2" | ||
log_must verify_encryption_root $TESTPOOL/$TESTFS2 $TESTPOOL/$TESTFS2 | ||
log_must key_unavailable $TESTPOOL/$TESTFS2 | ||
|
||
log_must eval "zfs send -w $TESTPOOL/$TESTFS1/child@snap | zfs receive $TESTPOOL/$TESTFS2/child" | ||
log_must verify_encryption_root $TESTPOOL/$TESTFS2/child $TESTPOOL/$TESTFS2/child | ||
log_must key_unavailable $TESTPOOL/$TESTFS2/child | ||
|
||
log_must_not zfs change-key -i $TESTPOOL/$TESTFS2/child | ||
log_must_not zfs change-key -f $TESTPOOL/$TESTFS2/child | ||
log_must zfs change-key -if $TESTPOOL/$TESTFS2/child | ||
log_must verify_encryption_root $TESTPOOL/$TESTFS2/child "$TESTPOOL/$TESTFS2" | ||
|
||
log_must key_unavailable $TESTPOOL/$TESTFS2 | ||
log_must key_unavailable $TESTPOOL/$TESTFS2/child | ||
|
||
log_must eval "echo $PASSPHRASE | zfs load-key $TESTPOOL/$TESTFS2" | ||
|
||
log_must key_available $TESTPOOL/$TESTFS2 | ||
log_must key_available $TESTPOOL/$TESTFS2/child | ||
|
||
log_must zfs mount $TESTPOOL/$TESTFS2 | ||
log_must zfs mount $TESTPOOL/$TESTFS2/child | ||
|
||
log_pass "'zfs change-key -if' causes a dataset to inherit its parent key" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied and modified parts from
zfs_change-key_inherit.ksh
andzfs_receive_raw.ksh
, but not sure if I'm supposed to keep these same copyright notices.