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