From patchwork Tue Jan 28 08:25:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1230212 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cbHvSGGv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 486KWr2SjWz9sP6 for ; Tue, 28 Jan 2020 19:28:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB88F81A48; Tue, 28 Jan 2020 09:27:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="cbHvSGGv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 36F9081A10; Tue, 28 Jan 2020 09:26:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 92D48819C5 for ; Tue, 28 Jan 2020 09:26:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x442.google.com with SMTP id n7so6223287pfn.0 for ; Tue, 28 Jan 2020 00:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4+DynTU0jQq/GM0njzHnzpbO6P/pSFZf7Nc8YhhsA+A=; b=cbHvSGGv8kWuSY+Q4ws5eZ8uWVCtmO8V5HTMcdpewwDYcjhHP2enW8365AYPQy2MMk y6wXOTveBn4NpwwASlIyS+3q2ubO1ojM8teIhJuheyVozjhFYdrx+yRCgnYJ/RqFVUxW CHWMkmr7RqNI9qyBcuCICO4Ey45AidEpLIHPfx7AgY5Ul2U7R4WLG+v4mpQ0cTSZsNLz q9kK3qjZYvn6KuMVyb4CF/CAajtxg0uyMoX3R+yQ8H1gV2uOw4a7RlOcHIbqcYpjwyS/ oOmzJCxyWSP0EOVLeiqhzVtakknpdKRMxgzx7aLictPmHo7SQINjw0LJQAeCLW6qmt7u IKMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4+DynTU0jQq/GM0njzHnzpbO6P/pSFZf7Nc8YhhsA+A=; b=rcGsXCLq8Qv/FYHk5v6B0jsVue7JEGZF/oILVdmpK3mb8vmMZmQsnc9N9Ee+k4O1Rq m5LiHjqtTXUc36yWNRkslopxNnaRt3uIQysq3JJYwcBb/OdwgTDgRCPIwO++ibmhjYfz kut+0jlZQ3vaZQSRz/n726g+GCLfzl2JeJKnqWTFZxDEQamspV6QhlKTxS5AlGH6TJrz hoEJjRF3gCW0ksrrF7XQ62y0VAIr1K2//a6hBcSUsEvuk5LhEUL7c8hvTpmj2J8kerQC cGxPfVosi/LW6vpUMuv8iHWPUGyqhmrHvZEBouqNKE92GptnkMUUWmcoqV6+zCJLdTCA 5kag== X-Gm-Message-State: APjAAAX7O5vL3w3vCP+efbExV0at3Za9bRO9JUwxt35tPVQSdyrkxtP2 5uyeHCvcLUTrtXC2y+Uw+MiH8A== X-Google-Smtp-Source: APXvYqxG4lcSB0tPvHXqfbYeTNDUdvlAu+ib1dDd3AqJCfT5J8q2U9PKt7mRxMgbynx/2jssT0l3kw== X-Received: by 2002:a63:87c3:: with SMTP id i186mr23587249pge.153.1580200012557; Tue, 28 Jan 2020 00:26:52 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id y62sm19284247pfg.45.2020.01.28.00.26.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2020 00:26:52 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Subject: [PATCH v5 10/16] cmd: env: add "-at" option to "env set -e" command Date: Tue, 28 Jan 2020 17:25:26 +0900 Message-Id: <20200128082532.15943-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200128082532.15943-1-takahiro.akashi@linaro.org> References: <20200128082532.15943-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS will be passed to SetVariable() to authenticate the variable. Signed-off-by: AKASHI Takahiro --- cmd/nvedit.c | 5 +++-- cmd/nvedit_efi.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 81d94cd193c6..966c13405956 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -1417,7 +1417,7 @@ static char env_help_text[] = #endif #endif #if defined(CONFIG_CMD_NVEDIT_EFI) - "env set -e [-nv][-bs][-rt][-a][-i addr,size][-v] name [arg ...]\n" + "env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n" " - set UEFI variable; unset if '-i' or 'arg' not specified\n" #endif "env set [-f] name [arg ...]\n"; @@ -1479,13 +1479,14 @@ U_BOOT_CMD_COMPLETE( setenv, CONFIG_SYS_MAXARGS, 0, do_env_set, "set environment variables", #if defined(CONFIG_CMD_NVEDIT_EFI) - "-e [-guid guid][-nv][-bs][-rt][-a][-v]\n" + "-e [-guid guid][-nv][-bs][-rt][-at][-a][-v]\n" " [-i addr,size name], or [name [value ...]]\n" " - set UEFI variable 'name' to 'value' ...'\n" " \"-guid\": set vendor guid\n" " \"-nv\": set non-volatile attribute\n" " \"-bs\": set boot-service attribute\n" " \"-rt\": set runtime attribute\n" + " \"-at\": set time-based authentication attribute\n" " \"-a\": append-write\n" " \"-i addr,size\": use as variable's value\n" " \"-v\": verbose message\n" diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 579cf430593c..837e39e02179 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -458,7 +458,7 @@ out: * Return: CMD_RET_SUCCESS on success, or CMD_RET_RET_FAILURE * * This function is for "env set -e" or "setenv -e" command: - * => env set -e [-guid guid][-nv][-bs][-rt][-a][-v] + * => env set -e [-guid guid][-nv][-bs][-rt][-at][-a][-v] * [-i address,size] var, or * var [value ...] * Encode values specified and set given UEFI variable. @@ -517,6 +517,9 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) attributes |= EFI_VARIABLE_RUNTIME_ACCESS; } else if (!strcmp(argv[0], "-nv")) { attributes |= EFI_VARIABLE_NON_VOLATILE; + } else if (!strcmp(argv[0], "-at")) { + attributes |= + EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; } else if (!strcmp(argv[0], "-a")) { attributes |= EFI_VARIABLE_APPEND_WRITE; } else if (!strcmp(argv[0], "-i")) {