Skip to content

Remove use of crypt, removed module in py3.13 - #67789

Merged
dwoz merged 2 commits into
saltstack:masterfrom
Vaelatern:remove-crypt
Nov 23, 2026
Merged

dwoz merged 2 commits into
saltstack:masterfrom
Vaelatern:remove-crypt

Conversation

@Vaelatern

Copy link
Copy Markdown
Contributor

What does this PR do?

What issues does this PR fix or reference?

Fixes #67118

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No but I'm set up to when wanted.

@twangboy

twangboy commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

Requirements probably need to be built for this in order for passlib to actually be propagated to the static requirements files.

@twangboy

Copy link
Copy Markdown
Contributor

Rebase, resolve conflicts, run pre-commit so the static requirements files are updated.

@Vaelatern

Copy link
Copy Markdown
Contributor Author

Ran pre-commit and here is a rebased force push.

twangboy
twangboy previously approved these changes Apr 27, 2026
@twangboy

Copy link
Copy Markdown
Contributor

Could we get a changelog please?

@Vaelatern

Copy link
Copy Markdown
Contributor Author

Could we get a changelog please?

done

Vaelatern and others added 2 commits November 22, 2026 23:28
The crypt module was deprecated in Python 3.11 and removed in 3.13.
salt/utils/pycrypto.py had a try/except ImportError on `import crypt`
that masked the actual failure mode: on 3.11+ the import would resolve
to `salt.utils.crypt` (a Salt internal helper), making HAS_CRYPT
spuriously True, then crashing at module load with
`AttributeError: module 'crypt' has no attribute 'methods'`.

Drop the crypt-based code path entirely and rely on passlib for
hashing. Add `passlib` to runtime requirements.

Update callers in tests that referenced the removed `methods` and
`HAS_CRYPT` symbols. Skip the nxos check_password test that depended
on crypt-style (no-rounds) hashes; passlib's sha256_crypt always
emits a `rounds=` prefix that nxos.check_password's existing regex
cannot parse — that's a separate bug.

Fixes saltstack#67118
- test_pycrypto_no_crypt_import: verifies HAS_CRYPT and module-level
  methods dict are gone (would fail on master where crypt.methods is
  referenced at import time)
- test_gen_hash_passlib: parametrized test covering sha512/sha256/md5/crypt
  via passlib (the only remaining backend after crypt removal)
- test_gen_hash_no_lib: verifies SaltInvocationError when HAS_PASSLIB=False

Fixes saltstack#67118

This branch was previously deployed

1 inactive deployment
ci — 4ac0bf59 Deployed Nov 23, 2026 by dwoz via Build Onedir Packages / macOS (arm64) #29506
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Salt relies on crypt module, deprecated in 3.11 and removed in 3.13

4 participants