[PATCH] libvirt: ensure defresult is used in virConnectAuthCallbackDefault

A previous change to this function's password handling broke the use of default values for credential types other than VIR_CRED_PASSPHRASE and VIR_CRED_NOECHOPROMPT. Signed-off-by: Matt Coleman <matt@datto.com> --- src/libvirt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libvirt.c b/src/libvirt.c index 0748eb2352..63c8bdea9f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -146,7 +146,9 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr cred, len = strlen(buf); if (len != 0 && buf[len-1] == '\n') buf[len-1] = '\0'; - bufptr = g_strdup(buf); + + if (strlen(buf) > 0) + bufptr = g_strdup(buf); break; case VIR_CRED_PASSPHRASE: -- 2.27.0

On Mon, Sep 21, 2020 at 10:02 PM Matt Coleman <mcoleman@datto.com> wrote:
A previous change to this function's password handling broke the use of default values for credential types other than VIR_CRED_PASSPHRASE and VIR_CRED_NOECHOPROMPT.
Signed-off-by: Matt Coleman <matt@datto.com> --- src/libvirt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 0748eb2352..63c8bdea9f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -146,7 +146,9 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr cred, len = strlen(buf); if (len != 0 && buf[len-1] == '\n') buf[len-1] = '\0'; - bufptr = g_strdup(buf); + + if (strlen(buf) > 0) + bufptr = g_strdup(buf); break;
case VIR_CRED_PASSPHRASE: -- 2.27.0
Reviewed-by: Neal Gompa <ngompa13@gmail.com> -- 真実はいつも一つ!/ Always, there's only one truth!

Some additional info (feel free to add it to the commit message): Starting in version 6.1.0, virsh does not use the default username while connecting: $ ./run tools/virsh -c hyperv://example-hyperv-server?transport=http capabilities Enter username for example-hyperv-server [administrator]: Enter 's password for example-hyperv-server: error: failed to connect to the hypervisor error: internal error: Transport error during enumeration: User, password or similar was not accepted (26) $ ./run tools/virsh -c hyperv://example-hyperv-server?transport=http capabilities Enter username for example-hyperv-server [administrator]: administrator Enter administrator's password for example-hyperv-server: <capabilities> <host> … I’ve reproduced this on several versions of Fedora and Ubuntu 20.04. You can reproduce it locally (although with a slightly different error) by replacing example-hyperv-server with 127.0.0.1. -- Matt

On Mon, Sep 21, 2020 at 10:01:46PM -0400, Matt Coleman wrote:
A previous change to this function's password handling broke the use of default values for credential types other than VIR_CRED_PASSPHRASE and VIR_CRED_NOECHOPROMPT.
Signed-off-by: Matt Coleman <matt@datto.com> --- src/libvirt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> and will push shortly Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (3)
-
Daniel P. Berrangé
-
Matt Coleman
-
Neal Gompa