Skip to content

Commit

Permalink
java: updated to work on a Debian 8 image
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
tcrivat committed Jul 16, 2016
1 parent 3dd5b31 commit b4419a2
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 40 deletions.
2 changes: 1 addition & 1 deletion conpaas-frontend/www/addservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<tr class="service">
<td class="description"> <img src="images/java.png" height="32" /></td>
<td class="radio"><input type="radio" name="type" value="java" /> java</td>
<td class="info"> Apache Tomcat 6.0 servlet container </td>
<td class="info"> Apache Tomcat 7.0 servlet container </td>
</tr>
</table>
<table class="form" cellspacing="0" cellpading="0">
Expand Down
4 changes: 2 additions & 2 deletions conpaas-services/config/agent/web-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions conpaas-services/scripts/agent/web-agent-start
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,19 @@ 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)
except Exception as ex:
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:
Expand All @@ -401,19 +401,19 @@ 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)
except Exception as ex:
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):
Expand Down
22 changes: 11 additions & 11 deletions conpaas-services/src/conpaas/services/webservers/agent/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Original file line number Diff line number Diff line change
@@ -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
// ============================================================================


Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
Expand All @@ -13,15 +13,19 @@
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="$port" protocol="HTTP/1.1"
connectionTimeout="20000"
<Connector port="$port" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
</Engine>
</Service>
Expand Down

0 comments on commit b4419a2

Please sign in to comment.