Allowed = None;
CurrentHost = "";
-EmailCheck = re.compile("^([^<>@]+@.+)?$");
+EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)?$");
+BSMTPCheck = re.compile(".*mx 0 klecker\.debian\.org\..*",re.DOTALL);
+DNSZone = ".debian.net"
def Sanitize(Str):
return string.translate(Str,string.maketrans("\n\r\t","$$$"));
raise "cdbmake gave an error";
Done(File,F,None);
+def GenSSH2Shadow(l,File):
+ F = None;
+ Fdb = None;
+ try:
+ OldMask = os.umask(0077);
+ F = open(File + ".tmp","w",0600);
+ Fdb = os.popen("cdbmake %s.cdb %s.cdb.tmp"%(File,File),"w");
+ os.umask(OldMask);
+
+ # Fetch all the users
+ global PasswdAttrs;
+ if PasswdAttrs == None:
+ raise "No Users";
+
+ I = 0;
+ for x in PasswdAttrs:
+ if x[1].has_key("uidnumber") == 0 or \
+ x[1].has_key("sshdsaauthkey") == 0:
+ continue;
+ for I in x[1]["sshdsaauthkey"]:
+ User = GetAttr(x,"uid");
+ Line = "%s: %s" %(User,I);
+ Line = Sanitize(Line) + "\n";
+ F.write(Line);
+ Fdb.write("+%d,%d:%s->%s\n"%(len(User),len(I),User,I));
+ Fdb.write("\n");
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,F,Fdb);
+ raise;
+ if Fdb.close() != None:
+ raise "cdbmake gave an error";
+ Done(File,F,None);
+
# Generate the group list
def GenGroup(l,File):
F = None;
Done(File,F,Fdb);
# Generate the DNS Zone file
-def GenDNS(l,File):
+def GenDNS(l,File,BSMTPFile,HomePrefix):
F = None;
- Fdb = None;
+ FB = None;
try:
F = open(File + ".tmp","w");
- Fdb = None;
-
+ FB = open(BSMTPFile + ".tmp","w");
+
# Fetch all the users
global PasswdAttrs;
if PasswdAttrs == None:
Line = string.join(Split," ") + "\n";
F.write(Line);
- # Write some identication information
- if string.lower(Split[2]) != "cname":
+ Host = Split[0] + DNSZone;
+ if BSMTPCheck.match(Line) != None:
+ F.write("; Has BSMTP\n");
+ FB.write("%s: user=%s group=Debian file=%s%s/bsmtp/%s\n"%(Host,
+ GetAttr(x,"uid"),HomePrefix,GetAttr(x,"uid"),Host));
+
+ # Write some identification information
+ if string.lower(Split[2]) == "a":
Line = "%s IN TXT \"%s\"\n"%(Split[0],EmailAddress(x));
for y in x[1]["keyfingerprint"]:
Line = Line + "%s IN TXT \"PGP %s\"\n"%(Split[0],FormatPGPKey(y));
F.write("\n");
except:
+ F.write("; Errors\n");
pass;
# Oops, something unspeakable happened.
except:
- Die(File,F,Fdb);
+ Die(File,F,None);
+ Die(BSMTPFile,FB,None);
raise;
- Done(File,F,Fdb);
+ Done(File,F,None);
+ Done(BSMTPFile,FB,None);
# Connect to the ldap server
l = ldap.open(LDAPServer);
"shadowmin","shadowmax","shadowwarning","shadowinactive",
"shadowexpire","emailforward","latitude","longitude",\
"allowedhosts","sshrsaauthkey","dnszoneentry","cn","sn",\
- "keyfingerprint","privatesub"]);
+ "keyfingerprint","privatesub","sshdsaauthkey"]);
# Open the control file
if len(sys.argv) == 1:
# Generate global things
GlobalDir = GenerateDir+"/";
+GenSSH2Shadow(l,GlobalDir+"ssh-dsa-shadow");
GenSSHShadow(l,GlobalDir+"ssh-rsa-shadow");
GenAllForward(l,GlobalDir+"mail-forward.cdb");
GenMarkers(l,GlobalDir+"markers");
-GenDNS(l,GlobalDir+"dns-zone");
GenPrivate(l,GlobalDir+"debian-private");
# Compatibility.
DoLink(GlobalDir,OutDir,"forward-alias");
if ExtraList.has_key("[DNS]"):
- DoLink(GlobalDir,OutDir,"dns-zone");
+ GenDNS(l,OutDir+"dns-zone",OutDir+"bsmtp",Split[1]);
if ExtraList.has_key("[PRIVATE]"):
DoLink(GlobalDir,OutDir,"debian-private");