Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1470745imc; Mon, 11 Mar 2019 14:41:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYW9oC4pHruEN6SLyMX6RWjSzLR4cNKF0qD4HFTeEDKoIGLrKzo/9cU/WtSdAVIC8YWZem X-Received: by 2002:a17:902:b20e:: with SMTP id t14mr35348440plr.97.1552340485387; Mon, 11 Mar 2019 14:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552340485; cv=none; d=google.com; s=arc-20160816; b=nVc6EJ9hgjawoNMQYCu8vbG78Kl1Db1Xr+W+73Zr1qX5psM06aK4Un3A+q2w6k6XBk Z6HB8qkZpiT3ktpNQl4GnXbBrLBGTvCvB9BNbh4fZiPKPqKD++WbUF7FSu1kUVolPbUo vezQKselQRmfY0XsiOCBQFTQfFlhNUcTwGUj/R3GlRt1OSoXrTIoAgidx625lrlnYPYf x9j/N5jYpfJLvUlS/Li1v3Me4JSVpH34/pPZQl6y0SY82vPTLfqo12Q0NNXo3ECg+gW1 zzixktfg92C7r8fcMLgPEMDci5M5RtMVF4+jH8oAg9js2x/OcKhTbIE1xhEND/LHkGD7 DISw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=56uzycKYGbQeJ0+a3h+lVj5unZ/ObiXGeBRFwMQZdh4=; b=l219p5Blr/cCNXU6QnQqL1vMljYlK8YrN34jpIzWcfgAti3e8aIZBxTYcVtZjx1Pxy JBes4YSICdTBpiEHeDQyvaycOUuqmUR51a+DW2IRd4aXlN/3ORpO5Ns1G3xouFD8OeET 1QGTMq3dzh/0azqNd8iHz40rUrMThrScI3SqHzjmUYxMpffXAhhGs+kvu6eoMTwbCtd7 UkXrSdX136+5wK7Caqt5eRp5Tk7MPAtY0YNWrkKBThTTnq2X1SoAEJ5LCO3UoX2IcQXe 3I75IEPzZerTpsRKy1QB4IGV87ljmFSj6paHOSVIzrtFT8O89EABOXyPh/P+tr1uTx8U LxxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37si3795011ple.250.2019.03.11.14.41.10; Mon, 11 Mar 2019 14:41:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728322AbfCKVjc (ORCPT + 99 others); Mon, 11 Mar 2019 17:39:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:51400 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727008AbfCKVjc (ORCPT ); Mon, 11 Mar 2019 17:39:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EEC5AABC3; Mon, 11 Mar 2019 21:39:30 +0000 (UTC) Date: Mon, 11 Mar 2019 22:39:29 +0100 From: Petr Vorel To: Mimi Zohar Cc: linux-integrity@vger.kernel.org, linux-kselftest@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Young , Matthew Garrett Subject: Re: [PATCH v3 2/7] selftests/ima: define a set of common functions Message-ID: <20190311213929.GA13024@x230> Reply-To: Petr Vorel References: <1552304473-3966-1-git-send-email-zohar@linux.ibm.com> <1552304473-3966-3-git-send-email-zohar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1552304473-3966-3-git-send-email-zohar@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Reviewed-by: Petr Vorel > Cc: Dave Young 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