public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Mimi Zohar <zohar@linux.ibm.com>
Cc: linux-integrity@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	Dave Young <dyoung@redhat.com>,
	Matthew Garrett <mjg59@google.com>
Subject: Re: [PATCH v3 2/7] selftests/ima: define a set of common functions
Date: Mon, 11 Mar 2019 22:39:29 +0100	[thread overview]
Message-ID: <20190311213929.GA13024@x230> (raw)
In-Reply-To: <1552304473-3966-3-git-send-email-zohar@linux.ibm.com>

Hi Mimi,

> Define, update and move get_secureboot_mode() to a common file for use
> by other tests.

> Updated to check both the efivar SecureBoot-$(UUID) and
> SetupMode-$(UUID), based on Dave Young's review.

> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Cc: Dave Young <dyoung@redhat.com>

Minor comment below.

...
> +++ b/tools/testing/selftests/ima/ima_common_lib.sh
> @@ -0,0 +1,36 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# Check efivar SecureBoot-$(the UUID) and SetupMode-$(the UUID).
> +# The secure boot mode can be accessed either as the last integer
> +# of "od -An -t u1 /sys/firmware/efi/efivars/SecureBoot-*" or from
> +# "od -An -t u1 /sys/firmware/efi/vars/SecureBoot-*/data".  The efi
> +# SetupMode can be similarly accessed.
> +# Return 1 for SecureBoot mode enabled and SetupMode mode disabled.
> +get_secureboot_mode()
> +{
> +	local efivarfs="/sys/firmware/efi/efivars"
> +	local secure_boot_file=$efivarfs/../vars/SecureBoot-*/data
> +	local setup_mode_file=$efivarfs/../vars/SetupMode-*/data
Sorry for nitpicking, but also quote variables these two variables
containing string:
	local secure_boot_file="$efivarfs/../vars/SecureBoot-*/data"
	local setup_mode_file="$efivarfs/../vars/SetupMode-*/data"

> +	local secureboot_mode=0
> +	local setup_mode=0
> +
> +	# Make sure that efivars is mounted in the normal location
> +	if ! grep -q "^\S\+ $efivarfs efivarfs" /proc/mounts; then
> +		log_skip "efivars is not mounted on $efivarfs"
> +	fi
> +
> +	if [ ! -e $secure_boot_file ] || [ ! -e $setup_mode_file ]; then
I prefer to quote every variable in [ ] (at least for -f -e -z -n,
to prevent shell behavior on empty (I know it's not necessary here):

f=; [ -e $f ]; echo $?
0
vs.
f=; [ -e "$f" ]; echo $?
1


Kind regards,
Petr

  reply	other threads:[~2019-03-11 21:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 11:41 [PATCH v3 0/7] selftests/ima: add kexec and kernel module tests Mimi Zohar
2019-03-11 11:41 ` [PATCH v3 1/7] selftests/ima: cleanup the kexec selftest Mimi Zohar
2019-03-11 11:41 ` [PATCH v3 2/7] selftests/ima: define a set of common functions Mimi Zohar
2019-03-11 21:39   ` Petr Vorel [this message]
2019-03-11 11:41 ` [PATCH v3 3/7] selftests/ima: define common logging functions Mimi Zohar
2019-03-11 11:41 ` [PATCH v3 4/7] kselftest/ima: define "require_root_privileges" Mimi Zohar
2019-03-11 11:41 ` [PATCH v3 5/7] selftests/ima: kexec_file_load syscall test Mimi Zohar
2019-03-12 12:10   ` Dave Young
2019-03-12 16:51     ` Mimi Zohar
2019-03-13 10:14       ` Petr Vorel
2019-03-14 18:38         ` Mimi Zohar
2019-03-11 11:41 ` [PATCH v3 6/7] selftests/ima: loading kernel modules Mimi Zohar
2019-03-11 11:41 ` [PATCH v3 7/7] selftests/ima: Add missing '=y' to config options Mimi Zohar
2019-03-11 21:51 ` [PATCH v3 0/7] selftests/ima: add kexec and kernel module tests Petr Vorel

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=20190311213929.GA13024@x230 \
    --to=pvorel@suse.cz \
    --cc=dyoung@redhat.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mjg59@google.com \
    --cc=zohar@linux.ibm.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