X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-info;h=2adbd24a7ccbb9b1637b0463c9270c5973dbb366;hb=d5ecd5cf0c1a103e7559e03d5206acd4be4f97af;hp=ce06934113e36dacd334bc82bd0b635e74eb6410;hpb=5cf899d9bd7e6f42621244325876dab9fb50c822;p=mirror%2Fuserdir-ldap.git diff --git a/ud-info b/ud-info index ce06934..2adbd24 100755 --- a/ud-info +++ b/ud-info @@ -17,7 +17,7 @@ # -r Enable 'root' functions, do this if your uid has access to # restricted variables. -import string, time, posix, pwd, sys, getopt, ldap, crypt, whrandom, readline, copy; +import string, time, os, pwd, sys, getopt, ldap, crypt, whrandom, readline, copy; from userdir_ldap import *; RootMode = 0; @@ -42,9 +42,11 @@ AttrInfo = {"cn": ["First Name", 101], "labeledurl": ["Home Page",11], "latitude": ["Latitude",12], "longitude": ["Longitude",13], - "comment": ["Comment",114], - "userpassword": ["Crypted Password",115], - "dnszoneentry": ["d.net Entry",116]}; + "icquin": ["ICQ UIN",14], + "privatesub": ["Debian-Private",15], + "comment": ["Comment",116], + "userpassword": ["Crypted Password",117], + "dnszoneentry": ["d.net Entry",118]}; AttrPrompt = {"cn": ["Common name or first name"], "mn": ["Middle name (or initial if it ends in a dot)"], @@ -63,11 +65,13 @@ AttrPrompt = {"cn": ["Common name or first name"], "comment": ["Admin Comment about the account"], "supplementarygid": ["Groups the user is in"], "allowedhosts": ["Grant access to certain hosts"], + "privatesub": ["Debian-Private mailing list subscription"], "member": ["LDAP Group Member for slapd ACLs"], "latitude": ["XEarth latitude in ISO 6709 format - see /usr/share/zoneinfo/zone.tab or etak.com"], "longitude": ["XEarth latitude in ISO 6709 format - see /usr/share/zoneinfo/zone.tab or etak.com"], "dnszoneentry": ["DNS Zone fragment associated this this user"], - "labeledurl": ["Web home page"]}; + "labeledurl": ["Web home page"], + "icquin": ["ICQ UIN Number"]}; # Create a map of IDs to desc,value,attr OrderedIndex = {}; @@ -235,7 +239,7 @@ def MultiChangeAttr(Attrs,Attr): print; # Main program starts here -User = pwd.getpwuid(posix.getuid())[0]; +User = pwd.getpwuid(os.getuid())[0]; BindUser = User; # Process options (options, arguments) = getopt.getopt(sys.argv[1:], "nu:c:a:r") @@ -296,6 +300,7 @@ while(1): if RootMode == 1: print " a) Arbitary Change"; + print " R) Randomize Password"; print " p) Change Password"; print " u) Switch Users"; print " x) Exit"; @@ -334,21 +339,38 @@ while(1): raw_input("Press a key"); continue; - # Hash it telling glibc to use the MD5 algorithm - if you dont have - # glibc then just change Salt = "$1$" to Salt = ""; - SaltVals = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/."; - Salt = "$1$"; - for x in range(0,10): - Salt = Salt + SaltVals[whrandom.randint(0,len(SaltVals)-1)]; - Pass = crypt.crypt(Pass1,Salt); - if len(Pass) < 14: - print "Caution! MD5 Password hashing failed, not changing password!"; + try: + Pass = HashPass(Pass1); + except: + print "%s: %s\n" %(sys.exc_type,sys.exc_value); raw_input("Press a key"); continue; print "Setting password.."; Pass = "{crypt}" + Pass; l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userpassword",Pass)]); + Attrs[0][1]["userpassword"] = [Pass]; + continue; + + # Randomize password + if Response == 'R' and RootMode == 1: + Resp = raw_input("Randomize Users Password? [no/yes]"); + if Resp != "yes": + continue; + + # Generate a random password + try: + Password = GenPass(); + Pass = HashPass(Password); + except: + print "%s: %s\n" %(sys.exc_type,sys.exc_value); + raw_input("Press a key"); + continue; + + print "Setting password.."; + Pass = "{crypt}" + Pass; + l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userpassword",Pass)]); + Attrs[0][1]["userpassword"] = [Pass]; continue; # Handle changing an arbitary value