Revisión 55
Añadido por jredrejo hace alrededor de 14 años
configura_hostapd.py | ||
---|---|---|
from parsehostapd import parsehostapd
|
||
import socket
|
||
import logging
|
||
import subprocess
|
||
|
||
LOG_FILENAME= "/var/log/configura-hostapd.log"
|
||
fecha=[]
|
||
... | ... | |
return g
|
||
|
||
def reinicia_hostapd():
|
||
resultado = os.system("invoke-rc.d hostapd restart")
|
||
resultado=subprocess.Popen(["invoke-rc.d","hostapd","restart"])
|
||
|
||
|
||
def userIsTeacher(user_name):
|
||
p1 = subprocess.Popen(["id", "-Gn",user_name], stdout=subprocess.PIPE)
|
||
p2 = subprocess.Popen(["grep", 'teachers'], stdin=p1.stdout, stdout=subprocess.PIPE)
|
||
output = p2.communicate()[0]
|
||
return (output != '')
|
||
|
||
if __name__ == '__main__':
|
||
logging.basicConfig(level=logging.DEBUG,
|
||
... | ... | |
f=descargar_fichero(fich)
|
||
if f!="":
|
||
user=devuelve_usuario()
|
||
hos=crea_hostapd(f,user,hora)
|
||
|
||
if userIsTeacher(user):
|
||
hos=crea_hostapd(f,user,hora)
|
||
else: #login de un alumno
|
||
subprocess.Popen(["invoke-rc.d","hostapd","stop"]).wait()
|
||
sys.exit(0)
|
||
|
||
if hos=="":
|
||
logging.getLogger().error("Error al generar las mac autorizadas")
|
||
|
Exportar a: Unified diff
asegura que el usuario es un profesor