From 696fd165feefdb8af04224664f8e2f64437b88d5 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Tue, 17 May 2011 17:04:06 +0200
Subject: [PATCH] resolve #20, #25, #27

---
 hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java           |   29 +++++++++++++++--------------
 hsarback/src/de/hsadmin/cliClientConnector/CLIClientConnectorServlet.java |    2 +-
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/hsarback/src/de/hsadmin/cliClientConnector/CLIClientConnectorServlet.java b/hsarback/src/de/hsadmin/cliClientConnector/CLIClientConnectorServlet.java
index efbc1e2..ed63ee5 100644
--- a/hsarback/src/de/hsadmin/cliClientConnector/CLIClientConnectorServlet.java
+++ b/hsarback/src/de/hsadmin/cliClientConnector/CLIClientConnectorServlet.java
@@ -35,7 +35,7 @@
 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;
diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java b/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java
index 6bc8db7..64add79 100644
--- a/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java
@@ -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 @@
 	/**
 	 *  @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) {

--
Gitblit v1.9.3