[Libguestfs] [PATCH] p2v: Test for sudo requiring a password first (RHBZ#1500673).
Pino Toscano
ptoscano at redhat.com
Wed Oct 11 15:06:05 UTC 2017
On Wednesday, 11 October 2017 16:16:32 CEST Richard W.M. Jones wrote:
> When testing if sudo -n requires a password, we tested for the prompt
> earlier than testing for the magic sudo message ‘a password is
> required’.
>
> Since the shell will print the prompt just after the sudo message:
>
> prompt$ sudo -n virt-v2v --version
> sudo: a password is required
> prompt$
>
> the prompt nearly always matched and we missed the magic sudo message.
> (The exception is in the case where we are running everything on
> localhost where the sudo message could be read in a single call to
> read(2) without seeing the prompt immediately afterwards. Even this
> exception was non-deterministic.)
>
> By swapping the priority of the sudo message and prompt we avoid this.
>
> Looking at the debug output (enabled by editing common/miniexpect)
> makes this clearer:
>
> DEBUG: writing: sudo -n virt-v2v --version
> DEBUG: buffer content: sudo: a password is required
> ESC]0;rjones at hamr:~^G###bphcxtq5###
>
> Thanks: Ming Xie.
> ---
LGTM.
Thanks,
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20171011/072977e5/attachment.sig>
More information about the Libguestfs
mailing list