Refreshing Python filters?

David Hláčik david at
Sun Jun 8 15:19:18 UTC 2008

Hello Julien,
unbelievable you just solved my really stressing problem and you
helped me a lot! According to my posts on inn-workers last days, i was
facing with modules import problem in python hooks for INN.
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

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 .

Please if you will have time look at this , i have solved whole my
problem with import ldap .. by calling another python script as
command inside my authenticate method. It works OK, but is not "clean"
and "satisfied" solution for my . This is a big problem also in order
to be able use python hooks in INN reasonably.

But, anyway , if you were reading my postings carefully i promised
that i will send a cans of Czech Beer
( using post service. So if you will
send me your postal adress on my mail, i will deliver a package within
2 weeks ( i am serious )

Thanks again,


On Sun, Jun 8, 2008 at 4:32 PM, Julien ÉLIE <julien at> wrote:
> Hi David,
>> -bash-3.1# patch -p0 < patch
>> patching file nnrpd/python.c
>> patch: **** malformed patch at line 6: PY_access(char* file, struct
>> vector *access_vec, char *Username)
> Well...  It is because PuTTY does not deal well with tabulations (it
> converts
> it to spaces on copy/paste).
> Please have a look at this patch for last 2.4.5 STABLE:
> --
> Julien ÉLIE
> « En France, on n'a pas de pétrole, mais on a des idées !
>  Alors, j'ai troqué ma deux-chevaux contre une deux-bœufs ! » (Raymond
> Devos)

More information about the inn-workers mailing list