Skip to content

Replace deprecated crypt module and bump version to 2.1 - #48

Merged
ericbsd merged 1 commit into
masterfrom
replace-deprecation
Oct 5, 2026
Merged

ericbsd merged 1 commit into
masterfrom
replace-deprecation

Conversation

@ericbsd

@ericbsd ericbsd commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

The crypt module is removed in Python 3.13. Verify the password by calling crypt(3) from libcrypt through ctypes instead, comparing in constant time and rejecting empty or locked hashes. Stop printing part of the stored hash to stdout.

Replace the no-op package_dir with packages=[] in setup.py.

Summary by Sourcery

Maintain password authentication compatibility with modern Python while improving verification security and package configuration.

Bug Fixes:

  • Replace the deprecated Python crypt module with libcrypt-based password verification compatible with Python 3.13.
  • Harden password checks by rejecting empty or locked hashes, comparing results in constant time, and avoiding stored-hash output.

Enhancements:

  • Clean up package configuration by replacing the no-op package_dir setting with an explicit empty package list.

The crypt module is removed in Python 3.13. Verify the password by
calling crypt(3) from libcrypt through ctypes instead, comparing in
constant time and rejecting empty or locked hashes. Stop printing
part of the stored hash to stdout.

Replace the no-op package_dir with packages=[] in setup.py.
@ericbsd
ericbsd requested review from a team as code owners October 4, 2026 11:56
@sourcery-ai

sourcery-ai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR prepares the project for Python 3.13 by replacing the deprecated crypt module with libcrypt access via ctypes and safer password-hash handling, while updating packaging configuration and the release version to 2.1.

Sequence diagram for ctypes-based password verification

sequenceDiagram
    participant User
    participant software_station
    participant libcrypt

    User->>software_station: enter password
    software_station->>software_station: ctypes.CDLL
    software_station->>libcrypt: crypt(password, stored_hash)
    libcrypt-->>software_station: computed_hash
    software_station->>software_station: hmac.compare_digest
    alt empty or locked stored hash
        software_station-->>User: reject password
    else hashes differ
        software_station-->>User: reject password
    else hashes match
        software_station-->>User: accept password
    end
Loading

File-Level Changes

Change Details Files
Replace Python's removed crypt-module dependency with a ctypes-based libcrypt password verification path.
  • Load and call the system crypt(3) function through ctypes.
  • Compare the generated hash with the stored hash in constant time.
  • Reject empty and locked password hashes before verification.
  • Remove stdout output that exposed part of the stored hash.
software-station
Update packaging metadata for the 2.1 release.
  • Replace the no-op package_dir configuration with packages=[].
  • Bump the package version to 2.1.
setup.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. This changes password verification at an authentication boundary by replacing Python's crypt call with a direct libcrypt invocation and digest comparison. If the ctypes binding or hash handling is wrong, users could be denied access or an invalid password could be accepted; reverting restores the old check but cannot undo any access granted while the faulty verifier was live.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@ericbsd
ericbsd merged commit 537c523 into master Oct 5, 2026
2 checks passed
@ericbsd
ericbsd deleted the replace-deprecation branch October 5, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants