freeradius users file doesn't like inline comments
which broke our parenthood implementation
This commit is contained in:
parent
a213295b7c
commit
5b0ca05fe3
1 changed files with 10 additions and 4 deletions
14
main.py
14
main.py
|
@ -72,7 +72,7 @@ def nthash(password):
|
|||
def create_user(username, password, creator):
|
||||
with exclusive_lock:
|
||||
f = open(users_file,"a")
|
||||
f.write('{} NT-Password := "{}" # created by {} \n'.format(username, nthash(password), creator))
|
||||
f.write('# created by {}\n{} NT-Password := "{}"\n'.format(creator, username, nthash(password)))
|
||||
f.close()
|
||||
reload_freeradius()
|
||||
|
||||
|
@ -125,13 +125,19 @@ def index():
|
|||
|
||||
def load_users():
|
||||
users = []
|
||||
creator = None
|
||||
with open(users_file) as f:
|
||||
for l in f:
|
||||
if l.strip().startswith("#"):
|
||||
l = l.strip()
|
||||
if l.startswith("#"):
|
||||
m = re.match("#\s+created by\s+(\S+)")
|
||||
if m:
|
||||
creator = m.group(1)
|
||||
continue
|
||||
m = re.match("(^\S+).*-Password\s+:=\s+\"(\S+)\"(?:\s+#.*created.by\s+(\S+))?", l)
|
||||
m = re.match("(^\S+).*-Password\s+:=\s+\"(\S+)\"", l)
|
||||
if m:
|
||||
users.append(m.groups())
|
||||
users.append((m.group(1), m.group(2), creator)
|
||||
creator = None
|
||||
return users
|
||||
|
||||
def check_login(username, password):
|
||||
|
|
Loading…
Reference in a new issue