From 5c3215619e8e51bf935c02c54cc7d13069a50c0c Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 28 Oct 2011 13:28:19 +0000 Subject: [PATCH] pacdomain --- .../de/hsadmin/mods/dom/DomainModuleImpl.java | 14 +- .../mods/dom/DomainProcessorFactory.java | 21 ++ .../mods/email/EMailAliasModuleImpl.java | 3 + hsarback/webapp/WEB-INF/web.xml | 315 ++++++++++++++++++ 4 files changed, 348 insertions(+), 5 deletions(-) create mode 100644 hsarback/webapp/WEB-INF/web.xml diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java index 36f34be..ba4d456 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -197,20 +197,24 @@ public class DomainModuleImpl extends AbstractModuleImpl { } } - private void needsWriteAccessOn(AbstractEntity ent, String method) throws AuthorisationException { + private void needsWriteAccessOn(AbstractEntity entity, String method) throws AuthorisationException { UnixUser loginUser = getTransaction().getLoginUser(); - if (ent instanceof Domain) { - Domain dom = (Domain) ent; + if (entity instanceof Domain) { + Domain dom = (Domain) entity; String aLoginUserName = loginUser.getName(); UnixUser domUser = dom.getUser(); Pac domPac = domUser.getPac(); boolean isPacAdmin = loginUser.hasPacAdminRoleFor(domPac); boolean isCustomer = aLoginUserName.equals(domPac.getCustomer().getName()); boolean isHostmaster = loginUser.hasHostmasterRole(); - if (!isPacAdmin && !isCustomer && !isHostmaster) + if (!isPacAdmin && !isCustomer && !isHostmaster) { throw new AuthorisationException(loginUser, method, dom); + } + if (dom.isPacDomain() && !isHostmaster && !"add".equals(method)) { + throw new AuthorisationException(loginUser, method, dom); + } } else { - throw new AuthorisationException(loginUser, method, ent); + throw new AuthorisationException(loginUser, method, entity); } } diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index 19aaaec..170fe31 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -64,6 +64,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory { templateVars.put("DOMAIN", domName); templateVars.put("USER_NAME", domUser.getComment()); mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(dom, templateVars), "Setup Apache VHost"); + if (dom.isPacDomain()) { + mainProcessor.appendProcessor(hiveName, createMovePacDomainContent(em, dom), "Move pac domain content"); + } return mainProcessor; } @@ -265,6 +268,24 @@ public class DomainProcessorFactory implements EntityProcessorFactory { return vhostDelProcessor; } + private Processor createMovePacDomainContent(EntityManager em, Domain dom) { + Pac pac = dom.getUser().getPac(); + String pacDir = pac.getAdminUser(em).getHomedir(); + String domDir = pacDir + "/doms/" + pac.getName() + ".hostsharing.net"; + String[] sourceDirs = new String[] { "web", "web-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ; + String[] targetDirs = new String[] { "htdocs", "htdocs-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ; + CompoundProcessor processor = new CompoundProcessor( + new ShellProcessor("rm -rf " + pacDir + "/subs " + pacDir + "/htdocs/.htaccess " + + pacDir + "/subs-ssl " + pacDir + "/htdocs-ssl/.htaccess ")); + for (int idx = 0; idx < sourceDirs.length; idx++) { + processor.appendProcessor( + new ShellProcessor("shopt dotglob && ls " + pacDir + "/" + sourceDirs[idx] + " >/dev/null 2>&1" + + " && mv " + domDir + "/" + sourceDirs[idx] + "/*" + targetDirs[idx] + "/ " + + " && rmdir " + domDir + "/" + sourceDirs[idx])); + } + return processor; + } + private String selectVHostTemplate(Domain dom) { String domName = dom.getName(); UnixUser user = dom.getUser(); diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java index 9cf2ce6..5d21211 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java @@ -41,6 +41,9 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl { if (pac == null || !pac.isReadAllowedFor(loginUser)) { throw new AuthorisationException(loginUser, "add", newEntity); } + if (!name.startsWith(pac.getName())) { + throw new AuthorisationException(loginUser, "add", newEntity); + } return super.add(newEntity); } diff --git a/hsarback/webapp/WEB-INF/web.xml b/hsarback/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..4030a94 --- /dev/null +++ b/hsarback/webapp/WEB-INF/web.xml @@ -0,0 +1,315 @@ + + + + + de.hsadmin.core.model.onetier.PersistenceManagerContextListener + + + + Queue Status Servlet + de.hsadmin.core.qserv.QueueStatusReceiverServlet + 1 + + + + CLI Client Connector + de.hsadmin.cliClientConnector.CLIClientConnectorServlet + + proxyValidateUrl + https://${cas.domain.name}:${cas.https.port}/cas/proxyValidate + + + proxyServiceUrl + https://${hsar.domain.name}:${hsar.https.port}/hsar/backend + + + Components + member,pac,user,domain,emailaddress,emailalias,mysqluser,mysqldb,postgresqluser,postgresqldb,q + + + ComponentClass_member + de.hsadmin.mods.cust.Customer + + + ComponentDescription_member + Mitglieder + + + ComponentClass_pac + de.hsadmin.mods.pac.Pac + + + ComponentDescription_pac + Pakete + + + ComponentClass_user + de.hsadmin.mods.user.UnixUser + + + ComponentDescription_user + Benutzer und Postfaecher anlegen + + + ComponentClass_domain + de.hsadmin.mods.dom.Domain + + + ComponentDescription_domain + Domains aufschalten + + + ComponentClass_emailaddress + de.hsadmin.mods.email.EMailAddress + + + ComponentDescription_emailaddress + E-Mail Adressen + + + ComponentClass_emailalias + de.hsadmin.mods.email.EMailAlias + + + ComponentDescription_emailalias + E-Mail Aliases + + + ComponentClass_postgresqluser + de.hsadmin.mods.db.PgSqlUser + + + ComponentDescription_postgresqluser + PostgreSQL DB-Administrator + + + ComponentClass_postgresqldb + de.hsadmin.mods.db.PgSqlDatabase + + + ComponentDescription_postgresqldb + PostgreSQL Datenbank + + + ComponentClass_mysqluser + de.hsadmin.mods.db.MySqlUser + + + ComponentDescription_mysqluser + MySQL DB-Administrator + + + ComponentClass_mysqldb + de.hsadmin.mods.db.MySqlDatabase + + + ComponentDescription_mysqldb + MySQL Datenbank + + + ComponentClass_q + de.hsadmin.core.qserv.QueueTask + + + ComponentDescription_q + Offene Aktionen + + 1 + + + + XmlRpcServlet + org.apache.xmlrpc.webserver.XmlRpcServlet + + enabledForExtensions + true + + + + + Queue Status Servlet + /queueStatus + + + + CLI Client Connector + /hsadmin/cli-interface/ + + + + XmlRpcServlet + /xmlrpc/* + + + + jdbc/HSAdminDB + javax.sql.DataSource + Container + + + + jms/QueueCF + javax.jms.QueueConnectionFactory + Container + Shareable + + + + jms/hsadminSystem-h81 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h01 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h02 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h03 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h04 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h05 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h06 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h07 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h08 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h09 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h50 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h51 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h52 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h55 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h56 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h57 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-h58 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-dns1 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-dns2 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-dns3 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-mail1 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-mail2 + javax.jms.Queue + Container + Shareable + + + jms/hsadminSystem-mail3 + javax.jms.Queue + Container + Shareable + + + jms/hsadminStatus + javax.jms.Queue + Container + Shareable + + + + + Hostsharing Administrative Area + /* + + + CONFIDENTIAL + + + +