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