diff --git a/freeradius/auth.py b/freeradius/auth.py index 9a9b2d2d..f45aa9af 100644 --- a/freeradius/auth.py +++ b/freeradius/auth.py @@ -62,6 +62,35 @@ def get_machines(auth_data, conn): conn.search(u'(&%s(|(macAddress=%s)(host=%s.wifi.crans.org)))' % (base, username, username)) +def get_prise(auth_data): + """Extrait la prise""" + ## Regarder dans + ## Filaire: NAS-Identifier => contient le nom du switch (batm-3.adm.crans.org) + ## Nas-Port => port du switch (ex 42) + ## WiFi: NAS-Identifier => vide + ## Nas-Port => numéro sur l'interface + ## Nas-IP-Address => adresse IP de la borne + is_wifi = True + bat_name = None + bat_num = None + port = None + + for (key, value) in auth_data: + if key == 'NAS-Identifier': + if value.startswith('bat'): + nas = value.split('.', 1)[0] + try: + bat_name = nas[3] + bat_num = nas.split('-', 1)[1] + except IndexError: + pass + + if key == 'Nas-Port': + port = int(value) + + if bat_num and bat_name and port: + return bat_name + "%01d%02d" % (bat_num, port) + # Decorateur utilisé plus tard (same connection) use_ldap = with_ldap_conn(retries=2, delay=5, constructor=lc_ldap_anonymous) @@ -182,14 +211,6 @@ def post_auth(auth_data, conn): def dummy_fun(p): return radiusd.RLM_MODULE_OK -recv_coa = dummy_fun -send_coa = dummy_fun -preacct = dummy_fun -accounting = dummy_fun -pre_proxy = dummy_fun -post_proxy = dummy_fun - - def detach(p=None): """Appelé lors du déchargement du module (enfin, normalement)""" print "*** goodbye from example.py ***" diff --git a/freeradius/rlm_python_wifi.conf b/freeradius/rlm_python_wifi.conf index 297cf776..a8b73e2b 100644 --- a/freeradius/rlm_python_wifi.conf +++ b/freeradius/rlm_python_wifi.conf @@ -11,25 +11,27 @@ python crans_wifi { func_authorize = wifi_authorize # Renseigne le vlan + # remplacer par dummy_fun pour ignorer le tagging de vlan mod_post_auth = freeradius.auth func_post_auth = post_auth - # Le reste est dumb et inutile - mod_accounting = freeradius.auth - func_accounting = accounting - - mod_pre_proxy = freeradius.auth - func_pre_proxy = pre_proxy - - mod_post_proxy = freeradius.auth - func_post_proxy = post_proxy - - mod_recv_coa = freeradius.auth - func_recv_coa = recv_coa - - mod_send_coa = freeradius.auth - func_send_coa = send_coa - + # Que faire avant de quitter mod_detach = freeradius.auth func_detach = detach + + # Le reste est dumb et inutile + mod_accounting = freeradius.auth + func_accounting = dummy_fun + + mod_pre_proxy = freeradius.auth + func_pre_proxy = dummy_fun + + mod_post_proxy = freeradius.auth + func_post_proxy = dummy_fun + + mod_recv_coa = freeradius.auth + func_recv_coa = dummy_fun + + mod_send_coa = freeradius.auth + func_send_coa = dummy_fun }