X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=db6770d3d4ac8e16453784f1803d72de67de1529;hb=refs%2Fheads%2Fsalsa;hp=a8ee8543ef8490603f71ef142dc2353ed61d56d1;hpb=16efeb47640693f4404729f08feeadc670ea0203;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index a8ee854..db6770d 100755 --- a/ud-generate +++ b/ud-generate @@ -32,6 +32,7 @@ from dsa_mq.connection import Connection from dsa_mq.config import Config import string, re, time, ldap, optparse, sys, os, pwd, posix, socket, base64, hashlib, shutil, errno, tarfile, grp, fcntl, dbm +import subprocess from userdir_ldap import * from userdir_exceptions import * import UDLdap @@ -184,9 +185,9 @@ def IsInGroup(account, allowed, current_host): return False def Die(File, F, Fdb): - if F != None: + if F is not None: F.close() - if Fdb != None: + if Fdb is not None: Fdb.close() try: os.remove(File + ".tmp") @@ -198,10 +199,10 @@ def Die(File, F, Fdb): pass def Done(File, F, Fdb): - if F != None: + if F is not None: F.close() os.rename(File + ".tmp", File) - if Fdb != None: + if Fdb is not None: Fdb.close() os.rename(File + ".tdb.tmp", File + ".tdb") @@ -214,6 +215,8 @@ def GenPasswd(accounts, File, HomePrefix, PwdMarker): userlist = {} i = 0 for a in accounts: + if 'loginShell' not in a: + continue # Do not let people try to buffer overflow some busted passwd parser. if len(a['gecos']) > 100 or len(a['loginShell']) > 50: continue @@ -309,7 +312,7 @@ def GenShadowSudo(accounts, File, untrusted, current_host): if 'sudoPassword' in a: for entry in a['sudoPassword']: Match = re.compile('^('+UUID_FORMAT+') (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*-]+) ([^ ]+)$').match(entry) - if Match == None: + if Match is None: continue uuid = Match.group(1) status = Match.group(2) @@ -848,7 +851,7 @@ def GenDNS(accounts, File): F.write(Line) Host = Split[0] + DNSZone - if BSMTPCheck.match(Line) != None: + if BSMTPCheck.match(Line) is not None: F.write("; Has BSMTP\n") # Write some identification information @@ -918,7 +921,7 @@ def ExtractDNSInfo(x): Algorithm = 2 if key_prefix == 'ssh-ed25519': Algorithm = 4 - if Algorithm == None: + if Algorithm is None: continue # and more from the registry sshfp_digest_codepoints = [ (1, 'sha1'), (2, 'sha256') ] @@ -989,7 +992,7 @@ def GenBSMTP(accounts, File, HomePrefix): Line = " ".join(Split) + "\n" Host = Split[0] + DNSZone - if BSMTPCheck.match(Line) != None: + if BSMTPCheck.match(Line) is not None: F.write("%s: user=%s group=Debian file=%s%s/bsmtp/%s\n"%(Host, a['uid'], HomePrefix, a['uid'], Host)) @@ -1142,7 +1145,7 @@ def get_hosts(ldap_conn): "mXRecord", "ipHostNumber", "dnsTTL", "machine", "architecture", "sshfpHostname"]) - if HostAttrs == None: + if HostAttrs is None: raise UDEmptyList, "No Hosts" HostAttrs.sort(lambda x, y: cmp((GetAttr(x, "hostname")).lower(), (GetAttr(y, "hostname")).lower())) @@ -1300,8 +1303,8 @@ def generate_host(host, global_dir, all_accounts, all_hosts, ssh_userkeys): DoLink(global_dir, OutDir, "mail-rhsbl") DoLink(global_dir, OutDir, "mail-whitelist") DoLink(global_dir, OutDir, "all-accounts.json") - DoLink(global_dir, Outdir, "default-mail-options.cdb") - DoLink(global_dir, Outdir, "default-mail-options.db") + DoLink(global_dir, OutDir, "default-mail-options.cdb") + DoLink(global_dir, OutDir, "default-mail-options.db") GenCDB(accounts, OutDir + "user-forward.cdb", 'emailForward') GenDBM(accounts, OutDir + "user-forward.db", 'emailForward') GenCDB(accounts, OutDir + "batv-tokens.cdb", 'bATVToken') @@ -1330,7 +1333,7 @@ def generate_host(host, global_dir, all_accounts, all_hosts, ssh_userkeys): v = entry.split('=',1) if v[0] != 'GITOLITE' or len(v) != 2: continue options = v[1].split(',') - group = options.pop(0); + group = options.pop(0) gitolite_accounts = filter(lambda x: IsInGroup(x, [group], current_host), all_accounts) if 'nohosts' not in options: gitolite_hosts = filter(lambda x: GitoliteExportHosts.match(x[1]["hostname"][0]), all_hosts)