Skip to content

tools/rotate-password.py fails on Python 3.13 (crypt removed) #311

Open

Description

@kasparovabi

Python 3.13 removed the crypt module from the standard library (PEP 594, What's New in 3.13). tools/rotate-password.py imports it on line 20, so on a 3.13 host the script stops before reading the password.

Running the file from a copy of the current tree in Docker with no network, with a two-line shadow file and the password on stdin:

python:3.12-slim   DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
                   root:$6$...:20753:0:99999:7:::
                   user:*:1:0:99999:7:::
python:3.13-slim   ModuleNotFoundError: No module named 'crypt'

There is no drop-in replacement in the standard library, so the fix needs a choice. Two options I can see:

  1. Call openssl passwd -6 -stdin, which produces the same $6$ SHA-512-crypt format that crypt.mksalt() picks by default. On python:3.12-slim a hash made this way passed crypt.crypt(password, hash) == hash, so glibc accepts it.
  2. Depend on crypt-r, a copy of the removed module, and change only the import. I have not installed it here.

I have not tried either option against a real BMC image, only the script itself with a sample shadow file. Happy to send a PR for whichever you prefer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions