Skip to content

Allow passing mode for CDLL #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pam/__internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ctypes import c_size_t
from ctypes import c_void_p
from ctypes import memmove
from ctypes import DEFAULT_MODE
from ctypes.util import find_library
from typing import Union

Expand Down Expand Up @@ -176,7 +177,7 @@ class PamAuthenticator:
code = 0
reason = None # type: Union[str, bytes, None]

def __init__(self):
def __init__(self, mode=None):
# use a trick of dlopen(), this effectively becomes
# dlopen("", ...) which opens our own executable. since 'python' has
# a libc dependency, this means libc symbols are already available
Expand All @@ -186,7 +187,7 @@ def __init__(self):
libc = cdll.LoadLibrary(None)
self.libc = libc

libpam = CDLL(find_library("pam"))
libpam = CDLL(find_library("pam"), mode=mode if mode else DEFAULT_MODE)
libpam_misc = CDLL(find_library("pam_misc"))

self.handle = None
Expand Down