This commit is contained in:
Peter Hormanns 2011-05-17 15:04:06 +00:00
parent 3c1480dfaf
commit 696fd165fe
2 changed files with 16 additions and 15 deletions

View File

@ -35,7 +35,7 @@ import de.hsadmin.core.model.onetier.TicketValidator;
public class CLIClientConnectorServlet extends HttpServlet {
private static final long serialVersionUID = 7150004719303750077L;
public static final String version = "1.0.9 (2010/Oct/05 18:34)";
public static final String version = "CLI Servlet 2.0.0 (2011/May/21 09:00 MEST)";
private Map<String, Class<?>> componentmap;
private Map<String, String> componentDescriptions;

View File

@ -1,8 +1,5 @@
package de.hsadmin.mods.user;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.EntityManager;
import de.hsadmin.core.model.AbstractEntity;
@ -55,18 +52,22 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
/**
* @return a Processor which deletes an existing UNIX user account
*/
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em,
T entity) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyMMdd-HHmm-");
String trashPrefix = "/home/trash/" + sdf.format(new Date());
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
UnixUser user = (UnixUser) entity;
CompoundProcessor aCP = new CompoundProcessor();
if (user.isDefaultHomedir())
aCP.appendProcessor(new ShellProcessor("mv '" + user.getHomedir()
+ "' '" + trashPrefix + user.getName() + "'"));
aCP.appendProcessor(new ShellProcessor("userdel " + user.getName()));
return aCP;
String uid = user.getName();
if (uid != null && uid.length() > 4) {
Processor userdelProc = null;
if (user.isDefaultHomedir()) {
userdelProc = new ShellProcessor("userdel " + uid + " && rm -rf '" + user.getHomedir() + "'");
} else {
userdelProc = new ShellProcessor("userdel " + uid);
}
CompoundProcessor proc = new CompoundProcessor(userdelProc);
proc.appendProcessor(new ShellProcessor("rm -f /var/spool/cron/crontabs/" + uid));
proc.appendProcessor(new ShellProcessor("rm -f /var/mail/" + uid));
return proc;
}
return null;
}
private void appendSetQuotaProcessor(CompoundProcessor aCP, UnixUser user) {