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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin P. Hellwig

    #1

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

    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_ECH O_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.LoadLibrar y('/usr/lib/libpam.so')
    >>libpam.pam_st art('auth','mar tin','PAM_PROMP T_ECHO_ON')
    Bus error (core dumped)


    Thanks in advance,

    Martin
  • Fredrik Lundh

    #2
    Re: ctypes wrapping libpam.so on FreeBSD 6.1 - Python Bus Error

    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_ECH O_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.LoadLibrar y('/usr/lib/libpam.so')
    >libpam.pam_sta rt('auth','mart in','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>



    Comment

    • Ganesan Rajagopal

      #3
      Re: ctypes wrapping libpam.so on FreeBSD 6.1 - Python Bus Error

      >>>>"Martin" == Martin P Hellwig <mhellwig@xs4al l.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_ECH O_ON' and
      not passing a pointer for getting the pam_handle_t are both candidates to
      cause a crash.

      Ganesan

      --
      Ganesan Rajagopal

      Comment

      • Martin P. Hellwig

        #4
        Re: ctypes wrapping libpam.so on FreeBSD 6.1 - Python Bus Error

        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

        Comment

        Working...