>From 46b12812c4eb81b48d9163af16aba4325e083cb3 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Wed, 21 Sep 2016 03:23:02 +0200
Subject: [PATCH] Added subsystem logging.properties for debugging.

A new logging.properties has been added to each subsystem to
define the log handler for troubleshooting PKI issues.

The pki.policy has been modified to allow Tomcat to read the
new subsystem logging.properties files in /usr/share/pki and
to generate debug logs in instance subfolders.

https://fedorahosted.org/pki/ticket/195
---
 .../webapps/ca/WEB-INF/classes/logging.properties  | 32 ++++++++++++++++++++++
 .../webapps/kra/WEB-INF/classes/logging.properties | 32 ++++++++++++++++++++++
 .../ocsp/WEB-INF/classes/logging.properties        | 32 ++++++++++++++++++++++
 base/server/share/conf/pki.policy                  |  2 ++
 .../webapps/tks/WEB-INF/classes/logging.properties | 32 ++++++++++++++++++++++
 .../webapps/tps/WEB-INF/classes/logging.properties | 32 ++++++++++++++++++++++
 6 files changed, 162 insertions(+)
 create mode 100644 base/ca/shared/webapps/ca/WEB-INF/classes/logging.properties
 create mode 100644 base/kra/shared/webapps/kra/WEB-INF/classes/logging.properties
 create mode 100644 base/ocsp/shared/webapps/ocsp/WEB-INF/classes/logging.properties
 create mode 100644 base/tks/shared/webapps/tks/WEB-INF/classes/logging.properties
 create mode 100644 base/tps/shared/webapps/tps/WEB-INF/classes/logging.properties

diff --git a/base/ca/shared/webapps/ca/WEB-INF/classes/logging.properties b/base/ca/shared/webapps/ca/WEB-INF/classes/logging.properties
new file mode 100644
index 0000000000000000000000000000000000000000..4bac0dd780b45574deff04da7cfe906108e72493
--- /dev/null
+++ b/base/ca/shared/webapps/ca/WEB-INF/classes/logging.properties
@@ -0,0 +1,32 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+# Modifications: configuration parameters
+# --- END COPYRIGHT BLOCK ---
+
+# 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.
+
+
+handlers = 1debug.java.util.logging.FileHandler
+
+1debug.java.util.logging.FileHandler.level = ALL
+1debug.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/ca/debug
+1debug.java.util.logging.FileHandler.limit = 10000000
+1debug.java.util.logging.FileHandler.append = true
+1debug.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format = %1$tF %1$tT %5$s%6$s%n
+
+.handlers = 1debug.java.util.logging.FileHandler, java.util.logging.ConsoleHandler
diff --git a/base/kra/shared/webapps/kra/WEB-INF/classes/logging.properties b/base/kra/shared/webapps/kra/WEB-INF/classes/logging.properties
new file mode 100644
index 0000000000000000000000000000000000000000..902ddb6dd727c294f8763aae17217998dc2f7ec0
--- /dev/null
+++ b/base/kra/shared/webapps/kra/WEB-INF/classes/logging.properties
@@ -0,0 +1,32 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+# Modifications: configuration parameters
+# --- END COPYRIGHT BLOCK ---
+
+# 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.
+
+
+handlers = 1debug.java.util.logging.FileHandler
+
+1debug.java.util.logging.FileHandler.level = ALL
+1debug.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/kra/debug
+1debug.java.util.logging.FileHandler.limit = 10000000
+1debug.java.util.logging.FileHandler.append = true
+1debug.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format = %1$tF %1$tT %5$s%6$s%n
+
+.handlers = 1debug.java.util.logging.FileHandler, java.util.logging.ConsoleHandler
diff --git a/base/ocsp/shared/webapps/ocsp/WEB-INF/classes/logging.properties b/base/ocsp/shared/webapps/ocsp/WEB-INF/classes/logging.properties
new file mode 100644
index 0000000000000000000000000000000000000000..a9da4dc8d7242aa61612e022e766cc36b2aed374
--- /dev/null
+++ b/base/ocsp/shared/webapps/ocsp/WEB-INF/classes/logging.properties
@@ -0,0 +1,32 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+# Modifications: configuration parameters
+# --- END COPYRIGHT BLOCK ---
+
+# 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.
+
+
+handlers = 1debug.java.util.logging.FileHandler
+
+1debug.java.util.logging.FileHandler.level = ALL
+1debug.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/ocsp/debug
+1debug.java.util.logging.FileHandler.limit = 10000000
+1debug.java.util.logging.FileHandler.append = true
+1debug.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format = %1$tF %1$tT %5$s%6$s%n
+
+.handlers = 1debug.java.util.logging.FileHandler, java.util.logging.ConsoleHandler
diff --git a/base/server/share/conf/pki.policy b/base/server/share/conf/pki.policy
index 7d8cfec4591ec3ee28ade876253f4f593e086e67..993118b2e33d4b392523d541ab8a56f830efcff3 100644
--- a/base/server/share/conf/pki.policy
+++ b/base/server/share/conf/pki.policy
@@ -12,6 +12,8 @@
 
 grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" {
         permission java.lang.RuntimePermission "accessClassInPackage.sun.util.logging.resources";
+        permission java.io.FilePermission "${catalina.base}/logs/-", "read, write";
+        permission java.io.FilePermission "/usr/share/pki/-", "read";
 };
 
 grant codeBase "file:${catalina.base}/bin/bootstrap.jar" {
diff --git a/base/tks/shared/webapps/tks/WEB-INF/classes/logging.properties b/base/tks/shared/webapps/tks/WEB-INF/classes/logging.properties
new file mode 100644
index 0000000000000000000000000000000000000000..3a83c878d24b8c97d08627597719b11aa84a8b39
--- /dev/null
+++ b/base/tks/shared/webapps/tks/WEB-INF/classes/logging.properties
@@ -0,0 +1,32 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+# Modifications: configuration parameters
+# --- END COPYRIGHT BLOCK ---
+
+# 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.
+
+
+handlers = 1debug.java.util.logging.FileHandler
+
+1debug.java.util.logging.FileHandler.level = ALL
+1debug.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/tks/debug
+1debug.java.util.logging.FileHandler.limit = 10000000
+1debug.java.util.logging.FileHandler.append = true
+1debug.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format = %1$tF %1$tT %5$s%6$s%n
+
+.handlers = 1debug.java.util.logging.FileHandler, java.util.logging.ConsoleHandler
diff --git a/base/tps/shared/webapps/tps/WEB-INF/classes/logging.properties b/base/tps/shared/webapps/tps/WEB-INF/classes/logging.properties
new file mode 100644
index 0000000000000000000000000000000000000000..36c5d445c29415ccec294a15c85b63dbdf65b326
--- /dev/null
+++ b/base/tps/shared/webapps/tps/WEB-INF/classes/logging.properties
@@ -0,0 +1,32 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2016 Red Hat, Inc.
+# All rights reserved.
+# Modifications: configuration parameters
+# --- END COPYRIGHT BLOCK ---
+
+# 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.
+
+
+handlers = 1debug.java.util.logging.FileHandler
+
+1debug.java.util.logging.FileHandler.level = ALL
+1debug.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/tps/debug
+1debug.java.util.logging.FileHandler.limit = 10000000
+1debug.java.util.logging.FileHandler.append = true
+1debug.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format = %1$tF %1$tT %5$s%6$s%n
+
+.handlers = 1debug.java.util.logging.FileHandler, java.util.logging.ConsoleHandler
-- 
2.5.5

