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

Discussion in 'Python' started by Martin P. Hellwig, Jul 13, 2006.

  1. 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_ECHO_ON')

    Bus error (core dumped)


    Thanks in advance,

    Martin
     
    Martin P. Hellwig, Jul 13, 2006
    #1
    1. Advertising

  2. 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>
     
    Fredrik Lundh, Jul 13, 2006
    #2
    1. Advertising

  3. >>>>> "Martin" == Martin P Hellwig <> writes:

    > 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
     
    Ganesan Rajagopal, Jul 13, 2006
    #3
  4. 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
     
    Martin P. Hellwig, Jul 15, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henk Punt
    Replies:
    0
    Views:
    424
    Henk Punt
    Jul 23, 2004
  2. gamename
    Replies:
    2
    Views:
    353
    gamename
    Oct 16, 2007
  3. gamename
    Replies:
    0
    Views:
    289
    gamename
    Oct 16, 2007
  4. Alaric Haag

    A "roadmap" for ctypes wrapping?

    Alaric Haag, Mar 23, 2008, in forum: Python
    Replies:
    2
    Views:
    384
    Alaric Haag
    Mar 25, 2008
  5. Robin
    Replies:
    1
    Views:
    543
    Robin
    Nov 13, 2009
Loading...

Share This Page