Trying to make user/pac deletion more reliable...
This commit is contained in:
parent
1f3c4ca0f0
commit
0ab359e690
@ -162,7 +162,12 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Processor createDelUserProc(String pacName) {
|
private Processor createDelUserProc(String pacName) {
|
||||||
return new ShellProcessor("rm -rf /home/pacs/" + pacName + "/* && deluser --remove-all-files " + pacName + ">/dev/null 2>&1");
|
Processor killProcessesProc = new ShellProcessor("killall -TERM -u " + pacName + " && sleep 5 && killall -KILL -u " + pacName + " && sleep 5");
|
||||||
|
Processor userdelProc = new ShellProcessor("deluser --remove-all-files " + pacName);
|
||||||
|
CompoundProcessor proc = new CompoundProcessor(killProcessesProc, userdelProc);
|
||||||
|
proc.appendProcessor(new ShellProcessor("rm -f '/var/spool/cron/crontabs/" + pacName + "'"));
|
||||||
|
proc.appendProcessor(new ShellProcessor("rm -f '/var/mail/" + pacName + "'"));
|
||||||
|
return proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createMakePacDirectoryStructure(UnixUser unixUser) {
|
private Processor createMakePacDirectoryStructure(UnixUser unixUser) {
|
||||||
|
@ -56,12 +56,12 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
|
|||||||
UnixUser user = (UnixUser) entity;
|
UnixUser user = (UnixUser) entity;
|
||||||
String uid = user.getName();
|
String uid = user.getName();
|
||||||
if (uid != null && uid.length() > 4) {
|
if (uid != null && uid.length() > 4) {
|
||||||
Processor killProcessesProc = new ShellProcessor("killall -u " + uid + " && sleep 2 || echo -n 'no processes'");
|
Processor killProcessesProc = new ShellProcessor("killall -TERM -u " + uid + " && sleep 5 && killall -KILL -u " + uid + " && sleep 5");
|
||||||
Processor userdelProc = null;
|
Processor userdelProc = null;
|
||||||
if (user.isDefaultHomedir()) {
|
if (user.isDefaultHomedir()) {
|
||||||
userdelProc = new ShellProcessor("userdel " + uid + " && rm -rf '" + user.getHomedir() + "'");
|
userdelProc = new ShellProcessor("deluser --remove-all-files " + uid);
|
||||||
} else {
|
} else {
|
||||||
userdelProc = new ShellProcessor("userdel " + uid);
|
userdelProc = new ShellProcessor("deluser " + uid);
|
||||||
}
|
}
|
||||||
CompoundProcessor proc = new CompoundProcessor(killProcessesProc, userdelProc);
|
CompoundProcessor proc = new CompoundProcessor(killProcessesProc, userdelProc);
|
||||||
proc.appendProcessor(new ShellProcessor("rm -f '/var/spool/cron/crontabs/" + uid + "'"));
|
proc.appendProcessor(new ShellProcessor("rm -f '/var/spool/cron/crontabs/" + uid + "'"));
|
||||||
|
Loading…
Reference in New Issue
Block a user