]> xenbits.xensource.com Git - libvirt.git/commit
vsh: Fix 'stdin' closing in 'cmdComplete'
authorPeter Krempa <pkrempa@redhat.com>
Tue, 26 Mar 2024 15:28:33 +0000 (16:28 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 25 Apr 2024 12:13:19 +0000 (14:13 +0200)
commitbb9bb5521102d8846c14054ec502f64ee95a0688
tree37fc34504c151ffe2a3d157f8301214f611569f9
parent0d687d13ed64ed57eb704c349e2330cd2b2181dd
vsh: Fix 'stdin' closing in 'cmdComplete'

While the 'complete' command is meant to be hidden and used only for
the completion script, there's nothing preventing it being used in all
virsh modes.

This poses a problem as the command tries to close 'stdin' to avoid the
possibility that an auth callback would want to read the password.

In interactive mode this immediately terminates virsh and in
non-interactive mode it attempts to close it multiple times if you use
virsh in batch mode.

Fix the issues by using virOnce() to close it exactly once and do so
only in non-interactive mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/vsh.c