URL: https://github.com/freeipa/freeipa/pull/699
Author: neffs
 Title: #699: ipaclient/ipapython macOS compatibility fixes
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/699/head:pr699
git checkout pr699
From 25d9d0a99d3451054fea2dfcc44a9dd7119e7593 Mon Sep 17 00:00:00 2001
From: David Kreitschmann <da...@kreitschmann.de>
Date: Fri, 7 Apr 2017 14:02:46 +0200
Subject: [PATCH 1/2] Fix libkrb5 filename for macOS

Signed-off-by: David Kreitschmann <da...@kreitschmann.de>
---
 ipapython/session_storage.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ipapython/session_storage.py b/ipapython/session_storage.py
index 1443413..7c302b7 100644
--- a/ipapython/session_storage.py
+++ b/ipapython/session_storage.py
@@ -3,13 +3,18 @@
 #
 
 import ctypes
+import sys
 
 
 KRB5_CC_NOSUPP = -1765328137
 
+if sys.platform == 'darwin':
+    LIBKRB5_FILENAME = 'libkrb5.dylib'
+else:
+    LIBKRB5_FILENAME = 'libkrb5.so.3'
 
 try:
-    LIBKRB5 = ctypes.CDLL('libkrb5.so.3')
+    LIBKRB5 = ctypes.CDLL(LIBKRB5_FILENAME)
 except OSError as e:  # pragma: no cover
     raise ImportError(str(e))
 

From 7536c29c2f31e36634ee143146bafa9393948513 Mon Sep 17 00:00:00 2001
From: David Kreitschmann <da...@kreitschmann.de>
Date: Fri, 7 Apr 2017 18:09:19 +0200
Subject: [PATCH 2/2] Use os.fsync instead of os.fdatasync because macOS
 doesn't support fdatasync

Signed-off-by: David Kreitschmann <da...@kreitschmann.de>
---
 ipaclient/plugins/vault.py         | 2 +-
 ipaclient/remote_plugins/schema.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipaclient/plugins/vault.py b/ipaclient/plugins/vault.py
index 3fb4900..94b76fb 100644
--- a/ipaclient/plugins/vault.py
+++ b/ipaclient/plugins/vault.py
@@ -603,7 +603,7 @@ def store_cert(self, domain, transport_cert):
                 try:
                     f.write(pem)
                     f.flush()
-                    os.fdatasync(f.fileno())
+                    os.fsync(f.fileno())
                     f.close()
                     os.rename(f.name, filename)
                 except Exception:
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py
index 3ecd608..b3fad8f 100644
--- a/ipaclient/remote_plugins/schema.py
+++ b/ipaclient/remote_plugins/schema.py
@@ -476,7 +476,7 @@ def _write_schema(self, fingerprint):
             try:
                 self._write_schema_data(f)
                 f.flush()
-                os.fdatasync(f.fileno())
+                os.fsync(f.fileno())
                 f.close()
             except Exception:
                 os.unlink(f.name)
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to