From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: Marko Myllynen <myllynen@redhat.com>, zsh-workers@zsh.org
Subject: Re: [PATCH] _virsh (Was: Re: zsh virsh completion)
Date: Fri, 22 Jul 2016 07:19:27 +0000 [thread overview]
Message-ID: <20160722071927.GG2521@tarsus.local2> (raw)
In-Reply-To: <25001.1469117569@hydra.kiddle.eu>
Oliver Kiddle wrote on Thu, Jul 21, 2016 at 18:12:49 +0200:
> Marko Myllynen wrote:
> > + _values servers ${=${(S)${${(f)$(sudo virt-admin srv-list)}##*--- }//[0-9]* }} && return 0
>
> > + _values servers ${=${${(f):-"$(sudo virt-admin srv-clients-list --server $srv)"}/ [a-z]*}//[^0-9]} && return 0
>
> I have pushed the change but I've just noticed these two lines. I'm not
> sure it is a good idea to be running sudo within completion functions.
> That can trigger logging and is often denied when you're already root.
> And there may be alternatives like doas.
>
> There's also another instance of this in Mandriva/Command/_rebootin.
>
> Anyone, have any thoughts on how this should be handled? I'm inclined
> to think that users should have to specifically set a gain-root
> style to enable this. Or perhaps it could only trigger if you
> complete after sudo virt-admin.
In principle, I fully agree with you, with two differences:
First, in addition to 'zstyle -t … gain-root' and
'(( $+funcstack[(r)_sudo] ))' as the conditions for invoking sudo,
I think a third alternative is to use _call_program and let the user set
the 'command' style to '-sudo'.
Secondly, you don't touch on what we would do when the 'gain-root' style
is unset. Given Marko's later email that virt-admin is not usable by
non-root users, perhaps we should do this:
.
if (( EUID == 0 )); then
# call 'virt-admin'
elif The 'gain-root' or 'command' style is set; then
# call virt-admin with sudo (or whatever the style prescribes)
else
_message "zsh: _libvirt: can't list completions because the 'gain-root' style is unset"
return 1
fi
.
?
The error message can also include the 'zstyle' incantation that sets
the style appropriately, to make it easier for the user.
Also, we should sanitize that $srv parameter before passing it to
a command run as root. I'm not sure how virt-admin's command-line
parser works: is there any possibility for $srv to be tokenised as
anything other than the argument of the --server option?
Cheers,
Daniel
> Oliver
next prev parent reply other threads:[~2016-07-22 7:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-11 11:52 zsh virsh completion Marko Myllynen
2016-07-11 15:03 ` Roman Neuhauser
2016-07-11 16:40 ` Bart Schaefer
2016-07-11 22:07 ` Oliver Kiddle
2016-07-12 10:23 ` Marko Myllynen
2016-07-13 4:59 ` Daniel Shahaf
2016-07-18 12:06 ` Marko Myllynen
2016-07-20 6:58 ` [PATCH] _virsh (Was: Re: zsh virsh completion) Daniel Shahaf
2016-07-20 8:36 ` Marko Myllynen
2016-07-21 6:57 ` Daniel Shahaf
2016-07-21 12:32 ` Marko Myllynen
2016-07-22 6:30 ` Daniel Shahaf
2016-07-22 8:17 ` Marko Myllynen
2016-07-21 16:12 ` Oliver Kiddle
2016-07-21 16:19 ` Marko Myllynen
2016-07-22 7:19 ` Daniel Shahaf [this message]
2016-08-31 21:15 ` Oliver Kiddle
2016-09-02 5:23 ` Daniel Shahaf
2016-09-02 15:02 ` Oliver Kiddle
2016-09-04 4:01 ` Daniel Shahaf
2016-09-07 6:39 ` Bart Schaefer
2016-09-09 22:09 ` Oliver Kiddle
2016-09-11 9:08 ` Daniel Shahaf
2016-09-14 23:19 ` Oliver Kiddle
2016-09-04 21:24 ` Daniel Shahaf
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=20160722071927.GG2521@tarsus.local2 \
--to=d.s@daniel.shahaf.name \
--cc=myllynen@redhat.com \
--cc=okiddle@yahoo.co.uk \
--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).