rlm_python import error undefinde symbol

Alexander Yu. Solodukhin alt at softwarium.net
Sat Feb 28 21:40:35 CET 2009


Hi all.
I try to use rlm_python and got import error on importing any module that  
relevant on shared object.
Here an rlm_python configuration:

## cut
python {
         mod_instantiate = account
         func_instantiate = instantiate

         mod_authorize = account
         func_authorize = authorize

         mod_accounting = account
         func_accounting = accounting

         mod_preproxy = account
         func_preproxy = preproxy

         mod_postproxy = account
         func_postproxy = postproxy

         mod_postauth = account
         func_postauth = postauth

         mod_detach = account
         func_detach = detach
}
## end cut

account.py is radiusd_test.py from src/modules/rlm_python with one line  
added on top of file:
import time

'time' is not plain python module, it is shared object found at  
/usr/lib/python2.5/lib-dynload/time.so

After starting radius i got this error:

rlm_python:python_load_function: module 'account' is not found
rlm_python:EXCEPT:<type 'exceptions.ImportError'>:  
/usr/lib/python2.5/lib-dynload/time.so: undefined symbol: PyExc_ValueError

I was examine rlm_python code, and example 'C' code from python  
documentation on how to embedd python into 'C', and don't found major  
differences.

This code works fine:

#include <Python.h>

int
main(int argc, char *argv[])
{
     PyObject *pName, *pModule, *pDict, *pFunc;
     PyObject *pArgs, *pValue;
     int i;

     if (argc < 3) {
         fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
         return 1;
     }

     Py_Initialize();
     pName = PyString_FromString(argv[1]);
     /* Error checking of pName left out */
     Py_INCREF(pName);

     pModule = PyImport_Import(pName);
     Py_DECREF(pName);

     if (pModule != NULL) {
         pFunc = PyObject_GetAttrString(pModule, argv[2]);
         /* pFunc is a new reference */

         if (pFunc && PyCallable_Check(pFunc)) {
             pArgs = PyTuple_New(argc - 3);
             for (i = 0; i < argc - 3; ++i) {
                 pValue = PyInt_FromLong(atoi(argv[i + 3]));
                 if (!pValue) {
                     Py_DECREF(pArgs);
                     Py_DECREF(pModule);
                     fprintf(stderr, "Cannot convert argument\n");
                     return 1;
                 }
                 /* pValue reference stolen here: */
                 PyTuple_SetItem(pArgs, i, pValue);
             }
             pValue = PyObject_CallObject(pFunc, pArgs);
             Py_DECREF(pArgs);
             if (pValue != NULL) {
                 printf("Result of call: %ld\n", PyInt_AsLong(pValue));
                 Py_DECREF(pValue);
             }
             else {
                 Py_DECREF(pFunc);
                 Py_DECREF(pModule);
                 PyErr_Print();
                 fprintf(stderr,"Call failed\n");
                 return 1;
             }
         }
         else {
             if (PyErr_Occurred())
                 PyErr_Print();
             fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
         }
         Py_XDECREF(pFunc);
         Py_DECREF(pModule);
     }
     else {
         PyErr_Print();
         fprintf(stderr, "Failed to load \"%s\"\n", argv[1]);
         return 1;
     }
     Py_Finalize();
     return 0;
}

Compiled with:
gcc call.c -o call -I/usr/include/python2.5 -L/usr/lib/python2.5/config  
-lpython2.5

Why this code does not through 'undefined symbol' error and rlm_python  
does?

PS: I read mailing list before posting this question and saw that this  
problem was found in 2007. I try newst freeradius 2.1.3 and problem still  
exists.

Any feedback will be great.


-- 
ISP CrIS, Softwarium



More information about the Freeradius-Users mailing list