Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6258532rwb; Tue, 9 Aug 2022 11:55:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6lmMAg/Izmr8YDftyH1nOCk8nQIUIOf6vJbbgSEkZp9vMRScBA6FeUQ12amWTa8nM5yvDs X-Received: by 2002:a17:907:1c95:b0:72b:4e37:7736 with SMTP id nb21-20020a1709071c9500b0072b4e377736mr17657714ejc.516.1660071324107; Tue, 09 Aug 2022 11:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071324; cv=none; d=google.com; s=arc-20160816; b=jdY2xffIw5FGX3JEqF29ALiC7xVYkpl0x6bQGSoBZrlYIM2Ha25jYfmCpPBCQrCUZz zz9ZcxE0cTWisFi50U6YYGGBp6Bq6TbMCRlRLcoE5t8gOkFMVcENntjgeLmzf/gc5ns0 ncEO+KCAzQwwjXJoCshNq2nszBQv2GU3iuh1YmF6Dk2arhiENwNB0Cq28uz4vXWG45/w LlYuRTIr8MTT9imQQV39dH2doRcP4tuf9G2RYogNP231H65t8BEzwIPPCFOPuH97YUfx AQHDAO2K/IkEzUV2jELmXMYgWbVxFiLoghHLAE8YaDgfG6Po9YDc+e+05guFv8mOvueX T8VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eS53HlxgKDj9oDC6NbyN8oSzjZ4CuFcJeZKSwXJzksA=; b=M9Lm4soZjWHa32bNmQ+oEnDSwXdYBIfcUq2piRXq6WY/DBfvpxGO3PoUECeIpmZ7Ki mf9qikzs2EIA81whOs/x60oMK8kKIrJ8eBSkRU3C+677DG9VM0DIL1k893PjIvepLl4I LSjiuU+lSehiIR/RVoG4b27PQB5K9quu/6eYUu0JyIEObvkb6NkdIIJIvGlda8dPUplB DDsUeF8wqEYxsJMi5tNq57mIgiXptYb48PYMUX7DHvqHMgaQwjmxAZX7aSf5/bVGFhEp bOVmRY3j/rQwyId5s5QqBCWTVWCgmaG3Lef6U0ff0JL96iTW6j/HlWyWptSAgLy4uH9G qUaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=Gjo98Eb6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a05640250ca00b004408bac1e00si7411272edb.103.2022.08.09.11.54.58; Tue, 09 Aug 2022 11:55:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=Gjo98Eb6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244994AbiHISrE (ORCPT + 99 others); Tue, 9 Aug 2022 14:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347182AbiHISpw (ORCPT ); Tue, 9 Aug 2022 14:45:52 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E30048CA3 for ; Tue, 9 Aug 2022 11:20:07 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E10DB240105 for ; Tue, 9 Aug 2022 20:19:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1660069175; bh=sEkmUijSzri/2YFuSr7hrT1VKhBgjLmd11jEikhP4rs=; h=Date:From:To:Cc:Subject:From; b=Gjo98Eb6UC1WttuMhado9zk0OupkaXhJLwnr4GA1hsP1k5kNNlW2xmYmSMg3A0cW2 oU7rmQZjZuQkh3bLO1YpyK0JeFgNjLQ08P4HAGe69RJyNoMshgTLfRwnSpNh+Gm3/N Y6Czng+sEWFeJzcWJUsJtAF351EeaFXbjnjNVDu3Uepbqpbcx1NA9SyR22I+yD/y16 /CGGZljqiFw71QbzYJPl2/3HLY+Q/UrKcOu7EP0oi1NY2fkVFTxBOlvMP0MsKTjJCA 2/H/hBTOzxVfEQ+HlAJrIksAjVFo4orRpcUqaUhWlTwBblIC/IUl3LzZVM9n3iJexj Crb2Q2Zg4va/g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4M2Lv91Z90z6tmr; Tue, 9 Aug 2022 20:19:33 +0200 (CEST) Date: Tue, 9 Aug 2022 18:19:29 +0000 From: Daniel =?utf-8?Q?M=C3=BCller?= To: Daniel Xu Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 1/2] selftests/bpf: Fix vmtest.sh -h to not require root Message-ID: <20220809181929.qtbhr637dpwhr244@muellerd-fedora-PC2BDTX9> References: <6a802aa37758e5a7e6aa5de294634f5518005e2b.1660064925.git.dxu@dxuuu.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6a802aa37758e5a7e6aa5de294634f5518005e2b.1660064925.git.dxu@dxuuu.xyz> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 09, 2022 at 11:11:09AM -0600, Daniel Xu wrote: > Set the exit trap only after argument parsing is done. This way argument > parse failure or `-h` will not require sudo. > > Reasoning is that it's confusing that a help message would require root > access. > > Signed-off-by: Daniel Xu > --- > tools/testing/selftests/bpf/vmtest.sh | 32 +++++++++++++-------------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh > index b86ae4a2e5c5..976ef7585b33 100755 > --- a/tools/testing/selftests/bpf/vmtest.sh > +++ b/tools/testing/selftests/bpf/vmtest.sh > @@ -307,6 +307,20 @@ update_kconfig() > fi > } > > +catch() > +{ > + local exit_code=$1 > + local exit_status_file="${OUTPUT_DIR}/${EXIT_STATUS_FILE}" > + # This is just a cleanup and the directory may > + # have already been unmounted. So, don't let this > + # clobber the error code we intend to return. > + unmount_image || true > + if [[ -f "${exit_status_file}" ]]; then > + exit_code="$(cat ${exit_status_file})" > + fi > + exit ${exit_code} > +} > + > main() > { > local script_dir="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" > @@ -353,6 +367,8 @@ main() > done > shift $((OPTIND -1)) > > + trap 'catch "$?"' EXIT > + > if [[ $# -eq 0 && "${debug_shell}" == "no" ]]; then > echo "No command specified, will run ${DEFAULT_COMMAND} in the vm" > else > @@ -409,20 +425,4 @@ main() > fi > } > > -catch() > -{ > - local exit_code=$1 > - local exit_status_file="${OUTPUT_DIR}/${EXIT_STATUS_FILE}" > - # This is just a cleanup and the directory may > - # have already been unmounted. So, don't let this > - # clobber the error code we intend to return. > - unmount_image || true > - if [[ -f "${exit_status_file}" ]]; then > - exit_code="$(cat ${exit_status_file})" > - fi > - exit ${exit_code} > -} > - > -trap 'catch "$?"' EXIT > - > main "$@" > -- > 2.37.1 > Makes sense and looks good to me. Acked-by: Daniel M?ller