"machine": ["Machine Hardware", 10],
"memory": ["Memory", 11],
"disk": ["Disk", 12],
+ "physicalHost": ["Physical Host", 13],
"sshRSAHostKey": ["SSH Host Keys", 14],
- "bandwidth": ["Bandwidth", 15]};
+ "bandwidth": ["Bandwidth", 15],
+ "purpose": ["Purposes", 16],};
AttrPrompt = {"description": ["Purpose of the machine"],
"hostname": ["The hostnames for the box (ipv4/ipv6)"],
"machine": ["Hardware description"],
"memory": ["Installed RAM"],
"disk": ["Disk Space, RAID levels, etc"],
+ "physicalHost": ["The box hosting this virtual server"],
"sshRSAHostKey": ["A copy of /etc/ssh/ssh_*host_key.pub"],
- "bandwidth": ["Available outbound"]};
+ "bandwidth": ["Available outbound"],
+ "purpose": ["The purposes of this host"],};
# Create a map of IDs to desc,value,attr
OrderedIndex = {};
# Change a single attribute
def ChangeAttr(Attrs,Attr):
- if (Attr == "sponsor" or Attr == "sshRSAHostKey"):
+ if (Attr in ["sponsor", "sshRSAHostKey", "purpose"]):
return MultiChangeAttr(Attrs,Attr);
print "Old value: '%s'" % (GetAttr(Attrs,Attr,""));
l = ldap.open(LDAPServer);
l.simple_bind_s("","")
-HBaseDn = HostBaseDn
-
if ListMode == 1:
- Attrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=*")
+ Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=*")
hosts = []
for hAttrs in Attrs:
hosts.append(hAttrs[1]['host'][0])
sys.exit(0)
elif FingerPrints == 1:
if Host is not None:
- Attrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=" + Host)
+ Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=" + Host)
else:
- Attrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=*")
+ Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=*")
hosts = []
for hAttrs in Attrs:
hosts.append(hAttrs[1]['host'][0])
os.unlink(tmpfile)
sys.exit(0)
-HostDn = "host=" + Host + "," + HBaseDn;
+HostDn = "host=" + Host + "," + HostBaseDn;
# Query the server for all of the attributes
-Attrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=" + Host);
+Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=" + Host);
if len(Attrs) == 0:
print "Host",Host,"was not found.";
sys.exit(0);
NewHost = raw_input("Host? ");
if NewHost == "":
continue;
- NAttrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=" + NewHost);
+ NAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=" + NewHost);
if len(NAttrs) == 0:
print "Host",NewHost,"was not found.";
continue;
Attrs = NAttrs;
Host = NewHost;
- HostDn = "host=" + Host + "," + HBaseDn;
+ HostDn = "host=" + Host + "," + HostBaseDn;
OrderedIndex = copy.deepcopy(OrigOrderedIndex);
continue;
NewHost = raw_input("Host? ");
if NewHost == "":
continue;
- NAttrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=" + NewHost);
+ NAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=" + NewHost);
if len(NAttrs) != 0:
print "Host",NewHost,"already exists.";
continue;
NewHostName = raw_input("Hostname? ");
if NewHost == "":
continue;
- Dn = "host=" + NewHost + "," + HBaseDn;
+ Dn = "host=" + NewHost + "," + HostBaseDn;
l.add_s(Dn,[("host", NewHost),
("hostname", NewHostName),
("objectClass", ("top", "debianServer"))]);
# Switch
- NAttrs = l.search_s(HBaseDn,ldap.SCOPE_ONELEVEL,"host=" + NewHost);
+ NAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=" + NewHost);
if len(NAttrs) == 0:
print "Host",NewHost,"was not found.";
continue;
Attrs = NAttrs;
Host = NewHost;
- HostDn = "host=" + Host + "," + HBaseDn;
+ HostDn = "host=" + Host + "," + HostBaseDn;
OrderedIndex = copy.deepcopy(OrigOrderedIndex);
continue;
# search through all UIDs.
def GetFreeID(l):
Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,
- "uidNumber=*",["uidNumber"]);
+ "uidNumber=*",["uidNumber", "gidNumber"]);
HighestUID = 0;
+ gids = [];
for I in Attrs:
ID = int(GetAttr(I,"uidNumber","0"));
+ gids.append(int(GetAttr(I, "gidNumber","0")))
if ID > HighestUID:
HighestUID = ID;
- return HighestUID + 1;
+
+ resGID = HighestUID + 1;
+ while resGID in gids:
+ resGID += 1
+
+ return (HighestUID + 1, resGID);
# Main starts here
AdminUser = pwd.getpwuid(os.getuid())[0];
# Process options
ForceMail = 0;
+NoAutomaticIDs = 0;
OldGPGKeyRings = GPGKeyRings;
userdir_gpg.GPGKeyRings = [];
-(options, arguments) = getopt.getopt(sys.argv[1:], "u:ma")
+(options, arguments) = getopt.getopt(sys.argv[1:], "u:man")
for (switch, val) in options:
if (switch == '-u'):
AdminUser = val;
ForceMail = 1;
elif (switch == '-a'):
userdir_gpg.GPGKeyRings = OldGPGKeyRings;
+ elif (switch == '-n'):
+ NoAutomaticIDs = 1;
l = passwdAccessLDAP(LDAPServer, BaseDn, AdminUser)
account = Addr[1];
privsub = email;
-gidNumber = str(DefaultGID);
+gidNumber = 0;
uidNumber = 0;
# Decide if we should use IDEA encryption
if Res != "":
privsub = Res;
-# GID
-Res = raw_input("Group ID Number [" + gidNumber + "]? ");
-if Res != "":
- gidNumber = Group2GID(l, Res);
+(uidNumber, generatedGID) = GetFreeID(l, RoleAccount)
+if not gidNumber:
+ gidNumber = DefaultGID
+UserGroup = 0
-# UID
-if uidNumber == 0:
- uidNumber = GetFreeID(l);
+if NoAutomaticIDs:
+ # UID
+ if not Update:
+ Res = raw_input("User ID Number [%s]? " % (uidNumber));
+ if Res != "":
+ uidNumber = Res;
+
+ # GID
+ Res = raw_input("Group ID Number (default group is %s, new usergroup %s) [%s]" % (DefaultGID, generatedGID, gidNumber));
+ if Res != "":
+ if Res.isdigit():
+ gidNumber = Res;
+ else:
+ gidNumber = Group2GID(l, Res);
+
+ if gidNumber == generatedGID:
+ UserGroup = 1
# Generate a random password
if Update == 0 or ForceMail == 1:
Details.append(("mn",mn));
if privsub != " ":
Details.append(("privateSub",privsub))
+
+ #Add user group if needed, then the actual user:
+ if UserGroup == 1:
+ Dn = "gid=" + account + "," + BaseDn;
+ l.add_s(Dn,[("gid",account), ("gidNumber",str(gidNumber)), ("objectClass",("top", "debianGroup"))]);
+
l.add_s(Dn,Details);
else:
# Modification
# Revision history:
#
-# XXX [PP]
-# - Now version controlled in db.d.o bzr repository - 2007-12-25
+# XXX
+# - [PP] Now version controlled in db.d.o bzr repository - 2007-12-25
+# - [HE] Add 'purpose', 'physicalHost' to debianServer - 2007-12-25
#
# 0.7 [RM]
# - Add 'gender' and 'birthDate' to debianDeveloper
# .30 - gender
# .31 - birthdate
# .32 - mailDisableMessage
+# .33 - purpose
+# .34 - physicalHost
#
# .3 - experimental LDAP objectClasses
# .1 - debianDeveloper
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+attributetype ( 1.3.6.1.4.1.9586.100.4.2.33
+ NAME 'purpose'
+ DESC 'purposes of this server'
+ EQUALITY caseIgnoreMatch
+ SUBSTR caseIgnoreSubstringsMatch
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+
+attributetype ( 1.3.6.1.4.1.9586.100.4.2.34
+ NAME 'physicalHost'
+ DESC 'FQDN of the physical host of this virtual server'
+ EQUALITY caseIgnoreIA5Match
+ SUBSTR caseIgnoreIA5SubstringsMatch
+ SINGLE-VALUE
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
+
# Public object classes
objectclass ( 1.3.6.1.4.1.9586.100.4.1.1
MUST ( host $ hostname )
MAY ( c $ access $ admin $ architecture $ bandwidth $ description $ disk $
distribution $ l $ machine $ memory $ sponsor $
- sponsor-admin $ sshRSAHostKey $ status
+ sponsor-admin $ sshRSAHostKey $ status $ purpose $ physicalHost
) )
objectclass ( 1.3.6.1.4.1.9586.100.4.3.3