Skip to content

Replace crypt with passlib md5_crypt in scheduler - #333

Open
kasparovabi wants to merge 1 commit into
beaker-project:python-3from
kasparovabi:chore/py313-crypt-scheduler
Open

kasparovabi wants to merge 1 commit into
beaker-project:python-3from
kasparovabi:chore/py313-crypt-scheduler

Conversation

@kasparovabi

@kasparovabi kasparovabi commented Sep 24, 2026 •

Copy link
Copy Markdown

#304 moved Server/bkr/server/model/identity.py from crypt.crypt to passlib.hash.md5_crypt. Server/bkr/server/model/scheduler.py still has import crypt at the top and calls crypt.crypt(group_pw, "$1$%s$" % salt) in Recipe.crypt_root_password. Python 3.13 removed the crypt module (PEP 594, What's New in 3.13), so on 3.13 the module import fails before anything in bkr.server.model loads:

$ docker run --rm --network none python:3.13-slim python -c "import crypt"
ModuleNotFoundError: No module named 'crypt'

This PR applies the same change as #304 to that one call site. passlib is already a requirement through identity.py (python3-passlib in beaker.spec and in the test-py3 container), so nothing new gets pulled in.

To check the hashes match I ran, on python:3.11-slim with passlib installed, 500 random password and 8-character salt pairs through both crypt.crypt(pw, "$1$<salt>$") and md5_crypt.using(salt=salt).hash(pw). All 500 were identical. The same call on python:3.13-slim gives the same string for a fixed input ($1$abcdefgh$1y4wFdC1gWzFZU0eph2bJ0 for beaker).

I left the import crypt lines in IntegrationTests alone (test_kickstart.py and three selenium tests) to keep this to the server code #304 touched. I can send those separately if you want them. I have not run the Beaker test suite against this branch.

I read this diff line by line before opening it, and I am happy to adjust or drop it. What brought me here was a checker I maintain that looks for imports of modules Python has removed, so I am saying that up front rather than leaving you to wonder. If you would rather not get this kind of contribution, tell me and I will not send another.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant