-# Fetch all the users
-PasswdAttrs = l.search_s(BaseDn, ldap.SCOPE_ONELEVEL, "uid=*",\
- ["uid", "uidNumber", "gidNumber", "supplementaryGid",\
- "gecos", "loginShell", "userPassword", "shadowLastChange",\
- "shadowMin", "shadowMax", "shadowWarning", "shadowInactive",
- "shadowExpire", "emailForward", "latitude", "longitude",\
- "allowedHost", "sshRSAAuthKey", "dnsZoneEntry", "cn", "sn",\
- "keyFingerPrint", "privateSub", "mailDisableMessage",\
- "mailGreylisting", "mailCallout", "mailRBL", "mailRHSBL",\
- "mailWhitelist", "sudoPassword", "objectClass", "accountStatus"])
-
-if PasswdAttrs is None:
- raise UDEmptyList, "No Users"
-
-# Fetch all the hosts
-HostAttrs = l.search_s(HostBaseDn, ldap.SCOPE_ONELEVEL, "sshRSAHostKey=*",\
- ["hostname", "sshRSAHostKey", "purpose"])
-
-# Open the control file
-if len(sys.argv) == 1:
- F = open(GenerateConf, "r")
-else:
- F = open(sys.argv[1], "r")
-
-# Generate global things
-GlobalDir = GenerateDir + "/"
-GenDisabledAccounts(GlobalDir + "disabled-accounts")
-
-PasswdAttrs = filter(lambda x: not IsRetired(x), PasswdAttrs)
-#DebianUsers = filter(lambda x: IsGidDebian(x), PasswdAttrs)
-DebianUsers = PasswdAttrs
-
-CheckForward()
-
-GenMailDisable(GlobalDir + "mail-disable")
-GenAllForward(GlobalDir + "mail-forward.cdb")
-GenPrivate(GlobalDir + "debian-private")
-#GenSSHKnown(l,GlobalDir+"authorized_keys", 'authorized_keys')
-GenMailBool(GlobalDir + "mail-greylist", "mailGreylisting")
-GenMailBool(GlobalDir + "mail-callout", "mailCallout")
-GenMailList(GlobalDir + "mail-rbl", "mailRBL")
-GenMailList(GlobalDir + "mail-rhsbl", "mailRHSBL")
-GenMailList(GlobalDir + "mail-whitelist", "mailWhitelist")
-GenKeyrings(GlobalDir)
-
-# Compatibility.
-GenForward(GlobalDir + "forward-alias")
-
-PasswdAttrs = filter(lambda x: not x in DisabledUsers, PasswdAttrs)
-
-SSHFiles = GenSSHShadow()
-GenMarkers(GlobalDir + "markers")
-GenSSHKnown(GlobalDir + "ssh_known_hosts")
-GenHosts(l, GlobalDir + "debianhosts")
-
-while(1):
- Line = F.readline()
- if Line == "":
- break
- Line = Line.strip()
- if Line == "":
- continue
- if Line[0] == '#':
- continue
+def generate_all(global_dir, ldap_conn):
+ accounts = get_accounts(ldap_conn)
+ host_attrs = get_hosts(ldap_conn)
+
+ global_dir += '/'
+ # Generate global things
+ accounts_disabled = GenDisabledAccounts(accounts, global_dir + "disabled-accounts")
+
+ accounts = filter(lambda x: not IsRetired(x), accounts)
+ #accounts_DDs = filter(lambda x: IsGidDebian(x), accounts)
+
+ CheckForward(accounts)
+
+ GenMailDisable(accounts, global_dir + "mail-disable")
+ GenCDB(accounts, global_dir + "mail-forward.cdb", 'emailForward')
+ GenCDB(accounts, global_dir + "mail-contentinspectionaction.cdb", 'mailContentInspectionAction')
+ GenPrivate(accounts, global_dir + "debian-private")
+ GenSSHKnown(host_attrs, global_dir+"authorized_keys", 'authorized_keys')
+ GenMailBool(accounts, global_dir + "mail-greylist", "mailGreylisting")
+ GenMailBool(accounts, global_dir + "mail-callout", "mailCallout")
+ GenMailList(accounts, global_dir + "mail-rbl", "mailRBL")
+ GenMailList(accounts, global_dir + "mail-rhsbl", "mailRHSBL")
+ GenMailList(accounts, global_dir + "mail-whitelist", "mailWhitelist")
+ GenWebPassword(accounts, global_dir + "web-passwords")
+ GenKeyrings(global_dir)
+
+ # Compatibility.
+ GenForward(accounts, global_dir + "forward-alias")
+
+ GenAllUsers(accounts, global_dir + 'all-accounts.json')
+ accounts = filter(lambda a: not a in accounts_disabled, accounts)
+
+ ssh_files = GenSSHShadow(global_dir, accounts)
+ GenMarkers(accounts, global_dir + "markers")
+ GenSSHKnown(host_attrs, global_dir + "ssh_known_hosts")
+ GenHosts(host_attrs, global_dir + "debianhosts")
+ GenSSHGitolite(accounts, global_dir + "ssh-gitolite")
+
+ GenDNS(accounts, global_dir + "dns-zone")
+ GenZoneRecords(host_attrs, global_dir + "dns-sshfp")
+
+ for host in host_attrs:
+ if not "hostname" in host[1]:
+ continue
+ generate_host(host, global_dir, accounts, ssh_files)
+
+def generate_host(host, global_dir, accounts, ssh_files):
+ global CurrentHost