Actions
Bug #24600
closedRoot password is sometimes not encrypted correctly
Description
Looks like we use SecureRandom in BASE64 for random seed and when it contains plus + it breaks the crypt method:
>> x = SecureRandom.base64(6); puts x; "test".crypt("$5$#{x}") ardeALd3 => "$5$ardeALd3$Qok7xO6ConFcg0KasVX4FRrm/FNABHsL7h2xnNh0uo1" >> x = SecureRandom.base64(6); puts x; "test".crypt("$5$#{x}") MWpOs+Y5 => "*0"
This is an ancient code in Foreman, root password had to “sometimes” set incorrectly when saved into database.
Linux crypt method accepts up to 16 characters long salt with characters [a-zA-Z0-9./]
while base64 encoding creates [a-zA-Z0-9+=/]
. This needs to be properly mapped. Maximum length without padding is 12 characters, therefore this is the suggested new salt.
Updated by The Foreman Bot over 6 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/5944 added
Updated by Lukas Zapletal over 6 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset 37c3ca544d03638227c65b03102cbbc6afc1ead5.
Updated by Ivan Necas over 6 years ago
SEO comment: I was this error message when hitting this issue:
Errno::EINVAL: Invalid argument - crypt
Perhaps it will help other folks finding solution when hitting similar problem :)
Actions