From b4419a21d77a4b789bbcff8b255443da48e4a057 Mon Sep 17 00:00:00 2001 From: tcrivat Date: Sat, 16 Jul 2016 13:26:15 +0200 Subject: [PATCH] java: updated to work on a Debian 8 image - updated the configuration files to be compatible with Debian 8 - updated the Tomcat version in the add service page - updated the agent startup script to force java to user ipv4 --- conpaas-frontend/www/addservice.php | 2 +- conpaas-services/config/agent/web-agent.cfg | 4 +- .../scripts/agent/web-agent-start | 3 + .../services/webservers/agent/internals.py | 12 +-- .../conpaas/services/webservers/agent/role.py | 22 ++--- .../webservers/etc/tomcat-catalina.policy | 95 ++++++++++++++++--- .../webservers/etc/tomcat-server-xml.tmpl | 18 ++-- 7 files changed, 116 insertions(+), 40 deletions(-) diff --git a/conpaas-frontend/www/addservice.php b/conpaas-frontend/www/addservice.php index 16f4df79..0b1e64a0 100644 --- a/conpaas-frontend/www/addservice.php +++ b/conpaas-frontend/www/addservice.php @@ -41,7 +41,7 @@ java - Apache Tomcat 6.0 servlet container + Apache Tomcat 7.0 servlet container diff --git a/conpaas-services/config/agent/web-agent.cfg b/conpaas-services/config/agent/web-agent.cfg index a5b2040a..7aa81b9a 100644 --- a/conpaas-services/config/agent/web-agent.cfg +++ b/conpaas-services/config/agent/web-agent.cfg @@ -10,5 +10,5 @@ SCALARIS_CTL = /usr/bin/scalarisctl SCALARIS_HOME = /root [tomcat] -TOMCAT_INSTANCE_CREATE = /usr/bin/tomcat6-instance-create -TOMCAT_STARTUP = /usr/share/tomcat6/bin/startup.sh +TOMCAT_INSTANCE_CREATE = /usr/bin/tomcat7-instance-create +TOMCAT_STARTUP = /usr/share/tomcat7/bin/startup.sh diff --git a/conpaas-services/scripts/agent/web-agent-start b/conpaas-services/scripts/agent/web-agent-start index 7a62c424..66b8d29a 100755 --- a/conpaas-services/scripts/agent/web-agent-start +++ b/conpaas-services/scripts/agent/web-agent-start @@ -5,6 +5,9 @@ cp $CPS_HOME/src/conpaas/services/webservers/etc/* $ETC/ mkdir $VAR_CACHE/www cp $CPS_HOME/src/conpaas/services/webservers/agent/session/* $VAR_CACHE/www/ 2> /tmp/error +# Make sure that java will choose ipv4 over ipv6 +export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true" + $CPS_HOME/sbin/agent/web-cpsagent -c $ROOT_DIR/config.cfg 1>$ROOT_DIR/agent.out 2>$ROOT_DIR/agent.err & agent_pid=$! echo $agent_pid > $ROOT_DIR/agent.pid diff --git a/conpaas-services/src/conpaas/services/webservers/agent/internals.py b/conpaas-services/src/conpaas/services/webservers/agent/internals.py index 2e3593df..274d8a20 100755 --- a/conpaas-services/src/conpaas/services/webservers/agent/internals.py +++ b/conpaas-services/src/conpaas/services/webservers/agent/internals.py @@ -380,7 +380,7 @@ def updatePHPCode(self, kwargs): @expose('GET') def getTomcatState(self, kwargs): - """GET state of Tomcat6""" + """GET state of Tomcat""" try: exp_params = [] check_arguments(exp_params, kwargs) @@ -388,11 +388,11 @@ def getTomcatState(self, kwargs): return HttpErrorResponse("%s" % ex) with self.tomcat_lock: - return self._get(kwargs, self.tomcat_file, role.Tomcat6) + return self._get(kwargs, self.tomcat_file, role.Tomcat) @expose('POST') def createTomcat(self, kwargs): - """Create Tomcat6""" + """Create Tomcat""" orig_kwargs = copy.copy(kwargs) exp_params = [('tomcat_port', is_pos_int)] try: @@ -401,11 +401,11 @@ def createTomcat(self, kwargs): return HttpErrorResponse("%s" % ex) with self.tomcat_lock: - return self._create(orig_kwargs, self.tomcat_file, role.Tomcat6) + return self._create(orig_kwargs, self.tomcat_file, role.Tomcat) @expose('POST') def stopTomcat(self, kwargs): - """KILL Tomcat6""" + """KILL Tomcat""" try: exp_params = [] check_arguments(exp_params, kwargs) @@ -413,7 +413,7 @@ def stopTomcat(self, kwargs): return HttpErrorResponse("%s" % ex) with self.tomcat_lock: - return self._stop(kwargs, self.tomcat_file, role.Tomcat6) + return self._stop(kwargs, self.tomcat_file, role.Tomcat) @expose('UPLOAD') def updateTomcatCode(self, kwargs): diff --git a/conpaas-services/src/conpaas/services/webservers/agent/role.py b/conpaas-services/src/conpaas/services/webservers/agent/role.py index 8d0e117d..dfa3ac06 100755 --- a/conpaas-services/src/conpaas/services/webservers/agent/role.py +++ b/conpaas-services/src/conpaas/services/webservers/agent/role.py @@ -243,7 +243,7 @@ def status(self): } -class Tomcat6: +class Tomcat: def __init__(self, tomcat_port=None): self.config_template = join(ETC, 'tomcat-server-xml.tmpl') @@ -474,14 +474,14 @@ def start(self, first_node, known_hosts): def stop(self): - # stopping Scalaris - scalaris_args = [ SCALARIS_CTL, 'stop' ] - logger.info('cmd ' + ' '.join(scalaris_args)) - devnull_fd = open(devnull, 'w') - proc = Popen(scalaris_args, stdout=devnull_fd, stderr=devnull_fd, close_fds=True, - env=dict(environ, HOME=SCALARIS_HOME)) + # stopping Scalaris + scalaris_args = [ SCALARIS_CTL, 'stop' ] + logger.info('cmd ' + ' '.join(scalaris_args)) + devnull_fd = open(devnull, 'w') + proc = Popen(scalaris_args, stdout=devnull_fd, stderr=devnull_fd, close_fds=True, + env=dict(environ, HOME=SCALARIS_HOME)) - if proc.wait() != 0: - logger.critical('Failed to stop Scalaris') - else: - logger.info('Scalaris stopped') + if proc.wait() != 0: + logger.critical('Failed to stop Scalaris') + else: + logger.info('Scalaris stopped') diff --git a/conpaas-services/src/conpaas/services/webservers/etc/tomcat-catalina.policy b/conpaas-services/src/conpaas/services/webservers/etc/tomcat-catalina.policy index 4722ff1f..f2776a7c 100755 --- a/conpaas-services/src/conpaas/services/webservers/etc/tomcat-catalina.policy +++ b/conpaas-services/src/conpaas/services/webservers/etc/tomcat-catalina.policy @@ -1,14 +1,28 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // ============================================================================ -// catalina.policy - Security Policy Permissions for Tomcat 6 +// catalina.policy - Security Policy Permissions for Tomcat 7 // // This file contains a default set of security policies to be enforced (by the // JVM) when Catalina is executed with the "-security" option. In addition // to the permissions granted here, the following additional permissions are -// granted to the codebase specific to each web application: -// -// * Read access to its document root directory -// * Read, write and delete access to its working directory +// granted to each web application: // +// * Read access to the web application's document root directory +// * Read, write and delete access to the web application's working directory // ============================================================================ @@ -39,13 +53,19 @@ grant codeBase "file:${java.home}/lib/ext/-" { // ========== CATALINA CODE PERMISSIONS ======================================= + +// These permissions apply to the daemon code +grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { + permission java.security.AllPermission; +}; + // These permissions apply to the logging API // Note: If tomcat-juli.jar is in ${catalina.base} and not in ${catalina.home}, // update this section accordingly. // grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {..} grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { permission java.io.FilePermission - "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; + "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; permission java.io.FilePermission "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; @@ -62,12 +82,14 @@ grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { permission java.util.PropertyPermission "java.util.logging.config.class", "read"; permission java.util.PropertyPermission "java.util.logging.config.file", "read"; + permission java.util.PropertyPermission "org.apache.juli.ClassLoaderLogManager.debug", "read"; permission java.util.PropertyPermission "catalina.base", "read"; // Note: To enable per context logging configuration, permit read access to // the appropriate file. Be sure that the logging configuration is // secure before enabling such access. - // E.g. for the examples web application: + // E.g. for the examples web application (uncomment and unwrap + // the following to be on a single line): // permission java.io.FilePermission "${catalina.base}${file.separator} // webapps${file.separator}examples${file.separator}WEB-INF // ${file.separator}classes${file.separator}logging.properties", "read"; @@ -78,21 +100,23 @@ grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { permission java.security.AllPermission; }; -grant codebase "file:/usr/share/tomcat6/lib/-" { +grant codeBase "file:/usr/share/tomcat7/lib/-" { permission java.security.AllPermission; }; -grant codebase "file:/usr/share/java/-" { + +grant codeBase "file:/usr/share/java/-" { permission java.security.AllPermission; }; + // ========== WEB APPLICATION PERMISSIONS ===================================== // These permissions are granted by default to all web applications // In addition, a web application will be given a read FilePermission // and JndiPermission for all files and directories in its document root. -grant { +grant { // Required for JNDI lookup of named JDBC DataSource's and // javamail named MimePart DataSource used to send mail permission java.util.PropertyPermission "java.home", "read"; @@ -129,15 +153,60 @@ grant { // Allow read of JAXP compliant XML parser debug permission java.util.PropertyPermission "jaxp.debug", "read"; + // All JSPs need to be able to read this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; + // Precompiled JSPs need access to these packages. permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime.*"; + permission java.lang.RuntimePermission + "accessClassInPackage.org.apache.jasper.runtime.*"; permission java.lang.RuntimePermission "accessClassInPackage.sun.security.util"; permission java.lang.RuntimePermission "accessClassInPackage.sun.security.util.*"; - + // Precompiled JSPs need access to these system properties. permission java.util.PropertyPermission "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read"; - permission java.util.PropertyPermission "org.apache.el.parser.COERCE_TO_ZERO", "read"; + permission java.util.PropertyPermission + "org.apache.el.parser.COERCE_TO_ZERO", "read"; + + // The cookie code needs these. + permission java.util.PropertyPermission + "org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR", "read"; + + // Applications using Comet need to be able to access this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet"; + + // Applications using the legacy WebSocket implementation need to be able to access this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.websocket"; + + // Applications using the JSR-356 WebSocket implementation need to be able to access these packages + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket.server"; +}; + + +// The Manager application needs access to the following packages to support the +// session display functionality. These settings support the following +// configurations: +// - default CATALINA_HOME == CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME +grant codeBase "file:${catalina.base}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; +grant codeBase "file:${catalina.home}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; }; diff --git a/conpaas-services/src/conpaas/services/webservers/etc/tomcat-server-xml.tmpl b/conpaas-services/src/conpaas/services/webservers/etc/tomcat-server-xml.tmpl index f914bc75..99470a2f 100755 --- a/conpaas-services/src/conpaas/services/webservers/etc/tomcat-server-xml.tmpl +++ b/conpaas-services/src/conpaas/services/webservers/etc/tomcat-server-xml.tmpl @@ -3,8 +3,8 @@ - + - - + + + + unpackWARs="true" autoDeploy="true"> +