From: Andrey Butirsky <butirsky@gmail.com>
To: dana <dana@dana.is>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: sudo autocompletion
Date: Tue, 11 Feb 2020 01:05:56 +0300 [thread overview]
Message-ID: <327afa53-4d22-7cea-9f4f-3bf9bcf82607@gmail.com> (raw)
In-Reply-To: <D0BDD1BB-192E-4D50-A0D2-0BB54388B9B9@dana.is>
[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]
On 10.02.2020 20:13, dana wrote:
> diff --git a/Completion/Unix/Command/_sudo
> b/Completion/Unix/Command/_sudo
> index 41e32cbae..52b212176 100644
> --- a/Completion/Unix/Command/_sudo
> +++ b/Completion/Unix/Command/_sudo
> @@ -54,6 +54,18 @@ else
> '(-)1:command: _command_names -e'
> '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[(I)(-[ugHEP]|--(user|group|set-home|preserve-env|preserve-groups))]} ) ; _normal }'
> )
> +
> + # By default, _command_names uses the current PATH to complete commands. This
> + # doesn't necessarily make sense for sudo on systems that use its secure_path
> + # feature -- a common issue is that /**/sbin appear in secure_path but not in
> + # unprivileged users' PATHs. Ideally we could parse the correct value out of
> + # `sudo -l`, but since that requires a password it won't work half the time.
> + # To do the right thing in the most common cases, we'll simply ensure that the
> + # sbin variants always appear in the default command-path (bash-completion's
> + # _sudo does something similar)
> + zstyle -t ":completion:${curcontext}:" command-path ||
> + zstyle -e ":completion:${curcontext%:}:*" command-path \
> + 'reply=( $path ${path/%\/bin//sbin} )'
> fi
>
> _arguments -s -S $args
>
Didn't see all the file, but probably 'su' and variants need something
similar also?
One of the "solutions"
(https://forums.gentoo.org/viewtopic-p-7978544.html?sid=fd1853347362adf53e40a5a0320030a8#7978544):
|[[ $UID -eq 0 ]] || () {||
|| local i||
|| local -T SUDO_PATH sudo_path||
|| local -U sudo_path=($path {,/usr{,/local}}/sbin(N-/))||
||
|| for i in su{,do}; do||
|| zstyle ":completion:*:$i:*" environ PATH="$SUDO_PATH"||
|| done||
||}|
next prev parent reply other threads:[~2020-02-10 22:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <912d22db-8a8f-90f2-6738-f9f395994dcb@gmail.com>
[not found] ` <CAN=4vMqvzUTZ7bBLcbTzi-pKAVEP1xDbq=f5pLAxmffxUjTszQ@mail.gmail.com>
[not found] ` <1770be62-54d8-70a6-8b05-cfc98faa9b9f@gmail.com>
[not found] ` <20200210030219.527a3ccf@tarpaulin.shahaf.local2>
[not found] ` <ADE72275-1311-44BE-9B1D-5E617E3D9F94@gmail.com>
2020-02-10 17:13 ` dana
2020-02-10 17:40 ` Peter Stephenson
2020-02-10 18:57 ` dana
2020-02-10 19:20 ` Daniel Shahaf
2020-02-11 10:12 ` Oliver Kiddle
2020-02-11 10:28 ` Setting/Querying cache-policy (was: Re: sudo autocompletion) Daniel Shahaf
2020-02-12 16:51 ` dana
2020-02-13 1:21 ` sudo autocompletion dana
2020-02-13 1:29 ` Bart Schaefer
2020-02-15 22:22 ` Andrey Butirsky
2020-02-15 22:48 ` dana
2020-03-11 21:57 ` dana
2020-03-12 21:51 ` Andrey Butirsky
2020-02-10 22:05 ` Andrey Butirsky [this message]
2020-02-10 23:02 ` dana
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=327afa53-4d22-7cea-9f4f-3bf9bcf82607@gmail.com \
--to=butirsky@gmail.com \
--cc=d.s@daniel.shahaf.name \
--cc=dana@dana.is \
--cc=zsh-workers@zsh.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).