# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import re, time, ldap, getopt, sys, os, pwd;
+import email.Header
+
from userdir_ldap import *;
from userdir_gpg import *;
elif (switch == '-n'):
NoAutomaticIDs = 1;
-l = passwdAccessLDAP(LDAPServer, BaseDn, AdminUser)
+l = passwdAccessLDAP(BaseDn, AdminUser)
# Locate the key of the user we are adding
SetKeyrings(ConfModule.add_keyrings.split(":"))
# first/middle/last name
Addr = SplitEmail(Keys[0][2]);
(cn,mn,sn) = NameSplit(re.sub('["]','',Addr[0]))
-email = Addr[1] + '@' + Addr[2];
+emailaddr = Addr[1] + '@' + Addr[2];
account = Addr[1];
-privsub = email;
+privsub = emailaddr
gidNumber = 0;
uidNumber = 0;
privsub = GetAttr(Attrs[0],"privateSub");
gidNumber = GetAttr(Attrs[0],"gidNumber");
uidNumber = GetAttr(Attrs[0],"uidNumber");
- email = GetAttr(Attrs[0],"emailForward");
+ emailaddr = GetAttr(Attrs[0],"emailForward");
cn = GetAttr(Attrs[0],"cn");
sn = GetAttr(Attrs[0],"sn");
mn = GetAttr(Attrs[0],"mn");
if Res != "":
cn = Res;
Res = raw_input("Middle name [" + mn + "]? ");
-if Res != "":
+if Res == " ":
+ mn = ""
+elif Res != "":
mn = Res;
Res = raw_input("Last name [" + sn + "]? ");
if Res != "":
sn = Res;
-Res = raw_input("Email forwarding address [" + email + "]? ");
+Res = raw_input("Email forwarding address [" + emailaddr + "]? ");
if Res != "":
- email = Res;
+ emailaddr = Res;
# Debian-Private subscription
Res = raw_input("Subscribe to debian-private (space is none) [" + privsub + "]? ");
print "Final information collected:"
print " %s <%s@%s>:" % (FullName,account,EmailAppend);
print " Assigned UID:",uidNumber," GID:", gidNumber;
-print " Email forwarded to:",email;
+print " Email forwarded to:",emailaddr
print " Private Subscription:",privsub;
print " GECOS Field: \"%s,,,,\"" % (FullName);
print " Login Shell: /bin/bash";
# Initialize the substitution Map
Subst = {}
+
+encto = ''
+try:
+ encto = FullName.decode('us-ascii')
+except UnicodeError:
+ encto = str(email.Header.Header(FullName, 'utf-8', 200)) + " " + emailaddr
+
+subjstring = "New Debian Maintainer " + FullName
+encsubj = ''
+try:
+ encsubj = subjstring.decode('us-ascii')
+except UnicodeError:
+ encsubj = str(email.Header.Header(subjstring, 'utf-8', 200))
+
+Subst["__HEADER_SUBJ__"] = encsubj
+Subst["__HEADER_EMAIL"] = encto
Subst["__REALNAME__"] = FullName;
Subst["__WHOAMI__"] = pwd.getpwuid(os.getuid())[0];
Subst["__DATE__"] = time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.gmtime(time.time()));
Subst["__LOGIN__"] = account;
Subst["__PRIVATE__"] = privsub;
-Subst["__EMAIL__"] = email;
+Subst["__EMAIL__"] = emailaddr
Subst["__PASSWORD__"] = CryptedPass;
# Submit the modification request
("keyFingerPrint",Keys[0][1]),
("cn",cn),
("sn",sn),
- ("emailForward",email),
+ ("emailForward",emailaddr),
("shadowLastChange",str(int(time.time()/24/60/60))),
("shadowMin","0"),
("shadowMax","99999"),
(ldap.MOD_REPLACE,"cn",cn),
(ldap.MOD_REPLACE,"mn",mn),
(ldap.MOD_REPLACE,"sn",sn),
- (ldap.MOD_REPLACE,"emailForward",email),
+ (ldap.MOD_REPLACE,"emailForward",emailaddr),
(ldap.MOD_REPLACE,"shadowLastChange",str(int(time.time()/24/60/60))),
(ldap.MOD_REPLACE,"shadowMin","0"),
(ldap.MOD_REPLACE,"shadowMax","99999"),
# Send the Welcome message
print "Sending Welcome Email"
-Reply = TemplateSubst(Subst,open(TemplatesDir + "/welcome-message-%d" % gidNumber, "r").read())
+Reply = TemplateSubst(Subst,open(TemplatesDir + "/welcome-message-%d" % int(gidNumber), "r").read())
Child = os.popen("/usr/sbin/sendmail -t","w");
#Child = os.popen("cat","w");
Child.write(Reply);