Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3096304ima; Sun, 3 Feb 2019 13:27:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IYaWORh6m6EyaeulPChICU+NaZDW/C04PGIFl4Mu4RIhJLLvJapGXrjXpppN9SBquR2V1dh X-Received: by 2002:a63:5402:: with SMTP id i2mr10268317pgb.79.1549229228205; Sun, 03 Feb 2019 13:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549229228; cv=none; d=google.com; s=arc-20160816; b=c+kVQjE8NYfMQi7BfY8aK+97K498ZbQ0fNy7JTM7Z/K0Daicym/7w62HXkOSN1BjQ9 ql0XEQE0sPtUrAUXbjAMdgC8YM+o9a3Qq4Esv6E9x8tC77w2VBl7bjzfmQWmWBVCsLwr vWYVFMQZeFH3p56vG4XZLkDVNgPKa2YIU8NwAyVPjbSC+dVWZvXtUt9mDXSvUqJECDKX R08nw6bElG42kSjupMlXqm8vae8TVgmEfpB70z2imawBbjJjRSPp+boYCNtx5WACosmH KBuROXDsqjPRbNvHK8dZIcc6+RnAnHGlWt6rqei8SWWdoQL85WF6600Eoa+7YuwATssf AEZQ== 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=J5uJILU1cU62+jo402h2cuoiNqg8FyTGq//l6z7jpbg=; b=fVHsyzq4e1c1Jve0cFXVtDyvz2zy+0kOD7BZiZ8zsOCNnD0u9sxBQcsEe7N9bck+Ma tXgLy3al/xNHsTuMrsx/MdxMhFowKtcsb6t3QB10oJLF5Kj604c9B//v9E8LMrUoU/94 TgjHnu/OBBf6DmXYRCmOQZWmm16BUpyT4wATPT0A5LmWBz6bvMbAcVNkxoi17rvYxeAH +32xGQ9UNul8+il94AyETvMuGFy895do7ax6SAwmdy/lNcB9aZu+ref1NoDibOXjlHJ8 583EfWyatQvJ9hQRUsrLWMpnfNOCPM1nzAHx4sEfvcNjnelX1IniMsdMJDLO6VK842t1 Dk1A== 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 y13si9068419pgj.157.2019.02.03.13.26.17; Sun, 03 Feb 2019 13:27:08 -0800 (PST) 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 S1727761AbfBCVUB (ORCPT + 99 others); Sun, 3 Feb 2019 16:20:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:58002 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726820AbfBCVUB (ORCPT ); Sun, 3 Feb 2019 16:20:01 -0500 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 32D3DAD6B; Sun, 3 Feb 2019 21:20:00 +0000 (UTC) Date: Sun, 3 Feb 2019 22:19:58 +0100 From: Petr Vorel To: Mimi Zohar Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, David Howells , Dave Young , Eric Biederman Subject: Re: [PATCH 2/3] scripts/ima: define a set of common functions Message-ID: <20190203211958.GB4022@x230> Reply-To: Petr Vorel References: <1548960936-7800-1-git-send-email-zohar@linux.ibm.com> <1548960936-7800-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: <1548960936-7800-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 and move get_secureboot_mode() to a common file for use by other > tests. > Signed-off-by: Mimi Zohar Reviewed-by: Petr Vorel > --- > tools/testing/selftests/ima/common_lib.sh | 20 ++++++++++++++++++++ > tools/testing/selftests/ima/test_kexec_load.sh | 17 +++-------------- > 2 files changed, 23 insertions(+), 14 deletions(-) > create mode 100755 tools/testing/selftests/ima/common_lib.sh > diff --git a/tools/testing/selftests/ima/common_lib.sh b/tools/testing/selftests/ima/common_lib.sh > new file mode 100755 > index 000000000000..ae097a634da5 > --- /dev/null > +++ b/tools/testing/selftests/ima/common_lib.sh > @@ -0,0 +1,20 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0+ # SPDX-License-Identifier: GPL-2.0-or-later > + > +get_secureboot_mode() > +{ > + EFIVARFS="/sys/firmware/efi/efivars" local efivarfs="/sys/firmware/efi/efivars" local file It's a good practise to use local keyword and lower case the name of the variable for variables used only locally (if you treat $EFIVARFS as constant, I'd move it outside of get_secureboot_mode()). I personally try to avoid using global variables (except constant like). > + # Make sure that efivars is mounted in the normal location > + if ! grep -q "^\S\+ $EFIVARFS efivarfs" /proc/mounts; then > + echo "$TEST: efivars is not mounted on $EFIVARFS" >&2 > + exit $ksft_skip > + fi There could be helper function printing error and exit in selftest library. > + # Get secureboot mode > + file="$EFIVARFS/SecureBoot-*" file="$efivarfs/SecureBoot-*" ... > KERNEL_IMAGE="/boot/vmlinuz-`uname -r`" Another candidate for helper for potential selftest library. Kind regards, Petr