glusterfs: Make commands that gluster calls work. Fixes #25620.

Done by setting PATH and PYTHONPATH appropriately.

Adds the following patches:

* One that removes hardcodes to /sbin, /usr/bin, etc.
from gluster, so that programs like `lvm` and `xfs_info` can be
called at runtime; see https://bugzilla.redhat.com/show_bug.cgi?id=1450546.
* One that fixes unsubstituted autoconf macros in paths (a problem
in the 3.10 release); see https://bugzilla.redhat.com/show_bug.cgi?id=1450588.
* One that removes uses of the `find_library()` Python function that does
not behave as expected in Python < 3.6 (and would not behave correctly
even on 3.6 in nixpkgs due to #25763);
see https://bugzilla.redhat.com/show_bug.cgi?id=1450593.

I think that all of these patches should be upstreamed.

Also adds tests to check that none of the Python based utilities
throw import errors, calling `--help` or equivalent on them.

+662 -4
+115 -4
pkgs/tools/filesystems/glusterfs/default.nix
··· 1 1 {stdenv, fetchurl, fuse, bison, flex_2_5_35, openssl, python2, ncurses, readline, 2 - autoconf, automake, libtool, pkgconfig, zlib, libaio, libxml2, acl, sqlite 3 - , liburcu, attr, makeWrapper, coreutils, gnused, gnugrep, which 2 + autoconf, automake, libtool, pkgconfig, zlib, libaio, libxml2, acl, sqlite, 3 + liburcu, attr, makeWrapper, coreutils, gnused, gnugrep, which, python2Packages, 4 + openssh, gawk, findutils, utillinux, lvm2, btrfs-progs, e2fsprogs, xfsprogs, systemd, 5 + rsync, glibc 4 6 }: 5 7 let 6 8 s = 7 9 rec { 8 10 baseName="glusterfs"; 11 + # NOTE: On each glusterfs release, it should be checked if gluster added 12 + # new, or changed, Python scripts whose PYTHONPATH has to be set in 13 + # `postFixup` below, and whose runtime deps need to go into 14 + # `nativeBuildInputs`. 15 + # The command 16 + # find /nix/store/...-glusterfs-.../ -name '*.py' -executable 17 + # can help with finding new Python scripts. 9 18 version = "3.10.1"; 10 19 name="${baseName}-${version}"; 11 20 url="https://github.com/gluster/glusterfs/archive/v${version}.tar.gz"; 12 21 sha256 = "0gmb3m98djljcycjggi1qv99ai6k4cvn2rqym2q9f58q8n8kdhh7"; 13 22 }; 14 23 buildInputs = [ 15 - fuse bison flex_2_5_35 openssl python2 ncurses readline 24 + fuse bison flex_2_5_35 openssl ncurses readline 16 25 autoconf automake libtool pkgconfig zlib libaio libxml2 17 26 acl sqlite liburcu attr makeWrapper 27 + (python2.withPackages (pkgs: [ 28 + pkgs.flask 29 + pkgs.prettytable 30 + pkgs.requests 31 + pkgs.xattr 32 + ])) 33 + # NOTE: `python2` has to be *AFTER* the above `python2.withPackages`, 34 + # to ensure that the packages are available but the `toPythonPath` 35 + # shell function used in `postFixup` is also still available. 36 + python2 18 37 ]; 19 38 # Some of the headers reference acl 20 39 propagatedBuildInputs = [ 21 40 acl 22 41 ]; 42 + # Packages from which GlusterFS calls binaries at run-time from PATH, 43 + # with comments on which commands are known to be called by it. 44 + runtimePATHdeps = [ 45 + attr # getfattr setfattr 46 + btrfs-progs # btrfs 47 + coreutils # lots of commands in bash scripts 48 + e2fsprogs # tune2fs 49 + findutils # find 50 + gawk # awk 51 + glibc # getent 52 + gnugrep # grep 53 + gnused # sed 54 + lvm2 # lvs 55 + openssh # ssh 56 + rsync # rsync, e.g. for geo-replication 57 + systemd # systemctl 58 + utillinux # mount umount 59 + which # which 60 + xfsprogs # xfs_info 61 + ]; 23 62 in 24 63 stdenv.mkDerivation 25 64 rec { 26 65 inherit (s) name version; 27 66 inherit buildInputs propagatedBuildInputs; 28 67 68 + patches = [ 69 + ./glusterfs-use-PATH-instead-of-hardcodes.patch 70 + ./glusterfs-fix-unsubstituted-autoconf-macros.patch 71 + ./glusterfs-python-remove-find_library.patch 72 + ]; 73 + 29 74 # Note that the VERSION file is something that is present in release tarballs 30 75 # but not in git tags (at least not as of writing in v3.10.1). 31 76 # That's why we have to create it. ··· 49 94 postInstall = '' 50 95 cp -r $out/$out/* $out 51 96 rm -r $out/nix 52 - wrapProgram $out/sbin/mount.glusterfs --set PATH "${stdenv.lib.makeBinPath [ coreutils gnused attr gnugrep which]}" 97 + ''; 98 + 99 + postFixup = '' 100 + # glusterd invokes `gluster` and other utilities when telling other glusterd nodes to run commands. 101 + # For example for `peer_georep-sshkey` key generation, so `$out/bin` is needed in the PATH. 102 + # It also invokes bash scripts like `gverify.sh`. 103 + # It also invokes executable Python scripts in `$out/libexec/glusterfs`, which is why we set up PYTHONPATH accordingly. 104 + # We set up the paths for the main entry point executables. 105 + 106 + GLUSTER_PATH="${stdenv.lib.makeBinPath runtimePATHdeps}:$out/bin" 107 + GLUSTER_PYTHONPATH="$(toPythonPath $out):$out/libexec/glusterfs" 108 + GLUSTER_LD_LIBRARY_PATH="$out/lib" 109 + 110 + wrapProgram $out/bin/glusterd --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 111 + wrapProgram $out/bin/gluster --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 112 + wrapProgram $out/sbin/mount.glusterfs --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 113 + 114 + # Set Python environment for the Python based utilities. 115 + # It would be nice if there was a better way to do this, automatically for all of them. 116 + # Also, this is brittle: If we forget a dependency or gluster adds a new one, things will break deep inside gluster. 117 + # We should better try to get an explicit list of Python dependencies from gluster and ensure all of them are in the PYTHONPATH of all these python scripts. 118 + # But at the time of writing (gluster 3.10), gluster only provides this in form of a gluster.spec file for RPM creation, 119 + # and even that one is not complete (for example it doesn't mention the `flask` dependency). 120 + 121 + wrapProgram $out/bin/gluster-eventsapi --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 122 + wrapProgram $out/bin/gluster-georep-sshkey --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 123 + wrapProgram $out/bin/gluster-mountbroker --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 124 + wrapProgram $out/bin/glusterfind --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 125 + 126 + # Note that we only wrap the symlinks in $out/bin, not the actual executable scripts in $out/libexec/glusterfs. 127 + # This is because those scripts use `__file__` in their program logic 128 + # (see https://github.com/gluster/glusterfs/blob/v3.10.1/extras/cliutils/cliutils.py#L116) 129 + # which would break if we changed the file name (which is what `wrapProgram` does). 130 + # Luckily, `libexec` scripts are never supposed to be invoked straight from PATH, 131 + # instead they are invoked directly from `gluster` or `glusterd`, which is why it is 132 + # sufficient to set PYTHONPATH for those executables. 133 + 134 + wrapProgram $out/share/glusterfs/scripts/eventsdash.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" 135 + ''; 136 + 137 + doInstallCheck = true; 138 + 139 + # Below we run Python programs. That generates .pyc/.pyo files. 140 + # By default they are indeterministic because such files contain time stamps 141 + # (see https://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html). 142 + # So we use the same environment variables as in 143 + # https://github.com/NixOS/nixpkgs/blob/249b34aadca7038207492f29142a3456d0cecec3/pkgs/development/interpreters/python/mk-python-derivation.nix#L61 144 + # to make these files deterministic. 145 + # A general solution to this problem might be brought by #25707. 146 + DETERMINISTIC_BUILD = 1; 147 + PYTHONHASHSEED = 0; 148 + 149 + installCheckPhase = '' 150 + # Tests that the above programs work without import errors. 151 + # For testing it manually in a shell you may want to substitute `$out` with `$(dirname $(readlink -f $(which gluster)))/../`. 152 + $out/bin/glusterd --help 153 + # $out/bin/gluster help # can't do this because even `gluster help` tries to write to `/var/log/glusterfs/cli.log` 154 + $out/bin/gluster-eventsapi --help 155 + $out/bin/gluster-georep-sshkey --help 156 + $out/bin/gluster-mountbroker --help 157 + $out/bin/glusterfind --help 158 + # gfid_to_path.py doesn't accept --help, and it requires different arguments 159 + # (a dir as single argument) than the usage prints when stdin is not a TTY. 160 + # The `echo ""` is just so that stdin is not a TTY even if you try this line 161 + # on a real TTY for testing purposes. 162 + echo "" | (mkdir -p nix-test-dir-for-gfid_to_path && touch b && $out/libexec/glusterfs/gfind_missing_files/gfid_to_path.py nix-test-dir-for-gfid_to_path) 163 + $out/share/glusterfs/scripts/eventsdash.py --help 53 164 ''; 54 165 55 166 src = fetchurl {
+236
pkgs/tools/filesystems/glusterfs/glusterfs-fix-unsubstituted-autoconf-macros.patch
··· 1 + From b37e0222a6a60505868a6fbb8591608cdc4bba57 Mon Sep 17 00:00:00 2001 2 + From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me> 3 + Date: Sat, 13 May 2017 15:33:27 +0200 4 + Subject: [PATCH] Revert "build/packaging: Debian and Ubuntu don't have 5 + /usr/libexec". Fixes #1450588 6 + 7 + This reverts commit 18509e436f8a728ef522f3e76e2f2dc30e1bd8ac. 8 + 9 + This fixes autoconf unsubstituted strings to appear in generated source code. 10 + --- 11 + cli/src/Makefile.am | 2 +- 12 + configure.ac | 12 ++++++------ 13 + events/src/Makefile.am | 8 ++++---- 14 + extras/Makefile.am | 2 +- 15 + geo-replication/src/Makefile.am | 8 ++++---- 16 + geo-replication/syncdaemon/Makefile.am | 2 +- 17 + tools/gfind_missing_files/Makefile.am | 4 ++-- 18 + tools/glusterfind/Makefile.am | 4 ++-- 19 + tools/glusterfind/src/Makefile.am | 2 +- 20 + xlators/features/ganesha/src/Makefile.am | 2 +- 21 + xlators/mgmt/glusterd/src/Makefile.am | 2 +- 22 + 11 files changed, 24 insertions(+), 24 deletions(-) 23 + 24 + diff --git a/cli/src/Makefile.am b/cli/src/Makefile.am 25 + index 5ef9389..f5b8d00 100644 26 + --- a/cli/src/Makefile.am 27 + +++ b/cli/src/Makefile.am 28 + @@ -18,7 +18,7 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) \ 29 + -I$(top_builddir)/rpc/xdr/src\ 30 + -DDATADIR=\"$(localstatedir)\" \ 31 + -DCONFDIR=\"$(sysconfdir)/glusterfs\" \ 32 + - -DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\"\ 33 + + -DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\"\ 34 + -DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) -DSBIN_DIR=\"$(sbindir)\"\ 35 + $(XML_CPPFLAGS) 36 + 37 + diff --git a/configure.ac b/configure.ac 38 + index c9742e2..0c3a386 100644 39 + --- a/configure.ac 40 + +++ b/configure.ac 41 + @@ -1056,24 +1056,24 @@ old_prefix=$prefix 42 + if test "x$prefix" = xNONE; then 43 + prefix=$ac_default_prefix 44 + fi 45 + -GLUSTERFS_LIBEXECDIR="$libexecdir/glusterfs" 46 + -GLUSTERFSD_MISCDIR="$prefix/var/lib/misc/glusterfsd" 47 + +GLUSTERFS_LIBEXECDIR="$(eval echo $prefix)/libexec/glusterfs" 48 + +GLUSTERFSD_MISCDIR="$(eval echo $prefix)/var/lib/misc/glusterfsd" 49 + prefix=$old_prefix 50 + 51 + ### Dirty hacky stuff to make LOCALSTATEDIR work 52 + if test "x$prefix" = xNONE; then 53 + - test $localstatedir = '$prefix/var' && localstatedir=$ac_default_prefix/var 54 + + test $localstatedir = '${prefix}/var' && localstatedir=$ac_default_prefix/var 55 + localstatedir=/var 56 + - LOCALSTATEDIR=$localstatedir 57 + + LOCALSTATEDIR=$(eval echo ${localstatedir}) 58 + else 59 + - LOCALSTATEDIR=$localstatedir 60 + + LOCALSTATEDIR=$(eval echo ${localstatedir}) 61 + fi 62 + 63 + old_prefix=$prefix 64 + if test "x$prefix" = xNONE; then 65 + prefix=$ac_default_prefix 66 + fi 67 + -GLUSTERD_VOLFILE="$sysconfdir/glusterfs/glusterd.vol" 68 + +GLUSTERD_VOLFILE="$(eval echo ${sysconfdir})/glusterfs/glusterd.vol" 69 + prefix=$old_prefix 70 + 71 + 72 + diff --git a/events/src/Makefile.am b/events/src/Makefile.am 73 + index 8493abd..87282c6 100644 74 + --- a/events/src/Makefile.am 75 + +++ b/events/src/Makefile.am 76 + @@ -5,7 +5,7 @@ EXTRA_DIST = glustereventsd.py __init__.py eventsapiconf.py.in \ 77 + BUILT_SOURCES = eventtypes.py 78 + CLEANFILES = eventtypes.py 79 + 80 + -eventsdir = $(GLUSTERFS_LIBEXECDIR)/events 81 + +eventsdir = $(libexecdir)/glusterfs/events 82 + events_PYTHON = __init__.py gf_event.py eventsapiconf.py eventtypes.py \ 83 + utils.py 84 + 85 + @@ -13,7 +13,7 @@ eventtypes.py: $(top_srcdir)/events/eventskeygen.py 86 + $(PYTHON) $(top_srcdir)/events/eventskeygen.py PY_HEADER 87 + 88 + if BUILD_EVENTS 89 + -eventspeerscriptdir = $(GLUSTERFS_LIBEXECDIR) 90 + +eventspeerscriptdir = $(libexecdir)/glusterfs 91 + eventsconfdir = $(sysconfdir)/glusterfs 92 + eventsconf_DATA = eventsconfig.json 93 + 94 + @@ -24,10 +24,10 @@ eventspeerscript_SCRIPTS = peer_eventsapi.py 95 + install-exec-hook: 96 + $(mkdir_p) $(DESTDIR)$(sbindir) 97 + rm -f $(DESTDIR)$(sbindir)/glustereventsd 98 + - ln -s $(GLUSTERFS_LIBEXECDIR)/events/glustereventsd.py \ 99 + + ln -s $(libexecdir)/glusterfs/events/glustereventsd.py \ 100 + $(DESTDIR)$(sbindir)/glustereventsd 101 + rm -f $(DESTDIR)$(sbindir)/gluster-eventsapi 102 + - ln -s $(GLUSTERFS_LIBEXECDIR)/peer_eventsapi.py \ 103 + + ln -s $(libexecdir)/glusterfs/peer_eventsapi.py \ 104 + $(DESTDIR)$(sbindir)/gluster-eventsapi 105 + 106 + uninstall-hook: 107 + diff --git a/extras/Makefile.am b/extras/Makefile.am 108 + index 9dfc93d..53ac476 100644 109 + --- a/extras/Makefile.am 110 + +++ b/extras/Makefile.am 111 + @@ -1,4 +1,4 @@ 112 + -addonexecdir = $(GLUSTERFS_LIBEXECDIR) 113 + +addonexecdir = $(libexecdir)/glusterfs 114 + addonexec_SCRIPTS = peer_add_secret_pub 115 + 116 + EditorModedir = $(docdir) 117 + diff --git a/geo-replication/src/Makefile.am b/geo-replication/src/Makefile.am 118 + index 9937a0b..87435d5 100644 119 + --- a/geo-replication/src/Makefile.am 120 + +++ b/geo-replication/src/Makefile.am 121 + @@ -1,4 +1,4 @@ 122 + -gsyncddir = $(GLUSTERFS_LIBEXECDIR) 123 + +gsyncddir = $(libexecdir)/glusterfs 124 + 125 + gsyncd_SCRIPTS = gverify.sh peer_gsec_create \ 126 + set_geo_rep_pem_keys.sh peer_mountbroker peer_mountbroker.py \ 127 + @@ -21,7 +21,7 @@ noinst_HEADERS = procdiggy.h 128 + 129 + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ 130 + -I$(top_srcdir)/rpc/xdr/src -I$(top_builddir)/rpc/xdr/src \ 131 + - -DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\" -DUSE_LIBGLUSTERFS \ 132 + + -DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\" -DUSE_LIBGLUSTERFS \ 133 + -DSBIN_DIR=\"$(sbindir)\" -DPYTHON=\"$(PYTHON)\" 134 + 135 + AM_CFLAGS = -Wall $(GF_CFLAGS) 136 + @@ -35,11 +35,11 @@ $(top_builddir)/libglusterfs/src/libglusterfs.la: 137 + install-exec-hook: 138 + $(mkdir_p) $(DESTDIR)$(sbindir) 139 + rm -f $(DESTDIR)$(sbindir)/gluster-mountbroker 140 + - ln -s $(GLUSTERFS_LIBEXECDIR)/peer_mountbroker.py \ 141 + + ln -s $(libexecdir)/glusterfs/peer_mountbroker.py \ 142 + $(DESTDIR)$(sbindir)/gluster-mountbroker 143 + 144 + rm -f $(DESTDIR)$(sbindir)/gluster-georep-sshkey 145 + - ln -s $(GLUSTERFS_LIBEXECDIR)/peer_georep-sshkey.py \ 146 + + ln -s $(libexecdir)/glusterfs/peer_georep-sshkey.py \ 147 + $(DESTDIR)$(sbindir)/gluster-georep-sshkey 148 + 149 + 150 + diff --git a/geo-replication/syncdaemon/Makefile.am b/geo-replication/syncdaemon/Makefile.am 151 + index f80fb26..7cdaf45 100644 152 + --- a/geo-replication/syncdaemon/Makefile.am 153 + +++ b/geo-replication/syncdaemon/Makefile.am 154 + @@ -1,4 +1,4 @@ 155 + -syncdaemondir = $(GLUSTERFS_LIBEXECDIR)/python/syncdaemon 156 + +syncdaemondir = $(libexecdir)/glusterfs/python/syncdaemon 157 + 158 + syncdaemon_PYTHON = gconf.py gsyncd.py __init__.py master.py README.md repce.py \ 159 + resource.py configinterface.py syncdutils.py monitor.py libcxattr.py \ 160 + diff --git a/tools/gfind_missing_files/Makefile.am b/tools/gfind_missing_files/Makefile.am 161 + index f77f789..043c34c 100644 162 + --- a/tools/gfind_missing_files/Makefile.am 163 + +++ b/tools/gfind_missing_files/Makefile.am 164 + @@ -1,4 +1,4 @@ 165 + -gfindmissingfilesdir = $(GLUSTERFS_LIBEXECDIR)/gfind_missing_files 166 + +gfindmissingfilesdir = $(libexecdir)/glusterfs/gfind_missing_files 167 + 168 + gfindmissingfiles_SCRIPTS = gfind_missing_files.sh gfid_to_path.sh \ 169 + gfid_to_path.py 170 + @@ -21,6 +21,6 @@ uninstall-local: 171 + 172 + install-data-local: 173 + rm -f $(DESTDIR)$(sbindir)/gfind_missing_files 174 + - ln -s $(GLUSTERFS_LIBEXECDIR)/gfind_missing_files/gfind_missing_files.sh $(DESTDIR)$(sbindir)/gfind_missing_files 175 + + ln -s $(libexecdir)/glusterfs/gfind_missing_files/gfind_missing_files.sh $(DESTDIR)$(sbindir)/gfind_missing_files 176 + 177 + CLEANFILES = 178 + diff --git a/tools/glusterfind/Makefile.am b/tools/glusterfind/Makefile.am 179 + index 92fa614..37f23be 100644 180 + --- a/tools/glusterfind/Makefile.am 181 + +++ b/tools/glusterfind/Makefile.am 182 + @@ -6,7 +6,7 @@ bin_SCRIPTS = glusterfind 183 + 184 + CLEANFILES = $(bin_SCRIPTS) 185 + 186 + -deletehookscriptsdir = $(GLUSTERFS_LIBEXECDIR)/glusterfind/ 187 + +deletehookscriptsdir = $(libexecdir)/glusterfs/glusterfind/ 188 + deletehookscripts_SCRIPTS = S57glusterfind-delete-post.py 189 + 190 + uninstall-local: 191 + @@ -16,5 +16,5 @@ install-data-local: 192 + $(mkdir_p) $(DESTDIR)$(GLUSTERD_WORKDIR)/glusterfind/.keys 193 + $(mkdir_p) $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/ 194 + rm -f $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/S57glusterfind-delete-post 195 + - ln -s $(GLUSTERFS_LIBEXECDIR)/glusterfind/S57glusterfind-delete-post.py \ 196 + + ln -s $(libexecdir)/glusterfs/glusterfind/S57glusterfind-delete-post.py \ 197 + $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/S57glusterfind-delete-post 198 + diff --git a/tools/glusterfind/src/Makefile.am b/tools/glusterfind/src/Makefile.am 199 + index e4469c1..541ff94 100644 200 + --- a/tools/glusterfind/src/Makefile.am 201 + +++ b/tools/glusterfind/src/Makefile.am 202 + @@ -1,4 +1,4 @@ 203 + -glusterfinddir = $(GLUSTERFS_LIBEXECDIR)/glusterfind 204 + +glusterfinddir = $(libexecdir)/glusterfs/glusterfind 205 + 206 + glusterfind_PYTHON = conf.py utils.py __init__.py \ 207 + main.py libgfchangelog.py changelogdata.py 208 + diff --git a/xlators/features/ganesha/src/Makefile.am b/xlators/features/ganesha/src/Makefile.am 209 + index 78715d6..54cfcb3 100644 210 + --- a/xlators/features/ganesha/src/Makefile.am 211 + +++ b/xlators/features/ganesha/src/Makefile.am 212 + @@ -12,7 +12,7 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ 213 + -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)\ 214 + -I$(top_srcdir)/rpc/xdr/src -I$(top_builddir)/rpc/xdr/src \ 215 + -DGANESHA_DIR=\"$(sysconfdir)/ganesha\" \ 216 + - -DGYSNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\" 217 + + -DGYSNCD_PREFIX=\"$(libexecdir)/glusterfs\" 218 + 219 + AM_CFLAGS = -Wall $(GF_CFLAGS) 220 + 221 + diff --git a/xlators/mgmt/glusterd/src/Makefile.am b/xlators/mgmt/glusterd/src/Makefile.am 222 + index 23ebf37..4f2fffd 100644 223 + --- a/xlators/mgmt/glusterd/src/Makefile.am 224 + +++ b/xlators/mgmt/glusterd/src/Makefile.am 225 + @@ -47,7 +47,7 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ 226 + -I$(CONTRIBDIR)/rbtree -I$(top_srcdir)/rpc/rpc-lib/src \ 227 + -I$(CONTRIBDIR)/mount -I$(CONTRIBDIR)/userspace-rcu \ 228 + -DSBIN_DIR=\"$(sbindir)\" -DDATADIR=\"$(localstatedir)\" \ 229 + - -DGSYNCD_PREFIX=\"$(GLUSTERFS_LIBEXECDIR)\" \ 230 + + -DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\" \ 231 + -DCONFDIR=\"$(localstatedir)/run/gluster/shared_storage/nfs-ganesha\" \ 232 + -DGANESHA_PREFIX=\"$(libexecdir)/ganesha\" \ 233 + -DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) $(XML_CPPFLAGS) 234 + -- 235 + 2.7.4 236 +
+151
pkgs/tools/filesystems/glusterfs/glusterfs-python-remove-find_library.patch
··· 1 + From d321df349d10f038f0c89b9c11f8059572264f1b Mon Sep 17 00:00:00 2001 2 + From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me> 3 + Date: Sat, 13 May 2017 18:54:36 +0200 4 + Subject: [PATCH] python: Remove all uses of find_library. Fixes #1450593 5 + 6 + `find_library()` doesn't consider LD_LIBRARY_PATH on Python < 3.6. 7 + --- 8 + api/examples/getvolfile.py | 2 +- 9 + geo-replication/syncdaemon/libcxattr.py | 3 +-- 10 + geo-replication/syncdaemon/libgfchangelog.py | 3 +-- 11 + tests/features/ipctest.py | 10 ++-------- 12 + tests/utils/libcxattr.py | 5 ++--- 13 + tools/glusterfind/src/libgfchangelog.py | 3 +-- 14 + .../features/changelog/lib/examples/python/libgfchangelog.py | 3 +-- 15 + 7 files changed, 9 insertions(+), 20 deletions(-) 16 + 17 + diff --git a/api/examples/getvolfile.py b/api/examples/getvolfile.py 18 + index 0c95213..32c2268 100755 19 + --- a/api/examples/getvolfile.py 20 + +++ b/api/examples/getvolfile.py 21 + @@ -3,7 +3,7 @@ 22 + import ctypes 23 + import ctypes.util 24 + 25 + -api = ctypes.CDLL(ctypes.util.find_library("gfapi")) 26 + +api = ctypes.CDLL("libgfapi.so") 27 + api.glfs_get_volfile.argtypes = [ctypes.c_void_p, 28 + ctypes.c_void_p, 29 + ctypes.c_ulong] 30 + diff --git a/geo-replication/syncdaemon/libcxattr.py b/geo-replication/syncdaemon/libcxattr.py 31 + index 3671e10..f576648 100644 32 + --- a/geo-replication/syncdaemon/libcxattr.py 33 + +++ b/geo-replication/syncdaemon/libcxattr.py 34 + @@ -10,7 +10,6 @@ 35 + 36 + import os 37 + from ctypes import CDLL, create_string_buffer, get_errno 38 + -from ctypes.util import find_library 39 + 40 + 41 + class Xattr(object): 42 + @@ -25,7 +24,7 @@ class Xattr(object): 43 + sizes we expect 44 + """ 45 + 46 + - libc = CDLL(find_library("c"), use_errno=True) 47 + + libc = CDLL("libc.so.6", use_errno=True) 48 + 49 + @classmethod 50 + def geterrno(cls): 51 + diff --git a/geo-replication/syncdaemon/libgfchangelog.py b/geo-replication/syncdaemon/libgfchangelog.py 52 + index d87b56c..003c28c 100644 53 + --- a/geo-replication/syncdaemon/libgfchangelog.py 54 + +++ b/geo-replication/syncdaemon/libgfchangelog.py 55 + @@ -10,12 +10,11 @@ 56 + 57 + import os 58 + from ctypes import CDLL, RTLD_GLOBAL, create_string_buffer, get_errno, byref, c_ulong 59 + -from ctypes.util import find_library 60 + from syncdutils import ChangelogException, ChangelogHistoryNotAvailable 61 + 62 + 63 + class Changes(object): 64 + - libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True) 65 + + libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL, use_errno=True) 66 + 67 + @classmethod 68 + def geterrno(cls): 69 + diff --git a/tests/features/ipctest.py b/tests/features/ipctest.py 70 + index 5aff319..9339248 100755 71 + --- a/tests/features/ipctest.py 72 + +++ b/tests/features/ipctest.py 73 + @@ -1,14 +1,8 @@ 74 + #!/usr/bin/python 75 + 76 + import ctypes 77 + -import ctypes.util 78 + - 79 + -# find_library does not lookup LD_LIBRARY_PATH and may miss the 80 + -# function. In that case, retry with less portable but explicit name. 81 + -libgfapi = ctypes.util.find_library("gfapi") 82 + -if libgfapi == None: 83 + - libgfapi = "libgfapi.so" 84 + -api = ctypes.CDLL(libgfapi,mode=ctypes.RTLD_GLOBAL) 85 + + 86 + +api = ctypes.CDLL("libgfapi.so",mode=ctypes.RTLD_GLOBAL) 87 + 88 + api.glfs_ipc.argtypes = [ ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p ] 89 + api.glfs_ipc.restype = ctypes.c_int 90 + diff --git a/tests/utils/libcxattr.py b/tests/utils/libcxattr.py 91 + index 149db72..4e6e6c4 100644 92 + --- a/tests/utils/libcxattr.py 93 + +++ b/tests/utils/libcxattr.py 94 + @@ -11,7 +11,6 @@ 95 + import os 96 + import sys 97 + from ctypes import CDLL, c_int, create_string_buffer 98 + -from ctypes.util import find_library 99 + 100 + 101 + class Xattr(object): 102 + @@ -28,9 +27,9 @@ class Xattr(object): 103 + 104 + if sys.hexversion >= 0x02060000: 105 + from ctypes import DEFAULT_MODE 106 + - libc = CDLL(find_library("libc"), DEFAULT_MODE, None, True) 107 + + libc = CDLL("libc.so.6", DEFAULT_MODE, None, True) 108 + else: 109 + - libc = CDLL(find_library("libc")) 110 + + libc = CDLL("libc.so.6") 111 + 112 + @classmethod 113 + def geterrno(cls): 114 + diff --git a/tools/glusterfind/src/libgfchangelog.py b/tools/glusterfind/src/libgfchangelog.py 115 + index dd8153e..da822cf 100644 116 + --- a/tools/glusterfind/src/libgfchangelog.py 117 + +++ b/tools/glusterfind/src/libgfchangelog.py 118 + @@ -12,14 +12,13 @@ 119 + import os 120 + from ctypes import CDLL, get_errno, create_string_buffer, c_ulong, byref 121 + from ctypes import RTLD_GLOBAL 122 + -from ctypes.util import find_library 123 + 124 + 125 + class ChangelogException(OSError): 126 + pass 127 + 128 + 129 + -libgfc = CDLL(find_library("gfchangelog"), use_errno=True, mode=RTLD_GLOBAL) 130 + +libgfc = CDLL("libgfchangelog.so", use_errno=True, mode=RTLD_GLOBAL) 131 + 132 + 133 + def raise_oserr(): 134 + diff --git a/xlators/features/changelog/lib/examples/python/libgfchangelog.py b/xlators/features/changelog/lib/examples/python/libgfchangelog.py 135 + index 10e73c0..2cdbf11 100644 136 + --- a/xlators/features/changelog/lib/examples/python/libgfchangelog.py 137 + +++ b/xlators/features/changelog/lib/examples/python/libgfchangelog.py 138 + @@ -1,9 +1,8 @@ 139 + import os 140 + from ctypes import * 141 + -from ctypes.util import find_library 142 + 143 + class Changes(object): 144 + - libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True) 145 + + libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL, use_errno=True) 146 + 147 + @classmethod 148 + def geterrno(cls): 149 + -- 150 + 2.7.4 151 +
+160
pkgs/tools/filesystems/glusterfs/glusterfs-use-PATH-instead-of-hardcodes.patch
··· 1 + From 67fbd3aadc2c4caeb14418609f5c7af6de36081b Mon Sep 17 00:00:00 2001 2 + From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me> 3 + Date: Sat, 13 May 2017 02:45:49 +0200 4 + Subject: [PATCH] Don't use hardcoded /sbin, /usr/bin etc. paths. Fixes 5 + #1450546. 6 + 7 + Instead, rely on programs to be in PATH, as gluster already 8 + does in many places across its code base. 9 + --- 10 + contrib/fuse-lib/mount-common.c | 8 ++++---- 11 + xlators/mgmt/glusterd/src/glusterd-ganesha.c | 8 ++++---- 12 + xlators/mgmt/glusterd/src/glusterd-quota.c | 6 +++--- 13 + xlators/mgmt/glusterd/src/glusterd-snapshot.c | 4 ++-- 14 + xlators/mgmt/glusterd/src/glusterd-utils.c | 13 +------------ 15 + 5 files changed, 14 insertions(+), 25 deletions(-) 16 + 17 + diff --git a/contrib/fuse-lib/mount-common.c b/contrib/fuse-lib/mount-common.c 18 + index e9f80fe..6380dd8 100644 19 + --- a/contrib/fuse-lib/mount-common.c 20 + +++ b/contrib/fuse-lib/mount-common.c 21 + @@ -255,16 +255,16 @@ fuse_mnt_umount (const char *progname, const char *abs_mnt, 22 + exit (1); 23 + } 24 + #ifdef GF_LINUX_HOST_OS 25 + - execl ("/bin/umount", "/bin/umount", "-i", rel_mnt, 26 + + execl ("umount", "umount", "-i", rel_mnt, 27 + lazy ? "-l" : NULL, NULL); 28 + - GFFUSE_LOGERR ("%s: failed to execute /bin/umount: %s", 29 + + GFFUSE_LOGERR ("%s: failed to execute umount: %s", 30 + progname, strerror (errno)); 31 + #elif __NetBSD__ 32 + /* exitting the filesystem causes the umount */ 33 + exit (0); 34 + #else 35 + - execl ("/sbin/umount", "/sbin/umount", "-f", rel_mnt, NULL); 36 + - GFFUSE_LOGERR ("%s: failed to execute /sbin/umount: %s", 37 + + execl ("umount", "umount", "-f", rel_mnt, NULL); 38 + + GFFUSE_LOGERR ("%s: failed to execute umount: %s", 39 + progname, strerror (errno)); 40 + #endif /* GF_LINUX_HOST_OS */ 41 + exit (1); 42 + diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c 43 + index 8dde82e..0038e69 100644 44 + --- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c 45 + +++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c 46 + @@ -123,15 +123,15 @@ manage_service (char *action) 47 + int i = 0; 48 + int ret = 0; 49 + struct service_command sc_list[] = { 50 + - { .binary = "/usr/bin/systemctl", 51 + + { .binary = "systemctl", 52 + .service = "nfs-ganesha", 53 + .action = sc_systemctl_action 54 + }, 55 + - { .binary = "/sbin/invoke-rc.d", 56 + + { .binary = "invoke-rc.d", 57 + .service = "nfs-ganesha", 58 + .action = sc_service_action 59 + }, 60 + - { .binary = "/sbin/service", 61 + + { .binary = "service", 62 + .service = "nfs-ganesha", 63 + .action = sc_service_action 64 + }, 65 + @@ -144,7 +144,7 @@ manage_service (char *action) 66 + if (ret == 0) { 67 + gf_msg_debug (THIS->name, 0, 68 + "%s found.", sc_list[i].binary); 69 + - if (strcmp (sc_list[i].binary, "/usr/bin/systemctl") == 0) 70 + + if (strcmp (sc_list[i].binary, "systemctl") == 0) 71 + ret = sc_systemctl_action (&sc_list[i], action); 72 + else 73 + ret = sc_service_action (&sc_list[i], action); 74 + diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c 75 + index c1c95ae..a6eeb69 100644 76 + --- a/xlators/mgmt/glusterd/src/glusterd-quota.c 77 + +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c 78 + @@ -30,7 +30,7 @@ 79 + 80 + #ifndef _PATH_SETFATTR 81 + # ifdef GF_LINUX_HOST_OS 82 + -# define _PATH_SETFATTR "/usr/bin/setfattr" 83 + +# define _PATH_SETFATTR "setfattr" 84 + # endif 85 + # ifdef __NetBSD__ 86 + # define _PATH_SETFATTR "/usr/pkg/bin/setfattr" 87 + @@ -335,7 +335,7 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, 88 + 89 + if (type == GF_QUOTA_OPTION_TYPE_ENABLE || 90 + type == GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS) 91 + - runner_add_args (&runner, "/usr/bin/find", ".", NULL); 92 + + runner_add_args (&runner, "find", ".", NULL); 93 + 94 + else if (type == GF_QUOTA_OPTION_TYPE_DISABLE) { 95 + 96 + @@ -351,7 +351,7 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, 97 + VIRTUAL_QUOTA_XATTR_CLEANUP_KEY, "1", 98 + "{}", "\\", ";", NULL); 99 + #else 100 + - runner_add_args (&runner, "/usr/bin/find", ".", 101 + + runner_add_args (&runner, "find", ".", 102 + "-exec", _PATH_SETFATTR, "-n", 103 + VIRTUAL_QUOTA_XATTR_CLEANUP_KEY, "-v", 104 + "1", "{}", "\\", ";", NULL); 105 + diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c 106 + index c75a101..b7b659e 100644 107 + --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c 108 + +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c 109 + @@ -121,7 +121,7 @@ glusterd_build_snap_device_path (char *device, char *snapname, 110 + } 111 + 112 + runinit (&runner); 113 + - runner_add_args (&runner, "/sbin/lvs", "--noheadings", "-o", "vg_name", 114 + + runner_add_args (&runner, "lvs", "--noheadings", "-o", "vg_name", 115 + device, NULL); 116 + runner_redir (&runner, STDOUT_FILENO, RUN_PIPE); 117 + snprintf (msg, sizeof (msg), "Get volume group for device %s", device); 118 + @@ -1982,7 +1982,7 @@ glusterd_is_thinp_brick (char *device, uint32_t *op_errno) 119 + 120 + runinit (&runner); 121 + 122 + - runner_add_args (&runner, "/sbin/lvs", "--noheadings", "-o", "pool_lv", 123 + + runner_add_args (&runner, "lvs", "--noheadings", "-o", "pool_lv", 124 + device, NULL); 125 + runner_redir (&runner, STDOUT_FILENO, RUN_PIPE); 126 + runner_log (&runner, this->name, GF_LOG_DEBUG, msg); 127 + diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c 128 + index 8f8447a..63d8add 100644 129 + --- a/xlators/mgmt/glusterd/src/glusterd-utils.c 130 + +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c 131 + @@ -5899,7 +5899,6 @@ static struct fs_info { 132 + char *fs_tool_pattern; 133 + char *fs_tool_pkg; 134 + } glusterd_fs[] = { 135 + - /* some linux have these in /usr/sbin/and others in /sbin/? */ 136 + { "xfs", "xfs_info", NULL, "isize=", "xfsprogs" }, 137 + { "ext3", "tune2fs", "-l", "Inode size:", "e2fsprogs" }, 138 + { "ext4", "tune2fs", "-l", "Inode size:", "e2fsprogs" }, 139 + @@ -5957,17 +5956,7 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) 140 + cur_word = "N/A"; 141 + goto cached; 142 + } 143 + - 144 + - snprintf (fs_tool_name, sizeof (fs_tool_name), 145 + - "/usr/sbin/%s", fs->fs_tool_name); 146 + - if (sys_access (fs_tool_name, R_OK|X_OK) == 0) 147 + - runner_add_arg (&runner, fs_tool_name); 148 + - else { 149 + - snprintf (fs_tool_name, sizeof (fs_tool_name), 150 + - "/sbin/%s", fs->fs_tool_name); 151 + - if (sys_access (fs_tool_name, R_OK|X_OK) == 0) 152 + - runner_add_arg (&runner, fs_tool_name); 153 + - } 154 + + runner_add_arg (&runner, fs->fs_tool_name); 155 + break; 156 + } 157 + } 158 + -- 159 + 2.7.4 160 +