ctypes wrapping libpam.so on FreeBSD 6.1 - Python Bus Error

Fredrik Lundh fredrik at pythonware.com
Thu Jul 13 08:31:48 EDT 2006


Martin P. Hellwig wrote:

> I'd like to wrap libpam so that I can use that for authentication and
> password management. I build ctypes (0.9.9.6) on my platform via ports.
>
> Now according to OpenPAM documentation all sessions start with pam_start().
> According to the man page it should contain this:
> pam_start(const char *service, const char *user,
> const struct pam_conv *pam_conv, pam_handle_t **pamh)
>
> Where service in my case should be 'auth' and user 'martin' with
> pam_conv being 'PAM_PROMPT_ECHO_ON' for testing purposes (at least I
> assumed it works this way, but probably I'm doing something wrong,
> though I don't know what the correct way should be like).
> >>> from ctypes import *
> >>> libpam = cdll.LoadLibrary('/usr/lib/libpam.so')
> >>> libpam.pam_start('auth','martin','PAM_PROMPT_ECHO_ON')

passing in a string where the function expects a "struct pam_conv" (i.e. a custom data
structure) is probably not a very good idea...  (look up "structures" in the ctypes manual
for more info on how to handle this)

</F> 






More information about the Python-list mailing list