projects
/
mirror
/
userdir-ldap.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Profile if UD_PROFILE is in environment
[mirror/userdir-ldap.git]
/
ud-useradd
diff --git
a/ud-useradd
b/ud-useradd
index
003f28c
..
099ff89
100755
(executable)
--- a/
ud-useradd
+++ b/
ud-useradd
@@
-35,24
+35,38
@@
HavePrivateList = getattr(ConfModule, "haveprivatelist", True)
# Regrettably ldap doesn't have an integer attribute comparision function
# so we can only cut the search down slightly
# Regrettably ldap doesn't have an integer attribute comparision function
# so we can only cut the search down slightly
+def ShouldIgnoreID(uid):
+ for i in IgnoreUsersForUIDNumberGen:
+ try:
+ if i.search(uid) is not None:
+ return True
+ except AttributeError:
+ if uid == i:
+ return True
+
+ return False
+
# [JT] This is broken with Woody LDAP and the Schema; for now just
# search through all UIDs.
def GetFreeID(l):
# [JT] This is broken with Woody LDAP and the Schema; for now just
# search through all UIDs.
def GetFreeID(l):
- Attrs = l.search_s(Base
Dn,ldap.SCOPE_ONELEVEL
,
- "uidNumber=*",["uidNumber", "gidNumber"]);
+ Attrs = l.search_s(Base
BaseDn,ldap.SCOPE_SUBTREE
,
+ "uidNumber=*",["uidNumber", "gidNumber"
, "uid"
]);
HighestUID = 0;
gids = [];
HighestUID = 0;
gids = [];
+ uids = [];
for I in Attrs:
ID = int(GetAttr(I,"uidNumber","0"));
for I in Attrs:
ID = int(GetAttr(I,"uidNumber","0"));
+ uids.append(ID)
gids.append(int(GetAttr(I, "gidNumber","0")))
gids.append(int(GetAttr(I, "gidNumber","0")))
- if ID > HighestUID:
+ uid = GetAttr(I, "uid", None)
+ if ID > HighestUID and not uid is None and not ShouldIgnoreID(uid):
HighestUID = ID;
HighestUID = ID;
- res
G
ID = HighestUID + 1;
- while res
G
ID in gids:
- res
G
ID += 1
+ res
U
ID = HighestUID + 1;
+ while res
UID in uids or resU
ID in gids:
+ res
U
ID += 1
- return (
HighestUID + 1, resGID);
+ return (
resUID, resUID)
# Main starts here
AdminUser = pwd.getpwuid(os.getuid())[0];
# Main starts here
AdminUser = pwd.getpwuid(os.getuid())[0];