URL: https://github.com/freeipa/freeipa/pull/780
Author: flo-renaud
 Title: #780: server-del: update defaultServerList in 
cn=default,ou=profile,$BASE
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/780/head:pr780
git checkout pr780
From 1871c142ec01dd5ef8f04f93af127f82f6241998 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <f...@redhat.com>
Date: Thu, 11 May 2017 11:41:23 +0200
Subject: [PATCH] server-del: update defaultServerList in
 cn=default,ou=profile,$BASE

ipa server-del should remove the server from the entry
cn=default,ou=profile,$BASE
The entry contains an attribute
defaultServerList: srv1.domain.com srv2.domain.com srv3.domain.com

The code calls srvlist = ret.single_value.get('defaultServerList') which means
that srvlist contains a single value (string) containing all the servers
separated by a space, and not a list of attribute values. Because of that,
srvlist[0] corresponds to the first character of the value.
The fix splits srvlist and not srvlist[0].

https://pagure.io/freeipa/issue/6943
---
 ipaserver/plugins/server.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ipaserver/plugins/server.py b/ipaserver/plugins/server.py
index b1ee472284..7aea619b34 100644
--- a/ipaserver/plugins/server.py
+++ b/ipaserver/plugins/server.py
@@ -608,14 +608,14 @@ def _remove_server_principal_references(self, master):
             dn = DN(('cn', 'default'), ('ou', 'profile'), env.basedn)
             ret = conn.get_entry(dn)
             srvlist = ret.single_value.get('defaultServerList', '')
-            srvlist = srvlist[0].split()
+            srvlist = srvlist.split()
             if master in srvlist:
                 srvlist.remove(master)
                 attr = ' '.join(srvlist)
-                mod = [(ldap.MOD_REPLACE, 'defaultServerList', attr)]
-                conn.conn.modify_s(str(dn), mod)
-        except (errors.NotFound, ldap.NO_SUCH_ATTRIBUTE,
-                ldap.TYPE_OR_VALUE_EXISTS):
+                ret['defaultServerList'] = attr
+                conn.update_entry(ret)
+        except (errors.NotFound, errors.MidairCollision,
+                errors.EmptyModlist):
             pass
         except Exception as e:
             self.add_message(
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to