Support passing args to the python script
Enables PAM modules to be written in Python
Brought to you by:
rstuart
Support passing args to the python script
I see an error when trying to pass args to my python script =>
/etc/pam.d/sshd =>
auth required pam_python.so my_pam.py --url=http://localhost:8181
Dec 11 14:57:27 the_host /lib/security/my_pam.py[26625]: AttributeError: 'module' object has no attribute 'argv'
From cursory investigation, it looks like PySys_SetArgvEx
needs to be called after Py_Initialize
.
https://stackoverflow.com/questions/13599724/why-is-sys-argv-not-available-in-sublime-api
https://stackoverflow.com/questions/12230210/attributeerror-module-object-has-no-attribute-argv-when-using-python-h
The module arguments aren't passed via
sys.argv
. They can't be. The program your module is running in might be a python one, and in that casesys.argv
will contain the command line arguments for the host program. Instead they are passed ain the manner the PAM Module Writers Guide perscribes:Thus for the C function
PAM_EXTERN int pam_sm_authenticate(pamh, flags, argc, argv)
the equivalent pyhton one ispam_sm_acct_mgmt(pamh, flags, args)
. Theargs
parameter contains the data you are after.Last edit: Russell Stuart 2019-12-12