Fix python crypt module to work with FIPS #3955
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-static
subpackages, etc.) have had theirRelease
tag incremented../cgmanifest.json
,./toolkit/tools/cgmanifest.json
,./toolkit/scripts/toolchain/cgmanifest.json
,.github/workflows/cgmanifest.json
)./SPECS/LICENSES-AND-NOTICES/data/licenses.json
,./SPECS/LICENSES-AND-NOTICES/LICENSES-MAP.md
,./SPECS/LICENSES-AND-NOTICES/LICENSE-EXCEPTIONS.PHOTON
)*.signatures.json
filessudo make go-tidy-all
andsudo make go-test-coverage
passSummary
When booting a FIPS system using the Azure cloud-init module it would fail to run. The failure was caused by calling
import crypt
here: https://github.com/canonical/cloud-init/blob/cd2cca35a1bf36b584422f431c3ddf55b820434c/cloudinit/sources/DataSourceAzure.py#L8When a system is running in FIPS mode,
glibc
'scrypt
library will detect this and limit the hashing algorithms it makes available. Python'scrypt
module wraps thisglibc
library, and when loaded withimport crypt
it queries the underlying library for the available algorithms. When in FIPS mode the library returns an error code formd5
since it is not a valid FIPS algorithm.A check was added in Python3.9 (python/cpython#16599) to validate the return codes from the glibc library, but it did not consider the different error codes a disabled algorithm would return vs. a missing one.
A recent patch (python/cpython#94742) was added to also handle the error codes generated for the disabled case but was not backported beyond 3.10.
Change Log
Does this affect the toolchain?
YES
Test Methodology