27 lines
753 B
Python
Executable File
27 lines
753 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
'''
|
|
delete all pffedportal (django) sessions relative to a (list of) sessionid from
|
|
the pfsense captive portal.
|
|
syntax : del_sessions_by_pfsenseid.py [sessionid_from_pfsense] [...]
|
|
'''
|
|
|
|
# initialise django environnement for pffedportal
|
|
# note : the script must be launch into the pffedportal direcory
|
|
import os
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
|
|
|
|
import sys
|
|
from django.contrib.sessions.models import Session
|
|
|
|
pfsenseids = sys.argv[1::]
|
|
|
|
# delete each session containing a sessionid in argv
|
|
for s in Session.objects.all():
|
|
d = s.get_decoded()
|
|
if 'pfsenseid' in d:
|
|
if d['pfsenseid'] in pfsenseids:
|
|
print "delete session %s (pfsenseid=%s)" % (s.pk, d['pfsenseid'])
|
|
s.delete()
|
|
|