python nnrpd auth or access hook import module error

David Hláčik david at
Sun Jun 8 15:50:10 UTC 2008


Lets just see a following scenario, this is my sample authenticate
method, i am importing there commands module (import commands) and
trying to post a result trough syslog to see it trough news.notice log
(please ignore other commands - as i just edited my

def authenticate(self, attributes):
       """Called when python_auth is encountered in readers.conf"""

       # just for debugging purposes
       syslog('notice', 'n_a authenticate() invoked: hostname %s,
ipaddress %s, interface %s, user %s' % (\
               attributes['hostname'], \
               attributes['ipaddress'], \
               attributes['interface'], \

       # do username passworld authentication
       #if 'foo' == str(attributes['user'])  \
       #   and 'foo' == str(attributes['pass']):
       #    syslog('notice', 'authentication by username succeeded')
       #    return ( self.authcodes['ALLOWED'], 'No error', 'default_user')
       #    syslog('notice', 'authentication by username failed')
       #    return ( self.authcodes['DENIED'], 'Access Denied!')

       import os
       result = int(os.popen("%s %s %s"
       import commands
       syslog('notice', commands.getoutput("ls -l"))
       if result == 1:
               syslog('notice', 'authentication by username succeeded')
               return(self.authcodes['ALLOWED'], 'OK')
               syslog('notice', 'authentication by username failed')
               return ( self.authcodes['DENIED'], 'FAILED')

But instead of "ls -l" result inside news.notice log i see :

Jun  8 17:09:44 dev01 nnrpd[25107]: python: n_a authenticate()
invoked: hostname, ipaddress,
interface, user boss
Jun  8 17:09:44 dev01 nnrpd[25107]: python authenticate method
returned wrong result

As you can see it will hang on import commands part in authenticate
method and not continue .
I have tested it trought my script to see if there is no bug
in python code. Code is clean.

Thanks again,


More information about the inn-bugs mailing list