Commit 2aa492c8 authored by Imran Hussain's avatar Imran Hussain
Browse files

Fix some bugs by getting rid of some of the magic numbers

parent c36f5647
......@@ -171,7 +171,8 @@ def listUsers():
def deleteUser(peopleList):
#get fs ready
directory = "/home/deleted"
basedir = "/home/deleted"
mboxdir = "/var/mail/"['sudo', 'mkdir', "-m", "700", directory])
for person in peopleList:
......@@ -184,18 +185,22 @@ def deleteUser(peopleList):
#get all their info from the ldap
userLDAPinfo = ldapconn.search_s(ldap_base,ldap.SCOPE_SUBTREE,"uid="+str(person[0]))
#declare some easy to use vars
username = str(person[0])
persondir = basedir+"/"+username
#make the dir to store their stuff["sudo", "mkdir", directory+"/"+str(person[0])])["sudo", "mkdir", persondir])
#kill all their procs["sudo", "pkill", "-u", str(person[0])])["sudo", "pkill", "-u", username])
#backup their ldap entry
#sudo ldapsearch -x -D "cn=Manager,dc=sucs,dc=org" -y /etc/ldap.secret "(uid=imranh)"
ldapbackupfile = open("./ldap-ldif", "w")["sudo", "ldapsearch", "-x", "-D", ldap_manager, "-y", ldap_manager_pass, "-L", "(uid="+str(person[0])+")"], stdout=ldapbackupfile)["sudo", "ldapsearch", "-x", "-D", ldap_manager, "-y", ldap_manager_pass, "-L", "(uid="+username+")"], stdout=ldapbackupfile)
ldapbackupfile.close()['sudo', 'mv', "-f", "./ldap-ldif", directory+"/"+str(person[0])+"ldap-ldif"])['sudo', 'mv', "-f", "./ldap-ldif", persondir+"/ldap-ldif"])
#delete them from ldap
......@@ -203,14 +208,14 @@ def deleteUser(peopleList):["sudo", "ldapdelete", "-D", ldap_manager, "-y", ldap_manager_pass, userLDAPinfo[0][0]])
#move their homedir to the deleted folder['sudo', 'mv', "-f", userLDAPinfo[0][1]["homeDirectory"][0], directory+"/"+str(person[0])+"/homedir"])['sudo', 'mv', "-f", userLDAPinfo[0][1]["homeDirectory"][0], persondir+"/homedir"])
#move their mail to the deleted folder['sudo', 'mv', "-f", "/var/mail"+"/"+str(person[0]), directory+"/"+str(person[0])+"/mbox"])['sudo', 'mv', "-f", mboxdir+username, persondir+"/mbox"])
#remove them from the printer
#pkusers --delete imranh['sudo', 'pkusers', "--delete", str(person[0])])['sudo', 'pkusers', "--delete", username])
#remove from mailing lists
#/usr/lib/mailman/bin/remove_members members
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment