mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
virsh: Provide no auth callbacks for bash completer
Our bash completion script parses (partially incomplete) command line and looks for two arguments: --readonly and --connect because in the next step it executes virsh with those two arguments like this: virsh --readonly --connect $URI complete -- "text to complete" Now, whenever virsh sees connection URI specified on its cmd line it connects to it right away (before executing any command). This happens inside virshConnect(). Here, virConnectOpenAuth() is called with the default auth callback (virConnectAuthPtrDefault). In majority of the cases this is desirable, as it might ask user for credentials (password for example). But in case of bash completion this is not desired because bash completion script must not expect users to input anything (that's why we even close stdin in cmdComplete()). Therefore, when connecting from virsh that's executed by the bash completion script provide no auth callbacks to prevent virsh from asking for credentials. Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/879 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Tested-by: Richrad W.M. Jones <rjones@redhat.com>
This commit is contained in:
1 parent
ebf353f3c4
commit
b489eb8d6b
1 file changed
+9
-1
+9
-1
@@ -124,8 +124,16 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
|
||||
|
||||
do {
|
||||
virErrorPtr err;
|
||||
virConnectAuthPtr auth = virConnectAuthPtrDefault;
|
||||
|
||||
if ((c = virConnectOpenAuth(uri, virConnectAuthPtrDefault,
|
||||
if (ctl->cmd->def->handler == cmdComplete) {
|
||||
/* When running from a bash completer we need to avoid any kind of
|
||||
* keyboard input (e.g. ssh asking for a password). To achieve
|
||||
* this, provide no authentication callbacks. */
|
||||
auth = NULL;
|
||||
}
|
||||
|
||||
if ((c = virConnectOpenAuth(uri, auth,
|
||||
readonly ? VIR_CONNECT_RO : 0)))
|
||||
break;
|
||||
|
||||
|
||||
Reference in new issue
Block a user