X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-info;h=7000ce9258394ee91c5fe3de611eafa9d693927f;hb=f27db3e7f5d3bb3fe0d36e1ab15e143ce45d269d;hp=5f144bd13a01f80bdc1eefa2bc4ef31eeef8577d;hpb=b5fb9ea2f797cc33f179e66050553560433f7a81;p=mirror%2Fuserdir-ldap.git diff --git a/ud-info b/ud-info index 5f144bd..7000ce9 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, os, pwd, sys, getopt, ldap, crypt, whrandom, readline, copy; +import time, os, pwd, sys, getopt, ldap, crypt, readline, copy; from userdir_ldap import *; RootMode = 0; @@ -45,9 +45,18 @@ AttrInfo = {"cn": ["First Name", 101], "icqUin": ["ICQ UIN",14], "jabberJID": ["Jabber ID",15], "privateSub": ["Debian-Private",16], + "gender": ["Gender",17], + "birthDate": ["Date of Birth",18], + "mailDisableMessage": ["Mail Disabled",19], + "mailGreylisting": ["Mail Greylisting",20], + "mailCallout": ["Mail Callouts",21], + "mailRBL": ["Mail RBLs",22], + "mailRHSBL": ["Mail RHSBLs",23], + "mailWhitelist": ["Mail Whitelist",24], "comment": ["Comment",116], "userPassword": ["Crypted Password",117], - "dnsZoneEntry": ["d.net Entry",118]}; + "dnsZoneEntry": ["d.net Entry",118], + "VoIP": ["VoIP Address",119]}; AttrPrompt = {"cn": ["Common name or first name"], "mn": ["Middle name (or initial if it ends in a dot)"], @@ -67,13 +76,22 @@ AttrPrompt = {"cn": ["Common name or first name"], "supplementaryGid": ["Groups the user is in"], "allowedHost": ["Grant access to certain hosts"], "privateSub": ["Debian-Private mailing list subscription"], + "gender": ["ISO5218 Gender code (1=male,2=female,9=unspecified)"], + "birthDate": ["Date of Birth (YYYYMMDD)"], + "mailDisableMessage": ["Error message to return via SMTP"], + "mailGreylisting": ["SMTP Greylisting (TRUE/FALSE)"], + "mailCallout": ["SMTP Callouts (TRUE/FALSE)"], + "mailRBL": ["SMTP time RBL lists"], + "mailRHSBL": ["SMTP time RHSBL lists"], + "mailWhitelist": ["SMTP time whitelist from other checks"], "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"], "labeledURI": ["Web home page"], "jabberJID": ["Jabber ID"], - "icqUin": ["ICQ UIN Number"]}; + "icqUin": ["ICQ UIN Number"], + "VoIP": ["VoIP Address"]}; # Create a map of IDs to desc,value,attr OrderedIndex = {}; @@ -174,7 +192,8 @@ def ShowAttrs(Attrs): # Change a single attribute def ChangeAttr(Attrs,Attr): if (Attr == "supplementaryGid" or Attr == "allowedHost" or \ - Attr == "member" or Attr == "dnsZoneEntry"): + Attr == "member" or Attr == "dnsZoneEntry" or Attr == "mailWhitelist" or \ + Attr == "mailRBL" or Attr == "mailRHSBL"): return MultiChangeAttr(Attrs,Attr); print "Old value: '%s'" % (GetAttr(Attrs,Attr,"")); @@ -212,7 +231,7 @@ def MultiChangeAttr(Attrs,Attr): Attrs[1][Attr].sort(); print "Old values: ",Attrs[1][Attr]; - Mode = string.upper(raw_input("[D]elete or [A]dd? ")); + Mode = raw_input("[D]elete or [A]dd? ").upper() if (Mode != 'D' and Mode != 'A'): return; @@ -244,7 +263,12 @@ def MultiChangeAttr(Attrs,Attr): User = pwd.getpwuid(os.getuid())[0]; BindUser = User; # Process options -(options, arguments) = getopt.getopt(sys.argv[1:], "nu:c:a:r") +try: + (options, arguments) = getopt.getopt(sys.argv[1:], "nu:c:a:r") +except getopt.GetoptError, data: + print data + sys.exit(1) + for (switch, val) in options: if (switch == '-u'): User = val; @@ -304,6 +328,7 @@ while(1): print " a) Arbitary Change"; print " R) Randomize Password"; print " p) Change Password"; + print " L) Lock account"; print " u) Switch Users"; print " x) Exit"; @@ -350,8 +375,11 @@ while(1): print "Setting password.."; Pass = "{crypt}" + Pass; - l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userPassword",Pass)]); + shadowLast = str(int(time.time()/24/60/60)); + l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userPassword",Pass), + (ldap.MOD_REPLACE,"shadowLastChange",shadowLast)]); Attrs[0][1]["userPassword"] = [Pass]; + Attrs[0][1]["shadowLastChange"] = [shadowLast]; continue; # Randomize password @@ -371,8 +399,28 @@ while(1): print "Setting password.."; Pass = "{crypt}" + Pass; - l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userPassword",Pass)]); + shadowLast = str(int(time.time()/24/60/60)); + l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userPassword",Pass), + (ldap.MOD_REPLACE,"shadowLastChange",shadowLast)]); Attrs[0][1]["userPassword"] = [Pass]; + Attrs[0][1]["shadowLastChange"] = [shadowLast]; + continue; + + # Lock account + if Response == 'L' and RootMode == 1: + Resp = raw_input("Really lock account? [no/yes]"); + if Resp != "yes": + continue; + + print "Setting password.."; + shadowLast = str(int(time.time()/24/60/60)); + l.modify_s(UserDn,[ + (ldap.MOD_REPLACE,"userPassword","{crypt}*LK*"), + (ldap.MOD_REPLACE,"mailDisableMessage","account locked"), + (ldap.MOD_REPLACE,"shadowLastChange",shadowLast)]); + Attrs[0][1]["userPassword"] = ["{crypt}*LK*"]; + Attrs[0][1]["mailDisableMessage"] = ["account locked"]; + Attrs[0][1]["shadowLastChange"] = [shadowLast]; continue; # Handle changing an arbitary value