From 2c4af1166018b7f12bfac58eb7d6011f4531ac8e Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 28 Nov 2023 11:58:51 +0100 Subject: [PATCH 01/34] Add new domain options passenger, passengerfriendlyerrorpages, cgi and fastcgi --- hsarback/database/data.sql | 8 +++++++ hsarback/database/database_update.sql | 5 +++++ .../de/hsadmin/mods/dom/apache-vhost.vm | 22 +++++++++++++++++++ hsarweb/src/texts/domain.properties | 4 ++++ hsarweb/src/texts/domain_de.properties | 4 ++++ .../de/hsadmin/mods/dom/DomainModuleImpl.java | 15 +++++++++++-- .../hsadmin/mods/dom/DomainOptionValues.java | 4 ++++ .../mods/dom/DomainProcessorFactory.java | 4 ++++ 8 files changed, 64 insertions(+), 2 deletions(-) diff --git a/hsarback/database/data.sql b/hsarback/database/data.sql index 363b0c0..8600003 100644 --- a/hsarback/database/data.sql +++ b/hsarback/database/data.sql @@ -209,6 +209,14 @@ INSERT INTO domain_option (domain_option_name) VALUES ('autoconfig'); INSERT INTO domain_option (domain_option_name) VALUES ('dkim'); +INSERT INTO domain_option (domain_option_name) + VALUES ('passenger'); +INSERT INTO domain_option (domain_option_name) + VALUES ('passengerfriendlyerrorpages'); +INSERT INTO domain_option (domain_option_name) + VALUES ('cgi'); +INSERT INTO domain_option (domain_option_name) + VALUES ('fastcgi'); -- -- table: price_list diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index ee09d66..aaf22cb 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -83,3 +83,8 @@ INSERT INTO price (article_number, price, vat, price_list) VALUES (3125, 80, 19. INSERT INTO price (article_number, price, vat, price_list) VALUES (3151, 160, 19.0, 1); INSERT INTO price (article_number, price, vat, price_list) VALUES (2017, 2, 19.0, 1); + +INSERT INTO domain_option (domain_option_name) VALUES ('passenger'); +INSERT INTO domain_option (domain_option_name) VALUES ('passengerfriendlyerrorpages'); +INSERT INTO domain_option (domain_option_name) VALUES ('cgi'); +INSERT INTO domain_option (domain_option_name) VALUES ('fastcgi'); diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 91f9ef0..735130c 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -26,21 +26,32 @@ +#if( ${passenger} ) PassengerEnabled On +#else + PassengerEnabled Off +#end +#if( ${passengerfriendlyerrorpages} ) + PassengerFriendlyErrorPages On +#end AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv +#if( ${cgi} ) PassengerEnabled Off SetHandler cgi-script Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch +#end +#if( ${fastcgi} ) PassengerEnabled Off SetHandler fcgid-script Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch +#end #if( ${autoconfig} ) @@ -104,21 +115,32 @@ +#if( ${passenger} ) PassengerEnabled On +#else + PassengerEnabled Off +#end +#if( ${passengerfriendlyerrorpages} ) + PassengerFriendlyErrorPages On +#end AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv +#if( ${cgi} ) PassengerEnabled Off SetHandler cgi-script Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch +#end +#if( ${fastcgi} ) PassengerEnabled Off SetHandler fcgid-script Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch +#end #if( ${autoconfig} ) diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index 47398bd..ed70489 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -9,6 +9,10 @@ domainoption.includes=Includes domainoption.indexes=Indexes domainoption.multiviews=MultiViews domainoption.php=PHP +domainoption.passenger=Passenger +domainoption.passengerfriendlyerrorpages=PassengerFriendlyErrorPages +domainoption.cgi=CGI +domainoption.fastcgi=FCGI yes=Yes no=No pac=packet diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index fddd54f..61f5ba1 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -9,6 +9,10 @@ domainoption.includes=Includes domainoption.indexes=Indexes domainoption.multiviews=MultiViews domainoption.php=PHP +domainoption.passenger=Passenger +domainoption.passengerfriendlyerrorpages=PassengerFriendlyErrorPages +domainoption.cgi=CGI +domainoption.fastcgi=FCGI yes=Ja no=Nein pac=Paket diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java index 3a8c8c4..dc4cbb4 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -30,6 +30,10 @@ public class DomainModuleImpl extends AbstractModuleImpl { public static final String DOMOPT_LETSENCRYPT = "letsencrypt"; public static final String DOMOPT_AUTOCONFIG = "autoconfig"; public static final String DOMOPT_DKIM = "dkim"; + public static final String DOMOPT_PASSENGER = "passenger"; + public static final String DOMOPT_PASSENGERFRIENDLYERRORPAGES = "passengerfriendlyerrorpages"; + public static final String DOMOPT_CGI = "cgi"; + public static final String DOMOPT_FASTCGI = "fastcgi"; public static final String[] ALL_DOMOPTS = new String[] { @@ -41,7 +45,11 @@ public class DomainModuleImpl extends AbstractModuleImpl { DOMOPT_BACKUPFOREXTERNALMX, DOMOPT_LETSENCRYPT, DOMOPT_AUTOCONFIG, - DOMOPT_DKIM + DOMOPT_DKIM, + DOMOPT_PASSENGER, + DOMOPT_PASSENGERFRIENDLYERRORPAGES, + DOMOPT_CGI, + DOMOPT_FASTCGI }; public static final String[] DEFAULT_DOMOPTS = new String[] { @@ -52,7 +60,10 @@ public class DomainModuleImpl extends AbstractModuleImpl { DOMOPT_INCLUDES, DOMOPT_LETSENCRYPT, DOMOPT_AUTOCONFIG, - DOMOPT_DKIM + DOMOPT_DKIM, + DOMOPT_PASSENGER, + DOMOPT_CGI, + DOMOPT_FASTCGI }; @Override diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainOptionValues.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainOptionValues.java index e2ff9d4..b856892 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainOptionValues.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainOptionValues.java @@ -27,6 +27,10 @@ public class DomainOptionValues extends DefaultSelectableValues { list.add(new BooleanListValue("letsencrypt")); list.add(new BooleanListValue("autoconfig")); list.add(new BooleanListValue("dkim")); + list.add(new BooleanListValue("passenger")); + list.add(new BooleanListValue("passengerfriendlyerrorpages")); + list.add(new BooleanListValue("cgi")); + list.add(new BooleanListValue("fastcgi")); return list; } diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index f7b5993..d8f6357 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -263,6 +263,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory { ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "letsencrypt", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "autoconfig", Boolean.TRUE, Boolean.FALSE); + ifOption(templateVars, query, "passenger", Boolean.TRUE, Boolean.FALSE); + ifOption(templateVars, query, "passengerfriendlyerrorpages", Boolean.TRUE, Boolean.FALSE); + ifOption(templateVars, query, "cgi", Boolean.TRUE, Boolean.FALSE); + ifOption(templateVars, query, "fastcgi", Boolean.TRUE, Boolean.FALSE); final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE); final Processor domSetupProcessor = new CompoundProcessor( isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"), -- 2.39.5 From 513431584eaec93d43948019b112fbb9af99cb54 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 28 Nov 2023 12:48:21 +0100 Subject: [PATCH 02/34] Add new domain properties PassengerPython, PassengerNodejs, PassengerRuby, FcgiPhpBin, ProxyHttpPort, ProxyWebsocketPort --- hsarback/database/database_update.sql | 7 ++ hsarback/database/schema.sql | 8 +- .../java/de/hsadmin/remote/DomainRemote.java | 36 +++++++++ .../hsadmin/servlets/JsonPillarServlet.java | 24 ++++++ .../de/hsadmin/mods/dom/apache-vhost.vm | 29 ++++++++ .../main/java/de/hsadmin/mods/dom/Domain.java | 74 ++++++++++++++++++- 6 files changed, 176 insertions(+), 2 deletions(-) diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index aaf22cb..5fde6a6 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -88,3 +88,10 @@ INSERT INTO domain_option (domain_option_name) VALUES ('passenger'); INSERT INTO domain_option (domain_option_name) VALUES ('passengerfriendlyerrorpages'); INSERT INTO domain_option (domain_option_name) VALUES ('cgi'); INSERT INTO domain_option (domain_option_name) VALUES ('fastcgi'); + +ALTER TABLE domain ADD COLUMN passenger_python character varying(255); +ALTER TABLE domain ADD COLUMN passenger_nodejs character varying(255); +ALTER TABLE domain ADD COLUMN passenger_ruby character varying(255); +ALTER TABLE domain ADD COLUMN fcgi_php_bin character varying(255); +ALTER TABLE domain ADD COLUMN proxy_http_port integer; +ALTER TABLE domain ADD COLUMN proxy_websocket_port integer; diff --git a/hsarback/database/schema.sql b/hsarback/database/schema.sql index a0de244..b2e30da 100644 --- a/hsarback/database/schema.sql +++ b/hsarback/database/schema.sql @@ -319,7 +319,13 @@ CREATE TABLE domain ( domain_dns_master character varying(64), domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL, domain_owner integer NOT NULL, - valid_subdomain_names character varying(256) DEFAULT 'www' NOT NULL + valid_subdomain_names character varying(256) DEFAULT 'www' NOT NULL, + passenger_python character varying(256) NULL, + passenger_nodejs character varying(256) NULL, + passenger_ruby character varying(256) NULL, + fcgi_php_bin character varying(256) NULL, + proxy_http_port integer DEFAULT NULL, + proxy_websocket_port integer DEFAULT NULL ); diff --git a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java index 134787b..a2d56c2 100644 --- a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java +++ b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java @@ -51,6 +51,18 @@ public class DomainRemote extends AbstractRemote { } final String validsubdomains = dom.getValidsubdomainnames(); resultMap.put("validsubdomainnames", validsubdomains); + final String passengerpython = dom.getPassengerPython(); + resultMap.put("passengerpython", passengerpython); + final String passengernodejs = dom.getPassengerNodejs(); + resultMap.put("passengernodejs", passengernodejs); + final String passengerruby = dom.getPassengerRuby(); + resultMap.put("passengerruby", passengerruby); + final String passengerfcgiphpbin = dom.getPassengerFcgiPhpBin(); + resultMap.put("passengerfcgiphpbin", passengerfcgiphpbin); + final String proxyhttpport = dom.getProxyHttpPort(); + resultMap.put("proxyhttpport", proxyhttpport); + final String proxywebsocketport = dom.getProxyWebsocketPort(); + resultMap.put("proxywebsocketport", proxywebsocketport); } @Override @@ -92,6 +104,30 @@ public class DomainRemote extends AbstractRemote { if (validsubdomains != null && validsubdomains instanceof String) { dom.setValidsubdomainnames((String) validsubdomains); } + final Object passengerpython = setParams.get("passengerpython"); + if (passengerpython != null && passengerpython instanceof String) { + dom.setPassengerPython((String) passengerpython); + } + final Object passengernodejs = setParams.get("passengernodejs"); + if (passengernodejs != null && passengernodejs instanceof String) { + dom.setPassengerNodejs((String) passengernodejs); + } + final Object passengerruby = setParams.get("passengerruby"); + if (passengerruby != null && passengerruby instanceof String) { + dom.setPassengerRuby((String) passengerruby); + } + final Object fcgiphpbin = setParams.get("fcgiphpbin"); + if (fcgiphpbin != null && fcgiphpbin instanceof String) { + dom.setFcgiPhpBin((String) fcgiphpbin); + } + final Object proxyhttpport = setParams.get("proxyhttpport"); + if (proxyhttpport != null && proxyhttpport instanceof Integer) { + dom.setProxyHttpPort((Integer)proxyhttpport); + } + final Object proxywebsocketport = setParams.get("proxywebsocketport"); + if (proxywebsocketport != null && proxywebsocketport instanceof Integer) { + dom.setProxyWebsocketPort((Integer)proxywebsocketport); + } } @Override diff --git a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java index f15b183..a94232d 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java @@ -121,6 +121,12 @@ public class JsonPillarServlet extends HttpServlet { domainadmins.add(domUserName); final Pac domPac = domUser.getPac(); final String validSubdomainNames = dom.getValidsubdomainnames(); + final String passengerPython = dom.getPassengerPython(); + final String passengerNodejs = dom.getPassengerNodejs(); + final String passengerRuby = dom.getPassengerRuby(); + final String fcgiPhpBin = dom.getFcgiPhpBin(); + final Integer proxyHttpPort = dom.getProxyHttpPort(); + final Integer proxyWebsocketPort = dom.getProxyWebsocketPort(); final INetAddress domINetAddr = domPac.getCurINetAddr(); writer.println(" \"domain\": \"" + domName + "\""); writer.println(" , \"pac\": \"" + domPac.getName() + "\""); @@ -148,6 +154,24 @@ public class JsonPillarServlet extends HttpServlet { } writer.println(" }"); writer.println(" , \"validsubdomains\": \"" + validSubdomainNames + "\""); + if (passengerPython.length() > 0) { + writer.println(" , \"passengerpython\": \"" + passengerPython + "\""); + } + if (passengerNodejs.length() > 0) { + writer.println(" , \"passengernodejs\": \"" + passengerNodejs + "\""); + } + if (passengerRuby.length() > 0) { + writer.println(" , \"passengerruby\": \"" + passengerRuby + "\""); + } + if (fcgPhpBin.length() > 0) { + writer.println(" , \"fcgiphpbin\": \"" + fcgPhpBin + "\""); + } + if (proxyHttpPort > 0) { + writer.println(" , \"proxyhttpport\": \"" + proxyHttpPort.toString() + "\""); + } + if (proxyWebsocketPort > 0) { + writer.println(" , \"proxywebsocketport\": \"" + proxyWebsocketPort.toString() + "\""); + } writer.println(" }"); } writer.println(" ]"); diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 735130c..2d41215 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -122,6 +122,15 @@ #end #if( ${passengerfriendlyerrorpages} ) PassengerFriendlyErrorPages On +#end +#if( ${passengerpython} ) + PassengerPython /home/pacs/${pac.name}/users/${dom.user.name}/${passengerpython} +#end +#if( ${passengernodejs} ) + PassengerNodejs /home/pacs/${pac.name}/users/${dom.user.name}/${passengernodejs} +#end +#if( ${passengerruby} ) + PassengerRuby /home/pacs/${pac.name}/users/${dom.user.name}/${passengerruby} #end AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv @@ -170,6 +179,26 @@ RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# !-d RewriteRule ^(.*) - [redirect=404,last] +#end + +#if( ${proxywebsocketport} ) +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{HTTP:Connection} Upgrade [NC,OR] +RewriteCond %{HTTP:Upgrade} websocket [NC] +RewriteRule .* ws://127.0.0.1:${proxywebsocketport}/%{REQUEST_URI} [proxy] + +#end + +#if( ${proxyhttpport} ) +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f +RewriteRule .* http://127.0.0.1:${proxyhttpport}/%{REQUEST_URI} [proxy,last] +RequestHeader set X-Forwarded-Proto "https" + +#end + +#if( ${fcgiphpbin} ) + SetEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php .php5 .php4 .php3 Action application/x-httpd-php /fastcgi-bin/phpstub diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index a6d0575..269bc94 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -65,7 +65,31 @@ public class Domain extends AbstractEntity { @AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE) @Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)") private String validsubdomainnames; - + + @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @Column(name = "passenger_python", columnDefinition = "character varying(256)") + private String passengerpython; + + @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @Column(name = "passenger_nodejs", columnDefinition = "character varying(256)") + private String passengernodejs; + + @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @Column(name = "passenger_ruby", columnDefinition = "character varying(256)") + private String passengerruby; + + @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @Column(name = "fcgi_php_bin", columnDefinition = "character varying(256)") + private String fcgiphpbin; + + @AnnFieldIO(validation="[0-9]*", rw=ReadWriteAccess.READWRITE) + @Column(name = "proxy_http_port", columnDefinition = "integer") + private Integer proxyhttpport; + + @AnnFieldIO(validation="[0-9]*", rw=ReadWriteAccess.READWRITE) + @Column(name = "proxy_websocket_port", columnDefinition = "integer") + private Integer proxywebsocketport; + public Domain() { } @@ -191,6 +215,54 @@ public class Domain extends AbstractEntity { this.validsubdomainnames = validSubdomainNames; } + public String getPassengerPython() { + return passengerpython; + } + + public void setPassengerPython(String value) { + passengerpython = value; + } + + public String getPassengerNodejs() { + return passengernodejs; + } + + public void setPassengerNodejs(String value) { + passengernodejs = value; + } + + public String getPassengerRuby() { + return passengerruby; + } + + public void setPassengerRuby(String value) { + passengerruby = value; + } + + public String getFcgiPhpBin() { + return fcgiphpbin; + } + + public void setFcgiPhpBin(String value) { + fcgiphpbin = value; + } + + public Integer getProxyHttpPort() { + return proxyhttpport; + } + + public void setProxyHttpPort(String value) { + proxyhttpport = value; + } + + public Integer getProxyWebsocketPort() { + return proxywebsocketport; + } + + public void setProxyWebsocketPort(String value) { + proxywebsocketport = value; + } + public String getServeraliases() { String[] subs = validsubdomainnames.split(","); StringBuffer aliases = new StringBuffer(); -- 2.39.5 From 237c6d49fbaae819c1713c06ae935c5bc57f0178 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Mon, 11 Dec 2023 17:14:27 +0100 Subject: [PATCH 03/34] =?UTF-8?q?Undo=20=C3=84nderungen=20an=20hsarweb=20d?= =?UTF-8?q?a=20es=20nicht=20mehr=20im=20Einsatz=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hsarweb/src/texts/domain.properties | 4 ---- hsarweb/src/texts/domain_de.properties | 4 ---- 2 files changed, 8 deletions(-) diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index ed70489..47398bd 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -9,10 +9,6 @@ domainoption.includes=Includes domainoption.indexes=Indexes domainoption.multiviews=MultiViews domainoption.php=PHP -domainoption.passenger=Passenger -domainoption.passengerfriendlyerrorpages=PassengerFriendlyErrorPages -domainoption.cgi=CGI -domainoption.fastcgi=FCGI yes=Yes no=No pac=packet diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index 61f5ba1..fddd54f 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -9,10 +9,6 @@ domainoption.includes=Includes domainoption.indexes=Indexes domainoption.multiviews=MultiViews domainoption.php=PHP -domainoption.passenger=Passenger -domainoption.passengerfriendlyerrorpages=PassengerFriendlyErrorPages -domainoption.cgi=CGI -domainoption.fastcgi=FCGI yes=Ja no=Nein pac=Paket -- 2.39.5 From 864c21be132bc4ab3a611b82340b677c3edb34e2 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Mon, 11 Dec 2023 17:21:10 +0100 Subject: [PATCH 04/34] =?UTF-8?q?proxy=5Fhttp=5Fport=20und=20proxy=5Fwebso?= =?UTF-8?q?cket=5Fport=20zur=C3=BCckgebaut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hsarback/database/database_update.sql | 2 -- hsarback/database/schema.sql | 4 +--- .../java/de/hsadmin/remote/DomainRemote.java | 12 ---------- .../hsadmin/servlets/JsonPillarServlet.java | 8 ------- .../de/hsadmin/mods/dom/apache-vhost.vm | 16 ------------- .../main/java/de/hsadmin/mods/dom/Domain.java | 24 ------------------- 6 files changed, 1 insertion(+), 65 deletions(-) diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index 5fde6a6..2010596 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -93,5 +93,3 @@ ALTER TABLE domain ADD COLUMN passenger_python character varying(255); ALTER TABLE domain ADD COLUMN passenger_nodejs character varying(255); ALTER TABLE domain ADD COLUMN passenger_ruby character varying(255); ALTER TABLE domain ADD COLUMN fcgi_php_bin character varying(255); -ALTER TABLE domain ADD COLUMN proxy_http_port integer; -ALTER TABLE domain ADD COLUMN proxy_websocket_port integer; diff --git a/hsarback/database/schema.sql b/hsarback/database/schema.sql index b2e30da..be464b0 100644 --- a/hsarback/database/schema.sql +++ b/hsarback/database/schema.sql @@ -323,9 +323,7 @@ CREATE TABLE domain ( passenger_python character varying(256) NULL, passenger_nodejs character varying(256) NULL, passenger_ruby character varying(256) NULL, - fcgi_php_bin character varying(256) NULL, - proxy_http_port integer DEFAULT NULL, - proxy_websocket_port integer DEFAULT NULL + fcgi_php_bin character varying(256) NULL ); diff --git a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java index a2d56c2..7d829fe 100644 --- a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java +++ b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java @@ -59,10 +59,6 @@ public class DomainRemote extends AbstractRemote { resultMap.put("passengerruby", passengerruby); final String passengerfcgiphpbin = dom.getPassengerFcgiPhpBin(); resultMap.put("passengerfcgiphpbin", passengerfcgiphpbin); - final String proxyhttpport = dom.getProxyHttpPort(); - resultMap.put("proxyhttpport", proxyhttpport); - final String proxywebsocketport = dom.getProxyWebsocketPort(); - resultMap.put("proxywebsocketport", proxywebsocketport); } @Override @@ -120,14 +116,6 @@ public class DomainRemote extends AbstractRemote { if (fcgiphpbin != null && fcgiphpbin instanceof String) { dom.setFcgiPhpBin((String) fcgiphpbin); } - final Object proxyhttpport = setParams.get("proxyhttpport"); - if (proxyhttpport != null && proxyhttpport instanceof Integer) { - dom.setProxyHttpPort((Integer)proxyhttpport); - } - final Object proxywebsocketport = setParams.get("proxywebsocketport"); - if (proxywebsocketport != null && proxywebsocketport instanceof Integer) { - dom.setProxyWebsocketPort((Integer)proxywebsocketport); - } } @Override diff --git a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java index a94232d..ab0376d 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java @@ -125,8 +125,6 @@ public class JsonPillarServlet extends HttpServlet { final String passengerNodejs = dom.getPassengerNodejs(); final String passengerRuby = dom.getPassengerRuby(); final String fcgiPhpBin = dom.getFcgiPhpBin(); - final Integer proxyHttpPort = dom.getProxyHttpPort(); - final Integer proxyWebsocketPort = dom.getProxyWebsocketPort(); final INetAddress domINetAddr = domPac.getCurINetAddr(); writer.println(" \"domain\": \"" + domName + "\""); writer.println(" , \"pac\": \"" + domPac.getName() + "\""); @@ -166,12 +164,6 @@ public class JsonPillarServlet extends HttpServlet { if (fcgPhpBin.length() > 0) { writer.println(" , \"fcgiphpbin\": \"" + fcgPhpBin + "\""); } - if (proxyHttpPort > 0) { - writer.println(" , \"proxyhttpport\": \"" + proxyHttpPort.toString() + "\""); - } - if (proxyWebsocketPort > 0) { - writer.println(" , \"proxywebsocketport\": \"" + proxyWebsocketPort.toString() + "\""); - } writer.println(" }"); } writer.println(" ]"); diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 2d41215..bcc9467 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -181,22 +181,6 @@ #end -#if( ${proxywebsocketport} ) -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{HTTP:Connection} Upgrade [NC,OR] -RewriteCond %{HTTP:Upgrade} websocket [NC] -RewriteRule .* ws://127.0.0.1:${proxywebsocketport}/%{REQUEST_URI} [proxy] - -#end - -#if( ${proxyhttpport} ) -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f -RewriteRule .* http://127.0.0.1:${proxyhttpport}/%{REQUEST_URI} [proxy,last] -RequestHeader set X-Forwarded-Proto "https" - -#end - #if( ${fcgiphpbin} ) SetEnv HTTP_PHP_BIN ${fcgiphpbin} #end diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index 269bc94..27afbd8 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -82,14 +82,6 @@ public class Domain extends AbstractEntity { @Column(name = "fcgi_php_bin", columnDefinition = "character varying(256)") private String fcgiphpbin; - @AnnFieldIO(validation="[0-9]*", rw=ReadWriteAccess.READWRITE) - @Column(name = "proxy_http_port", columnDefinition = "integer") - private Integer proxyhttpport; - - @AnnFieldIO(validation="[0-9]*", rw=ReadWriteAccess.READWRITE) - @Column(name = "proxy_websocket_port", columnDefinition = "integer") - private Integer proxywebsocketport; - public Domain() { } @@ -247,22 +239,6 @@ public class Domain extends AbstractEntity { fcgiphpbin = value; } - public Integer getProxyHttpPort() { - return proxyhttpport; - } - - public void setProxyHttpPort(String value) { - proxyhttpport = value; - } - - public Integer getProxyWebsocketPort() { - return proxywebsocketport; - } - - public void setProxyWebsocketPort(String value) { - proxywebsocketport = value; - } - public String getServeraliases() { String[] subs = validsubdomainnames.split(","); StringBuffer aliases = new StringBuffer(); -- 2.39.5 From e57a3d7c840af4c1a82f6385a06926c93685137d Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Mon, 11 Dec 2023 17:28:22 +0100 Subject: [PATCH 05/34] fix typos --- hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java | 2 +- .../src/main/java/de/hsadmin/servlets/JsonPillarServlet.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java index 7d829fe..708826d 100644 --- a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java +++ b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java @@ -57,7 +57,7 @@ public class DomainRemote extends AbstractRemote { resultMap.put("passengernodejs", passengernodejs); final String passengerruby = dom.getPassengerRuby(); resultMap.put("passengerruby", passengerruby); - final String passengerfcgiphpbin = dom.getPassengerFcgiPhpBin(); + final String passengerfcgiphpbin = dom.getFcgiPhpBin(); resultMap.put("passengerfcgiphpbin", passengerfcgiphpbin); } diff --git a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java index ab0376d..c3cb924 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java @@ -161,8 +161,8 @@ public class JsonPillarServlet extends HttpServlet { if (passengerRuby.length() > 0) { writer.println(" , \"passengerruby\": \"" + passengerRuby + "\""); } - if (fcgPhpBin.length() > 0) { - writer.println(" , \"fcgiphpbin\": \"" + fcgPhpBin + "\""); + if (fcgiPhpBin.length() > 0) { + writer.println(" , \"fcgiphpbin\": \"" + fcgiPhpBin + "\""); } writer.println(" }"); } -- 2.39.5 From 9032f0d81c03d2730af050aef68fa061023b3b0d Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Mon, 11 Dec 2023 23:52:26 +0100 Subject: [PATCH 06/34] =?UTF-8?q?Makefile=20hinzuf=C3=BCgen=20f=C3=BCr=20o?= =?UTF-8?q?ft=20auszuf=C3=BChrende=20Operationen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f25cdde --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +SHELL := /bin/bash + +info: + @echo "Achtung: nur auf Entwicklungs- und Testservern einsetzen!" + @echo "make build: build the jar files" + @echo "make psql: start psql shell on the database" + @echo "make resetdata: reset the data in the database" + @echo "make run: run catalina and watch the output" + @echo "make test: run all continuous integration tests" + @echo "make testdomain: run one specific test for domains" + +build: + source ~/.profile + cd ~/hsadmin/util && mvn clean install + cd ~/hsadmin/qserv && mvn clean install + cd ~/hsadmin/hsarback && mvn package -DskipTests + cp ~/hsadmin/qserv/target/hsadmin-*.jar ~/tomcatmq/webapps/hsar/WEB-INF/lib/ + cp ~/hsadmin/util/target/hsadmin-*.jar ~/tomcatmq/webapps/hsar/WEB-INF/lib/ + + +resetdata: + psql -U tim03_hsatest < ~/hsadmin/hsarback/database/dropschema.sql + psql -U tim03_hsatest < ~/hsadmin/hsarback/database/schema.sql + psql -U tim03_hsatest < ~/hsadmin/hsarback/database/data.sql + +test: resetdata + source ~/.profile + cd ~/hsadmin/hsarback && mvn test -Dtest=ContinuousIntegrationTest + +testdomain: resetdata + source ~/.profile + cd ~/hsadmin/hsarback && mvn test -Dtest=InitDataTest && mvn test -Dtest=DomainTest + +run: + source ~/.profile + cd ~/tomcatmq && ./bin/catalina.sh run + +psql: + WHOAMI=`whoami` && psql -U $${WHOAMI//\-/_} -- 2.39.5 From 0941515461af53e892882651b3698888e2f658b4 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 00:32:36 +0100 Subject: [PATCH 07/34] Add Test for Updating Domain Properties and Domain Options --- .../java/de/hsadmin/remote/DomainTest.java | 122 ++++++++++++++++-- 1 file changed, 108 insertions(+), 14 deletions(-) diff --git a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java index f2f8421..2c7a6e8 100644 --- a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java +++ b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java @@ -19,7 +19,7 @@ import org.junit.Test; public class DomainTest { private static final String MODULE = "domain"; - + private XmlRpcClient client; private RemoteCASHelper cas; @@ -40,8 +40,8 @@ public class DomainTest { String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); - Object[] params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + Object[] params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), whereParams }; try { Object execute = client.execute(MODULE + ".search", params); @@ -61,15 +61,15 @@ public class DomainTest { } @Test - public void testUpdate() { + public void testUpdateWithoutPermissionFail() { String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); Map whereParams = new HashMap(); setParams.put("user", "aaa00"); whereParams.put("name", "example01.org"); - Object[] params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + Object[] params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), setParams, whereParams }; try { Object execute = client.execute(MODULE + ".update", params); @@ -87,8 +87,8 @@ public class DomainTest { Map setParams = new HashMap(); setParams.put("name", "f8n.de"); setParams.put("user", "aaa00-admin"); - Object[] params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + Object[] params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), setParams }; try { Object execute = client.execute(MODULE + ".add", params); @@ -99,6 +99,100 @@ public class DomainTest { assertEquals(count + 1, getDomsCount()); } + @Test + public void testUpdateDomain() { + String user = "aaa00"; + String grantingTicketURL = cas.getGrantingTicketURL(user); + + // first create the domain + Map setParams = new HashMap(); + setParams.put("name", "exampleupdate.de"); + setParams.put("user", "aaa00-admin"); + Object[] params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + setParams }; + try { + Object execute = client.execute(MODULE + ".add", params); + assertTrue(execute instanceof Map); + } catch (XmlRpcException e) { + fail(e.getMessage()); + } + + // check initial values + Map whereParams = new HashMap(); + whereParams.put("name", "exampleupdate.de"); + params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + whereParams }; + try { + Object execute = client.execute(MODULE + ".search", params); + if (execute instanceof Object[]) { + Object[] result = (Object[]) execute; + assertTrue("expected 1 result, but got " + result.length, 1 == result.length); + for (Object o : result) { + if (o instanceof Map) { + Map row = (Map) o; + assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); + assertTrue("ValidSubdomainNames should be * but is " + row.get("validsubdomainnames"), "*".equals(row.get("validsubdomainnames"))); + Object[] domainoptions = (Object[]) row.get("domainoptions"); + String options = ""; + for (Object option: domainoptions) { + options += option + " "; + } + String defaultDomainOptions = "htdocsfallback indexes dkim autoconfig greylisting includes letsencrypt multiviews "; + assertTrue("Domainoptions should be " + defaultDomainOptions + " but are " + options, defaultDomainOptions.equals(options)); + } + else { + fail("Map expected"); + } + } + } + else { + fail("Object[] expected"); + } + } catch (XmlRpcException e) { + fail(e.getMessage()); + } + + // now update the domain + setParams = new HashMap(); + whereParams = new HashMap(); + setParams.put("validsubdomainnames", "www2"); + setParams.put("domainoptions", new String[] {"greylisting", "letsencrypt"}); + whereParams.put("name", "exampleupdate.de"); + params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + setParams, whereParams }; + try { + Object execute = client.execute(MODULE + ".update", params); + if (execute instanceof Object[]) { + Object[] result = (Object[]) execute; + assertTrue("expected 1 result, but got " + result.length, 1 == result.length); + for (Object o : result) { + if (o instanceof Map) { + Map row = (Map) o; + assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); + assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames"))); + Object[] domainoptions = (Object[]) row.get("domainoptions"); + String options = ""; + for (Object option: domainoptions) { + options += option + " "; + } + assertTrue("Domainoptions should be greylisting letsencrypt but are " + options, "greylisting letsencrypt ".equals(options)); + } + else { + fail("Map expected"); + } + } + } + else { + fail("Object[] expected"); + } + } catch (XmlRpcException e) { + fail(e.getMessage()); + } + } + @Test public void testCreateForeignSubdomain() throws UnknownHostException, IOException { int count = getDomsCount(); @@ -107,8 +201,8 @@ public class DomainTest { Map setParams = new HashMap(); setParams.put("name", "f6n.de"); setParams.put("user", "aaa00-admin"); - Object[] params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + Object[] params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), setParams }; try { Object execute = client.execute(MODULE + ".add", params); @@ -123,8 +217,8 @@ public class DomainTest { setParams = new HashMap(); setParams.put("name", "subdomain.f6n.de"); setParams.put("user", "aaa01"); - params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), setParams }; try { Object execute = client.execute(MODULE + ".add", params); @@ -140,8 +234,8 @@ public class DomainTest { String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); - Object[] params = new Object[] { user, - cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), + Object[] params = new Object[] { user, + cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), whereParams }; try { Object execute = client.execute(MODULE + ".search", params); -- 2.39.5 From fea2612a4848c44c208cd981e8cbd4dec52ef6ff Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 10:55:37 +0100 Subject: [PATCH 08/34] Teste die neuen Domain Optionen --- .../test/java/de/hsadmin/remote/DomainTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java index 2c7a6e8..99e6652 100644 --- a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java +++ b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; +import java.util.Arrays; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; @@ -158,7 +159,8 @@ public class DomainTest { setParams = new HashMap(); whereParams = new HashMap(); setParams.put("validsubdomainnames", "www2"); - setParams.put("domainoptions", new String[] {"greylisting", "letsencrypt"}); + String[] newDomainOptions = new String[] {"greylisting", "letsencrypt", "passenger", "passengerfriendlyerrorpages", "cgi", "fastcgi"}; + setParams.put("domainoptions", newDomainOptions); whereParams.put("name", "exampleupdate.de"); params = new Object[] { user, cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), @@ -174,11 +176,11 @@ public class DomainTest { assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames"))); Object[] domainoptions = (Object[]) row.get("domainoptions"); - String options = ""; - for (Object option: domainoptions) { - options += option + " "; - } - assertTrue("Domainoptions should be greylisting letsencrypt but are " + options, "greylisting letsencrypt ".equals(options)); + String[] checkDomainOptions = Arrays.asList(domainoptions).toArray(new String[0]); + Arrays.sort(newDomainOptions); + Arrays.sort(checkDomainOptions); + assertTrue("Domainoptions should be " + Arrays.toString(newDomainOptions) + " but are " + Arrays.toString(checkDomainOptions), + Arrays.toString(newDomainOptions).equals(Arrays.toString(checkDomainOptions))); } else { fail("Map expected"); -- 2.39.5 From 643b23ad34abd94fcccfb82e4763f0a116c30d71 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 11:01:19 +0100 Subject: [PATCH 09/34] Vereinheitlichung der Tests von DomainOptionen --- .../test/java/de/hsadmin/remote/DomainTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java index 99e6652..44c03ee 100644 --- a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java +++ b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java @@ -135,13 +135,12 @@ public class DomainTest { Map row = (Map) o; assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); assertTrue("ValidSubdomainNames should be * but is " + row.get("validsubdomainnames"), "*".equals(row.get("validsubdomainnames"))); - Object[] domainoptions = (Object[]) row.get("domainoptions"); - String options = ""; - for (Object option: domainoptions) { - options += option + " "; - } - String defaultDomainOptions = "htdocsfallback indexes dkim autoconfig greylisting includes letsencrypt multiviews "; - assertTrue("Domainoptions should be " + defaultDomainOptions + " but are " + options, defaultDomainOptions.equals(options)); + String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]); + String[] expectedDomainOptions = new String[] {"htdocsfallback", "indexes", "dkim", "autoconfig", "greylisting", "includes", "letsencrypt", "multiviews"}; + Arrays.sort(expectedDomainOptions); + Arrays.sort(checkDomainOptions); + assertTrue("Domainoptions should be " + Arrays.toString(expectedDomainOptions) + " but are " + Arrays.toString(checkDomainOptions), + Arrays.toString(expectedDomainOptions).equals(Arrays.toString(checkDomainOptions))); } else { fail("Map expected"); @@ -175,8 +174,7 @@ public class DomainTest { Map row = (Map) o; assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames"))); - Object[] domainoptions = (Object[]) row.get("domainoptions"); - String[] checkDomainOptions = Arrays.asList(domainoptions).toArray(new String[0]); + String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]); Arrays.sort(newDomainOptions); Arrays.sort(checkDomainOptions); assertTrue("Domainoptions should be " + Arrays.toString(newDomainOptions) + " but are " + Arrays.toString(checkDomainOptions), -- 2.39.5 From 9a6a6d094a2a3fa8a1adade41f2fa2e08ddf50ea Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 11:52:39 +0100 Subject: [PATCH 10/34] =?UTF-8?q?Erweiterung=20der=20Tests=20um=20das=20?= =?UTF-8?q?=C3=84ndern=20von=20den=20neuen=20Domain=20Eigenschaften,=20z.B?= =?UTF-8?q?.=20PassengerPython?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/de/hsadmin/remote/DomainTest.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java index 44c03ee..736282d 100644 --- a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java +++ b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java @@ -135,6 +135,13 @@ public class DomainTest { Map row = (Map) o; assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); assertTrue("ValidSubdomainNames should be * but is " + row.get("validsubdomainnames"), "*".equals(row.get("validsubdomainnames"))); + String defaultPassengerPython = ""; + + assertTrue("PassengerPython should be empty but is " + row.get("passengerpython"), isNullOrEmpty(row.get("passengerpython"))); + assertTrue("PassengerNodejs should be empty but is " + row.get("passengernodejs"), isNullOrEmpty(row.get("passengernodejs"))); + assertTrue("PassengerRuby should be empty but is " + row.get("passengerruby"), isNullOrEmpty(row.get("passengerruby"))); + assertTrue("FcgiPhpBin should be empty but is " + row.get("fcgiphpbin"), isNullOrEmpty(row.get("fcgiphpbin"))); + String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]); String[] expectedDomainOptions = new String[] {"htdocsfallback", "indexes", "dkim", "autoconfig", "greylisting", "includes", "letsencrypt", "multiviews"}; Arrays.sort(expectedDomainOptions); @@ -156,10 +163,21 @@ public class DomainTest { // now update the domain setParams = new HashMap(); - whereParams = new HashMap(); setParams.put("validsubdomainnames", "www2"); + + String newPassengerPython = "/home/pacs/aaa00/users/admin/.venv/bin/python3"; + setParams.put("passengerpython", newPassengerPython); + String newPassengerRuby = "/home/pacs/aaa00/users/admin/.rbenv/shims/ruby"; + setParams.put("passengerruby", newPassengerRuby); + String newPassengerNodejs = "/home/pacs/aaa00/users/admin/.nvm/versions/node/v18.19.0/bin/node"; + setParams.put("passengernodejs", newPassengerNodejs); + String newFcgiPhpBin = "/usr/bin/php8.1"; + setParams.put("fcgiphpbin", newFcgiPhpBin); + String[] newDomainOptions = new String[] {"greylisting", "letsencrypt", "passenger", "passengerfriendlyerrorpages", "cgi", "fastcgi"}; setParams.put("domainoptions", newDomainOptions); + + whereParams = new HashMap(); whereParams.put("name", "exampleupdate.de"); params = new Object[] { user, cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), @@ -174,6 +192,12 @@ public class DomainTest { Map row = (Map) o; assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name"))); assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames"))); + + assertTrue("PassengerPython should be " + newPassengerPython + " but is " + row.get("passengerpython"), newPassengerPython.equals(row.get("passengerpython"))); + assertTrue("PassengerNodejs should be " + newPassengerNodejs + " but is " + row.get("passengernodejs"), newPassengerNodejs.equals(row.get("passengernodejs"))); + assertTrue("PassengerRuby should be " + newPassengerRuby + " but is " + row.get("passengerruby"), newPassengerRuby.equals(row.get("passengerruby"))); + assertTrue("FcgiPhpBin should be " + newFcgiPhpBin + " but is " + row.get("fcgiphpbin"), newFcgiPhpBin.equals(row.get("fcgiphpbin"))); + String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]); Arrays.sort(newDomainOptions); Arrays.sort(checkDomainOptions); @@ -193,6 +217,12 @@ public class DomainTest { } } + private Boolean isNullOrEmpty(Object s) { + if (s == null) return true; + if (((String)s).equals("")) return true; + return false; + } + @Test public void testCreateForeignSubdomain() throws UnknownHostException, IOException { int count = getDomsCount(); -- 2.39.5 From 13316d265ef484a9e0cb7a8693a2430fd4c6d416 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 11:53:25 +0100 Subject: [PATCH 11/34] use this --- qserv/src/main/java/de/hsadmin/mods/dom/Domain.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index 27afbd8..abce2b5 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -212,7 +212,7 @@ public class Domain extends AbstractEntity { } public void setPassengerPython(String value) { - passengerpython = value; + this.passengerpython = value; } public String getPassengerNodejs() { @@ -220,7 +220,7 @@ public class Domain extends AbstractEntity { } public void setPassengerNodejs(String value) { - passengernodejs = value; + this.passengernodejs = value; } public String getPassengerRuby() { @@ -228,7 +228,7 @@ public class Domain extends AbstractEntity { } public void setPassengerRuby(String value) { - passengerruby = value; + this.passengerruby = value; } public String getFcgiPhpBin() { @@ -236,7 +236,7 @@ public class Domain extends AbstractEntity { } public void setFcgiPhpBin(String value) { - fcgiphpbin = value; + this.fcgiphpbin = value; } public String getServeraliases() { -- 2.39.5 From c4bbde598474634f4af41f58923d914de183742d Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 12 Dec 2023 14:38:59 +0100 Subject: [PATCH 12/34] rename setter and getter --- hsarback/database/database_update.sql | 103 ++---------------- .../java/de/hsadmin/remote/DomainRemote.java | 16 +-- .../hsadmin/servlets/JsonPillarServlet.java | 8 +- .../main/java/de/hsadmin/mods/dom/Domain.java | 16 +-- 4 files changed, 30 insertions(+), 113 deletions(-) diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index 2010596..1510e3b 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -1,95 +1,12 @@ -DROP VIEW ipconfig; -ALTER TABLE packet - ALTER COLUMN packet_name TYPE VARCHAR(6); -ALTER TABLE packet - ALTER COLUMN hive_id DROP NOT NULL; - -UPDATE packet SET packet_name='vm10' || substr(packet_name,4,2) WHERE packet_name LIKE 'srv%'; +ALTER TABLE domain + ADD COLUMN passenger_python character varying(256) NULL, + ADD COLUMN passenger_nodejs character varying(256) NULL, + ADD COLUMN passenger_ruby character varying(256) NULL, + ADD COLUMN fcgi_php_bin character varying(256) NULL; -CREATE VIEW ipconfig AS - SELECT DISTINCT ON (theunion.ipv4) theunion.ipv4, - theunion.name, - theunion.alias, - theunion.hivename - FROM ( SELECT h.hive_name AS hivename, - ip.inet_addr AS ipv4, - 'eth0:'::text || p.packet_name::text AS alias, - p.packet_name AS name, - 2 AS prio - FROM inet_addr ip - JOIN packet p ON p.cur_inet_addr_id = ip.inet_addr_id - JOIN hive h ON h.hive_id = p.hive_id - UNION - SELECT h.hive_name AS hivename, - ip.inet_addr AS ipv4, - 'eth0'::text AS alias, - h.hive_name AS name, - 1 AS prio - FROM inet_addr ip - JOIN hive h ON h.inet_addr_id = ip.inet_addr_id - ORDER BY 2, 5) theunion; - -INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number) - VALUES ('SRV/CLD', 'Cloud Server', 0, true, 3000); - -INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) - VALUES ('BANDWIDTH', 'Bandbreite 95/5 (Mbit/s)', 0, true); - -INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) - VALUES ('SLAINFR8H', 'HS Ext. Support (24x7 8h) for Infrastructure', 0, true); -INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) - VALUES ('SLAINFR4H', 'HS Ext. Support (24x7 4h) for Infrastructure', 0, true); -INSERT INTO basecomponent (basecomponent_code, description, sorting, valid) - VALUES ('SLAINFR2H', 'HS Ext. Support (24x7 2h) for Infrastructure', 0, true); - -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 1, 102400000, 1, 1, 0, false, 3011 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='CPU'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 1024, 102400000, 1024, 1024, 0, false, 3012 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='RAM'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 102400000, 250, 250, 0, false, 3013 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='TRAFFIC'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 1000, 0, 1, 0, false, 3017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='BANDWIDTH'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 25600, 102400000, 25600, 25600, 0, false, 3014 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='QUOTA'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 102400000, 0, 256000, 0, false, 3015 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='STORAGE'; - -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 1, 1, 1, 1, 0, false, 3136 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLABASIC'; - -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3122 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR8H'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3125 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR4H'; -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3151 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR2H'; - -INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number) - SELECT basepacket_id, basecomponent_id, 0, 1000, 0, 1, 0, false, 2017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='BANDWIDTH'; -UPDATE component SET min_quantity=0 WHERE component_id=38; -- min. Traffic für Managed Server auf 0 - -INSERT INTO price (article_number, price, vat, price_list) VALUES (3011, 15, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3012, 5, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3013, 5, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3014, 5, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3015, 5, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3017, 2, 19.0, 1); - -INSERT INTO price (article_number, price, vat, price_list) VALUES (3136, 10, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3122, 40, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3125, 80, 19.0, 1); -INSERT INTO price (article_number, price, vat, price_list) VALUES (3151, 160, 19.0, 1); - -INSERT INTO price (article_number, price, vat, price_list) VALUES (2017, 2, 19.0, 1); - -INSERT INTO domain_option (domain_option_name) VALUES ('passenger'); -INSERT INTO domain_option (domain_option_name) VALUES ('passengerfriendlyerrorpages'); -INSERT INTO domain_option (domain_option_name) VALUES ('cgi'); -INSERT INTO domain_option (domain_option_name) VALUES ('fastcgi'); - -ALTER TABLE domain ADD COLUMN passenger_python character varying(255); -ALTER TABLE domain ADD COLUMN passenger_nodejs character varying(255); -ALTER TABLE domain ADD COLUMN passenger_ruby character varying(255); -ALTER TABLE domain ADD COLUMN fcgi_php_bin character varying(255); +INSERT INTO domain_option (domain_option_name) VALUES + ('passenger'), + ('passengerfriendlyerrorpages'), + ('cgi'), + ('fastcgi'); diff --git a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java index 708826d..3e5b6d7 100644 --- a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java +++ b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java @@ -51,13 +51,13 @@ public class DomainRemote extends AbstractRemote { } final String validsubdomains = dom.getValidsubdomainnames(); resultMap.put("validsubdomainnames", validsubdomains); - final String passengerpython = dom.getPassengerPython(); + final String passengerpython = dom.getPassengerpython(); resultMap.put("passengerpython", passengerpython); - final String passengernodejs = dom.getPassengerNodejs(); + final String passengernodejs = dom.getPassengernodejs(); resultMap.put("passengernodejs", passengernodejs); - final String passengerruby = dom.getPassengerRuby(); + final String passengerruby = dom.getPassengerruby(); resultMap.put("passengerruby", passengerruby); - final String passengerfcgiphpbin = dom.getFcgiPhpBin(); + final String passengerfcgiphpbin = dom.getFcgiphpbin(); resultMap.put("passengerfcgiphpbin", passengerfcgiphpbin); } @@ -102,19 +102,19 @@ public class DomainRemote extends AbstractRemote { } final Object passengerpython = setParams.get("passengerpython"); if (passengerpython != null && passengerpython instanceof String) { - dom.setPassengerPython((String) passengerpython); + dom.setPassengerpython((String) passengerpython); } final Object passengernodejs = setParams.get("passengernodejs"); if (passengernodejs != null && passengernodejs instanceof String) { - dom.setPassengerNodejs((String) passengernodejs); + dom.setPassengernodejs((String) passengernodejs); } final Object passengerruby = setParams.get("passengerruby"); if (passengerruby != null && passengerruby instanceof String) { - dom.setPassengerRuby((String) passengerruby); + dom.setPassengerruby((String) passengerruby); } final Object fcgiphpbin = setParams.get("fcgiphpbin"); if (fcgiphpbin != null && fcgiphpbin instanceof String) { - dom.setFcgiPhpBin((String) fcgiphpbin); + dom.setFcgiphpbin((String) fcgiphpbin); } } diff --git a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java index c3cb924..02f854a 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java @@ -121,10 +121,10 @@ public class JsonPillarServlet extends HttpServlet { domainadmins.add(domUserName); final Pac domPac = domUser.getPac(); final String validSubdomainNames = dom.getValidsubdomainnames(); - final String passengerPython = dom.getPassengerPython(); - final String passengerNodejs = dom.getPassengerNodejs(); - final String passengerRuby = dom.getPassengerRuby(); - final String fcgiPhpBin = dom.getFcgiPhpBin(); + final String passengerPython = dom.getPassengerpython(); + final String passengerNodejs = dom.getPassengernodejs(); + final String passengerRuby = dom.getPassengerruby(); + final String fcgiPhpBin = dom.getFcgiphpbin(); final INetAddress domINetAddr = domPac.getCurINetAddr(); writer.println(" \"domain\": \"" + domName + "\""); writer.println(" , \"pac\": \"" + domPac.getName() + "\""); diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index abce2b5..5090784 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -207,35 +207,35 @@ public class Domain extends AbstractEntity { this.validsubdomainnames = validSubdomainNames; } - public String getPassengerPython() { + public String getPassengerpython() { return passengerpython; } - public void setPassengerPython(String value) { + public void setPassengerpython(String value) { this.passengerpython = value; } - public String getPassengerNodejs() { + public String getPassengernodejs() { return passengernodejs; } - public void setPassengerNodejs(String value) { + public void setPassengernodejs(String value) { this.passengernodejs = value; } - public String getPassengerRuby() { + public String getPassengerruby() { return passengerruby; } - public void setPassengerRuby(String value) { + public void setPassengerruby(String value) { this.passengerruby = value; } - public String getFcgiPhpBin() { + public String getFcgiphpbin() { return fcgiphpbin; } - public void setFcgiPhpBin(String value) { + public void setFcgiphpbin(String value) { this.fcgiphpbin = value; } -- 2.39.5 From 02e55ee7a387c157fbbc625f7b88711c5e087c33 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 14:56:32 +0100 Subject: [PATCH 13/34] small fix for default domain options --- hsarback/src/test/java/de/hsadmin/remote/DomainTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java index 736282d..ce2f8eb 100644 --- a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java +++ b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java @@ -143,10 +143,10 @@ public class DomainTest { assertTrue("FcgiPhpBin should be empty but is " + row.get("fcgiphpbin"), isNullOrEmpty(row.get("fcgiphpbin"))); String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]); - String[] expectedDomainOptions = new String[] {"htdocsfallback", "indexes", "dkim", "autoconfig", "greylisting", "includes", "letsencrypt", "multiviews"}; + String[] expectedDomainOptions = new String[] {"htdocsfallback", "cgi", "fastcgi", "passenger", "indexes", "dkim", "autoconfig", "greylisting", "includes", "letsencrypt", "multiviews"}; Arrays.sort(expectedDomainOptions); Arrays.sort(checkDomainOptions); - assertTrue("Domainoptions should be " + Arrays.toString(expectedDomainOptions) + " but are " + Arrays.toString(checkDomainOptions), + assertTrue("Default Domainoptions should be " + Arrays.toString(expectedDomainOptions) + " but are " + Arrays.toString(checkDomainOptions), Arrays.toString(expectedDomainOptions).equals(Arrays.toString(checkDomainOptions))); } else { -- 2.39.5 From e2d6e75375624c8e2e9ed9a385317551032e434d Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 15:12:01 +0100 Subject: [PATCH 14/34] fix passengerfcgiphpbin to fcgiphpbin --- hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java index 3e5b6d7..6ed410a 100644 --- a/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java +++ b/hsarback/src/main/java/de/hsadmin/remote/DomainRemote.java @@ -57,8 +57,8 @@ public class DomainRemote extends AbstractRemote { resultMap.put("passengernodejs", passengernodejs); final String passengerruby = dom.getPassengerruby(); resultMap.put("passengerruby", passengerruby); - final String passengerfcgiphpbin = dom.getFcgiphpbin(); - resultMap.put("passengerfcgiphpbin", passengerfcgiphpbin); + final String fcgiphpbin = dom.getFcgiphpbin(); + resultMap.put("fcgiphpbin", fcgiphpbin); } @Override -- 2.39.5 From 0ca3cac46582b44f50ef813e9bc9873abb2482d4 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 12 Dec 2023 17:54:42 +0100 Subject: [PATCH 15/34] copy hsar.war to tomcatmq after mvn package --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index f25cdde..447a14f 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ build: cd ~/hsadmin/hsarback && mvn package -DskipTests cp ~/hsadmin/qserv/target/hsadmin-*.jar ~/tomcatmq/webapps/hsar/WEB-INF/lib/ cp ~/hsadmin/util/target/hsadmin-*.jar ~/tomcatmq/webapps/hsar/WEB-INF/lib/ + cp ~/hsadmin/hsarback/target/hsar.war ~/tomcatmq/webapps resetdata: -- 2.39.5 From 006eef9ab5641bbde790182d158d9d7a430cedd9 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 19 Dec 2023 20:20:16 +0100 Subject: [PATCH 16/34] domain properties order --- qserv/hsadmin.properties | 14 +++++++++++ .../main/java/de/hsadmin/mods/dom/Domain.java | 24 +++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 qserv/hsadmin.properties diff --git a/qserv/hsadmin.properties b/qserv/hsadmin.properties new file mode 100644 index 0000000..6ae4402 --- /dev/null +++ b/qserv/hsadmin.properties @@ -0,0 +1,14 @@ +hsadmin.jms.url=ssl://hsh02.hostsharing.net:61619 +hsadmin.jms.username=user-h98 +hsadmin.jms.password=Duoqu4chae8oofahgei9SouK +hsadmin.jms.system-queue=queue.hsadminSystem-h98 +hsadmin.jms.status-queue=queue.hsadminStatus +accountprefix.customer=hsh00 +accountprefix.hostmaster=hsh01 +queues.dns=testdns +queues.mail=testmail +hsadmin.smtp.from=peter.hormanns@hostsharing.net +hsadmin.smtp.cc=peter.hormanns@hostsharing.net +loginURL=TestUmgebung +backendURL=https://config.hostsharing.net:443/hsar/backend +xmlrpcURL=http://localhost:8080/hsar/xmlrpc/hsadmin diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index 5090784..20638a9 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -55,6 +55,10 @@ public class Domain extends AbstractEntity { @Column(name = "domain_dns_master", columnDefinition = "character varying(64)") private String dnsMaster; + @AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE) + @Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)") + private String validsubdomainnames; + @AnnFieldIO(validation="[a-zA-Z0-9\\-\\.]*", rw=ReadWriteAccess.READWRITE, referTo=DomainOption.class, selectableValues=DomainOptionValues.class) @ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST) @JoinTable(name="domain__domain_option", @@ -62,10 +66,6 @@ public class Domain extends AbstractEntity { inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")}) private Set domainoptions; - @AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE) - @Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)") - private String validsubdomainnames; - @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) @Column(name = "passenger_python", columnDefinition = "character varying(256)") private String passengerpython; @@ -191,14 +191,6 @@ public class Domain extends AbstractEntity { "obj.user=:loginUser"; } - public Set getDomainoptions() { - return domainoptions; - } - - public void setDomainoptions(Set domainOptions) { - this.domainoptions = domainOptions; - } - public String getValidsubdomainnames() { return validsubdomainnames; } @@ -207,6 +199,14 @@ public class Domain extends AbstractEntity { this.validsubdomainnames = validSubdomainNames; } + public Set getDomainoptions() { + return domainoptions; + } + + public void setDomainoptions(Set domainOptions) { + this.domainoptions = domainOptions; + } + public String getPassengerpython() { return passengerpython; } -- 2.39.5 From 83b7eba59e5676ada709c1f107ba8fc2da3bf0dd Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 12 Jan 2024 18:34:35 +0100 Subject: [PATCH 17/34] rollback activemq and openjpa updates --- hsarback/pom.xml | 8 ++-- .../servlets/QueueStatusReceiverServlet.java | 42 ----------------- qserv/hsadmin.properties | 14 ++++++ qserv/pom.xml | 45 ++++++++++++++++--- .../de/hsadmin/core/model/Transaction.java | 10 ++--- .../de/hsadmin/core/qserv/QueueServer.java | 26 +++-------- 6 files changed, 69 insertions(+), 76 deletions(-) create mode 100644 qserv/hsadmin.properties diff --git a/hsarback/pom.xml b/hsarback/pom.xml index 89331f5..0f9af1a 100644 --- a/hsarback/pom.xml +++ b/hsarback/pom.xml @@ -70,13 +70,13 @@ org.apache.velocity - velocity-engine-core - 2.3 + velocity + 1.7 org.apache.openjpa openjpa - 3.2.2 + 2.4.3 junit @@ -93,7 +93,7 @@ org.apache.activemq activemq-all - 5.18.1 + 5.5.0 provided diff --git a/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java index 3c72b77..eed9ffa 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java @@ -16,8 +16,6 @@ import javax.jms.QueueSession; import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; -import javax.naming.NameClassPair; -import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.persistence.EntityManager; import javax.servlet.ServletConfig; @@ -26,12 +24,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.activemq.ActiveMQConnectionFactory; - import de.hsadmin.core.model.TechnicalException; import de.hsadmin.core.model.TicketValidator; import de.hsadmin.core.model.Transaction; -import de.hsadmin.core.qserv.NullProcessor; import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.util.Config; @@ -41,8 +36,6 @@ public class QueueStatusReceiverServlet extends HttpServlet private static final long serialVersionUID = -5701350884034782083L; - private static boolean initQueuesDone = false; - private String jmsUser; private String jmsPass; private QueueConnectionFactory queueConnectionFactory; @@ -61,14 +54,6 @@ public class QueueStatusReceiverServlet extends HttpServlet isConnected = false; messageCount = 0; errorCount = 0; - try { - if (!initQueuesDone) { - initQueues(); - } - initQueuesDone = true; - } catch (NamingException e) { - throw new ServletException(e); - } try { connect(); } catch (NamingException e) { @@ -83,10 +68,6 @@ public class QueueStatusReceiverServlet extends HttpServlet InitialContext ctx = new InitialContext(); Context env = (Context) ctx.lookup("java:comp/env"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); - if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) queueConnectionFactory; - activeMQConnectionFactory.setTrustAllPackages(true); - } int timeoutCounter = 10; while (!isConnected && (timeoutCounter > 0)) { try { @@ -108,29 +89,6 @@ public class QueueStatusReceiverServlet extends HttpServlet } } - private void initQueues() throws NamingException { - InitialContext ctx = new InitialContext(); - NamingEnumeration list = ctx.list("java:comp/env/jms"); - Transaction transaction = new Transaction("anonymous"); - transaction.beginTransaction(); - EntityManager entityManager = transaction.getEntityManager(); - while (list.hasMore()) { - NameClassPair pair = list.next(); - String jndiName = pair.getName(); - if (jndiName != null && jndiName.startsWith("hsadminSystem-")) { - QueueTask task = new QueueTask(); - task.setProcessor(new NullProcessor()); - entityManager.persist(task); - entityManager.flush(); - String hive = jndiName.substring(14); - transaction.enqueue(hive, task); - } - } - transaction.commitTransaction(); - transaction.close(); - ctx.close(); - } - @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { diff --git a/qserv/hsadmin.properties b/qserv/hsadmin.properties new file mode 100644 index 0000000..abc80cf --- /dev/null +++ b/qserv/hsadmin.properties @@ -0,0 +1,14 @@ +hsadmin.jms.url=ssl://hsh02.hostsharing.net:61617 +hsadmin.jms.username=user-h98 +hsadmin.jms.password=kein-echtes-ppasswort +hsadmin.jms.system-queue=queue.hsadminSystem-h98 +hsadmin.jms.status-queue=queue.hsadminStatus +accountprefix.customer=hsh00 +accountprefix.hostmaster=hsh01 +queues.dns=testdns +queues.mail=testmail +hsadmin.smtp.from=nobody@hostsharing.net +hsadmin.smtp.cc=hostmaster@hostsharing.net +loginURL=TestUmgebung +backendURL=https://config.hostsharing.net:443/hsar/backend +xmlrpcURL=http://localhost:8080/hsar/xmlrpc/hsadmin diff --git a/qserv/pom.xml b/qserv/pom.xml index d2694d6..5a3b2a0 100644 --- a/qserv/pom.xml +++ b/qserv/pom.xml @@ -27,13 +27,13 @@ org.apache.velocity - velocity-engine-core - 2.3 + velocity + 1.7 org.apache.openjpa openjpa - 3.2.2 + 2.4.3 junit @@ -44,7 +44,7 @@ org.apache.activemq activemq-all - 5.18.1 + 5.5.0 provided @@ -68,7 +68,7 @@ org.apache.openjpa openjpa-maven-plugin - 3.2.2 + 2.4.3 **/QueueTask.class,**/Domain.class,**/DomainOption.class,**/EMailAddress.class,**/EMailAlias.class,**/Customer.class,**/Contact.class,**/UnixUser.class,**/Pac.class,**/BasePac.class,**/BaseComponent.class,**/PacComponent.class,**/Component.class,**/Hive.class,**/INetAddress.class,**/Database.class,**/DatabaseUser.class,**/PgSqlDatabase.class,**/MySqlDatabase.class,**/PgSqlUser.class,**/MySqlUser.class @@ -89,5 +89,40 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.openjpa + + + openjpa-maven-plugin + + + [2.4.3,) + + + enhance + + + + + + + + + + + + diff --git a/qserv/src/main/java/de/hsadmin/core/model/Transaction.java b/qserv/src/main/java/de/hsadmin/core/model/Transaction.java index 4e7f890..13fd71a 100644 --- a/qserv/src/main/java/de/hsadmin/core/model/Transaction.java +++ b/qserv/src/main/java/de/hsadmin/core/model/Transaction.java @@ -15,7 +15,7 @@ import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.Query; -import org.apache.activemq.ActiveMQConnectionFactory; +//import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.openjpa.persistence.OpenJPAEntityManager; import de.hsadmin.core.qserv.QueueClient; @@ -43,10 +43,10 @@ public class Transaction { ctx = new InitialContext(); Context env = (Context) ctx.lookup("java:comp/env"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); - if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory; - activeMQconnectionFatory.setTrustAllPackages(true); - } +// if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { +// ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory; +// activeMQconnectionFatory.setTrustAllPackages(true); +// } } catch (NamingException e) { throw new TechnicalException("no jms queue: jms/QueueCF", e); } diff --git a/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java b/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java index f997a7b..bf64403 100644 --- a/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java +++ b/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java @@ -7,6 +7,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.jms.Connection; +import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -23,8 +24,6 @@ import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; -import org.apache.activemq.ActiveMQConnectionFactory; - public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener { private static final String VERSION_NO = "4.0.11"; @@ -53,13 +52,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except throw new Exception(userHelp(propFile)); } } - FileInputStream propStream = null; - try { - propStream = new FileInputStream(propFile); - } catch (Exception e) { - System.out.println("couldn't read config file " + propFile.getAbsolutePath()); - System.exit(1); - } + FileInputStream propStream = new FileInputStream(propFile); Properties props = new Properties(System.getProperties()); props.load(propStream); propStream.close(); @@ -85,7 +78,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except } }); while (!qServ.connect()) { - Thread.sleep(30000); + Thread.sleep(10000); } while (true) { Thread.sleep(10000); @@ -130,11 +123,8 @@ public class QueueServer extends QueueCommons implements MessageListener, Except // create JMS connection and session try { Context ctx = new InitialContext(); - QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup(jmsFactory); - if (connectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) connectionFactory; - activeMQConnectionFactory.setTrustAllPackages(true); - } + QueueConnectionFactory connectionFactory = + (QueueConnectionFactory) ctx.lookup(jmsFactory); conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord); conn.setExceptionListener(this); queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); @@ -215,11 +205,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except try { logger.log(Level.INFO, "sendStatus(" + queueMessage + ")"); Context ctx = new InitialContext(); - QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup(jmsFactory); - if (connectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) connectionFactory; - activeMQConnectionFactory.setTrustAllPackages(true); - } + ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(jmsFactory); Destination queue = (Destination) ctx.lookup(jmsStatusQueue); statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord); statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); -- 2.39.5 From 023509d2dde32c22c08f7dc571a920424d438729 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 12 Jan 2024 19:16:26 +0100 Subject: [PATCH 18/34] compile in java-8-compatibility mode --- hsarback/pom.xml | 8 ++++---- qserv/pom.xml | 6 +++--- util/pom.xml | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hsarback/pom.xml b/hsarback/pom.xml index 0f9af1a..290d540 100644 --- a/hsarback/pom.xml +++ b/hsarback/pom.xml @@ -11,8 +11,8 @@ UTF-8 UTF-8 - 11 - 11 + 8 + 8 @@ -116,8 +116,8 @@ maven-compiler-plugin 3.11.0 - 11 - 11 + 8 + 8 diff --git a/qserv/pom.xml b/qserv/pom.xml index 5a3b2a0..828e017 100644 --- a/qserv/pom.xml +++ b/qserv/pom.xml @@ -7,7 +7,7 @@ 4.0.15 UTF-8 - 11 + 8 @@ -61,8 +61,8 @@ maven-compiler-plugin 3.11.0 - 11 - 11 + 8 + 8 diff --git a/util/pom.xml b/util/pom.xml index 9a3de76..5ed41c6 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -7,7 +7,7 @@ 4.0.15 UTF-8 - 11 + 8 @@ -24,8 +24,8 @@ maven-compiler-plugin 3.11.0 - 11 - 11 + 8 + 8 -- 2.39.5 From c87ef04330ed697e3d3def72f3197b24240b27d4 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 17 Jan 2024 11:26:11 +0100 Subject: [PATCH 19/34] new domainoption defaults --- qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java index dc4cbb4..cca5ab9 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -54,15 +54,11 @@ public class DomainModuleImpl extends AbstractModuleImpl { public static final String[] DEFAULT_DOMOPTS = new String[] { DOMOPT_GREYLISTING, - DOMOPT_MULTIVIEWS, DOMOPT_INDEXES, DOMOPT_HTDOCSFALLBACK, - DOMOPT_INCLUDES, DOMOPT_LETSENCRYPT, DOMOPT_AUTOCONFIG, DOMOPT_DKIM, - DOMOPT_PASSENGER, - DOMOPT_CGI, DOMOPT_FASTCGI }; -- 2.39.5 From 73f47dfb47ec03d0c7f8e406f3792335dde2cdba Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Wed, 17 Jan 2024 11:34:44 +0100 Subject: [PATCH 20/34] Makefile: tomcat7 statt tomcatmq --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 447a14f..9ddf3ec 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,9 @@ build: cd ~/hsadmin/util && mvn clean install cd ~/hsadmin/qserv && mvn clean install cd ~/hsadmin/hsarback && mvn package -DskipTests - cp ~/hsadmin/qserv/target/hsadmin-*.jar ~/tomcatmq/webapps/hsar/WEB-INF/lib/ - cp ~/hsadmin/util/target/hsadmin-*.jar ~/tomcatmq/webapps/hsar/WEB-INF/lib/ - cp ~/hsadmin/hsarback/target/hsar.war ~/tomcatmq/webapps + cp ~/hsadmin/qserv/target/hsadmin-*.jar ~/tomcat7/webapps/hsar/WEB-INF/lib/ + cp ~/hsadmin/util/target/hsadmin-*.jar ~/tomcat7/webapps/hsar/WEB-INF/lib/ + cp ~/hsadmin/hsarback/target/hsar.war ~/tomcat7/webapps resetdata: -- 2.39.5 From 767f47fe7fb40175ac40dcead455f6dd9f504f2f Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 17 Jan 2024 11:48:05 +0100 Subject: [PATCH 21/34] apache-vhost review --- .../de/hsadmin/mods/dom/apache-vhost.vm | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index bcc9467..f5be01b 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -17,8 +17,12 @@ DocumentRoot /home/doms/${dom.name}/htdocs +#if( ${cgi} ) Alias /cgi-bin/ /home/doms/${dom.name}/cgi/ +#end +#if( ${fastcgi} ) Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/ +#end PassengerEnabled Off @@ -33,6 +37,15 @@ #end #if( ${passengerfriendlyerrorpages} ) PassengerFriendlyErrorPages On +#end +#if( ${passengerpython} ) + PassengerPython ${passengerpython} +#end +#if( ${passengernodejs} ) + PassengerNodejs ${passengernodejs} +#end +#if( ${passengerruby} ) + PassengerRuby ${passengerruby} #end AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv @@ -82,7 +95,10 @@ RewriteRule ^(.*) - [redirect=404,last] #end - AddType application/x-httpd-php .php .php5 .php4 .php3 +#if( ${fcgiphpbin} ) + SetEnv HTTP_PHP_BIN ${fcgiphpbin} +#end + AddType application/x-httpd-php .php Action application/x-httpd-php /fastcgi-bin/phpstub @@ -105,8 +121,12 @@ DocumentRoot /home/doms/${dom.name}/htdocs-ssl +#if( ${cgi} ) Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/ +#end +#if( ${fastcgi} ) Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/ +#end SSLRequireSSL On @@ -124,13 +144,13 @@ PassengerFriendlyErrorPages On #end #if( ${passengerpython} ) - PassengerPython /home/pacs/${pac.name}/users/${dom.user.name}/${passengerpython} + PassengerPython ${passengerpython} #end #if( ${passengernodejs} ) - PassengerNodejs /home/pacs/${pac.name}/users/${dom.user.name}/${passengernodejs} + PassengerNodejs ${passengernodejs} #end #if( ${passengerruby} ) - PassengerRuby /home/pacs/${pac.name}/users/${dom.user.name}/${passengerruby} + PassengerRuby ${passengerruby} #end AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv @@ -182,9 +202,9 @@ #end #if( ${fcgiphpbin} ) - SetEnv HTTP_PHP_BIN ${fcgiphpbin} + SetEnv HTTP_PHP_BIN ${fcgiphpbin} #end - AddType application/x-httpd-php .php .php5 .php4 .php3 + AddType application/x-httpd-php .php Action application/x-httpd-php /fastcgi-bin/phpstub -- 2.39.5 From bf2a2a885ebf7c8919500e64b09584bec5661280 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 17 Jan 2024 12:11:24 +0100 Subject: [PATCH 22/34] provide path variables to vhost template --- .../de/hsadmin/mods/dom/DomainProcessorFactory.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index d8f6357..fdd5b9f 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -267,6 +267,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory { ifOption(templateVars, query, "passengerfriendlyerrorpages", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "cgi", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "fastcgi", Boolean.TRUE, Boolean.FALSE); + setPathInTemplate(templateVars, "passengerpython", "/usr/bin/python3", dom.getPassengerpython()); + setPathInTemplate(templateVars, "passengernodejs", "/usr/bin/node", dom.getPassengernodejs()); + setPathInTemplate(templateVars, "passengerruby", "/usr/bin/ruby", dom.getPassengerruby()); + setPathInTemplate(templateVars, "fcgiphpbin", "/usr/bin/php", dom.getFcgiphpbin()); final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE); final Processor domSetupProcessor = new CompoundProcessor( isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"), @@ -296,6 +300,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory { return domSetupProcessor; } + private void setPathInTemplate(final Map templateVars, final String templateVariable, final String defaultPath, final String actualPath) { + String pathVariable = actualPath; + if (pathVariable == null || pathVariable.isEmpty()) { + pathVariable = defaultPath; + } + templateVars.put(templateVariable, pathVariable); + } + private void ifOption(Map templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) { query.setParameter("option", option); if (query.getResultList().isEmpty()) { -- 2.39.5 From 6e2db93a0fbf93c7e89cb1d6b4d0e85577516b35 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Wed, 17 Jan 2024 19:49:34 +0100 Subject: [PATCH 23/34] apache vhost: PHP: use FcgidInitialEnv and cgi-bin --- .../src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm | 4 ++-- hsarback/src/test/java/de/hsadmin/remote/DomainTest.java | 2 +- .../main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index f5be01b..589d911 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -96,7 +96,7 @@ #end #if( ${fcgiphpbin} ) - SetEnv HTTP_PHP_BIN ${fcgiphpbin} + FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php Action application/x-httpd-php /fastcgi-bin/phpstub @@ -202,7 +202,7 @@ #end #if( ${fcgiphpbin} ) - SetEnv HTTP_PHP_BIN ${fcgiphpbin} + FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php Action application/x-httpd-php /fastcgi-bin/phpstub diff --git a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java index ce2f8eb..82c712f 100644 --- a/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java +++ b/hsarback/src/test/java/de/hsadmin/remote/DomainTest.java @@ -171,7 +171,7 @@ public class DomainTest { setParams.put("passengerruby", newPassengerRuby); String newPassengerNodejs = "/home/pacs/aaa00/users/admin/.nvm/versions/node/v18.19.0/bin/node"; setParams.put("passengernodejs", newPassengerNodejs); - String newFcgiPhpBin = "/usr/bin/php8.1"; + String newFcgiPhpBin = "/usr/lib/cgi-bin/php8.1"; setParams.put("fcgiphpbin", newFcgiPhpBin); String[] newDomainOptions = new String[] {"greylisting", "letsencrypt", "passenger", "passengerfriendlyerrorpages", "cgi", "fastcgi"}; diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index fdd5b9f..101324a 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -270,7 +270,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { setPathInTemplate(templateVars, "passengerpython", "/usr/bin/python3", dom.getPassengerpython()); setPathInTemplate(templateVars, "passengernodejs", "/usr/bin/node", dom.getPassengernodejs()); setPathInTemplate(templateVars, "passengerruby", "/usr/bin/ruby", dom.getPassengerruby()); - setPathInTemplate(templateVars, "fcgiphpbin", "/usr/bin/php", dom.getFcgiphpbin()); + setPathInTemplate(templateVars, "fcgiphpbin", "/usr/lib/cgi-bin/php", dom.getFcgiphpbin()); final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE); final Processor domSetupProcessor = new CompoundProcessor( isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"), -- 2.39.5 From 15ca8d9dd4fbe6df17357a7d6d4160668aa4e0b4 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Wed, 17 Jan 2024 19:59:42 +0100 Subject: [PATCH 24/34] protect phpstub with chattr +i and drop chattr -i for deleting domain --- .../java/de/hsadmin/mods/dom/DomainProcessorFactory.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index 101324a..e561095 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -242,6 +242,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory { domDirsProcessor.appendProcessor( new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755") ); + domDirsProcessor.appendProcessor( + new ShellProcessor("chattr +i " + domainDir + " /fastcgi/phpstub && " + + "chattr +i " + domainDir + " /fastcgi-ssl/phpstub") + ); domDirsProcessor.appendProcessor( new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " + "chown --no-dereference " + userName + ":httpd /home/doms/" + domName @@ -333,6 +337,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && rm -f /etc/apache2/pems-generated/" + domname + ".crt" + " && rm -f /etc/apache2/pems-generated/" + domname + ".key" + " && rm -f /etc/apache2/pems-generated/" + domname + ".chain" + + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/phpstub" + + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/phpstub" + " && mkdir " + homedir + "/doms.bak" + " && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" + " && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" + @@ -349,6 +355,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && rm -f /etc/apache2/pems-generated/" + domname + ".crt" + " && rm -f /etc/apache2/pems-generated/" + domname + ".key" + " && rm -f /etc/apache2/pems-generated/" + domname + ".chain" + + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/phpstub" + + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/phpstub" + " && rm -rf " + homedir + "/doms/" + domname + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); } -- 2.39.5 From 85271e07760e6286a3dad6f56b1420a6548892f5 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 19 Jan 2024 12:02:16 +0100 Subject: [PATCH 25/34] fix path to phpstub --- .../main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index e561095..4181594 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -243,8 +243,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory { new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755") ); domDirsProcessor.appendProcessor( - new ShellProcessor("chattr +i " + domainDir + " /fastcgi/phpstub && " + - "chattr +i " + domainDir + " /fastcgi-ssl/phpstub") + new ShellProcessor("chattr +i " + domainDir + "/fastcgi/phpstub && " + + "chattr +i " + domainDir + "/fastcgi-ssl/phpstub") ); domDirsProcessor.appendProcessor( new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " + -- 2.39.5 From d95ebd4957050223e5df8fd7aa64b04413104cd3 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 22 Jan 2024 13:36:06 +0100 Subject: [PATCH 26/34] db migration: define useful default settings --- hsarback/database/database_update.sql | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index 1510e3b..0cda115 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -1,12 +1,21 @@ ALTER TABLE domain - ADD COLUMN passenger_python character varying(256) NULL, - ADD COLUMN passenger_nodejs character varying(256) NULL, - ADD COLUMN passenger_ruby character varying(256) NULL, - ADD COLUMN fcgi_php_bin character varying(256) NULL; - + ADD COLUMN passenger_python character varying(256) DEFAULT '/usr/bin/python3', + ADD COLUMN passenger_nodejs character varying(256) DEFAULT '/usr/bin/node', + ADD COLUMN passenger_ruby character varying(256) DEFAULT '/usr/bin/ruby', + ADD COLUMN fcgi_php_bin character varying(256) DEFAULT '/usr/lib/cgi-bin/php'; + +UPDATE domain SET fcgi_php_bin = '/usr/lib/cgi-bin/php7.4'; + INSERT INTO domain_option (domain_option_name) VALUES ('passenger'), ('passengerfriendlyerrorpages'), ('cgi'), ('fastcgi'); + +INSERT INTO domain__domain_option ( domain_option_id, domain_id ) + SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='cgi' ), domain_id FROM domain; +INSERT INTO domain__domain_option ( domain_option_id, domain_id ) + SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='fastcgi' ), domain_id FROM domain; +INSERT INTO domain__domain_option ( domain_option_id, domain_id ) + SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='passenger' ), domain_id FROM domain; -- 2.39.5 From b16ba638330042b9f742106fd175b5df8466f43f Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 22 Jan 2024 19:03:14 +0100 Subject: [PATCH 27/34] remove all cgi btw. fastcgi dependencies --- .../resources/de/hsadmin/mods/dom/apache-vhost.vm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 589d911..7930578 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -81,8 +81,12 @@ RewriteEngine On RewriteOptions Inherit +#if( ${cgi} ) RewriteCond %{REQUEST_URI} !^/cgi-bin/ +#end +#if( ${fastcgi} ) RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ +#end RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary] RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last] @@ -95,11 +99,13 @@ RewriteRule ^(.*) - [redirect=404,last] #end +#if( ${fastcgi} ) #if( ${fcgiphpbin} ) FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php Action application/x-httpd-php /fastcgi-bin/phpstub +#end @@ -186,8 +192,12 @@ RewriteEngine On RewriteOptions Inherit +#if( ${cgi} ) RewriteCond %{REQUEST_URI} !^/cgi-bin/ +#end +#if( ${fastcgi} ) RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ +#end RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary] RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last] @@ -200,11 +210,11 @@ RewriteRule ^(.*) - [redirect=404,last] #end - +#if( ${fastcgi} ) #if( ${fcgiphpbin} ) FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php Action application/x-httpd-php /fastcgi-bin/phpstub - +#end -- 2.39.5 From 22a99e98a34abb340d98968c42896e80737b7336 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 25 Jan 2024 18:01:43 +0100 Subject: [PATCH 28/34] use hs-phpstub as phpstub --- hsarback/database/database_update.sql | 4 +--- .../resources/de/hsadmin/mods/dom/apache-vhost.vm | 4 ++-- .../hsadmin/mods/dom/DomainProcessorFactory.java | 15 ++++++--------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index 0cda115..e3398af 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -4,9 +4,7 @@ ALTER TABLE domain ADD COLUMN passenger_nodejs character varying(256) DEFAULT '/usr/bin/node', ADD COLUMN passenger_ruby character varying(256) DEFAULT '/usr/bin/ruby', ADD COLUMN fcgi_php_bin character varying(256) DEFAULT '/usr/lib/cgi-bin/php'; - -UPDATE domain SET fcgi_php_bin = '/usr/lib/cgi-bin/php7.4'; - + INSERT INTO domain_option (domain_option_name) VALUES ('passenger'), ('passengerfriendlyerrorpages'), diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 7930578..748e48a 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -104,7 +104,7 @@ FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php - Action application/x-httpd-php /fastcgi-bin/phpstub + Action application/x-httpd-php /fastcgi-bin/hs-phpstub #end @@ -215,6 +215,6 @@ FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin} #end AddType application/x-httpd-php .php - Action application/x-httpd-php /fastcgi-bin/phpstub + Action application/x-httpd-php /fastcgi-bin/hs-phpstub #end diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index 4181594..4317bdd 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -237,14 +237,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory { new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false) ); domDirsProcessor.appendProcessor( - new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755") + new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi/hs-phpstub", userName, pacName, "755") ); domDirsProcessor.appendProcessor( - new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755") + new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi-ssl/hs-phpstub", userName, pacName, "755") ); domDirsProcessor.appendProcessor( - new ShellProcessor("chattr +i " + domainDir + "/fastcgi/phpstub && " + - "chattr +i " + domainDir + "/fastcgi-ssl/phpstub") + new ShellProcessor("chattr +i " + domainDir + "/fastcgi/hs-phpstub && " + + "chattr +i " + domainDir + "/fastcgi-ssl/hs-phpstub") ); domDirsProcessor.appendProcessor( new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " + @@ -337,12 +337,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && rm -f /etc/apache2/pems-generated/" + domname + ".crt" + " && rm -f /etc/apache2/pems-generated/" + domname + ".key" + " && rm -f /etc/apache2/pems-generated/" + domname + ".chain" + - " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/phpstub" + - " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/phpstub" + " && mkdir " + homedir + "/doms.bak" + " && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" + " && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" + - // " && salt-call state.sls pacs " + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); } return @@ -355,8 +352,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && rm -f /etc/apache2/pems-generated/" + domname + ".crt" + " && rm -f /etc/apache2/pems-generated/" + domname + ".key" + " && rm -f /etc/apache2/pems-generated/" + domname + ".chain" + - " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/phpstub" + - " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/phpstub" + + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/hs-phpstub" + + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/hs-phpstub" + " && rm -rf " + homedir + "/doms/" + domname + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); } -- 2.39.5 From 694b13bb551222da9d0292c4b313ea1b96a0b34e Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 25 Jan 2024 19:39:35 +0100 Subject: [PATCH 29/34] avoid nullpointer in pillarservlet --- .../java/de/hsadmin/servlets/JsonPillarServlet.java | 8 ++++---- qserv/src/main/java/de/hsadmin/mods/dom/Domain.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java index 02f854a..c6a76de 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/JsonPillarServlet.java @@ -152,16 +152,16 @@ public class JsonPillarServlet extends HttpServlet { } writer.println(" }"); writer.println(" , \"validsubdomains\": \"" + validSubdomainNames + "\""); - if (passengerPython.length() > 0) { + if (passengerPython != null && passengerPython.length() > 0) { writer.println(" , \"passengerpython\": \"" + passengerPython + "\""); } - if (passengerNodejs.length() > 0) { + if (passengerNodejs != null && passengerNodejs.length() > 0) { writer.println(" , \"passengernodejs\": \"" + passengerNodejs + "\""); } - if (passengerRuby.length() > 0) { + if (passengerRuby != null && passengerRuby.length() > 0) { writer.println(" , \"passengerruby\": \"" + passengerRuby + "\""); } - if (fcgiPhpBin.length() > 0) { + if (fcgiPhpBin != null && fcgiPhpBin.length() > 0) { writer.println(" , \"fcgiphpbin\": \"" + fcgiPhpBin + "\""); } writer.println(" }"); diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index 20638a9..22bd396 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -208,6 +208,9 @@ public class Domain extends AbstractEntity { } public String getPassengerpython() { + if (passengerpython == null) { + return "/usr/bin/python3"; + } return passengerpython; } @@ -216,6 +219,9 @@ public class Domain extends AbstractEntity { } public String getPassengernodejs() { + if (passengernodejs == null) { + return "/usr/bin/node"; + } return passengernodejs; } @@ -224,6 +230,9 @@ public class Domain extends AbstractEntity { } public String getPassengerruby() { + if (passengerruby == null) { + return "/usr/bin/ruby"; + } return passengerruby; } @@ -232,6 +241,9 @@ public class Domain extends AbstractEntity { } public String getFcgiphpbin() { + if (fcgiphpbin == null) { + return "/usr/lib/cgi-bin/php"; + } return fcgiphpbin; } -- 2.39.5 From 7a16ff9165c898f01e13f2cd253f7676fcb6a50a Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 13 Mar 2024 11:04:52 +0100 Subject: [PATCH 30/34] Option Includes replaces IncludesNoExec --- .../resources/de/hsadmin/mods/dom/apache-vhost.vm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 748e48a..310e14c 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -47,14 +47,14 @@ #if( ${passengerruby} ) PassengerRuby ${passengerruby} #end - AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv + AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv #if( ${cgi} ) PassengerEnabled Off SetHandler cgi-script - Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch + Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch #end @@ -62,7 +62,7 @@ PassengerEnabled Off SetHandler fcgid-script - Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch + Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch #end @@ -158,14 +158,14 @@ #if( ${passengerruby} ) PassengerRuby ${passengerruby} #end - AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv + AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv #if( ${cgi} ) PassengerEnabled Off SetHandler cgi-script - Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch + Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch #end @@ -173,7 +173,7 @@ PassengerEnabled Off SetHandler fcgid-script - Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch + Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch #end -- 2.39.5 From e1db7a784fd5451dc80d84b88226e0d8ff1dc5ab Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 25 Mar 2024 13:54:44 +0100 Subject: [PATCH 31/34] use systemctl instead of invoke-rc.d --- .../de/hsadmin/mods/dom/DomainProcessorFactory.java | 10 +++++----- .../java/de/hsadmin/mods/pac/PacProcessorFactory.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java index 4317bdd..dfe9b84 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -106,7 +106,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm", templateVars, "/etc/bind/named-hsh.conf.tmp", true), new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " + - "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )") + "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )") ); } @@ -173,7 +173,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm", templateVars, "/etc/postgrey/whitelist_recipients.tmp", true), new ShellProcessor(" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) " + - "|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )") + "|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && systemctl restart postgrey.service )") ); } @@ -299,7 +299,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " || (mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName + " && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName + " && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName + - " && invoke-rc.d apache2 reload >/dev/null 2>&1)") + " && systemctl reload apache2.service >/dev/null 2>&1)") ); return domSetupProcessor; } @@ -340,7 +340,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && mkdir " + homedir + "/doms.bak" + " && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" + " && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" + - " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + " && systemctl reload apache2.service >/dev/null 2>&1"); } return new ShellProcessor("rm -f /home/doms/" + domname + @@ -355,7 +355,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/hs-phpstub" + " && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/hs-phpstub" + " && rm -rf " + homedir + "/doms/" + domname + - " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + " && systemctl reload apache2.service >/dev/null 2>&1"); } private Processor createTriggerAcmebotProcessor(final EntityManager em, final Domain dom) { diff --git a/qserv/src/main/java/de/hsadmin/mods/pac/PacProcessorFactory.java b/qserv/src/main/java/de/hsadmin/mods/pac/PacProcessorFactory.java index 40c9900..6ade622 100644 --- a/qserv/src/main/java/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/qserv/src/main/java/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -113,7 +113,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" + " && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" + " && rm -f /etc/bind/pri." + domName + - " && invoke-rc.d bind9 reload"); + " && systemctl reload named.service"); } private Processor createAccountingRulesProc() { @@ -142,13 +142,13 @@ public class PacProcessorFactory implements EntityProcessorFactory { private Processor createLinkSiteProc(final String pacDomain) { return new ShellProcessor("ln -sf /etc/apache2/sites-available/" + pacDomain + " /etc/apache2/sites-enabled/97-" + pacDomain - + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + + " && systemctl reload apache2.service >/dev/null 2>&1"); } private Processor createUnlinkSiteProc(final String pacDomain) { return new ShellProcessor("rm -f /etc/apache2/sites-enabled/97-" + pacDomain + " && rm -f /etc/apache2/sites-available/" + pacDomain + "" - + " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + + " && systemctl reload apache2.service >/dev/null 2>&1"); } private Processor createZonefileProc(final EntityManager em, final Pac pac) { @@ -281,7 +281,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm", templateVars, "/etc/bind/named-hsh.conf.tmp", true), new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " + - "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )") + "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )") ); } -- 2.39.5 From 96c339693474a10faabcc0a48c757399bd4861a4 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 25 Mar 2024 18:52:56 +0100 Subject: [PATCH 32/34] add Option PassengerPreloadBundler to apache vhosts --- hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 310e14c..16ec131 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -32,6 +32,7 @@ #if( ${passenger} ) PassengerEnabled On + PassengerPreloadBundler On #else PassengerEnabled Off #end @@ -143,6 +144,7 @@ #if( ${passenger} ) PassengerEnabled On + PassengerPreloadBundler On #else PassengerEnabled Off #end -- 2.39.5 From 69d9d87c9b443afc50d534bc142c4c8961535a90 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Sat, 6 Apr 2024 14:43:42 +0200 Subject: [PATCH 33/34] available only on bookworm --- .../src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm index 16ec131..964011d 100644 --- a/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm +++ b/hsarback/src/main/resources/de/hsadmin/mods/dom/apache-vhost.vm @@ -32,7 +32,7 @@ #if( ${passenger} ) PassengerEnabled On - PassengerPreloadBundler On + # PassengerPreloadBundler On #else PassengerEnabled Off #end @@ -144,7 +144,7 @@ #if( ${passenger} ) PassengerEnabled On - PassengerPreloadBundler On + # PassengerPreloadBundler On #else PassengerEnabled Off #end -- 2.39.5 From 79c653e910f1ba335b8babd4e0fc9c7a6edb8c29 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 16 Apr 2024 22:13:57 +0200 Subject: [PATCH 34/34] Paths for Passenger Python, Ruby, Node and PHP should also support underscore characters --- qserv/src/main/java/de/hsadmin/mods/dom/Domain.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java index 22bd396..57e6455 100644 --- a/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java +++ b/qserv/src/main/java/de/hsadmin/mods/dom/Domain.java @@ -66,19 +66,19 @@ public class Domain extends AbstractEntity { inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")}) private Set domainoptions; - @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) @Column(name = "passenger_python", columnDefinition = "character varying(256)") private String passengerpython; - @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) @Column(name = "passenger_nodejs", columnDefinition = "character varying(256)") private String passengernodejs; - @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) @Column(name = "passenger_ruby", columnDefinition = "character varying(256)") private String passengerruby; - @AnnFieldIO(validation="[a-zA-Z0-9\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) + @AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE) @Column(name = "fcgi_php_bin", columnDefinition = "character varying(256)") private String fcgiphpbin; -- 2.39.5