>From 74873bf8acc400a50455740278830b0846036b60 Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Thu, 23 Apr 2015 13:47:24 -0400
Subject: [PATCH] Remove duplicate prompt on nuxwdog startup

---
 base/ca/shared/conf/CS.cfg.in                 |  2 +-
 base/kra/shared/conf/CS.cfg.in                |  2 +-
 base/ocsp/shared/conf/CS.cfg.in               |  2 +-
 base/server/upgrade/10.2.3/02-FixBindPWPrompt | 49 +++++++++++++++++++++++++++
 base/tks/shared/conf/CS.cfg.in                |  2 +-
 base/tps/shared/conf/CS.cfg.in                |  2 +-
 6 files changed, 54 insertions(+), 5 deletions(-)
 create mode 100755 base/server/upgrade/10.2.3/02-FixBindPWPrompt

diff --git a/base/ca/shared/conf/CS.cfg.in b/base/ca/shared/conf/CS.cfg.in
index 8353edee13c4d008e8303b2f6e5c086422b9442a..3d2dd5e436fa30515e8ececf6283fbd676b27d79 100644
--- a/base/ca/shared/conf/CS.cfg.in
+++ b/base/ca/shared/conf/CS.cfg.in
@@ -816,7 +816,7 @@ internaldb.maxConns=15
 internaldb.minConns=3
 internaldb.ldapauth.authtype=BasicAuth
 internaldb.ldapauth.bindDN=cn=Directory Manager
-internaldb.ldapauth.bindPWPrompt=Internal LDAP Database
+internaldb.ldapauth.bindPWPrompt=internaldb
 internaldb.ldapauth.clientCertNickname=
 internaldb.ldapconn.host=
 internaldb.ldapconn.port=
diff --git a/base/kra/shared/conf/CS.cfg.in b/base/kra/shared/conf/CS.cfg.in
index da719553006d81b18de548899d50e3b4a745e3d1..7ecacf64dacae14ea86ec7b32328b555e2c27aeb 100644
--- a/base/kra/shared/conf/CS.cfg.in
+++ b/base/kra/shared/conf/CS.cfg.in
@@ -224,7 +224,7 @@ internaldb.maxConns=15
 internaldb.minConns=3
 internaldb.ldapauth.authtype=BasicAuth
 internaldb.ldapauth.bindDN=cn=Directory Manager
-internaldb.ldapauth.bindPWPrompt=Internal LDAP Database
+internaldb.ldapauth.bindPWPrompt=internaldb
 internaldb.ldapauth.clientCertNickname=
 internaldb.ldapconn.host=
 internaldb.ldapconn.port=
diff --git a/base/ocsp/shared/conf/CS.cfg.in b/base/ocsp/shared/conf/CS.cfg.in
index cfc9ec24bd395294c33c8c51119b0af7755d257d..9c878e89e8757d8c3be8e3040d54c8c4eb0bf7a7 100644
--- a/base/ocsp/shared/conf/CS.cfg.in
+++ b/base/ocsp/shared/conf/CS.cfg.in
@@ -183,7 +183,7 @@ internaldb.maxConns=15
 internaldb.minConns=3
 internaldb.ldapauth.authtype=BasicAuth
 internaldb.ldapauth.bindDN=cn=Directory Manager
-internaldb.ldapauth.bindPWPrompt=Internal LDAP Database
+internaldb.ldapauth.bindPWPrompt=internaldb
 internaldb.ldapauth.clientCertNickname=
 internaldb.ldapconn.host=
 internaldb.ldapconn.port=
diff --git a/base/server/upgrade/10.2.3/02-FixBindPWPrompt b/base/server/upgrade/10.2.3/02-FixBindPWPrompt
new file mode 100755
index 0000000000000000000000000000000000000000..7b99afd6f3ca0d40fcb656b8a9ea0cc47e365c61
--- /dev/null
+++ b/base/server/upgrade/10.2.3/02-FixBindPWPrompt
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# Authors:
+#     Ade Lee <alee@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 fileinput
+import os
+import re
+import sys
+import pki.server.upgrade
+
+
+class FixBindPWPrompt(pki.server.upgrade.PKIServerUpgradeScriptlet):
+
+    def __init__(self):
+        self.message = 'Fix bindPWPrompt for internalDB'
+
+    def upgrade_subsystem(self, instance, subsystem):
+
+        cs_cfg = os.path.join(
+            instance.base_dir,
+            'conf',
+            subsystem.name,
+            'CS.cfg')
+
+        self.backup(cs_cfg)
+
+        for line in fileinput.input(cs_cfg, inplace=1):
+            line = re.sub(r"^internaldb.ldapauth.bindPWPrompt=.*",
+                          "internaldb.ldapauth.bindPWPrompt=internaldb",
+                          line)
+            sys.stdout.write(line)
+
diff --git a/base/tks/shared/conf/CS.cfg.in b/base/tks/shared/conf/CS.cfg.in
index 8579ef21b9d2653569b973e4667356340feaa024..f864e298a68653f58a09dacb5a2cdfe21029aa8d 100644
--- a/base/tks/shared/conf/CS.cfg.in
+++ b/base/tks/shared/conf/CS.cfg.in
@@ -175,7 +175,7 @@ internaldb.maxConns=15
 internaldb.minConns=3
 internaldb.ldapauth.authtype=BasicAuth
 internaldb.ldapauth.bindDN=cn=Directory Manager
-internaldb.ldapauth.bindPWPrompt=Internal LDAP Database
+internaldb.ldapauth.bindPWPrompt=internaldb
 internaldb.ldapauth.clientCertNickname=
 internaldb.ldapconn.host=
 internaldb.ldapconn.port=
diff --git a/base/tps/shared/conf/CS.cfg.in b/base/tps/shared/conf/CS.cfg.in
index e4733f815a66f5303ba8e8a558c8fa584b8bc5ea..4fa477dbc731db0da46df29d88563ea26d5aadae 100644
--- a/base/tps/shared/conf/CS.cfg.in
+++ b/base/tps/shared/conf/CS.cfg.in
@@ -164,7 +164,7 @@ internaldb._001=## Internal Database
 internaldb._002=##
 internaldb.ldapauth.authtype=BasicAuth
 internaldb.ldapauth.bindDN=cn=Directory Manager
-internaldb.ldapauth.bindPWPrompt=Internal LDAP Database
+internaldb.ldapauth.bindPWPrompt=internaldb
 internaldb.ldapauth.clientCertNickname=
 internaldb.ldapconn.host=
 internaldb.ldapconn.port=
-- 
1.9.3

