File: rlm_python

package info (click to toggle)
freeradius 1.0.2-4sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,792 kB
  • ctags: 6,980
  • sloc: ansic: 52,618; sh: 9,731; php: 5,764; perl: 2,309; makefile: 1,056; sql: 730; python: 159; tcl: 33; sed: 23
file content (76 lines) | stat: -rw-r--r-- 1,887 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Python module for freeradius
Copyright 2002 Miguel A Paraz <mparaz@mparaz.com>
Copyright 2002 Imperium Technology, Inc.

PURPOSE:
To allow module writers to write modules in a high-level language, 
for implementation or for prototyping.

REQUIRES:
Python - tested with 2.2

BUILDING:
Build with: './configure --with-static-modules=python' since Python does not
supply a dynamic library by default.

USAGE:
Make your module available to the Python interpreter by either putting it
in a standard location, or 'EXPORT PYTHONPATH=$location'.





BUGS:
1. Can't compile statically (./configure --enable-shared=no)  - causes
SIGSEGV on the first malloc() in main().

Design:
1. Support for all module functions.
2. One module per function allowed, for example, from experimental.conf:

	python {
		mod_instantiate = radiusd_test
		func_instantiate = instantiate

		mod_authorize = radiusd_test
		func_authorize = authorize

		mod_accounting = radiusd_test
		func_accounting = accounting

		mod_preacct = radiusd_test
		func_preacct = preacct

		mod_detach = radiusd_test
		func_detach = detach

	}


3. Different functions are wrappers around the same core.
4. func_detach is passed no parameters, returns module return value.
5. If functions returns None (plain 'return' no return), default to RLM_OK
6. Python instantation function can return -1 to signal failure and abort
   startup.

Available to module:
import radiusd
radiusd.rad_log(radiusd.L_XXX, message_string)
radiusd.RLM_XXX



TODO:
1. Do we need to support other pair operations beyond set (:=) ?
2. Should we pass the value pair info as a dict and not a tuple? Faster?
2. Give access to more radiusd variables like the dictionary.
3. Give access to other C functions.  
   Let the Python module deal with the structures directly, instead of
   letting our C code do it afterwards.
   What's a good way to represent this?