From 32e231850ed74a882b7d91928fc34e27dc518933 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Fri, 20 May 2011 16:12:39 +0200
Subject: [PATCH] nur erlaubte aliases anlegen

---
 hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java |   15 +++++++++++++++
 hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java |    5 +++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
index 1a45e5d..80671b8 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -79,10 +79,11 @@
 		for (String queueName : mailServerQueues) {
 			relayDomainsProcessor = new CompoundProcessor(
 				new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains", 
-							domName + " anything" + "\n." + domName + " anything"), 
+							domName + " anything\n" +
+							"." + domName + " anything\n"), 
 				new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport", 
 							domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n" +
-							"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n.")
+							"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n")
 			);
 			mainProcessor.appendProcessor(queueName, relayDomainsProcessor, queueName + ".hostsharing.net");
 		}
diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java
index caf4c9b..bdf9b63 100644
--- a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java
+++ b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java
@@ -4,6 +4,7 @@
 
 import de.hsadmin.core.model.AbstractModuleImpl;
 import de.hsadmin.core.model.AbstractEntity;
+import de.hsadmin.core.model.AuthenticationException;
 import de.hsadmin.core.model.HSAdminException;
 
 public class EMailAliasModuleImpl extends AbstractModuleImpl {
@@ -16,5 +17,19 @@
 		}
 		return super.search(entityClass, condition, orderBy);
 	}
+
+	@Override
+	public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
+		EMailAlias alias = (EMailAlias) newEntity;
+		String name = alias.getName();
+		String pacname = alias.getPac().getName();
+		if (!name.startsWith(pacname)) {
+			throw new AuthenticationException("alias not allowed");
+		}
+		if (name.length() > 5 && (name.charAt(5) != '-') || name.length() == 6) {
+			throw new AuthenticationException("alias not allowed");
+		}
+		return super.add(newEntity);
+	}
 	
 }

--
Gitblit v1.9.3