17b94a
From 55d945603bb52f0787c5200118673d6206ec3492 Mon Sep 17 00:00:00 2001
17b94a
From: Sunny Kumar <sunkumar@redhat.com>
17b94a
Date: Fri, 12 Apr 2019 19:55:10 +0530
17b94a
Subject: [PATCH 106/124] libgfchangelog : use find_library to locate shared
17b94a
 library
17b94a
17b94a
Issue:
17b94a
17b94a
libgfchangelog.so: cannot open shared object file
17b94a
17b94a
Due to hardcoded shared library name runtime loader looks for particular version of
17b94a
a shared library.
17b94a
17b94a
Solution:
17b94a
17b94a
Using find_library to locate shared library at runtime solves this issue.
17b94a
17b94a
Traceback (most recent call last):
17b94a
  File "/usr/libexec/glusterfs/python/syncdaemon/gsyncd.py", line 323, in main
17b94a
    func(args)
17b94a
  File "/usr/libexec/glusterfs/python/syncdaemon/subcmds.py", line 82, in subcmd_worker
17b94a
    local.service_loop(remote)
17b94a
  File "/usr/libexec/glusterfs/python/syncdaemon/resource.py", line 1261, in service_loop
17b94a
    changelog_agent.init()
17b94a
  File "/usr/libexec/glusterfs/python/syncdaemon/repce.py", line 233, in __call__
17b94a
    return self.ins(self.meth, *a)
17b94a
  File "/usr/libexec/glusterfs/python/syncdaemon/repce.py", line 215, in __call__
17b94a
    raise res
17b94a
OSError: libgfchangelog.so: cannot open shared object file: No such file or directory
17b94a
17b94a
>Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/22557/
17b94a
>Change-Id: I3dd013d701ed1cd99ba7ef20d1898f343e1db8f5
17b94a
>fixes: bz#1699394
17b94a
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
17b94a
17b94a
fixes: bz#1699271
17b94a
Change-Id: If8b5827cdac658eb3a211109bd397db9a6fee8e6
17b94a
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/167907
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
17b94a
---
17b94a
 geo-replication/syncdaemon/libgfchangelog.py                     | 3 ++-
17b94a
 tools/glusterfind/src/libgfchangelog.py                          | 7 +++----
17b94a
 xlators/features/changelog/lib/examples/python/libgfchangelog.py | 4 +++-
17b94a
 3 files changed, 8 insertions(+), 6 deletions(-)
17b94a
17b94a
diff --git a/geo-replication/syncdaemon/libgfchangelog.py b/geo-replication/syncdaemon/libgfchangelog.py
17b94a
index fff9d24..8d12956 100644
17b94a
--- a/geo-replication/syncdaemon/libgfchangelog.py
17b94a
+++ b/geo-replication/syncdaemon/libgfchangelog.py
17b94a
@@ -10,13 +10,14 @@
17b94a
 
17b94a
 import os
17b94a
 from ctypes import CDLL, RTLD_GLOBAL, get_errno, byref, c_ulong
17b94a
+from ctypes.util import find_library
17b94a
 from syncdutils import ChangelogException, ChangelogHistoryNotAvailable
17b94a
 from py2py3 import gr_cl_history_changelog, gr_cl_done, gr_create_string_buffer
17b94a
 from py2py3 import gr_cl_register, gr_cl_history_done, bytearray_to_str
17b94a
 
17b94a
 
17b94a
 class Changes(object):
17b94a
-    libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL,
17b94a
+    libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL,
17b94a
                   use_errno=True)
17b94a
 
17b94a
     @classmethod
17b94a
diff --git a/tools/glusterfind/src/libgfchangelog.py b/tools/glusterfind/src/libgfchangelog.py
17b94a
index 1ef177a..513bb10 100644
17b94a
--- a/tools/glusterfind/src/libgfchangelog.py
17b94a
+++ b/tools/glusterfind/src/libgfchangelog.py
17b94a
@@ -9,8 +9,8 @@
17b94a
 # cases as published by the Free Software Foundation.
17b94a
 
17b94a
 import os
17b94a
-from ctypes import CDLL, get_errno, create_string_buffer, c_ulong, byref
17b94a
-from ctypes import RTLD_GLOBAL
17b94a
+from ctypes import CDLL, RTLD_GLOBAL, get_errno, create_string_buffer, c_ulong, byref
17b94a
+from ctypes.util import find_library
17b94a
 from gfind_py2py3 import bytearray_to_str, gf_create_string_buffer
17b94a
 from gfind_py2py3 import gfind_history_changelog, gfind_changelog_register
17b94a
 from gfind_py2py3 import gfind_history_changelog_done
17b94a
@@ -19,8 +19,7 @@ from gfind_py2py3 import gfind_history_changelog_done
17b94a
 class ChangelogException(OSError):
17b94a
     pass
17b94a
 
17b94a
-
17b94a
-libgfc = CDLL("libgfchangelog.so", use_errno=True, mode=RTLD_GLOBAL)
17b94a
+libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True)
17b94a
 
17b94a
 
17b94a
 def raise_oserr(prefix=None):
17b94a
diff --git a/xlators/features/changelog/lib/examples/python/libgfchangelog.py b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
17b94a
index 2cdbf11..2da9f2d 100644
17b94a
--- a/xlators/features/changelog/lib/examples/python/libgfchangelog.py
17b94a
+++ b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
17b94a
@@ -1,8 +1,10 @@
17b94a
 import os
17b94a
 from ctypes import *
17b94a
+from ctypes.util import find_library
17b94a
 
17b94a
 class Changes(object):
17b94a
-    libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL, use_errno=True)
17b94a
+    libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL,
17b94a
+                  use_errno=True)
17b94a
 
17b94a
     @classmethod
17b94a
     def geterrno(cls):
17b94a
-- 
17b94a
1.8.3.1
17b94a