-
Notifications
You must be signed in to change notification settings - Fork 27
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
Allow fallback to interactive key entry if TPM2 fails #7
base: main
Are you sure you want to change the base?
Conversation
…take over on failed TPM login attempt. `systemd-cryptsetup` gives no indication or prompt that it's looking for a password (if it failes to unlock via TPM, such as after UEFI firmware or Linux kernel update) and (once you figure out that it's waiting for a password), everything you type is in plain text and not masked or hidden in any way! This disables it waiting for a password if it fails to unlock via TPM2.
If TPM2 and/or keyfile fail to unlock the disk, fall back to interactive unlock.
Password fallback expectation - it does/should work (untested), but I'm not a fan of the code - executing the attempt to unlock inside the if statement chain with '&&' to make it conditional. I can see it is less code than the alternative, but it's not "easy to read". To be fair, I've got patches in the repo, so looking at a diff of those patches is also not easy to read - so I know I'm hypocritical... sorry. I like the general changes in the other commit - but I feel I should also sanity check it before accepting it and I cannot do that right now. Thanks for the 2 PRs though - I'll merge them and/or equivalent soon. |
I've tested these commits on my own machine (they're actually the result of applying the patches from your repo then tweaking until it worked). I agree that the |
Actually, while writing that comment, I realized that you could actually have a variable outside the |
Bring in changes from upstream repo
Tested this on my laptop successfully just now. Disabled secure boot a few days ago to test some stuff, and was expecting to have to manually enter my passphrase, but it took me a while to figure out how to do that. Came looking here to poke around and try to figure out how to fall back to graphical password entry, and what do you know... thanks @aaronjamt! I agree that the logic is hard to follow (the double negatives don't help either), looking forward to the updates. |
Glad that this helped someone, I've had it installed on my laptop since I created this PR and kinda forgot about it. I also agree that the logic isn't great, so if you (or anyone else) has suggestions to make it cleaner I'd love to clean it up. I believe the reason I did it this way is to minimize the number of lines changed by the patch file (for future-proofing sake) but maybe a more readable patch that could be understood and fixed down the road would be better. |
@wmcelderry this looks as readable as shell can be to me. It could be done a little differently by putting the unlock_mapping in a separate |
I think it would be better to use a boolean variable then have a few nested |
First of all, many thanks for writing these scripts to the maintainer, and thanks for making this PR to fix something I require for this to be usuable. I was wondering what is holding back this PR? I've recently had to reinstall and was suprised this wasn't merged yet. |
Thanks, I appreciate it! I like to think of it as my duty to the open source community: find something I don't like, fix it, then push it to the rest of the world
I believe the issue is that the way I've written it is somewhat messy (I don't entirely remember why I wrote it the way I did, if that's the issue I'd be happy to clean it up). Maybe @wmcelderry can pitch in here? |
This PR contains 2 commits that, together, will allow the stock interactive password/key entry to take over if the TPM2 (or keyfile) fails to unlock the disk. If, for instance, you have configured the TPM2 to require that the Linux kernel hasn't been modified but you update it, TPM will not automatically unlock the disk anymore. Currently, it is technically possible to unlock using a regular LUKS key, but only if you're using regular text mode and if you type your password (in plain text without any masking) without being prompted for it. Now, with these commits, it will fall back to whatever default password entry screen is provided by the OS and, if the base OS supports it, allow you to enter your password into a graphical interface or, at the very least, properly prompt you for it and mask what you type in.