From nobody Fri Apr 12 21:36:24 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VGVHr4CqDz5GB98; Fri, 12 Apr 2024 21:36:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VGVHr24ncz4l3V; Fri, 12 Apr 2024 21:36:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712957784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2OjSgmfNnmT7JmQhHkKpqBUjUneKWVV0Bmpd14+TorY=; b=oGI7kv7HJLY28EoZYH6TrARTuF7IvGTxAS9VowA5IKwGghMdfmEtESChdejUn1NPaETN1t Rvx6QEZmk8kldyebrb1PTSCsd3OaeVMjpe/ZZCloJyVmgYj89R5gOqFWTylB28U9ZskorM c2nccVaCL43MWpTiimtFUusq/sy/e0rOesqfrcYkTvhbpSuRhPJ9uc87Y68XqXQPUDIWXM jUN/q4RxHqFn0+9oKyYkRZQuUau+7jCH9DLnFPHHM8IXWdQf3eHehMA0Rp7fNj91KRSvPU UIXV5i7FGIjrceWmgE7cqf1U6Iq0EUAyZz/9CmvHsXhqJR8BNL9FRoHXpjkojg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712957784; a=rsa-sha256; cv=none; b=eSVHXGta6j8R8BWHaoYTW2hjXmFsx4t4JwB8CFDIQKSb3ASJ0dAsVOfhxjX1ghFnYQ8XoL fbj1QcPUhYd0gTddMdpg553sPoZJMMi5E4c+MI47cwDL048XzzFjSLu7f0Y5iZbYE1yk5H D/+hMBv/rVOlL7AiR36pkh/a03DinMrN223e0v2fMyEWgeKzLeHQEX8gMzp5EjoZ01wLVN 8+jYOdSTZn5cis4RCoTf4KcKhgr6+eW2kt24s3TEr7PZ5GXqnq3LA8y60T6d9f6NY0gOag RDey7GvvCSkeUrWJ0r/Hg4tCu+HKCOg1iuMKgkpAhAHmwtgvyXVWMsT9U163KQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712957784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2OjSgmfNnmT7JmQhHkKpqBUjUneKWVV0Bmpd14+TorY=; b=wYPhE+Ltz9TRCHv2LCRFrtyDYX1lKqhZdOiJ9reZ5gji+X3RydB9XA/hiB66MYsWqNYArZ 00IaBUQCN1jKPidcJzm04qEYi58ivcw7InoTwJwH7T+SrPPpm6ULMiuAwUIgGMzoZ4hNyI b78yMHAG8AL8Rtas5pZkmRnwZ1AMnjOM37GeJzVldRtbnMAtgSqMMQhqrnCFluxFCdLKUi vBzZjSihM+8foOzxxT5pe4CLDQX9uXsWap+qadHv82KuFuZavj27zQg/B8jrA8hthI9kRL R2+9vJF8+LtMgsoeiAtygkuUUW07SiLX6nPbn1ZdQxCUjJ2G8fSteklh/mHCDA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VGVHr1Zgwz15gP; Fri, 12 Apr 2024 21:36:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43CLaOIu016229; Fri, 12 Apr 2024 21:36:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43CLaOPJ016226; Fri, 12 Apr 2024 21:36:24 GMT (envelope-from git) Date: Fri, 12 Apr 2024 21:36:24 GMT Message-Id: <202404122136.43CLaOPJ016226@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e6e38bc522e2 - main - rc.d/ldconfig: Compute ldconfig paths in a function List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e6e38bc522e29de6299536b547bf11dab11e9679 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e6e38bc522e29de6299536b547bf11dab11e9679 commit e6e38bc522e29de6299536b547bf11dab11e9679 Author: Konrad Witaszczyk AuthorDate: 2024-04-12 21:34:59 +0000 Commit: John Baldwin CommitDate: 2024-04-12 21:34:59 +0000 rc.d/ldconfig: Compute ldconfig paths in a function Move logic that computes paths passed to ldconfig(8) to a ldconfig_paths() function that can be called for multiple ABIs. Reviewed by: olce, kib Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D44751 --- libexec/rc/rc.d/ldconfig | 55 +++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/libexec/rc/rc.d/ldconfig b/libexec/rc/rc.d/ldconfig index 5c404a823dbb..fd54b2d3444e 100755 --- a/libexec/rc/rc.d/ldconfig +++ b/libexec/rc/rc.d/ldconfig @@ -14,6 +14,31 @@ ldconfig_command="/sbin/ldconfig" start_cmd="ldconfig_start" stop_cmd=":" +ldconfig_paths() +{ + local _dirs _files _ii _ldpaths _paths + + _dirs="${1}" + _paths="${2}" + _ldpaths="${3}" + + for _ii in ${_dirs}; do + if [ -d "${_ii}" ]; then + _files=`find ${_ii} -type f` + if [ -n "${_files}" ]; then + _paths="${_paths} `cat ${_files} | sort -u`" + fi + fi + done + for _ii in ${_paths}; do + if [ -r "${_ii}" ]; then + _ldpaths="${_ldpaths} ${_ii}" + fi + done + + echo "${_ldpaths}" +} + ldconfig_start() { local _files _ins @@ -23,31 +48,12 @@ ldconfig_start() checkyesno ldconfig_insecure && _ins="-i" if [ -x "${ldconfig_command}" ]; then _LDC=$(/libexec/ld-elf.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' ') - for i in ${ldconfig_local_dirs}; do - if [ -d "${i}" ]; then - _files=`find ${i} -type f` - if [ -n "${_files}" ]; then - ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`" - fi - fi - done - for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do - if [ -r "${i}" ]; then - _LDC="${_LDC} ${i}" - fi - done + _LDC=$(ldconfig_paths "${ldconfig_local_dirs}" \ + "${ldconfig_paths} /etc/ld-elf.so.conf" "$_LDC") startmsg 'ELF ldconfig path:' ${_LDC} ${ldconfig} -elf ${_ins} ${_LDC} if check_kern_features compat_freebsd32; then - for i in ${ldconfig_local32_dirs}; do - if [ -d "${i}" ]; then - _files=`find ${i} -type f` - if [ -n "${_files}" ]; then - ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`" - fi - fi - done _LDC="" if [ -x /libexec/ld-elf32.so.1 ]; then for x in $(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' '); do @@ -56,11 +62,8 @@ ldconfig_start() fi done fi - for i in ${ldconfig32_paths}; do - if [ -r "${i}" ]; then - _LDC="${_LDC} ${i}" - fi - done + _LDC=$(ldconfig_paths "${ldconfig_local32_dirs}" \ + "${ldconfig32_paths}" "$_LDC") startmsg '32-bit compatibility ldconfig path:' ${_LDC} ${ldconfig} -32 ${_ins} ${_LDC} fi