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

clevis-luks-bind: Fix error with password of spaces #280

Merged
merged 2 commits into from
Jan 14, 2021
Merged

clevis-luks-bind: Fix error with password of spaces #280

merged 2 commits into from
Jan 14, 2021

Conversation

ly4096x
Copy link
Contributor

@ly4096x ly4096x commented Jan 10, 2021

This fixes the problem with passwords that contain spaces at beginning or ending. Such a password will make the existing_key variable has an incorrect key and result into a "No key available with this passphrase.` or "Nothing to read on input." error.

@@ -98,8 +98,8 @@ fi
existing_key=
keyfile=
case "${KEY}" in
"") read -r -s -p "Enter existing LUKS password: " existing_key; echo >&2;;
-) read -r -s -p "" existing_key
"") echo -n "Enter existing LUKS password: "; existing_key=$(head -1); echo >&2;;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something bad with this fix is that the password will be displayed as it is being typed. Perhaps a better way to fix this would be to clear IFS? Something like the following:

IFS= read -r -s -p "Enter existing LUKS password: " existing_key; echo >&2;;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. This is a better solution. I have updated my code. Thank you!

This fixes the problem with passwords that contain spaces at beginning or ending. Such a password will make the existing_key variable has an incorrect key and result into a "No key available with this passphrase.` or "Nothing to read on input." error.
Copy link
Collaborator

@sergio-correia sergio-correia left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@sergio-correia sergio-correia merged commit 3cf3f37 into latchset:master Jan 14, 2021
@ly4096x ly4096x deleted the patch-1 branch January 14, 2021 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants