By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
>>from ctypes import *
libpam = cdll.LoadLibrary('/usr/lib/libpam.so')
libpam.pam_start('auth','martin','PAM_PROMPT_ECH O_ON')
Bus error (core dumped)
Thanks in advance,

Martin
Jul 13 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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>

Jul 13 '06 #2

P: n/a
>>>>"Martin" == Martin P Hellwig <mh******@xs4all.nlwrites:
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

--
Ganesan Rajagopal

Jul 13 '06 #3

P: n/a
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
Jul 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.