From nobody Tue Aug 27 21:26:37 2024 X-Original-To: dev-commits-src-all@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 4WtgbK3r9hz5MR0B; Tue, 27 Aug 2024 21:26:37 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WtgbK2wvDz4y1N; Tue, 27 Aug 2024 21:26:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724793997; 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=DdS3BQaBzhuhSF3a42EVj11hy9gn6L8LhexXkXYm1bA=; b=AFeSWdWG1Tn022w7OY2AOZ+XoERr3MVzaPAOOKDy+ZCxhq9b2/nJiCV9z2WBiLpzu2Sizo y9IagINnFCC+AyaH66QuGRi1e+C58K//3d6qgQjsp9w87MjI56Xdo2aOVp7/d/WVvRBryJ r/0KxFkEfUZszGhOmAb/puCpwh9a/fcmWM4sg0ELMg2sFEZ3LnxDbrEvfOCFMaVlrrDLFK uVyJ/TGdo5NlTJPN7WfpD8DZ2DfJ+OhoVeh3pKhrtKKvz8QGrUdMkqW4/MObd3CPbPiV+l zwRgpZ8aK1AGWhusjPtqfct7xQf3wC3n3ljrW/x7XzKZtSsrbsqUokAq1qniKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724793997; a=rsa-sha256; cv=none; b=qf7nl2/bIzuoStlQ5LDCXfXe2r+m6TLky6ZVnPLfcclBwOmwj1MyHoQzihRgBPet882W4F Ghdxx6kL7MXzBF6g2J8/dj8OoVtVoPoY3AEFTdm8BWe933g4M9uZbJQ6otw9WlozG+IcuT Pq5sL86jl+WUKaEYvinEvF9klTfLaAaX2oXO2iBPeOtujn+4PnR6+/u31UfAyPJM9tvv2G 4L3Fd7+HSrjzkWuvo72c8CZ3Magxq9imQwIeofsmiEoUIQip3zOL+3Fy6yHpwSHCO/tf0m FexLZZQosC+q9SvDPQl682xJyFTH6vAEHK2lBqeSZ1bjARFXZTC/QRwrB2r8dg== 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=1724793997; 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=DdS3BQaBzhuhSF3a42EVj11hy9gn6L8LhexXkXYm1bA=; b=bP2nQVm58HFPxq8g89XsBiep/wuLNMsCkODQ7jYpH8+yYI9Nnfrfdyvx+1ahjhyKR8xXL3 jg2+d3UyiGDh0/NnkmtB3DX5TNLOrSAOLabMiOiuD7MUJKOcnQ7DzGdFsBbaxjSTySeA4p xQ5S8Hpk40FaXk4p8KePX6RE6ViRVc5w4FWIJU1BX8vwSr1WGydNesdC6MM8XeQs7Iel88 p+gAVflDiX0n4jmbiT4fKtNoY5z44KSoNYddXVnQc6xZtgez3b2+CiGcrdH18Frz6nWKsz p05wQupzWBVMB+OwBNUTGnuClCgkIUN+obkPPiAwhbDJ0Km1aS4I75G7JEwvVA== 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 4WtgbK29mlz15B0; Tue, 27 Aug 2024 21:26:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47RLQbui034390; Tue, 27 Aug 2024 21:26:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47RLQbYT034387; Tue, 27 Aug 2024 21:26:37 GMT (envelope-from git) Date: Tue, 27 Aug 2024 21:26:37 GMT Message-Id: <202408272126.47RLQbYT034387@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: ee104259c72c - stable/14 - rc.d/ldconfig: Compute ldconfig paths in a function List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: ee104259c72c24ca2495f7d7c4aac2672c010478 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ee104259c72c24ca2495f7d7c4aac2672c010478 commit ee104259c72c24ca2495f7d7c4aac2672c010478 Author: Konrad Witaszczyk AuthorDate: 2024-04-12 21:34:59 +0000 Commit: John Baldwin CommitDate: 2024-08-27 18:15:48 +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 (cherry picked from commit e6e38bc522e29de6299536b547bf11dab11e9679) --- 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