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