3bb48c0
From 085cc4ff56857d234e80f37d0316c13eb5718696 Mon Sep 17 00:00:00 2001
3bb48c0
From: Kamil Dudka <kdudka@redhat.com>
3bb48c0
Date: Tue, 3 Jul 2018 10:46:58 +0200
3bb48c0
Subject: [PATCH] test/runwrapper: copy the preloaded library
3bb48c0
3bb48c0
... to a temporary directory because the original location might
3bb48c0
not be accessible by other users.
3bb48c0
---
3bb48c0
 test/runwrapper | 20 ++++++++++++++++++--
3bb48c0
 1 file changed, 18 insertions(+), 2 deletions(-)
3bb48c0
3bb48c0
diff --git a/test/runwrapper b/test/runwrapper
3bb48c0
index 6e0e899..de4555a 100755
3bb48c0
--- a/test/runwrapper
3bb48c0
+++ b/test/runwrapper
3bb48c0
@@ -1,7 +1,23 @@
3bb48c0
 #!/bin/bash
3bb48c0
 
3bb48c0
-if [ -e "$PWD/.libs/libtestlookup.so" ]; then
3bb48c0
-	export LD_PRELOAD="$PWD/.libs/libtestlookup.so"
3bb48c0
+src="$PWD/.libs/libtestlookup.so"
3bb48c0
+dst=
3bb48c0
+if [ -e "$src" ]; then
3bb48c0
+	# copy the preloaded library to a temporary directory because
3bb48c0
+	# the original location might not be accessible by other users
3bb48c0
+	tmp="$(mktemp -d)"
3bb48c0
+	chmod 0755 "$tmp"
3bb48c0
+	dst="${tmp}/libtestlookup.so"
3bb48c0
+	cp -L "$src" "$dst"
3bb48c0
+	export LD_PRELOAD="$dst"
3bb48c0
 fi
3bb48c0
 
3bb48c0
 "${srcdir:-${PWD}}"/test/run "$@"
3bb48c0
+ec="$?"
3bb48c0
+
3bb48c0
+if [ -n "$dst" ]; then
3bb48c0
+	# remove the temporary location
3bb48c0
+	rm -rf "$dst"
3bb48c0
+fi
3bb48c0
+
3bb48c0
+exit "$ec"
3bb48c0
-- 
3bb48c0
2.14.4
3bb48c0