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