X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=54aa36105c861835717419543b069bc59b987bcf;hb=8f5c789b5d2a89f4bb20964f02499ad8808ebcbb;hp=3a9840bd301cb03beadd8751c43391d0b71dfce6;hpb=20a7ce0ff4a25931f46e14b2b245859e52674d3e;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index 3a9840b..54aa361 100755 --- a/ud-generate +++ b/ud-generate @@ -88,7 +88,7 @@ def Done(File,F,Fdb): os.rename(File + ".tdb.tmp",File+".tdb"); # Generate the password list -def GenPasswd(l,File,HomePrefix): +def GenPasswd(l,File,HomePrefix,PwdMarker,UidShift): F = None; try: F = open(File + ".tdb.tmp","w"); @@ -107,7 +107,8 @@ def GenPasswd(l,File,HomePrefix): if len(GetAttr(x,"gecos")) > 100 or len(GetAttr(x,"loginShell")) > 50: continue; - Line = "%s:x:%s:%s:%s:%s%s:%s" % (GetAttr(x,"uid"),\ + Line = "%s:%s:%s:%s:%s:%s%s:%s" % (GetAttr(x,"uid"),\ + PwdMarker,\ GetAttr(x,"uidNumber"),GetAttr(x,"gidNumber"),\ GetAttr(x,"gecos"),HomePrefix,GetAttr(x,"uid"),\ GetAttr(x,"loginShell")); @@ -115,7 +116,7 @@ def GenPasswd(l,File,HomePrefix): Line = Sanitize(Line) + "\n"; F.write("0%u %s" % (I,Line)); F.write(".%s %s" % (GetAttr(x,"uid"),Line)); - F.write("=%s %s" % (GetAttr(x,"uidNumber"),Line)); + F.write("=%s %s" % ((int(GetAttr(x,"uidNumber"))+UidShift),Line)); I = I + 1; # Oops, something unspeakable happened. @@ -208,7 +209,7 @@ def GenSSHShadow(l,File): Done(File,F,None); # Generate the group list -def GenGroup(l,File): +def GenGroup(l,File,UidShift): F = None; try: F = open(File + ".tdb.tmp","w"); @@ -241,7 +242,10 @@ def GenGroup(l,File): for x in GroupMap.keys(): if GroupIDMap.has_key(x) == 0: continue; - Line = "%s:x:%u:" % (x,GroupIDMap[x]); + NewGid = int(GroupIDMap[x]); + if NewGid >= 500: + NewGid = NewGid + UidShift + Line = "%s:x:%u:" % (x,NewGid) Comma = ''; for I in GroupMap[x]: Line = Line + ("%s%s" % (Comma,I)); @@ -249,7 +253,7 @@ def GenGroup(l,File): Line = Sanitize(Line) + "\n"; F.write("0%u %s" % (J,Line)); F.write(".%s %s" % (x,Line)); - F.write("=%u %s" % (GroupIDMap[x],Line)); + F.write("=%u %s" % (NewGid,Line)); J = J + 1; # Oops, something unspeakable happened. @@ -852,9 +856,14 @@ while(1): DoLink(GlobalDir,OutDir,"disabled-accounts") sys.stdout.flush(); - GenPasswd(l,OutDir+"passwd",Split[1]); + UidShift = 0 + if ExtraList.has_key("[UIDSHIFT]"): UidShift=1000 + if ExtraList.has_key("[NOPASSWD]"): + GenPasswd(l,OutDir+"passwd",Split[1], "*", UidShift); + else: + GenPasswd(l,OutDir+"passwd",Split[1], "x", UidShift); sys.stdout.flush(); - GenGroup(l,OutDir+"group"); + GenGroup(l,OutDir+"group", UidShift); if ExtraList.has_key("[UNTRUSTED]"): continue; if not ExtraList.has_key("[NOPASSWD]"):