[Freeipa-devel] [PATCH] 0037 make-lint fails on Fedora 16/Rawhide

Alexander Bokovoy abokovoy at redhat.com
Mon Nov 28 12:28:52 UTC 2011


Hi,

Attached are fixes for ldap.LDAPObject.add_s(self, dn, modlist) uses
which now don't pass 'make-lint' on Fedora 16/Rawhide.

-- 
/ Alexander Bokovoy
-------------- next part --------------
>From dd866262c98be779a094a617975145e2fb1e0dd1 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <abokovoy at redhat.com>
Date: Mon, 28 Nov 2011 14:21:17 +0200
Subject: [PATCH] Be more explicit when passing Entry class to
 ldap.LDAPObject.add_s()

ldap.LDAPObject.add_s(self, dn, modlist) requires two positional arguments.
We used to pass our Entry class which implements dictionary access that gives
proper way to pass the positional arguments, but PyLint in Fedora 16/Rawhide
became more strict about that and can't infer dictionary interface through
static checking.

Thus, we need to explicitly annotate dictionary passing with **entry syntax.
This has additional benefit to remind that we deal with multiple arguments here.
---
 ipaserver/install/adtrustinstance.py |    6 +++---
 ipaserver/install/krbinstance.py     |    4 ++--
 ipaserver/install/replication.py     |   14 +++++++-------
 ipaserver/install/service.py         |    2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 96f99dc9b76370c07b727e8e94ccabfe7afca074..2f6d75bb2921eca455e49cc970ddc68e21e1ce55 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -99,7 +99,7 @@ class ADTRUSTInstance(service.Service):
         entry.setValues("objectclass", ["account", "simplesecurityobject"])
         entry.setValues("uid", "samba")
         entry.setValues("userPassword", self.smb_dn_pwd)
-        self.admin_conn.add_s(entry)
+        self.admin_conn.add_s(**entry)
 
         # And finally grant it permission to read NT passwords, we do not want
         # to support LM passwords so there is no need to allow access to them.
@@ -188,7 +188,7 @@ class ADTRUSTInstance(service.Service):
             entry = ipaldap.Entry(self.trust_dn)
             entry.setValues("objectclass", ["nsContainer"])
             entry.setValues("cn", "trusts")
-            self.admin_conn.add_s(entry)
+            self.admin_conn.add_s(**entry)
 
         entry = ipaldap.Entry(self.smb_dom_dn)
         entry.setValues("objectclass", ["sambaDomain", "nsContainer"])
@@ -196,7 +196,7 @@ class ADTRUSTInstance(service.Service):
         entry.setValues("sambaDomainName", self.netbios_name)
         entry.setValues("sambaSID", self.__gen_sid_string())
         #TODO: which MAY attributes do we want to set ?
-        self.admin_conn.add_s(entry)
+        self.admin_conn.add_s(**entry)
 
     def __write_smb_conf(self):
         self.fstore.backup_file(self.smb_conf)
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 6ed38516223a56e723bcc9cf643ac2b362200da4..72c22d7971a024f19e06c2eae8d4129f6f60cf1e 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -259,7 +259,7 @@ class KrbInstance(service.Service):
         entry.setValues("nsSaslMapFilterTemplate", '(krbPrincipalName=\\1@\\2)')
 
         try:
-            self.admin_conn.add_s(entry)
+            self.admin_conn.add_s(**entry)
         except ldap.ALREADY_EXISTS:
             root_logger.critical("failed to add Full Principal Sasl mapping")
             raise e
@@ -272,7 +272,7 @@ class KrbInstance(service.Service):
         entry.setValues("nsSaslMapFilterTemplate", '(krbPrincipalName=&@%s)' % self.realm)
 
         try:
-            self.admin_conn.add_s(entry)
+            self.admin_conn.add_s(**entry)
         except ldap.ALREADY_EXISTS:
             root_logger.critical("failed to add Name Only Sasl mapping")
             raise e
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index a139fd0fbe7168193dcfa6ba5f4d19f20d395c52..7aaf959a3904916101b0454b6df502e2996f2771 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -227,7 +227,7 @@ class ReplicationManager(object):
         ent.setValues("sn", "replication manager pseudo user")
 
         try:
-            conn.add_s(ent)
+            conn.add_s(**ent)
         except ldap.ALREADY_EXISTS:
             conn.modify_s(dn, [(ldap.MOD_REPLACE, "userpassword", pw)])
             pass
@@ -277,7 +277,7 @@ class ReplicationManager(object):
         entry.setValues('nsds5replicabinddn', [replica_binddn])
         entry.setValues('nsds5replicalegacyconsumer', "off")
 
-        conn.add_s(entry)
+        conn.add_s(**entry)
 
     def setup_changelog(self, conn):
         dn = "cn=changelog5, cn=config"
@@ -287,7 +287,7 @@ class ReplicationManager(object):
         entry.setValues('cn', "changelog5")
         entry.setValues('nsslapd-changelogdir', dirpath)
         try:
-            conn.add_s(entry)
+            conn.add_s(**entry)
         except ldap.ALREADY_EXISTS:
             return
 
@@ -310,7 +310,7 @@ class ReplicationManager(object):
                 entry.setValues('nsmultiplexorbinddn', self.repl_man_dn)
                 entry.setValues('nsmultiplexorcredentials', self.repl_man_passwd)
 
-                self.conn.add_s(entry)
+                conn.add_s(**entry)
                 done = True
             except ldap.ALREADY_EXISTS:
                 benum += 1
@@ -378,7 +378,7 @@ class ReplicationManager(object):
         entry.setValues("objectclass", ["account", "simplesecurityobject"])
         entry.setValues("uid", "passsync")
         entry.setValues("userPassword", password)
-        conn.add_s(entry)
+        conn.add_s(**entry)
 
         # Add it to the list of users allowed to bypass password policy
         extop_dn = "cn=ipa_pwd_extop,cn=plugins,cn=config"
@@ -476,7 +476,7 @@ class ReplicationManager(object):
         if iswinsync:
             self.setup_winsync_agmt(entry, win_subtree)
 
-        a_conn.add_s(entry)
+        a_conn.add_s(**entry)
 
         try:
             mod = [(ldap.MOD_ADD, 'nsDS5ReplicatedAttributeListTotal',
@@ -765,7 +765,7 @@ class ReplicationManager(object):
         entry.setValues("ipaConfigString", "winsync:%s" % self.hostname)
 
         try:
-            self.conn.add_s(entry)
+            self.conn.add_s(**entry)
         except Exception, e:
             root_logger.info("Failed to create public entry for winsync replica")
 
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 249727b15b6f3c879336c36d43410fc7234d9d9d..2211ba5946d8a1af99f33044d80e57be8a017992 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -289,7 +289,7 @@ class Service(object):
                         "enabledService", "startOrder " + str(order))
 
         try:
-            conn.add_s(entry)
+            conn.add_s(**entry)
         except ldap.ALREADY_EXISTS, e:
             root_logger.critical("failed to add %s Service startup entry" % name)
             raise e
-- 
1.7.7.3



More information about the Freeipa-devel mailing list