Commit ee76d0dc authored by Daniel Stan's avatar Daniel Stan

portail_captif: /enable => autorise surcis

parent d947a602
# -*- coding: utf-8 -*-
import sys
import subprocess
import time
......@@ -32,6 +34,7 @@ deco={
'ex_crous': 'ERR_CUSTOM_EX_CROUS.html',
'ex_crous_enable': 'ERR_CUSTOM_EX_CROUS_ENABLE.html',
'confirmation': 'ERR_RECONNECT_CONFIRM.html',
'age': 'ERR_CUSTOM_AGE.html',
'ago': 'ERR_CUSTOM_AGO.html',
......@@ -48,7 +51,7 @@ deco={
'bloq':'ERR_CUSTOM_BLOQ.html',
'nouvelle_annee':'ERR_CUSTOM_NOUVELLE_ANNEE.html',
'paiement': 'ERR_CUSTOM_NOUVELLE_ANNEE.html',
'paiement': 'ERR_CUSTOM_READHESION.html',
'proxy_local':'ERR_CUSTOM_PROXY_LOCAL.html',
'virus':'ERR_CUSTOM_BL_VIRUS.html',
......@@ -83,7 +86,8 @@ def mac_from_ip(ip):
def enable_access(ip):
"""Lance la commande idoine pour autoriser l'adresse IP"""
p = subprocess.Popen(['sudo', '-n', '/usr/scripts/utils/install-party/ipset_allow', ip],
cmd = ['/usr/sbin/ipset', 'add', 'CONFIRMATION', ip]
p = subprocess.Popen(['sudo', '-n'] + cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
......@@ -169,6 +173,9 @@ def app(environ, start_response):
data = deco['ex_crous_enable']
else:
data = deco['ex_crous']
elif environ.get('RAW_URI', '').startswith('/enable'):
enable_access(ip)
data = deco['confirmation']
elif ip in cache.keys() and cache[ip]['time']>(now - cache_time):
data=cache[ip]['page']
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment