dhcp and rlm_python am i missing something?
all i need is just to invoke my python script from dhcp section to perform my actions and return some values. if i got it right, there are handlers in python module, for corresponding sections in radiusd.conf for example, i have instantiate section in radiusd.conf and def instantiate(_params) function in my script and it is being invoked successfully there's python module config as well, where we define module and appropriate function for each event, such as mod_instantiate = "test_freeradius" func_instantiate = "instantiate" next, i've not found any mention of 'dhcp' section in rlm_python sources and even added it. and added module and func_dhcp='dhcp' in the module config nothing happened indeed now, the question. how do i call my python function from dhcp {whatever} section? python script is being called but there's no entry point, like 'python returns noop' therefore i can't return any values into radius instance. weird feeling i'm doing it first in the universe, please any help appreciated, spent over a week on this issue. thanks. ps i dont need any auth, acct, detail, post-auth logic. all i need is to call my python scipt from dhcp section and return values.
ps i dont need any auth, acct, detail, post-auth logic. all i need is to call my python scipt from dhcp section and return values
python.authorize Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
Would you add a few words please? Thanks. On Thu, May 8, 2014 at 12:35 AM, Arran Cudbard-Bell < a.cudbardb@freeradius.org> wrote:
ps i dont need any auth, acct, detail, post-auth logic. all i need is to
call my python scipt from dhcp section and return values
python.authorize
Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team
FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 8 May 2014, at 13:34, Serge Krawczenko <skrawczenko@gmail.com> wrote:
Would you add a few words please? Thanks.
Module calls are <instance name>[.<method override>] If you want to call a python function associated with the authorize section in a normal RADIUS virtual-server, use python.authorize. If you want to call a python function associated with the accounting section in a normal RADIUS virtual-server, use python.accounting. and so on... Pick the behaviour you need and use the correct method override. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
I'm really sorry Arran, python syntax does not allow function naming as python.authorize Also, tried to declare func_dhcp as python.dhcp in the module config, but no, it wants exact function name. Or didn't i get you right again? i have python module call in the instantiate section and i have func_instantiate declared in the module config and it is invoked properly when instantiated i just want the same for dhcp. Thank you. On Thu, May 8, 2014 at 4:15 PM, Arran Cudbard-Bell < a.cudbardb@freeradius.org> wrote:
On 8 May 2014, at 13:34, Serge Krawczenko <skrawczenko@gmail.com> wrote:
Would you add a few words please? Thanks.
Module calls are
<instance name>[.<method override>]
If you want to call a python function associated with the authorize section in a normal RADIUS virtual-server, use python.authorize.
If you want to call a python function associated with the accounting section in a normal RADIUS virtual-server, use python.accounting.
and so on...
Pick the behaviour you need and use the correct method override.
-Arran
Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team
FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Serge Krawczenko wrote:
I'm really sorry Arran, python syntax does not allow function naming as python.authorize
That is what you put into the "dhcp" section of the virtual server.
Also, tried to declare func_dhcp as python.dhcp in the module config, but no, it wants exact function name.
Yes, because it *is* the function name. You can't just put random things in there and expect it to work.
i have python module call in the instantiate section and i have func_instantiate declared in the module config and it is invoked properly when instantiated i just want the same for dhcp.
See the directions above. Alan DeKok.
On 8 May 2014, at 15:24, Serge Krawczenko <skrawczenko@gmail.com> wrote:
I'm really sorry Arran, python syntax does not allow function naming as python.authorize
Um. I didn't say python.authorize was anything to do with python code. In the server configuration, when you list the python module, use python.authorize instead of just python... Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS Development Team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 08/05/14 15:24, Serge Krawczenko wrote:
I'm really sorry Arran, python syntax does not allow function naming as python.authorize
No, that's not what Arran means or said. In the *RADIUS* configs, you can call a module: authorize { ... my_module ... } ...or you can make the server call a different "section" handler of the module e.g. authorize { ... my_module.post_auth ... } ...or: dhcp DHCP-Discover { ... my_module.authorize ... }
Regarding the post-auth I've seen such an opinion somewhere and tested it, unfortunately func_post_auth wasn't called. Does it imply i need to add post-auth section into config like post-auth { python } OR just dhcp is enough and it will be intepreted as post-auth in python module? also, i'm talking about version 2.2.4, should i try 3.x.x? On Thu, May 8, 2014 at 4:05 PM, Phil Mayers <p.mayers@imperial.ac.uk> wrote:
On 07/05/14 22:26, Serge Krawczenko wrote:
next, i've not found any mention of 'dhcp' section in rlm_python sources
"dhcp" sections are actually post-auth. Use:
mod_post_auth = my_dhcp_mod func_post_auth = my_dhcp_func
You don't need to edit the source code. - List info/subscribe/unsubscribe? See http://www.freeradius.org/ list/users.html
here we are my module config python { mod_instantiate = radiusd_test func_instantiate = instantiate mod_dhcp = radiusd_test func_dhcp = dhcp mod_post_auth = radiusd_test func_post_auth = post_auth } my "script", i'm just trying to get any function called import radiusd import os import sys def instantiate(p): log = open ("/tmp/1","w") print >> log, "open" print >> log, p print >> log, __name__ log.close() radiusd.radlog(radiusd.L_DBG, "spam.py: instantiated") return radiusd.RLM_MODULE_OK def dhcp(p): log = open ("/tmp/2","w") print >> log, "open" print >> log, os.environ print >> log, p radiusd.radlog(radiusd.L_DBG, "dhcp: called") return (radiusd.RLM_MODULE_UPDATED, (('Client-IP-Address','10.10.10.3'),)) def post_auth(p): log = open ("/tmp/3","w") print >> log, "open" print >> log, p print >> log, __name__ log.close() return radiusd.RLM_MODULE_OK radiusd config, all default except following: dhcp DHCP-Discover { update reply { DHCP-Message-Type = DHCP-Offer Packet-Dst-Port = 67 } # The contents here are invented. Change them! update reply { DHCP-Domain-Name-Server = 8.8.8.8 # DHCP-Domain-Name-Server = 127.0.0.2 DHCP-Subnet-Mask = 255.255.255.0 DHCP-Router-Address = 10.10.10.2 DHCP-IP-Address-Lease-Time = 60 DHCP-DHCP-Server-Identifier = 10.45.5.233 } python # Do a simple mapping of MAC to assigned IP. # # See below for the definition of the "mac2ip" .... and output -X: server dhcp { # from file /usr/local/etc/raddb/radiusd.conf modules { Module: Checking dhcp DHCP-Discover {...} for more modules to load Module: Linked to module rlm_always Module: Instantiating module "ok" from file /usr/local/etc/raddb/modules/always always ok { rcode = "ok" simulcount = 0 mpp = no } Module: Checking dhcp DHCP-Request {...} for more modules to load Module: Checking dhcp (null) {...} for more modules to load /usr/local/etc/raddb/radiusd.conf[1070]: No name specified for Post-Auth-Type block } # modules } # server radiusd: #### Opening IP addresses and Ports #### listen { type = "auth" ipaddr = * port = 0 } listen { type = "acct" ipaddr = * port = 0 } listen { type = "control" listen { socket = "/usr/local/var/run/radiusd/radiusd.sock" } } listen { type = "auth" ipaddr = 127.0.0.1 port = 18120 } listen { type = "dhcp" ipaddr = 10.45.5.233 port = 67 } ..... Ready to process requests. Received DHCP-Discover of id 4d620942 from 10.45.5.230:68 to 10.45.5.233:67 DHCP-Opcode = Client-Message DHCP-Hardware-Type = Ethernet DHCP-Hardware-Address-Length = 6 DHCP-Hop-Count = 1 DHCP-Transaction-Id = 1298270530 DHCP-Number-of-Seconds = 0 DHCP-Flags = 0 DHCP-Client-IP-Address = 0.0.0.0 DHCP-Your-IP-Address = 0.0.0.0 DHCP-Server-IP-Address = 0.0.0.0 DHCP-Gateway-IP-Address = 10.45.5.230 DHCP-Client-Hardware-Address = 00:1a:92:e7:63:4a DHCP-Message-Type += DHCP-Discover DHCP-Hostname += "qinq" DHCP-Parameter-Request-List += DHCP-Subnet-Mask DHCP-Parameter-Request-List += DHCP-Broadcast-Address DHCP-Parameter-Request-List += DHCP-Time-Offset DHCP-Parameter-Request-List += DHCP-Router-Address DHCP-Parameter-Request-List += DHCP-Domain-Name DHCP-Parameter-Request-List += DHCP-Domain-Name-Server DHCP-Parameter-Request-List += DHCP-Domain-Search DHCP-Parameter-Request-List += DHCP-Hostname DHCP-Parameter-Request-List += DHCP-NETBIOS-Name-Servers DHCP-Parameter-Request-List += DHCP-NETBIOS DHCP-Parameter-Request-List += DHCP-Interface-MTU-Size DHCP-Parameter-Request-List += DHCP-Classless-Static-Route DHCP-Parameter-Request-List += DHCP-NTP-Servers DHCP-Relay-Circuit-Id = 0x000401bd0002 DHCP-Relay-Remote-Id = 0x00065cd998d4a3a0 server dhcp { Trying sub-section dhcp DHCP-Discover {...} +group DHCP-Discover { ++update reply { ++} # update reply = noop ++update reply { ++} # update reply = noop ++[python] = noop ++[ok] = ok On Thu, May 8, 2014 at 5:13 PM, Phil Mayers <p.mayers@imperial.ac.uk> wrote:
On 08/05/14 14:42, Serge Krawczenko wrote:
Regarding the post-auth
I've seen such an opinion somewhere and tested it, unfortunately func_post_auth wasn't called.
Post a debug from "radiusd -X".
- List info/subscribe/unsubscribe? See http://www.freeradius.org/ list/users.html
Gentelmen, finally got it. Works as inteneded. Many thanks. ps hopefully values will be returned properly:) On Thu, May 8, 2014 at 12:26 AM, Serge Krawczenko <skrawczenko@gmail.com>wrote:
all i need is just to invoke my python script from dhcp section to perform my actions and return some values.
if i got it right, there are handlers in python module, for corresponding sections in radiusd.conf
for example, i have instantiate section in radiusd.conf and def instantiate(_params) function in my script and it is being invoked successfully
there's python module config as well, where we define module and appropriate function for each event, such as
mod_instantiate = "test_freeradius" func_instantiate = "instantiate"
next, i've not found any mention of 'dhcp' section in rlm_python sources and even added it.
and added module and func_dhcp='dhcp' in the module config nothing happened indeed
now, the question.
how do i call my python function from dhcp {whatever} section?
python script is being called but there's no entry point, like 'python returns noop' therefore i can't return any values into radius instance.
weird feeling i'm doing it first in the universe, please any help appreciated, spent over a week on this issue. thanks.
ps i dont need any auth, acct, detail, post-auth logic. all i need is to call my python scipt from dhcp section and return values.
Hi,
Gentelmen, finally got it. Works as inteneded.
yes...thats my favourite bit of this - you ask a question, help is given...you dont provide all the required info and then finally a 'its all working now' message without providing your final config section/solution so noone else coming along can see the final working thing required. :( alan
participants (5)
-
A.L.M.Buxey@lboro.ac.uk -
Alan DeKok -
Arran Cudbard-Bell -
Phil Mayers -
Serge Krawczenko