Skip to content

fix: thread-safe pam.authenticate() (#40) - #71

Merged
FirefighterBlu3 merged 2 commits into
mainfrom
fix/40-thread-safe-authenticate
Jul 26, 2026
Merged

fix: thread-safe pam.authenticate() (#40)#71
FirefighterBlu3 merged 2 commits into
mainfrom
fix/40-thread-safe-authenticate

Conversation

@FirefighterBlu3

Copy link
Copy Markdown
Owner

Summary

  • Stop sharing a process-global PamAuthenticator in pam.authenticate() so concurrent callers no longer race on handle (segfault / ctypes.ArgumentError).
  • Load libpam/libc ctypes bindings once at class level; each auth call still gets its own PAM handle (no global lock on the hot path).
  • Document the threading model in the README; add regression tests and a scratch harness.

Closes #40

Test plan

  • poetry run pytest tests/ -q (54 passed)
  • Ubuntu 24.04 container: scratch/issue40_threaded.py --mode both — 2880/2880 ok for both pam.authenticate() and fresh instances (previously shared mode segfaulted)

Made with Cursor

FirefighterBlu3 and others added 2 commits July 26, 2026 02:23
Stop reusing a process-global PamAuthenticator (issue #40) and load
libpam ctypes bindings once so high-QPS parallel auth stays performant.

Co-authored-by: Cursor <cursoragent@cursor.com>
Disable not-callable for symbols assigned in _ensure_libs, and fix
import grouping / return-statement noise so CI fail-under=8.0 passes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@FirefighterBlu3
FirefighterBlu3 merged commit 7affefe into main Jul 26, 2026
6 checks passed
@FirefighterBlu3
FirefighterBlu3 deleted the fix/40-thread-safe-authenticate branch July 26, 2026 06:28
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.

ctypes.ArgumentError: argument 1: TypeError: expected PamHandle instance instead of NoneType

1 participant