Blame SOURCES/0019-Issue-51144-dsctl-fails-with-instance-names-that-con.patch

d69b2b
From 2844d4ad90cbbd23ae75309e50ae4d7145586bb7 Mon Sep 17 00:00:00 2001
d69b2b
From: Mark Reynolds <mreynolds@redhat.com>
d69b2b
Date: Wed, 10 Jun 2020 14:07:24 -0400
d69b2b
Subject: [PATCH] Issue 51144 - dsctl fails with instance names that contain
d69b2b
 slapd-
d69b2b
d69b2b
Bug Description:  If an instance name contains 'slapd-' the CLI breaks:
d69b2b
d69b2b
                      slapd-test-slapd
d69b2b
d69b2b
Fix Description:  Only strip off "slapd-" from the front of the instance
d69b2b
                  name.
d69b2b
d69b2b
relates: https://pagure.io/389-ds-base/issue/51144
d69b2b
d69b2b
Reviewed by: firstyear(Thanks!)
d69b2b
---
d69b2b
 src/lib389/lib389/__init__.py | 2 +-
d69b2b
 src/lib389/lib389/dseldif.py  | 3 ++-
d69b2b
 2 files changed, 3 insertions(+), 2 deletions(-)
d69b2b
d69b2b
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
d69b2b
index 0ff1ab173..63d44b60a 100644
d69b2b
--- a/src/lib389/lib389/__init__.py
d69b2b
+++ b/src/lib389/lib389/__init__.py
d69b2b
@@ -710,7 +710,7 @@ class DirSrv(SimpleLDAPObject, object):
d69b2b
         # Don't need a default value now since it's set in init.
d69b2b
         if serverid is None and hasattr(self, 'serverid'):
d69b2b
             serverid = self.serverid
d69b2b
-        elif serverid is not None:
d69b2b
+        elif serverid is not None and serverid.startswith('slapd-'):
d69b2b
             serverid = serverid.replace('slapd-', '', 1)
d69b2b
 
d69b2b
         if self.serverid is None:
d69b2b
diff --git a/src/lib389/lib389/dseldif.py b/src/lib389/lib389/dseldif.py
d69b2b
index 96c9af9d1..f2725add9 100644
d69b2b
--- a/src/lib389/lib389/dseldif.py
d69b2b
+++ b/src/lib389/lib389/dseldif.py
d69b2b
@@ -40,7 +40,8 @@ class DSEldif(DSLint):
d69b2b
         if serverid:
d69b2b
             # Get the dse.ldif from the instance name
d69b2b
             prefix = os.environ.get('PREFIX', ""),
d69b2b
-            serverid = serverid.replace("slapd-", "")
d69b2b
+            if serverid.startswith("slapd-"):
d69b2b
+                serverid = serverid.replace("slapd-", "", 1)
d69b2b
             self.path = "{}/etc/dirsrv/slapd-{}/dse.ldif".format(prefix[0], serverid)
d69b2b
         else:
d69b2b
             ds_paths = Paths(self._instance.serverid, self._instance)
d69b2b
-- 
d69b2b
2.26.2
d69b2b