F = open(File, "w", 0600)
os.umask(OldMask)
- root = Element('include')
-
for a in accounts:
if not 'voipPassword' in a: continue
if not a.pw_active(): continue
Pass = str(a['voipPassword'])
- user = Element('user')
- user.attrib['id'] = "%s" % (a['uid'])
- root.append(user)
- params = Element('params')
- user.append(params)
- param = Element('param')
- params.append(param)
- param.attrib['name'] = "a1-hash"
- param.attrib['value'] = "%s" % (Pass)
- variables = Element('variables')
- user.append(variables)
- variable = Element('variable')
- variable.attrib['name'] = "toll_allow"
- variable.attrib['value'] = "domestic,international,local"
- variables.append(variable)
-
- F.write("%s" % (prettify(root)))
+ realm = 'sip.debian.org'
+ A1 = "%s:%s%:%s" : (a['uid'], realm, Pass)
+ HA1 = hashlib.md5(A1).hexdigest()
+ Line = "%s:%s:%s:AUTHORIZED" % (a['uid'], HA1, Pass)
+ Line = Sanitize(Line) + "\n"
+ F.write("%s" % (Line))
except:
Die(File, None, F)
Fdb.close()
except:
# python-dbm names the files Fdb.db.db so we want to them to be Fdb.db
- Die(File, Fdb + ".db", None)
+ os.remove(File + ".db")
raise
# python-dbm names the files Fdb.db.db so we want to them to be Fdb.db
- Done(File, Fdb + ".db", None)
+ os.rename (File + ".db", File)
# Generate the anon XEarth marker file
def GenMarkers(accounts, File):