From nobody Sun Oct 06 11:07:25 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 4XLzyP2m34z5XffS; Sun, 06 Oct 2024 11:07:25 +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 4XLzyP1p0Zz4rw9; Sun, 6 Oct 2024 11:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728212845; 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=vq6UAL2YTyPpn+m7DdrKOrIFtWu4gQppr1+4aAMKQTQ=; b=WU1yC1H+DrBOQ8qnC2JD+8H9PH2u8GFYiRQpFmWrCgBOkqLYKu2CjsF9aA9cYGvRxdLJYn 4AFij/yJO2jlTg17UoKaDB5oWzqqRbPi0wWItBWrBIDs8B1dmZBD7OLdW+qeljYeHcrKfi GdmSBhcQxVdcq20AHei/maDbAVmdoecN8B7NXMh1KsIgpkUtaQ8QLIchK8PZRcfUiFBixF ipc2Uh7zLkyoNWR10P5iCIheSNa1aIi3em+e9O/x/9kTd4MUgc9ue64T77QjNlA5Jz6Gwv FlywHRqzM/1AtfTUKiM2sNwWwa9K/ukjCq8vPnPuwfZFqEZLMhIZPSx12xCdaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728212845; 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=vq6UAL2YTyPpn+m7DdrKOrIFtWu4gQppr1+4aAMKQTQ=; b=sI2SB7ugW8dHgDDV5msNn+wx7SIUfKsx9j85EKR7MRfnlh2lcCdOIk4KbqwfVIl9y0bFCc 4xasfu8+6l+DOvDEUtWTCR+U8BFN8oc9dFshMpjkVA5RsbVxpzV+JuGJXKsgKtYzlateJW IGIWcPIWwz+lq9XATmSzQN1daGAPapr1rm+8BjKhs1QHh9+tY1a8DAEQz7BZmoOw77fVIi AYDDBH3DOuYy8PL+MF0PWrjPwmRoqMKZ9rdFJHdVLLAkS+a3GdD1rbRs06rBIPbCGp18Am QHZi/ve1VLXJDaeI4gMILxUdtoUHlalg36/v7fxCen423x541ZwBRnNUp67jkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728212845; a=rsa-sha256; cv=none; b=irpbMDI5bTif4duU7ccEesxSsR7HqYHCaoHIKUIARJ+xeM4r3CWe0Ez/hkCrlQOwMgwrAz N2hkn9eCcrWtjYoc/Dq3i3sk/pi0TleRkD6Ua1EESQzgJ57ug7zmyVXdLDQFtvHEfRyEsL uGj0Q8sChlxyLmaSfior5z/GBcnOoxF5jTdCgftQRo7+u7IFONIGEIFUv39rb93bEP9dwk QKVC5RhbqX4LWoz/J6URA+fZIzEviHaS0cTKF6xPMiKiUzrF1QfuUsrQT6HdJa60V5dK33 XGZi7Agh/9UCYBbOeAK9MdHPaLrJ/n3s8iEc3+ijmzb0Hi83W03jG7AEDmh3eg== 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 4XLzyP0qs6z10d6; Sun, 6 Oct 2024 11:07:25 +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 496B7Pls039272; Sun, 6 Oct 2024 11:07:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 496B7PIv039268; Sun, 6 Oct 2024 11:07:25 GMT (envelope-from git) Date: Sun, 6 Oct 2024 11:07:25 GMT Message-Id: <202410061107.496B7PIv039268@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: eefeb6ca68bf - stable/13 - locate.updatedb: Explicitly exit from trap code. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eefeb6ca68bf8ef42d4f98fc386288de5b2012c5 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=eefeb6ca68bf8ef42d4f98fc386288de5b2012c5 commit eefeb6ca68bf8ef42d4f98fc386288de5b2012c5 Author: Dag-Erling Smørgrav AuthorDate: 2024-08-29 15:05:47 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-10-06 09:16:34 +0000 locate.updatedb: Explicitly exit from trap code. When a signal is trapped, the script continues after the trap code has run, unless the trap code explicitly exits. In the particular case of locate.updatedb, this is mostly harmless, except that the trap code is executed twice (once for the signal and once when we reach the end of the script), but it's still worth fixing. Furthermore, install the trap as soon as we've created the temporary directory, to minimize the window during which we can fail to clean up after ourselves if interrupted. While here, simplify the empty check at the end and make some minor style tweaks. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D46475 (cherry picked from commit f62c1f3f8e91c78d402e1db4e518e4899a4ba2b9) --- usr.bin/locate/locate/updatedb.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh index e874700afdb8..846fd6dc0d7b 100644 --- a/usr.bin/locate/locate/updatedb.sh +++ b/usr.bin/locate/locate/updatedb.sh @@ -42,13 +42,14 @@ fi # The directory containing locate subprograms : ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR : ${TMPDIR:=/tmp}; export TMPDIR -if ! TMPDIR=`mktemp -d $TMPDIR/locateXXXXXXXXXX`; then +if ! TMPDIR=$(mktemp -d $TMPDIR/locateXXXXXXXXXX); then exit 1 fi +tmp=$TMPDIR/_updatedb$$ +trap 'rc=$?; rm -f $tmp; rmdir $TMPDIR; trap - 0; exit $rc' 0 1 2 3 5 10 15 PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH - : ${mklocatedb:=locate.mklocatedb} # make locate database program : ${FCODES:=/var/db/locate.database} # the database : ${SEARCHPATHS="/"} # directories to be put in the database @@ -87,17 +88,13 @@ if [ -n "$PRUNEDIRS" ]; then done fi -tmp=$TMPDIR/_updatedb$$ -trap 'rm -f $tmp; rmdir $TMPDIR' 0 1 2 3 5 10 15 - # search locally if $find -s $SEARCHPATHS $excludes -or -print 2>/dev/null | $mklocatedb -presort > $tmp then - if [ -n "$($find $tmp -size -257c -print)" ]; then + if ! grep -aq / $tmp; then echo "updatedb: locate database $tmp is empty" >&2 exit 1 - else - cat $tmp > $FCODES # should be cp? fi + install $tmp $FCODES fi