From 1a4b1a4b983b12c1e8cc4e3b0fb6cbdb46376254 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Wed, 4 Oct 2017 04:31:28 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20probl=C3=A8me=20de=20variables=20globales?= =?UTF-8?q?=20r=C3=A9assign=C3=A9es=20en=20fonctions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freeradius_utils/auth.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 55964b83..17e9abab 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -263,6 +263,7 @@ def check_user_machine_and_register(nas_type, username, mac_address): def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): # Get port from switch and port number + extra_log = "" if not nas: return ('?', u'Nas inconnu', VLAN_OK) @@ -275,10 +276,13 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): port = port.first() # Si un vlan a été précisé, on l'utilise pour VLAN_OK if port.vlan_force: - VLAN_OK = int(port.vlan_force.vlan_id) + DECISION_VLAN = int(port.vlan_force.vlan_id) + extra_log = u"Force sur vlan " + str(DECISION_VLAN) + else: + DECISION_VLAN = VLAN_OK if port.radius == 'NO': - return (sw_name, u"Pas d'authentification sur ce port", VLAN_OK) + return (sw_name, u"Pas d'authentification sur ce port" + extra_log, DECISION_VLAN) if port.radius == 'BLOQ': return (sw_name, u'Port desactive', VLAN_NOK) @@ -312,12 +316,12 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): else: result, reason = room_user.first().autoregister_machine(mac_address, nas_type) if result: - return (sw_name, u'Access Ok, Capture de la mac...', VLAN_OK) + return (sw_name, u'Access Ok, Capture de la mac...' + extra_log, DECISION_VLAN) else: return (sw_name, u'Erreur dans le register mac %s' % reason + unicode(mac_address), VLAN_NOK) elif not interface.first().is_active: return (sw_name, u'Machine non active / adherent non cotisant', VLAN_NOK) else: - return (sw_name, u'Machine OK', VLAN_OK) + return (sw_name, u'Machine OK' + extra_log, DECISION_VLAN)