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

M

Martin P. Hellwig

Hey all,

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).

When I tried it, python dumps the core with a Bus Error, I also tried
other combinations but it all ends in a Bus Error, any suggestion how I
should proceed? I don't know much about PAM or C so any help is much
appreciated.

This (and other things) is what I've done:

[martin@xinag /usr/home/martin]$ su
Password:
xinag# python
Python 2.4.3 (#2, May 24 2006, 00:05:56)
[GCC 3.4.4 [FreeBSD] 20050518] on freebsd6
Type "help", "copyright", "credits" or "license" for more information.Bus error (core dumped)


Thanks in advance,

Martin
 
F

Fredrik Lundh

Martin said:
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).

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>
 
G

Ganesan Rajagopal

Martin" == Martin P Hellwig said:
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)

Note that pam_conv is a structure. Passing a string 'PAM_PROMPT_ECHO_ON' and
not passing a pointer for getting the pam_handle_t are both candidates to
cause a crash.

Ganesan
 
M

Martin P. Hellwig

Frederik & Ganesan,

Thanks for the explanation, it did me realize that I should learn some C
first before I'm going to start wrapping something :)

At least I got a reason now to do something with C, though it should
take me some time.

But again, thanks!

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top