From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 01/23] iotests: Introduce $SOCK_DIR
Date: Thu, 17 Oct 2019 09:52:51 -0500 [thread overview]
Message-ID: <b8251992-a52b-f605-e45e-edf381394130@redhat.com> (raw)
In-Reply-To: <20191017133155.5327-2-mreitz@redhat.com>
On 10/17/19 8:31 AM, Max Reitz wrote:
> Unix sockets generally have a maximum path length. Depending on your
> $TEST_DIR, it may be exceeded and then all tests that create and use
> Unix sockets there may fail.
>
> Circumvent this by adding a new scratch directory specifically for
> Unix socket files. It defaults to a temporary directory (mktemp -d)
> that is completely removed after the iotests are done.
>
> (By default, mktemp -d creates a /tmp/tmp.XXXXXXXXXX directory, which
> should be short enough for our use cases.)
>
> Use mkdir -p to create the directory (because it seems right), and do
> the same for $TEST_DIR (because there is no reason for that to be
> created in any different way).
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> tests/qemu-iotests/check | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
> @@ -116,10 +117,14 @@ set_prog_path()
> if [ -z "$TEST_DIR" ]; then
> TEST_DIR=$PWD/scratch
> fi
> +mkdir -p "$TEST_DIR" || _init_error 'Failed to create TEST_DIR'
This one seems fine. We are either using the user's name (and if it is
pre-existing, not fail) or using a well-known name (if someone else
slams in files into that directory in parallel with our test run, oh
well). But at least the well-known name is a directory that is probably
already accessible only to the current user, not world-writable.
>
> -if [ ! -e "$TEST_DIR" ]; then
> - mkdir "$TEST_DIR"
> +tmp_sock_dir=false
> +if [ -z "$SOCK_DIR" ]; then
> + SOCK_DIR=$(mktemp -d)
> + tmp_sock_dir=true
> fi
> +mkdir -p "$SOCK_DIR" || _init_error 'Failed to create SOCK_DIR'
Thinking about this again: if the user passed in a name, we probably
want to use it no matter whether the directory already exists (mkdir -p
makes sense: either the directory did not exist, or the user is in
charge of passing us a directory that they already secured). But if we
generate our own name in a world-writable location in /tmp, using mkdir
-p means someone else can race us to the creation of the directory, and
potentially populate it in a way to cause us a security hole while we
execute our tests.
I would be a bit more comfortable with:
tmp_sock_dir=false
tmp_sock_opt=-p
if [ -z "$SOCK_DIR" ]; then
SOCK_DIR=$(mktemp -d)
tmp_sock_dir=true
tmp_sock_opt= # disable -p for our generated name
fi
mkdir $tmp_sock_opt "$SOCK_DIR" || _init_error 'Failed to create SOCK_DIR'
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2019-10-17 15:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 13:31 [PATCH v2 00/23] iotests: Add and use $SOCK_DIR Max Reitz
2019-10-17 13:31 ` [PATCH v2 01/23] iotests: Introduce $SOCK_DIR Max Reitz
2019-10-17 14:52 ` Eric Blake [this message]
2019-10-18 9:03 ` Max Reitz
2019-10-18 13:30 ` Eric Blake
2019-10-17 13:31 ` [PATCH v2 02/23] iotests.py: Store socket files in $SOCK_DIR Max Reitz
2019-10-17 13:31 ` [PATCH v2 03/23] iotests.py: Add @base_dir to FilePaths etc Max Reitz
2019-10-17 13:31 ` [PATCH v2 04/23] iotests: Filter $SOCK_DIR Max Reitz
2019-10-17 15:50 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 05/23] iotests: Let common.nbd create socket in $SOCK_DIR Max Reitz
2019-10-17 15:52 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 06/23] iotests/083: Create " Max Reitz
2019-10-17 13:31 ` [PATCH v2 07/23] iotests/140: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 08/23] iotests/143: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 09/23] iotests/147: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 10/23] iotests/181: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 11/23] iotests/182: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 12/23] iotests/183: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 13/23] iotests/192: " Max Reitz
2019-10-17 15:53 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 14/23] iotests/194: Create sockets " Max Reitz
2019-10-17 13:31 ` [PATCH v2 15/23] iotests/201: Create socket " Max Reitz
2019-10-17 15:55 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 16/23] iotests/205: " Max Reitz
2019-10-17 15:56 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 17/23] iotests/208: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 18/23] iotests/209: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 19/23] iotests/222: " Max Reitz
2019-10-17 13:31 ` [PATCH v2 20/23] iotests/223: " Max Reitz
2019-10-17 15:57 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 21/23] iotests/240: " Max Reitz
2019-10-17 15:57 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 22/23] iotests/267: " Max Reitz
2019-10-17 15:58 ` Thomas Huth
2019-10-17 13:31 ` [PATCH v2 23/23] iotests: Drop TEST_DIR filter from _filter_nbd Max Reitz
2019-10-17 15:58 ` Thomas Huth
2019-10-17 14:59 ` [PATCH v2 00/23] iotests: Add and use $SOCK_DIR Eric Blake
2019-10-18 16:02 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b8251992-a52b-f605-e45e-edf381394130@redhat.com \
--to=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).