summaryrefslogtreecommitdiffstats
path: root/base/server/upgrade/10.2.3
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-04-08 16:28:29 -0400
committerEndi S. Dewata <edewata@redhat.com>2015-04-08 18:33:07 -0400
commit33bd7720dc151fd23d36f15888411ded6b1b7c08 (patch)
treec6a1b627ddb6f9d1c9144d2cdf5178a97abe733d /base/server/upgrade/10.2.3
parent38dcd9f5797d64f38139aa42c76038b158edc48e (diff)
downloadpki-33bd7720dc151fd23d36f15888411ded6b1b7c08.tar.gz
pki-33bd7720dc151fd23d36f15888411ded6b1b7c08.tar.xz
pki-33bd7720dc151fd23d36f15888411ded6b1b7c08.zip
Added upgrade script to fix instance work folder ownership.
The <instance>/work/Catalina/localhost/pki folder was owned by root in Dogtag 10.0.x but now should be owned by pkiuser. An upgrade script has been added to fix the ownership. https://fedorahosted.org/pki/ticket/802
Diffstat (limited to 'base/server/upgrade/10.2.3')
-rwxr-xr-xbase/server/upgrade/10.2.3/01-FixInstanceWorkFolderOwnership57
1 files changed, 57 insertions, 0 deletions
diff --git a/base/server/upgrade/10.2.3/01-FixInstanceWorkFolderOwnership b/base/server/upgrade/10.2.3/01-FixInstanceWorkFolderOwnership
new file mode 100755
index 000000000..6872a165a
--- /dev/null
+++ b/base/server/upgrade/10.2.3/01-FixInstanceWorkFolderOwnership
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# Authors:
+# Endi S. Dewata <edewata@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+
+import grp
+import os
+import pwd
+import re
+import pki.server.upgrade
+
+
+class FixInstanceWorkFolderOwnership(pki.server.upgrade.PKIServerUpgradeScriptlet):
+
+ def __init__(self):
+ self.message = 'Fix instance work folder ownership'
+
+ def upgrade_instance(self, instance):
+ registry_file = os.path.join(
+ pki.server.REGISTRY_DIR, 'tomcat', instance.name, instance.name)
+
+ with open(registry_file, "r") as registry:
+ lines = registry.readlines()
+
+ user = None
+ group = None
+
+ for line in lines:
+ m = re.search('^PKI_USER=(.*)$', line)
+ if m:
+ user = m.group(1)
+ m = re.search('^PKI_GROUP=(.*)$', line)
+ if m:
+ group = m.group(1)
+
+ uid = pwd.getpwnam(user).pw_uid
+ gid = grp.getgrnam(group).gr_gid
+
+ dir = os.path.join(instance.base_dir, 'work/Catalina/localhost/pki')
+
+ pki.util.chown(dir, uid, gid)