-
Notifications
You must be signed in to change notification settings - Fork 17
Add support for LUKS token activation via PIN #460
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
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds a public method Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
jbaublitz
left a comment
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.
Overall this looks good, but I believe that this method was added in 2.4.0 based on a walk through git on the libcryptsetup.h header file. We need a version guard (as you will see with other more recently added methods). I believe for this it should be #[cfg(cryptsetup24supported)]
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/luks2/token.rs (1)
287-287: Consider exposing the token type parameter.The hardcoded
ptr::null()corresponds to thetypeparameter incrypt_activate_by_token_pin, which filters activation to tokens of a specific type (e.g., "luks2-keyring"). WhileNULL(meaning "any type") is a reasonable default, hardcoding it prevents callers from filtering by token type.Consider adding an
Option<&str>parameter fortypeto provide flexibility for use cases that require type-specific token activation. This would align with the pattern used for thenameandtokenparameters.Would you like me to generate a revised implementation that exposes the token type parameter?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/luks2/token.rs(1 hunks)
🔇 Additional comments (2)
src/luks2/token.rs (2)
273-280: LGTM! Consistent parameter handling.The parameter conversion logic correctly mirrors the implementation in
activate_by_token, maintaining consistency across the API.
291-292: Verify theto_byte_ptr!macro conversion.The PIN is passed as a pointer (via
to_byte_ptr!) and length. Ensure that theto_byte_ptr!macro correctly converts&[u8]to the appropriate C pointer type expected by the FFI function (likely*const c_charor*const u8).
jbaublitz
left a comment
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.
Okay looks good to me!
|
Actually, I missed CodeRabbit's "nitpick" comment earlier. It might be an issue. |
|
@lehtojo Would you like to implement that? If so, I can hold off on merging this and re-review once you've done that. |
This commit introduces support for LUKS tokens that require a PIN for activation. Previously, only PIN-less token activation was supported.
|
@jbaublitz Done! I also changed how the name is passed in. |
|
Looks good to me! I'll merge this. |
This pull request introduces support for LUKS tokens that require a PIN for activation. Previously, only PIN-less token activation was supported.
Implementation Details
CryptLuks2TokenHandle::activate_by_token_pinlibcryptsetup_rs_sys::crypt_activate_by_token_pinfunction.I implemented this as a separate method to keep the API clean. However, an alternative approach would be to refactor the existing
CryptLuks2TokenHandle::activate_by_tokenmethod to accept an optional PIN parameter.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.