about summary refs log tree commit diff
path: root/pkgs/tools/filesystems/glusterfs/glusterfs-python-remove-find_library.patch
blob: 4757f2fce771930d8f59f7955683390288ac61e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
From e6293e367f56833457291e32a4df7b21a52365a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
Date: Sat, 13 May 2017 18:54:36 +0200
Subject: [PATCH] python: Remove all uses of find_library. Fixes #1450593

`find_library()` doesn't consider LD_LIBRARY_PATH on Python < 3.6.

Change-Id: Iee26085cb5d14061001f19f032c2664d69a378a8
---
 api/examples/getvolfile.py                                     |  2 +-
 geo-replication/syncdaemon/libcxattr.py                        |  3 +--
 geo-replication/syncdaemon/libgfchangelog.py                   |  6 ++----
 tests/features/ipctest.py                                      | 10 ++--------
 tests/utils/libcxattr.py                                       |  5 ++---
 tools/glusterfind/src/libgfchangelog.py                        |  3 +--
 .../features/changelog/lib/examples/python/libgfchangelog.py   |  3 +--
 7 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/api/examples/getvolfile.py b/api/examples/getvolfile.py
index 0c95213f0..32c2268b3 100755
--- a/api/examples/getvolfile.py
+++ b/api/examples/getvolfile.py
@@ -3,7 +3,7 @@
 import ctypes
 import ctypes.util
 
-api = ctypes.CDLL(ctypes.util.find_library("gfapi"))
+api = ctypes.CDLL("libgfapi.so")
 api.glfs_get_volfile.argtypes = [ctypes.c_void_p,
                                  ctypes.c_void_p,
                                  ctypes.c_ulong]
diff --git a/geo-replication/syncdaemon/libcxattr.py b/geo-replication/syncdaemon/libcxattr.py
index 3671e102c..f576648b7 100644
--- a/geo-replication/syncdaemon/libcxattr.py
+++ b/geo-replication/syncdaemon/libcxattr.py
@@ -10,7 +10,6 @@
 
 import os
 from ctypes import CDLL, create_string_buffer, get_errno
-from ctypes.util import find_library
 
 
 class Xattr(object):
@@ -25,7 +24,7 @@ class Xattr(object):
          sizes we expect
     """
 
-    libc = CDLL(find_library("c"), use_errno=True)
+    libc = CDLL("libc.so.6", use_errno=True)
 
     @classmethod
     def geterrno(cls):
diff --git a/geo-replication/syncdaemon/libgfchangelog.py b/geo-replication/syncdaemon/libgfchangelog.py
index 334f5e9ea..093ae157a 100644
--- a/geo-replication/syncdaemon/libgfchangelog.py
+++ b/geo-replication/syncdaemon/libgfchangelog.py
@@ -9,14 +9,12 @@
 #
 
 import os
-from ctypes import CDLL, RTLD_GLOBAL, create_string_buffer, \
-    get_errno, byref, c_ulong
-from ctypes.util import find_library
+from ctypes import CDLL, RTLD_GLOBAL, create_string_buffer, get_errno, byref, c_ulong
 from syncdutils import ChangelogException, ChangelogHistoryNotAvailable
 
 
 class Changes(object):
-    libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL,
+    libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL,
                   use_errno=True)
 
     @classmethod
diff --git a/tests/features/ipctest.py b/tests/features/ipctest.py
index 5aff319b8..933924861 100755
--- a/tests/features/ipctest.py
+++ b/tests/features/ipctest.py
@@ -1,14 +1,8 @@
 #!/usr/bin/python
 
 import ctypes
-import ctypes.util
-
-# find_library does not lookup LD_LIBRARY_PATH and may miss the
-# function. In that case, retry with less portable but explicit name.
-libgfapi = ctypes.util.find_library("gfapi")
-if libgfapi == None:
-	libgfapi = "libgfapi.so"
-api = ctypes.CDLL(libgfapi,mode=ctypes.RTLD_GLOBAL)
+
+api = ctypes.CDLL("libgfapi.so",mode=ctypes.RTLD_GLOBAL)
 
 api.glfs_ipc.argtypes = [ ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p ]
 api.glfs_ipc.restype = ctypes.c_int
diff --git a/tests/utils/libcxattr.py b/tests/utils/libcxattr.py
index 149db72e6..4e6e6c46d 100644
--- a/tests/utils/libcxattr.py
+++ b/tests/utils/libcxattr.py
@@ -11,7 +11,6 @@
 import os
 import sys
 from ctypes import CDLL, c_int, create_string_buffer
-from ctypes.util import find_library
 
 
 class Xattr(object):
@@ -28,9 +27,9 @@ class Xattr(object):
 
     if sys.hexversion >= 0x02060000:
         from ctypes import DEFAULT_MODE
-        libc = CDLL(find_library("libc"), DEFAULT_MODE, None, True)
+        libc = CDLL("libc.so.6", DEFAULT_MODE, None, True)
     else:
-        libc = CDLL(find_library("libc"))
+        libc = CDLL("libc.so.6")
 
     @classmethod
     def geterrno(cls):
diff --git a/tools/glusterfind/src/libgfchangelog.py b/tools/glusterfind/src/libgfchangelog.py
index 0f6b40d6c..9ca3f326b 100644
--- a/tools/glusterfind/src/libgfchangelog.py
+++ b/tools/glusterfind/src/libgfchangelog.py
@@ -11,14 +11,13 @@
 import os
 from ctypes import CDLL, get_errno, create_string_buffer, c_ulong, byref
 from ctypes import RTLD_GLOBAL
-from ctypes.util import find_library
 
 
 class ChangelogException(OSError):
     pass
 
 
-libgfc = CDLL(find_library("gfchangelog"), use_errno=True, mode=RTLD_GLOBAL)
+libgfc = CDLL("libgfchangelog.so", use_errno=True, mode=RTLD_GLOBAL)
 
 
 def raise_oserr():
diff --git a/xlators/features/changelog/lib/examples/python/libgfchangelog.py b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
index 10e73c02b..2cdbf1152 100644
--- a/xlators/features/changelog/lib/examples/python/libgfchangelog.py
+++ b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
@@ -1,9 +1,8 @@
 import os
 from ctypes import *
-from ctypes.util import find_library
 
 class Changes(object):
-    libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True)
+    libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL, use_errno=True)
 
     @classmethod
     def geterrno(cls):
-- 
2.12.0