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@hamr:~^G###bphcxtq5###
> 
> Thanks: Ming Xie.
> ---

LGTM.

Thanks,
-- 
Pino Toscano

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Libguestfs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to