From nobody Fri Aug 16 20:16:41 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 4WltYk0fWFz5TVS4; Fri, 16 Aug 2024 20:16:42 +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 4WltYj5265z46KW; Fri, 16 Aug 2024 20:16:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723839401; 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=oFH3qfbn/M5LFWbFWjty5ZsMrrEWZe71OkAjAkE9sfk=; b=AlPHlcSNhJpnq/cniLSUBuHWIZxeLy8t9K6MslpDo/dp9Ui1WyJ7lyDr97XSAnHAfqq+Fw 4UDJATuKqW2WFnn2P2I0Qp0es275X5m8KR1PiHWB6rQWxlwMSgk7UoF0Jg8Za9jNnnri8f TBvWIAQCgQiq6Yy2JdHvsV3nCYXAZsWZvoKgA3EBOJqYZKNsxLzKNPX3xZut52HQZO80sA nUZVfxuA85DPAw9RxcRblp2uH0EREQDcgSuyta7b3AB++z7zEO4Q8jhXmFLl2GdRwx5jyo W6RoI/yldzoVyGURmZANBZlaXDLFoM5qTuitEsmK7jh0DMNsMDIxN3rLNZjcHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723839401; a=rsa-sha256; cv=none; b=xfccFqua9lmg5hRR7f5Q5g9N2HYum53CiR9K8za+1zK7042WGMKIRwolFxQniz6uuVFqg9 fmuBfcrY2v4HmCCXrUgVTOeCRN9KvU+oOIalz4I5y0GoHNyMZKF9gndogknlzyAffDml6T Vkj4mlz3zNGMG2svIQBRIJDmA8CZFw9vC4gAP+Sg5bsLcrRd6nFxaGoG6KzECesG3ZW01d ZUsgMYejD+95uaY6CC/UyQJYf9JOz5cg/+qU7Y5IgaDDL8zGVRFUzQWHAHszXqtwtBtZOh U/YBlgJfk4Jci22eEuFpLeYi+d5+Vf/EnO3KrLhopxDHQxqdwsrPlXa7mDCKgw== 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=1723839401; 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=oFH3qfbn/M5LFWbFWjty5ZsMrrEWZe71OkAjAkE9sfk=; b=EGXTcsnmLEHX5AmymO9Jos+NEiGohFYBvdKq4NE4k996NHLP+nqSdgC36lOF8AxbDwVlf6 9cilBPKAxmfUpyn+8MwsOtsAAOLY+1WCwmw6jacI3WofMKUE1YgAaqrU5D43/a5WKVmxZO gboiviQnbrKYtz6owqs3NJMWJWCTwb4fgimMGBD7wLuoUOYru3b3SaV7OjadqshUwZCtR8 u7wIOHuaWif7XrCnNCqJGby4dPu52fgkkx/kOVeZKyOvCY2Eo8mAiNroJEqrmlJBPfay8d 1/29r4t6ho4bhTKyVGlYMt79MKuu+XyjiIJ0hQyfq6ri1ZErjafL6jtUnPISYA== 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 4WltYj4VnqzLJT; Fri, 16 Aug 2024 20:16:41 +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 47GKGfkc054933; Fri, 16 Aug 2024 20:16:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47GKGfpY054930; Fri, 16 Aug 2024 20:16:41 GMT (envelope-from git) Date: Fri, 16 Aug 2024 20:16:41 GMT Message-Id: <202408162016.47GKGfpY054930@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Simon J. Gerraty" Subject: git: 35399f68c8e8 - main - safe_dot check file is a file 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 Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35399f68c8e8a9b3bb4905057ca59766751766f3 Auto-Submitted: auto-generated The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=35399f68c8e8a9b3bb4905057ca59766751766f3 commit 35399f68c8e8a9b3bb4905057ca59766751766f3 Author: Simon J. Gerraty AuthorDate: 2024-08-16 20:15:20 +0000 Commit: Simon J. Gerraty CommitDate: 2024-08-16 20:15:20 +0000 safe_dot check file is a file Since we are being paranoid, check that each arg to safe_dot is actually a file as well as non-empty. Check for white-space in filenames - these require special handling. --- libexec/rc/safe_eval.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libexec/rc/safe_eval.sh b/libexec/rc/safe_eval.sh index 0e1410b771cb..d03eacbdff72 100644 --- a/libexec/rc/safe_eval.sh +++ b/libexec/rc/safe_eval.sh @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-2-Clause # RCSid: -# $Id: safe_eval.sh,v 1.16 2024/08/15 02:28:30 sjg Exp $ +# $Id: safe_eval.sh,v 1.20 2024/08/16 00:57:58 sjg Exp $ # # @(#) Copyright (c) 2023-2024 Simon J. Gerraty # @@ -54,9 +54,10 @@ safe_eval_export() { # feed all "file" that exist to safe_eval # safe_dot() { - eval ${local:-:} ef ex f + eval ${local:-:} ef ex f rc ef= ex= + rc=1 while : do case "$1" in @@ -66,11 +67,20 @@ safe_dot() { done for f in "$@" do - test -s $f || continue + test -s "$f" -a -f "$f" || continue + : check for space or tab in "$f" + case "$f" in + *[[:space:]]*|*" "*|*" "*) # we cannot do this efficiently + dotted="$dotted $f" + safe_eval$ex "$f" + rc=$? + continue + ;; + esac ef="${ef:+$ef }$f" dotted="$dotted $f" done - test -z "$ef" && return 1 + test -z "$ef" && return $rc safe_eval$ex $ef return 0 }