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