radius: fonction get_prise
This commit is contained in:
parent
4ce302b699
commit
bbb12b733f
2 changed files with 47 additions and 24 deletions
|
@ -62,6 +62,35 @@ def get_machines(auth_data, conn):
|
||||||
conn.search(u'(&%s(|(macAddress=%s)(host=%s.wifi.crans.org)))' %
|
conn.search(u'(&%s(|(macAddress=%s)(host=%s.wifi.crans.org)))' %
|
||||||
(base, username, username))
|
(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)
|
# Decorateur utilisé plus tard (same connection)
|
||||||
use_ldap = with_ldap_conn(retries=2, delay=5, constructor=lc_ldap_anonymous)
|
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):
|
def dummy_fun(p):
|
||||||
return radiusd.RLM_MODULE_OK
|
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):
|
def detach(p=None):
|
||||||
"""Appelé lors du déchargement du module (enfin, normalement)"""
|
"""Appelé lors du déchargement du module (enfin, normalement)"""
|
||||||
print "*** goodbye from example.py ***"
|
print "*** goodbye from example.py ***"
|
||||||
|
|
|
@ -11,25 +11,27 @@ python crans_wifi {
|
||||||
func_authorize = wifi_authorize
|
func_authorize = wifi_authorize
|
||||||
|
|
||||||
# Renseigne le vlan
|
# Renseigne le vlan
|
||||||
|
# remplacer par dummy_fun pour ignorer le tagging de vlan
|
||||||
mod_post_auth = freeradius.auth
|
mod_post_auth = freeradius.auth
|
||||||
func_post_auth = post_auth
|
func_post_auth = post_auth
|
||||||
|
|
||||||
# Le reste est dumb et inutile
|
# Que faire avant de quitter
|
||||||
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
|
|
||||||
|
|
||||||
mod_detach = freeradius.auth
|
mod_detach = freeradius.auth
|
||||||
func_detach = detach
|
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue