+
+# 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,BSMTPFile,HomePrefix):
+ F = None;
+ FB = None;
+ try:
+ F = open(File + ".tmp","w");
+ FB = open(BSMTPFile + ".tmp","w");
+
+ # 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);
+
+ 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(Line);
+ else:
+ Line = "; Err %s"%(str(Split));
+ F.write(Line);
+
+ F.write("\n");
+ except:
+ F.write("; Errors\n");
+ pass;
+
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,F,None);
+ Die(BSMTPFile,FB,None);
+ raise;
+ Done(File,F,None);
+ Done(BSMTPFile,FB,None);
+