1 ## $Id: nnrpd_access_wrapper.py 7899 2008-06-22 18:22:07Z iulius $
3 ## Example wrapper for support of old Python authentication scripts,
6 ## This file contains a sample Python script which can be used to
7 ## duplicate the behaviour of the old nnrppythonauth functionality.
8 ## This script only supports access control.
10 ## How to use this wrapper:
11 ## - insert your authentication class into this file;
12 ## - rename your authentication class OLDAUTH.
14 ## See the INN Python Filtering and Authentication Hooks documentation
15 ## for more information.
16 ## The use of this file is *discouraged*.
19 ## Insert your old auth class here.
20 ## Do not include the code which sets the hook.
25 ## Wrapper ACCESS class. It creates an instance of the old class and
26 ## calls its methods. Arguments and return values are munged as
27 ## needed to fit the new way of doing things.
30 """Provide access callbacks to nnrpd."""
31 def access_init(self):
34 def access(self, attributes):
35 attributes['type'] = buffer('connect')
36 perm = (self.old).authenticate(attributes)
37 result = dict([('users','*')])
39 result['read'] = perm[3]
41 result['post'] = perm[3]
44 def access_close(self):
48 ## The rest is used to hook up the access module on nnrpd. It is unlikely
49 ## you will ever need to modify this.
51 ## Import functions exposed by nnrpd. This import must succeed, or nothing
55 ## Create a class instance.
58 ## ...and try to hook up on nnrpd. This would make access object methods visible
61 set_auth_hook(myaccess)
62 syslog('notice', "access module successfully hooked into nnrpd")
63 except Exception, errmsg:
64 syslog('error', "Cannot obtain nnrpd hook for access method: %s" % errmsg[0])