Minor refactoring of IsInGroup so it can take arrays and dicts
[mirror/userdir-ldap.git] / ud-generate
index 21d8baa..db1c077 100755 (executable)
@@ -62,7 +62,7 @@ SubGroupMap = None
 
 UUID_FORMAT = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
 
-EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)?$")
+EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)(,\s*([^ <>@]+@[^ ,<>@]+))*$")
 BSMTPCheck = re.compile(".*mx 0 (master)\.debian\.org\..*",re.DOTALL)
 PurposeHostField = re.compile(r".*\[\[([\*\-]?[a-z0-9.\-]*)(?:\|.*)?\]\]")
 IsV6Addr = re.compile("^[a-fA-F0-9:]+$")
@@ -172,7 +172,7 @@ def IsInGroup(account, allowed, current_host):
   supgroups=[]
   addGroups(supgroups, account['supplementaryGid'], account['uid'], current_host)
   for g in supgroups:
-     if allowed.has_key(g):
+     if g in allowed:
         return True
   return False
 
@@ -407,8 +407,7 @@ def GenVoipPassword(accounts, File):
       F = open(File, "w", 0600)
       os.umask(OldMask)
 
-      root = Element('domain')
-      root.attrib['name'] = "$${sip_profile}"
+      root = Element('include')
 
       for a in accounts:
          if not 'voipPassword' in a: continue
@@ -424,6 +423,12 @@ def GenVoipPassword(accounts, File):
          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)))
 
@@ -660,6 +665,7 @@ def GenPrivate(accounts, File):
       # Write out the position for each user
       for a in accounts:
          if not a.is_active_user(): continue
+         if a.is_guest_account(): continue
          if not 'privateSub' in a: continue
          try:
             Line = "%s"%(a['privateSub'])
@@ -773,6 +779,7 @@ def GenDNS(accounts, File):
       for a in accounts:
          if not 'dnsZoneEntry' in a: continue
          if not a.is_active_user() and not isRoleAccount(a): continue
+         if a.is_guest_account(): continue
 
          try:
             F.write("; %s\n"%(a.email_address()))