+ Die(File,F,Fdb);
+ raise;
+ Done(File,F,Fdb);
+
+def GenAllForward(l,File):
+ Fdb = None;
+ try:
+ OldMask = os.umask(0022);
+ Fdb = os.popen("cdbmake %s %s.tmp"%(File,File),"w");
+ os.umask(OldMask);
+
+ # Fetch all the users
+ global PasswdAttrs;
+ if PasswdAttrs == None:
+ raise "No Users";
+
+ # Write out the email address for each user
+ for x in PasswdAttrs:
+ if x[1].has_key("emailforward") == 0:
+ continue;
+
+ # Do not allow people to try to buffer overflow busted parsers
+ Forward = GetAttr(x,"emailforward");
+ if len(Forward) > 200:
+ continue;
+
+ User = GetAttr(x,"uid");
+ Fdb.write("+%d,%d:%s->%s\n"%(len(User),len(Forward),User,Forward));
+ Fdb.write("\n");
+ # Oops, something unspeakable happened.
+ except:
+ Fdb.close();
+ raise;
+ if Fdb.close() != None:
+ raise "cdbmake gave an error";
+
+# Generate the anon XEarth marker file
+def GenMarkers(l,File):
+ F = None;
+ Fdb = None;
+ try:
+ F = open(File + ".tmp","w");
+ Fdb = None;
+
+ # Fetch all the users
+ global PasswdAttrs;
+ if PasswdAttrs == None:
+ raise "No Users";
+
+ # Write out the position for each user
+ for x in PasswdAttrs:
+ if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0:
+ continue;
+ try:
+ Line = "%8s %8s \"\""%(DecDegree(GetAttr(x,"latitude"),1),DecDegree(GetAttr(x,"longitude"),1));
+ Line = Sanitize(Line) + "\n";
+ F.write(Line);
+ except:
+ pass;
+
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,F,Fdb);
+ raise;
+ Done(File,F,Fdb);
+
+# Generate the debian-private subscription list
+def GenPrivate(l,File):
+ F = None;
+ Fdb = None;
+ try:
+ F = open(File + ".tmp","w");
+ Fdb = None;
+
+ # Fetch all the users
+ global PasswdAttrs;
+ if PasswdAttrs == None:
+ raise "No Users";
+
+ # Write out the position for each user
+ for x in PasswdAttrs:
+ if x[1].has_key("privatesub") == 0:
+ continue;
+
+ # If the account is locked, do not write it
+ if (string.find(GetAttr(x,"userpassword"),"*LK*") != -1):
+ continue;
+
+ # If the account has no PGP key, do not write it
+ if x[1].has_key("keyfingerprint") == 0:
+ continue;
+
+ # Must be in the Debian group (yuk, hard coded for now)
+ if GetAttr(x,"gidnumber") != "800":
+ continue;
+
+ try:
+ Line = "%s"%(GetAttr(x,"privatesub"));
+ Line = Sanitize(Line) + "\n";
+ F.write(Line);
+ except:
+ pass;
+
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,F,Fdb);
+ raise;
+ Done(File,F,Fdb);
+
+# Generate the DNS Zone file
+def GenDNS(l,File):
+ F = None;
+ Fdb = None;
+ try:
+ F = open(File + ".tmp","w");
+ Fdb = None;
+
+ # Fetch all the users
+ global PasswdAttrs;
+ if PasswdAttrs == None:
+ raise "No Users";
+
+ # Write out the zone file entry for each user
+ for x in PasswdAttrs:
+ if x[1].has_key("dnszoneentry") == 0:
+ continue;
+ try:
+ F.write("; %s\n"%(EmailAddress(x)));
+ for z in x[1]["dnszoneentry"]:
+ Split = string.split(string.lower(z));
+ if string.lower(Split[1]) == 'in':
+ for y in range(0,len(Split)):
+ if Split[y] == "$":
+ Split[y] = "\n\t";
+ Line = string.join(Split," ") + "\n";
+ F.write(Line);
+
+ # Write some identication information
+ if string.lower(Split[2]) != "cname":
+ 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(Line);
+ else:
+ Line = "; Err %s"%(str(Split));
+ F.write(Line);
+
+ F.write("\n");
+ except:
+ pass;
+
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,F,Fdb);