git: 806e4e3273be - main - ldconfig: filter out non-existing directories from default path

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 20 Nov 2023 11:27:10 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=806e4e3273bee2e3a12ffc2e74db5c912fbd7aa9

commit 806e4e3273bee2e3a12ffc2e74db5c912fbd7aa9
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-11-16 05:38:00 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-11-20 11:26:00 +0000

    ldconfig: filter out non-existing directories from default path
    
    This is done only for ld-elf32.so.1, where /lib32 is kept in the path
    due to the way STANDARD_LIBRARY_PATH is defined in rtld_paths.h.
    
    This change fixes innocent warning appearing after
    99132daf6f70cb0cc969c555d3612547fa3cf1db
    
    Reviewed by:    dim, emaste
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D42626
---
 libexec/rc/rc.d/ldconfig | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libexec/rc/rc.d/ldconfig b/libexec/rc/rc.d/ldconfig
index ecbbca210ea0..ed3484017d84 100755
--- a/libexec/rc/rc.d/ldconfig
+++ b/libexec/rc/rc.d/ldconfig
@@ -53,7 +53,11 @@ ldconfig_start()
 			done
 			_LDC=""
 			if [ -x /libexec/ld-elf32.so.1 ]; then
-				_LDC=$(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' ')
+				for x in $(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' '); do
+					if [ -d "${x}" ]; then
+						_LDC="${_LDC} ${x}"
+					fi
+				done
 			fi
 			for i in ${ldconfig32_paths}; do
 				if [ -r "${i}" ]; then