From 930991a61cc7787ead36e6cd79c1cd5c25ec72f6 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 30 Oct 2017 20:53:49 +0100 Subject: [PATCH] =?UTF-8?q?Cas=20o=C3=B9=20il=20n'y=20a=20pas=20d'ipv4=20s?= =?UTF-8?q?ur=20machine=20active,=20on=20assigne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freeradius_utils/auth.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 8f2a6f8a..16f3f084 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -247,6 +247,9 @@ def check_user_machine_and_register(nas_type, username, mac_address): return (False, u"Machine enregistrée sur le compte d'un autre user...", '') elif not interface.is_active: return (False, u"Machine desactivée", '') + elif not interface.ipv4: + interface.assign_ipv4() + return (True, u"Ok, Reassignation de l'ipv4", user.pwd_ntlm) else: return (True, u"Access ok", user.pwd_ntlm) elif nas_type: @@ -324,9 +327,14 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): 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' + extra_log, DECISION_VLAN) + interface = interface.first() + if not interface.is_active: + return (sw_name, u'Machine non active / adherent non cotisant', VLAN_NOK) + elif not interface.ipv4: + interface.assign_ipv4() + return (sw_name, u"Ok, Reassignation de l'ipv4" + extra_log, DECISION_VLAN) + else: + return (sw_name, u'Machine OK' + extra_log, DECISION_VLAN)