Multiple authorize methods with python module

Gary Gwin garygwin at gmail.com
Fri Dec 8 01:46:58 CET 2017


If I reference the same python module from mypython1 and mypython2

python mypython1 {
        module = example
        ...
}

python mypython2 {
        module = example
        ...
}

Then FreeRADIUS initializes and functions properly. However, if I use a
different module for each, and in this test case a copy of same tested and
functioning python program with a different name:

python mypython1 {
        module = example
        ...
}

python mypython2 {
        module = example2
        ...
}

I get the following error initializing:

# Instantiating module "mypython2" from file
/etc/freeradius/3.0/mods-enabled/mypython2
python_function_load - Module 'example2' not found
<type 'exceptions.SystemError'> (null argument to internal routine)
python_function_load - Failed to import python function 'example2.authorize'
/etc/freeradius/3.0/mods-enabled/mypython2[2]: Instantiation failed for
module "mypython2"

Gary

On Mon, Dec 4, 2017 at 3:07 PM, Alan DeKok <aland at deployingradius.com>
wrote:

> On Dec 4, 2017, at 5:03 PM, Gary Gwin <garygwin at gmail.com> wrote:
> >
> > I need two distinct python module authorize methods. One for client
> > authentication with the dynamic_clients virtual server and the other for
> > user authorization in the default virtual server. I can detect state in a
> > single python authorize method using various RADIUS request variables,
> but
> > that seems fragile. What I'd really like is a way to use a different
> python
> > authorize method for each the of the dynamci_clients and default virtual
> > servers.
>
>   Makes sense...
>
> > Have had no luck configuring and referencing unique instance names as
> > suggested in radiusd.conf:
> >
> >        #       python mypython1 {
> >        #               config_item = value
> >        #               ...
> >        #       }
> >
> >        #       python mypython2 {
> >        #               config_item = value
> >        #               ...
> >        #       }
> >
> > I've tried various other configuration options.
> >
> > Is this possible? If yes, what needs to be done?
>
>   Yes... just add raddb/mods-enabled/mypython1 with:
>
> python mypython1 {
>         ... python1 config ...
> }
>
>   and add raddb/mods-enabled/mypython2 with:
>
> python mypython2 {
>         ... python2 config ...
> }
>
>   The contents are the same as the normal 'python' module.  The only real
> difference is the name (mypython1) and the script you're loading.
>
>   As always, what does the debug output say?
>
>   Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/
> list/users.html


More information about the Freeradius-Users mailing list