All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <qmo@kernel.org>
To: Rong Tao <rtoax@foxmail.com>,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: rongtao@cest.ccn, Rong Tao <rongtao@cestc.cn>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Tao Chen <chen.dylane@gmail.com>,
	Mykyta Yatsenko <yatsenko@meta.com>, Daniel Xu <dxu@dxuuu.xyz>,
	"open list:BPF [TOOLING] (bpftool)" <bpf@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next] bpftool: bash-completion: Add nopasswd sudo prefix for bpftool
Date: Wed, 12 Feb 2025 11:00:34 +0000	[thread overview]
Message-ID: <97fd1bbb-1261-4af5-9321-27353547dbf7@kernel.org> (raw)
In-Reply-To: <tencent_515567355C0AA854BDA68C3A219A18040B0A@qq.com>

2025-02-12 18:14 UTC+0800 ~ Rong Tao <rtoax@foxmail.com>
> From: Rong Tao <rongtao@cestc.cn>
> 
> In the bpftool script of bash-completion, many bpftool commands require
> superuser privileges to execute. Otherwise, Operation not permission will
> be displayed. Here, we check whether ordinary users are exempt from
> entering the sudo password. If so, we need to add the sudo prefix to the
> bpftool command to be executed. In this way, we can obtain the correct
> command completion content instead of the wrong one.
> 
> For example, when updating array_of_maps, the wrong 'hex' is completed:
> 
>     $ sudo bpftool map update name arr_maps key 0 0 0 0 value [tab]
>     $ sudo bpftool map update name arr_maps key 0 0 0 0 value hex
> 
> However, what we need is "id name pinned". Similarly, there is the same
> problem in getting the map 'name' and 'id':
> 
>     $ sudo bpftool map show name [tab] < get nothing
>     $ sudo bpftool map show id [tab]   < get nothing
> 
> This commit fixes the issue.
> 
>     $ sudo bpftool map update name arr_maps key 0 0 0 0 value [tab]
>     id      name    pinned
> 
>     $ sudo bpftool map show name
>     arr_maps         cgroup_hash      inner_arr1       inner_arr2
> 
>     $ sudo bpftool map show id
>     11    1383  4091  4096
> 
> Signed-off-by: Rong Tao <rongtao@cestc.cn>

Hi, thanks for the patch.

I agree it's annoying to have a partially-working completion for
non-root users, however, I don't feel very comfortable introducing calls
to "sudo" in bash completion, without the user noticing. For what it's
worth, I searched other bash completion files (from
https://github.com/scop/bash-completion/) and I can't find any of them
running sudo to help complete commands, so it doesn't seem to be
something usual in completion. I think I'd rather keep the current state
(or fix the first example to have the right keywords displayed but
without running sudo).

Quentin

  reply	other threads:[~2025-02-12 11:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 10:14 [PATCH bpf-next] bpftool: bash-completion: Add nopasswd sudo prefix for bpftool Rong Tao
2025-02-12 11:00 ` Quentin Monnet [this message]
2025-02-12 11:21   ` Rong Tao

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=97fd1bbb-1261-4af5-9321-27353547dbf7@kernel.org \
    --to=qmo@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chen.dylane@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=rongtao@cest.ccn \
    --cc=rongtao@cestc.cn \
    --cc=rtoax@foxmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yatsenko@meta.com \
    --cc=yonghong.song@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.