X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=943da311577e1c64e25691f8bd95d96c2dea52d7;hb=29816c66079debfbaaa183bd46466698ce4d29fd;hp=fc6dbb20b85d5abc155c5937ad16161d412d24fa;hpb=92ba9e85b9d04a159ca5e15add1b5c8d5eb7ac16;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index fc6dbb2..943da31 100755 --- a/ud-generate +++ b/ud-generate @@ -1076,9 +1076,14 @@ def GenKeyrings(OutDir): # Connect to the ldap server l = connectLDAP() -F = open(PassDir + "/pass-" + pwd.getpwuid(os.getuid())[0], "r") -Pass = F.readline().strip().split(" ") -F.close() +# for testing purposes it's sometimes useful to pass username/password +# via the environment +if 'UD_CREDENTIALS' in os.environ: + Pass = os.environ['UD_CREDENTIALS'].split() +else: + F = open(PassDir + "/pass-" + pwd.getpwuid(os.getuid())[0], "r") + Pass = F.readline().strip().split(" ") + F.close() l.simple_bind_s("uid=" + Pass[0] + "," + BaseDn, Pass[1]) # Fetch all the groups @@ -1123,6 +1128,10 @@ if HostAttrs == None: HostAttrs.sort(lambda x, y: cmp((GetAttr(x, "hostname")).lower(), (GetAttr(y, "hostname")).lower())) +# override globaldir for testing +if 'UD_GENERATEDIR' in os.environ: + GenerateDir = os.environ['UD_GENERATEDIR'] + # Generate global things GlobalDir = GenerateDir + "/" GenDisabledAccounts(GlobalDir + "disabled-accounts")