URL: https://github.com/freeipa/freeipa/pull/856
Author: stlaz
 Title: #856: adtrustinstance: fix a bug + pep8, py3 fixes
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/856/head:pr856
git checkout pr856
From 4d54c5caf097995e39abd337843f4d64533a808b Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Wed, 7 Jun 2017 08:16:17 +0200
Subject: [PATCH 1/2] adtrustinstance: pep8 fix

---
 ipaserver/install/adtrustinstance.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 66dd6b57b6..5b706c3410 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -349,7 +349,7 @@ def __add_rid_bases(self):
 
             if abs(self.rid_base - self.secondary_rid_base) > size:
                 self.print_msg("Primary and secondary RID base are too close. "
-                      "They have to differ at least by %d." % size)
+                               "They have to differ at least by %d." % size)
                 raise RuntimeError("RID bases too close.\n")
 
             # Modify the range

From 4adb1fa9baa8d21b8b86564ba72a6a9902aea932 Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Wed, 7 Jun 2017 08:18:32 +0200
Subject: [PATCH 2/2] adtrustinstance: write the conf as a string

Since ipautil.template_file() returns a string, we should not try
to write it as bytes.

https://pagure.io/freeipa/issue/4985
---
 ipaserver/install/adtrustinstance.py | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 5b706c3410..3bad638e9b 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -504,23 +504,16 @@ def __add_s4u2proxy_target(self):
             self.print_msg(UPGRADE_ERROR % dict(dn=targets_dn))
 
     def __write_smb_registry(self):
-        template = os.path.join(paths.USR_SHARE_IPA_DIR, "smb.conf.template")
-        conf = ipautil.template_file(template, self.sub_dict)
-        [tmp_fd, tmp_name] = tempfile.mkstemp()
-        os.write(tmp_fd, conf)
-        os.close(tmp_fd)
-
         # Workaround for: https://fedorahosted.org/freeipa/ticket/5687
         # We make sure that paths.SMB_CONF file exists, hence touch it
         with open(paths.SMB_CONF, 'a'):
             os.utime(paths.SMB_CONF, None)
 
-        args = [paths.NET, "conf", "import", tmp_name]
-
-        try:
-            ipautil.run(args)
-        finally:
-            os.remove(tmp_name)
+        template = os.path.join(paths.USR_SHARE_IPA_DIR, "smb.conf.template")
+        conf = ipautil.template_file(template, self.sub_dict)
+        with tempfile.NamedTemporaryFile(mode='w') as tmp_conf:
+            tmp_conf.write(conf)
+            ipautil.run([paths.NET, "conf", "import", tmp_conf.name])
 
     def __setup_group_membership(self):
         # Add the CIFS and host principals to the 'adtrust agents' group
_______________________________________________
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