Skip to contentSkip to conversation

infra: do not append an empty LD_LIBRARY_PATH

PATCH New Yann E. MORIN 3 participants 3 messages Nov 21, 2014 – Nov 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infra: do not append an empty LD_LIBRARY_PATH

When we set LD_LIBRARY_PATH when building our host tools, we append any pre-existing value to our custom path:

        LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"

But then if LD_LIBRARY_PATH was previously empty, we end up with an LD_LIBRARY_PATH that ends with a colon.

Also, when we check that an existing LD_LIBRARY_PATH does not contain CWD, we previously did not look for a zero-length prefix.

Since 'man ld.so' says of LD_LIBRARY_PATH:
A colon-separated list of directories in which to search for ELF libraries at execution-time. Similar to the PATH environment variable.

And POSIX states about PATH:
A zero-length prefix is a legacy feature that indicates the current working directory.

And bash also recognises a zero-length prefix to searh in CWD:
A zero-length (null) directory name in the value of PATH indicates the current directory.

We may thus end up on a system where a zero-length prefix in LD_LIBRARY_PATH is interpreted as VWD.

Do not append the previous LD_LIBRARY_PATH if it was empty, and check for a zero-length prefix when checking dependencies.

Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>

---
Note: I have had no bug that was due to this, but better be safe than sorry.

---
 package/Makefile.in                  | 4 ++--
 support/dependencies/dependencies.sh | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)
package/Makefile.in +2 -2
index df39afd..36ecf0b 100644
@@ -307,11 +307,11 @@ HOST_CONFIGURE_OPTS = PATH=$(BR_PATH) \
 		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
 		PKG_CONFIG_SYSROOT_DIR="/" \
 		PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig" \
-		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)" \
+		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))" \
 		INTLTOOL_PERL=$(PERL)
 
 HOST_MAKE_ENV = PATH=$(BR_PATH) \
-		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)" \
+		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))" \
 		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
 		PKG_CONFIG_SYSROOT_DIR="/" \
 		PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig"
support/dependencies/dependencies.sh +3 -0
index a9c5b31..af5ce0e 100755
@@ -14,8 +14,11 @@ fi
 # sanity check for CWD in LD_LIBRARY_PATH
 # try not to rely on egrep..
 if test -n "$LD_LIBRARY_PATH" ; then
+	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep '::' >/dev/null 2>&1 ||
 	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':\.:' >/dev/null 2>&1 ||
+	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start:' >/dev/null 2>&1 ||
 	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start\.:' >/dev/null 2>&1 ||
+	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':TRiGGER_end' >/dev/null 2>&1 ||
 	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
 	echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
 	if test $? = 0; then
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 infra: do not append an empty LD_LIBRARY_PATH

Hi Yann,

Quoted 19 lines · Yann E. MORIN

When we set LD_LIBRARY_PATH when building our host tools, we append any pre-existing value to our custom path:

        LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"

But then if LD_LIBRARY_PATH was previously empty, we end up with an LD_LIBRARY_PATH that ends with a colon.

Also, when we check that an existing LD_LIBRARY_PATH does not contain CWD, we previously did not look for a zero-length prefix.

Since 'man ld.so' says of LD_LIBRARY_PATH:
A colon-separated list of directories in which to search for ELF libraries at execution-time. Similar to the PATH environment variable.

And POSIX states about PATH:
A zero-length prefix is a legacy feature that indicates the current working directory.

Quoted 6 lines

And bash also recognises a zero-length prefix to searh in CWD:
A zero-length (null) directory name in the value of PATH indicates the current directory.

We may thus end up on a system where a zero-length prefix in LD_LIBRARY_PATH is interpreted as VWD.

s/VWD/CWD/

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 infra: do not append an empty LD_LIBRARY_PATH

In reply to Yann E. MORIN
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

When we set LD_LIBRARY_PATH when building our host tools, we append any pre-existing value to our custom path:

        LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"

But then if LD_LIBRARY_PATH was previously empty, we end up with an LD_LIBRARY_PATH that ends with a colon.

Also, when we check that an existing LD_LIBRARY_PATH does not contain CWD, we previously did not look for a zero-length prefix.

Since 'man ld.so' says of LD_LIBRARY_PATH:
A colon-separated list of directories in which to search for ELF libraries at execution-time. Similar to the PATH environment variable.

And POSIX states about PATH:
A zero-length prefix is a legacy feature that indicates the current working directory.

And bash also recognises a zero-length prefix to searh in CWD:
A zero-length (null) directory name in the value of PATH indicates the current directory.

We may thus end up on a system where a zero-length prefix in LD_LIBRARY_PATH is interpreted as VWD.

Do not append the previous LD_LIBRARY_PATH if it was empty, and check for a zero-length prefix when checking dependencies.

Quoted 7 lines
Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>

---
Note: I have had no bug that was due to this, but better be safe than sorry.

Committed with the /VWD/CWD/ typo fixed, thanks.

Signature · 1 line
Bye, Peter Korsgaard