1

I'am tring to import an external library into (PyJWT) for a freeradius authorization, but when i run freeradius -X i get this error message.

  # Instantiating module "python" from file /etc/freeradius/mods-enabled/python  
mod_init done
rlm_python:mod_load_function: module 'example' is not found  
rlm_python:EXCEPT:<type 'exceptions.ImportError'>: No module named jwt  
rlm_python:mod_load_function: failed to import python function 'example.authorize'  
/etc/freeradius/mods-enabled/python[10]: Instantiation failed for module "python"

When i try to import the package from the terminal, everything is ok.

Python 2.7.10 (default, Oct 14 2015, 16:09:02)  
[GCC 5.2.1 20151010] on linux2  
Type "help", "copyright", "credits" or "license" for more information.  
>>> import jwt  
>>> encoded = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')  
>>> jwt.decode(encoded, 'secret', algorithms=['HS256'])  
{u'some': u'payload'}  

The python file is :

#! /usr/bin/env python  
# ...  

import radiusd  
import jwt   

def instantiate(p):  
 ....  
def authorize(p):  
  print "*** authorize ***"

but if instead i use :

#! /usr/bin/env python  
# ...  

import radiusd  
#import jwt   

def instantiate(p):  
 ....  
def authorize(p):  
  print "*** authorize ***"

,freeradius start as espected .

My dockerfile is :

From ubuntu:15.10  

#1;5C radiussrvbase  docker image configuration file  
# This docker configuration file use ubuntu 15:10 willy distrib and   install freeradius server 3.x.  

RUN     apt-get update \  
        && apt-get install -y software-properties-common \  
        && apt-get install -y python2.7-dev \  
        && apt-get install -y python-pip \  
        && pip install PyJWT \  
        && add-apt-repository ppa:freeradius/stable-3.0 \  
        && apt-get update \  
        && apt-get install -y freeradius-mysql \  
        && apt-get install -y freeradius=3.0.11-ppa2~wily  

WORKDIR /etc/freeradius  
#File import

Should i declare external python library in freeradius ?

Does i miss something ?
Best regard

1 Answers1

2

you have to find where is this module "jwt", so you include in the mods-available/python

python_path = ${modconfdir}/${.:name}:/path/to/the/package1:/path/to/the/package2

example:

python_path = ${modconfdir}/${.:name}:/usr/lib/python2.7/

you can find by: sudo find / -name "*jwt*"

Colt
  • 1,939
  • 6
  • 20
  • 25