From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id e25975cd for ; Mon, 10 Feb 2020 22:06:41 +0000 (UTC) Received: (qmail 21681 invoked by alias); 10 Feb 2020 22:06:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45414 Received: (qmail 6352 invoked by uid 1010); 10 Feb 2020 22:06:34 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f181.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25718. spamassassin: 3.4.2. Clear:RC:0(209.85.208.181):SA:0(-2.0/5.0):. Processed in 1.598192 secs); 10 Feb 2020 22:06:34 -0000 X-Envelope-From: butirsky@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.208.181 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Y7906fsvXQeQoUwxYwdZ4U84fyeUUtYe3OdFXuesBNA=; b=GNwAzFdzaPZYBaoac17YYVIF+iifNE1VDqrjNIGo/xu07O5MdoCk/Gw56Bqvo0X0WX Nsyc8+5y1Y7CSHxLHQF0EJt5ILGzXPvQEotNjscbHFayawPlXpZVF3QmFUvoPw2J3W5u zKE8xzgytscVX66IpYRYsl6cu8rlhVKTv3TsMxyeTYX4/TbO8DoymAmIr8qCReVI+8zN PTT9MsG8pO85ovaTP9shxAbTV2qwH556CBYm61svoX/610BnnVgj95ca14uZHnVPM0yq LCniUXKZ9rVqJ3cqOQ4PHSwM9HSBbxTK66q1oOh/ftIx57YOIsWy8Dx0MY96Mymf9JNV CliA== X-Gm-Message-State: APjAAAUEEh1UT73gxonnGaSaMSoQdb6X2uTSsRXAaJyOiv3dOjOsb3LH +ZVZkEprN6EYOsZNeQPgbxuAfvqfcbU= X-Google-Smtp-Source: APXvYqzkV7uhbrD6M9n8LCknLBYNRNUJjo7rbHG6KZ8zHD7QBJr8h653Bh0mefRK5mtCwB2nV8SiTw== X-Received: by 2002:a2e:8e63:: with SMTP id t3mr2117333ljk.239.1581372358370; Mon, 10 Feb 2020 14:05:58 -0800 (PST) Subject: Re: sudo autocompletion To: dana Cc: Daniel Shahaf , Zsh hackers list References: <912d22db-8a8f-90f2-6738-f9f395994dcb@gmail.com> <1770be62-54d8-70a6-8b05-cfc98faa9b9f@gmail.com> <20200210030219.527a3ccf@tarpaulin.shahaf.local2> From: Andrey Butirsky Message-ID: <327afa53-4d22-7cea-9f4f-3bf9bcf82607@gmail.com> Date: Tue, 11 Feb 2020 01:05:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Thunderbird/73.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------4834AB476F0EE020229746A4" Content-Language: en-US --------------4834AB476F0EE020229746A4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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|| ||}| --------------4834AB476F0EE020229746A4--