-import termios, TERMIOS, re, string, imp, ldap, sys, whrandom, crypt, rfc822;
+import termios, re, string, imp, ldap, sys, whrandom, crypt, rfc822;
+import userdir_gpg
LDAPServer = ConfModule.ldaphost;
EmailAppend = ConfModule.emailappend;
AdminUser = ConfModule.adminuser;
LDAPServer = ConfModule.ldaphost;
EmailAppend = ConfModule.emailappend;
AdminUser = ConfModule.adminuser;
# This is a list of common last-name prefixes
LastNamesPre = {"van": None, "le": None, "de": None, "di": None};
# SSH Key splitting. The result is:
# (options,size,modulous,exponent,comment)
SSHAuthSplit = re.compile('^(.* )?(\d+) (\d+) (\d+) ?(.+)$');
# This is a list of common last-name prefixes
LastNamesPre = {"van": None, "le": None, "de": None, "di": None};
# SSH Key splitting. The result is:
# (options,size,modulous,exponent,comment)
SSHAuthSplit = re.compile('^(.* )?(\d+) (\d+) (\d+) ?(.+)$');
#'^([^\d](?:[^ "]+(?:".*")?)*)? ?(\d+) (\d+) (\d+) (.+)$');
AddressSplit = re.compile("(.*).*<([^@]*)@([^>]*)>");
#'^([^\d](?:[^ "]+(?:".*")?)*)? ?(\d+) (\d+) (\d+) (.+)$');
AddressSplit = re.compile("(.*).*<([^@]*)@([^>]*)>");
def HashPass(Password):
# Hash it telling glibc to use the MD5 algorithm - if you dont have
# glibc then just change Salt = "$1$" to Salt = "";
def HashPass(Password):
# Hash it telling glibc to use the MD5 algorithm - if you dont have
# glibc then just change Salt = "$1$" to Salt = "";
Pass = crypt.crypt(Password,Salt);
if len(Pass) < 14:
raise "Password Error", "MD5 password hashing failed, not changing the password!";
Pass = crypt.crypt(Password,Salt);
if len(Pass) < 14:
raise "Password Error", "MD5 password hashing failed, not changing the password!";
# Convert a lat/long attribute into Decimal degrees
def DecDegree(Posn,Anon=0):
# Convert a lat/long attribute into Decimal degrees
def DecDegree(Posn,Anon=0):
+def FormatSSH2Auth(Str):
+ Match = SSH2AuthSplit.match(Str);
+ if Match == None:
+ return "<unknown format>";
+ G = Match.groups();
+
+ if G[0] == None:
+ return "ssh-%s %s..%s %s"%(G[1],G[2][:8],G[2][-8:],G[3]);
+ return "%s ssh-%s %s..%s %s"%(G[0],G[1],G[2][:8],G[2][-8:],G[3]);
+
# Take an email address and split it into 3 parts, (Name,UID,Domain)
def SplitEmail(Addr):
# Take an email address and split it into 3 parts, (Name,UID,Domain)
def SplitEmail(Addr):
Stat = "unknown map hit for"+str(Name);
return (UnknownMap[Name[2]],[Stat]);
Stat = "unknown map hit for"+str(Name);
return (UnknownMap[Name[2]],[Stat]);
+ # Then the name component (another ie there was no email address to match)
+ if UnknownMap.has_key(Name[0]):
+ Stat = "unknown map hit for"+str(Name);
+ return (UnknownMap[Name[0]],[Stat]);
+
# Search for a possible first/last name hit
try:
Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(cn=%s)(sn=%s))"%(cn,sn),["uid"]);
# Search for a possible first/last name hit
try:
Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(cn=%s)(sn=%s))"%(cn,sn),["uid"]);