From owner-dev-commits-src-main@freebsd.org Tue Jan 19 11:56:51 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA1904F0E2D; Tue, 19 Jan 2021 11:56:51 +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 4DKnFH5RCjz3KNS; Tue, 19 Jan 2021 11:56:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AD688260A8; Tue, 19 Jan 2021 11:56:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10JBupCt021545; Tue, 19 Jan 2021 11:56:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10JBuptZ021544; Tue, 19 Jan 2021 11:56:51 GMT (envelope-from git) Date: Tue, 19 Jan 2021 11:56:51 GMT Message-Id: <202101191156.10JBuptZ021544@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Stefan Eßer Subject: git: 24f44a445c48 - main - Remove dependency on files in /usr/bin MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 24f44a445c4875a329d3947c50083f3e8b9b37db Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 11:56:51 -0000 The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=24f44a445c4875a329d3947c50083f3e8b9b37db commit 24f44a445c4875a329d3947c50083f3e8b9b37db Author: Stefan Eßer AuthorDate: 2021-01-19 11:46:52 +0000 Commit: Stefan Eßer CommitDate: 2021-01-19 11:56:23 +0000 Remove dependency on files in /usr/bin In order to reduce the pre-requisites of this file, implement the pattern matching and creation of a temporary test directory without use of grep respectively mktemp. The new version makes it possible to provide a writable /tmp in any case and independently of other local or remote file systems (except / and /dev) being mounted. The use of "dd if=/dev/random" has the same dependency on /dev/random being operational as the previous version that used "mktemp". If this is found to be an issue on platforms that do not have gathered sufficient entropy at the time when this scriot is run, I suggest to replace the "dd" command with "ps lauxww" to get a somewhat random test directory name. Approved by: rgrimes, glebius, cy MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D28209 --- libexec/rc/rc.d/tmp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libexec/rc/rc.d/tmp b/libexec/rc/rc.d/tmp index a61321e058ee..7d270335cb27 100755 --- a/libexec/rc/rc.d/tmp +++ b/libexec/rc/rc.d/tmp @@ -40,10 +40,16 @@ load_rc_config $name mount_tmpmfs() { - if ! /bin/df /tmp | grep -q "^/dev/md[0-9].* /tmp"; then - mount_md ${tmpsize} /tmp "${tmpmfs_flags}" - chmod 01777 /tmp - fi + while read line; do + case $line in + /dev/md[0-9]*\ /tmp) + return;; + esac + done <<*EOF +$(df /tmp) +*EOF + mount_md ${tmpsize} /tmp "${tmpmfs_flags}" + chmod 01777 /tmp } # If we do not have a writable /tmp, create a memory @@ -52,7 +58,8 @@ mount_tmpmfs() # case "${tmpmfs}" in [Aa][Uu][Tt][Oo]) - if _tmpdir=$(mktemp -d -q /tmp/.diskless.XXXXXX); then + _tmpdir=/tmp/.diskless.$(dd if=/dev/random bs=32 count=1 status=none | sha256) + if mkdir -m 0700 ${_tmpdir}; then rmdir ${_tmpdir} else if [ -h /tmp ]; then