tests: when generating crypted password, generate in target env#1252
Conversation
There are inconsistencies for cryptographic libraries across major distribution releases. From a bionic host, attempting run run crypt.crypt locally using salt and format info from a Jammmy /etc/shadow file will result in a failure to produce an encrpted password. To avoid inconsistencies of python cryptographic libs across Linux releases, perform the password encryption on the system under test.
|
Something doesn't seem right about this resolution to the problem. Even though the user is added via
What am I missing here? I don't understand why this fixes the odd behavior I just mentioned. |
|
Ok @TheRealFalcon and I debugged this further. A couple things to note:
The userdata provided to the instance actually provides additional passwd via chpasswd which effectively overwrites the values provided in "users:" cloud-config.
git-ubuntu clone libxcrypt
cd libxcrypt
# All ubuntu package source uploads are represented under git branches pkg/ubuntu/(bionic|focal|jammy)-(proposed|devel|updates)?
# the defaut clone drops you into pkg/ubuntu/devel (which is current the ubuntu jammy release of libxcrypt)
git diff pkg/ubuntu/bionic-develThe resulting diff shows us that bionic had no yescrypt support, so running python3 crypt.crypt locally on our bionic system will return None for salt/hash/formats it doesn't understand. The solution to validate hashed passwd via crypt on the target environment will avoid this type of failure due to versionitis. |
6c76ab9 to
1f6ebb0
Compare
Aha! This is the piece I was missing. Thanks for the explanation. I agree that passing through crypt behavior rather than assuming a specific version of crypt is the way to go. +1 on the approach |
There was a problem hiding this comment.
In addition to this change I think we need to add yescrypt support (parsing $y in addition to $1/$5/$6/etc) with changes in the docs and in the parsing code.
While we're at it we might want to add support for the other recently added hashing methods supported by crypt too ($2b/$gy/$7).
That doesn't need to be in this PR, however.
This resolves
AssertionError: assert None == '$y$j9T$la3Xe...iM0xEOjQwtjxB'failures on our bionic Jenkins test runner when exercising lxd_container jammy-daily jobsProposed Commit Message
Additional Context
Test Steps
From a bionic host system
Checklist: