zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

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

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