import termios, re, imp, ldap, sys, crypt, rfc822, pwd, os, getpass
import userdir_gpg
import hmac
-import sha as sha1_module
+import hashlib
try:
File = open("/etc/userdir-ldap/userdir-ldap.conf");
except AttributeError:
UseSSL = False;
+try:
+ BaseBaseDn = ConfModule.basebasedn;
+except AttributeError:
+ BaseBaseDn = BaseDn
+
+try:
+ IgnoreUsersForUIDNumberGen = ConfModule.ignoreusersforuidnumbergen
+except AttributeError:
+ IgnoreUsersForUIDNumberGen = ['nobody']
+
+
# Break up the keyring list
userdir_gpg.SetKeyrings(ConfModule.keyrings.split(":"))
"""
print "Accessing LDAP directory as '" + AdminUser + "'";
while (1):
- Password = getpass.getpass(AdminUser + "'s password: ")
+ if 'LDAP_PASSWORD' in os.environ:
+ Password = os.environ['LDAP_PASSWORD']
+ else:
+ Password = getpass.getpass(AdminUser + "'s password: ")
if len(Password) == 0:
sys.exit(0)
try:
l.simple_bind_s(UserDn,Password);
except ldap.INVALID_CREDENTIALS:
+ if 'LDAP_PASSWORD' in os.environ:
+ print "password in environment does not work"
+ del os.environ['LDAP_PASSWORD']
continue
break
return l
return -1
def make_hmac(str):
- File = open(PassDir+"/key-hmac-"+pwd.getpwuid(os.getuid())[0],"r");
- HmacKey = File.readline().strip()
- File.close();
- return hmac.new(HmacKey, str, sha1_module).hexdigest()
+ if 'UD_HMAC_KEY' in os.environ:
+ HmacKey = os.environ['UD_HMAC_KEY']
+ else:
+ File = open(PassDir+"/key-hmac-"+pwd.getpwuid(os.getuid())[0],"r");
+ HmacKey = File.readline().strip()
+ File.close();
+ return hmac.new(HmacKey, str, hashlib.sha1).hexdigest()
def make_passwd_hmac(status, purpose, uid, uuid, hosts, cryptedpass):
return make_hmac(':'.join([status, purpose, uid, uuid, hosts, cryptedpass]))