Skip to content
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

Systemd mount generator: don't fail keyload from file if already loaded #10103

Merged
merged 1 commit into from
Mar 9, 2020

Conversation

InsanePrawn
Copy link
Contributor

@InsanePrawn InsanePrawn commented Mar 4, 2020

Motivation and Context

Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

This would lead to systemd marking the system as degraded, for example if an initcpio hook already loaded an encryption key in order to mount the rootfs.

-> No more red text during startup! (make sure not to boot with plymouth or the quiet kernel arg)

Description

Move the code to check whether the key is already loaded
from keylocation=prompt handling to the general key loading code.

How Has This Been Tested?

Manually confirmed the resulting unit files behave correctly tolerate a key already being loaded.
Simple reproducer script here

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied.
  • All commit messages are properly formatted and contain Signed-off-by.

Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

Move the code to check whether the key is already loaded
from keylocation=prompt handling to general key loading code.

Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Mar 4, 2020
@codecov-io
Copy link

Codecov Report

Merging #10103 into master will decrease coverage by <1%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #10103    +/-   ##
========================================
- Coverage      79%      79%   -<1%     
========================================
  Files         385      385            
  Lines      122314   122314            
========================================
- Hits        97013    97009     -4     
- Misses      25301    25305     +4
Flag Coverage Δ
#kernel 80% <ø> (ø) ⬆️
#user 67% <ø> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3212d2...545ec3b. Read the comment docs.

Copy link
Member

@rlaager rlaager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

You might consider using the same variable (keyloadcmd) for both pieces (i.e. the second part overwrites the keyloadcmd variable).

@InsanePrawn
Copy link
Contributor Author

InsanePrawn commented Mar 7, 2020

Thanks for the reviews!

You might consider using the same variable (keyloadcmd) for both pieces (i.e. the second part overwrites the keyloadcmd variable).

I see. Do you want me to make those changes? I have no strong feelings towards either version; I thought a different variable name might help indicate the different levels of shells/escaping.

@rlaager
Copy link
Member

rlaager commented Mar 7, 2020

I don’t have strong feelings about it either. It’s probably fine as is.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Mar 9, 2020
@behlendorf
Copy link
Contributor

I'll go ahead and merge this as is.

@behlendorf behlendorf merged commit ff2f960 into openzfs:master Mar 9, 2020
@InsanePrawn InsanePrawn deleted the sysdgen-skipkeyload-file branch March 11, 2020 11:59
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Apr 22, 2020
Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

Move the code to check whether the key is already loaded
from keylocation=prompt handling to general key loading code.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes openzfs#10103
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Apr 22, 2020
Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

Move the code to check whether the key is already loaded
from keylocation=prompt handling to general key loading code.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes openzfs#10103
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Apr 28, 2020
Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

Move the code to check whether the key is already loaded
from keylocation=prompt handling to general key loading code.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes openzfs#10103
tonyhutter pushed a commit that referenced this pull request May 12, 2020
Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

Move the code to check whether the key is already loaded
from keylocation=prompt handling to general key loading code.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #10103
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
Previously the generated keyload units for encryption roots with
keylocation=file://* didn't contain the code to detect if the key
was already loaded and would be marked failed in such situations.

Move the code to check whether the key is already loaded
from keylocation=prompt handling to general key loading code.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes openzfs#10103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants