
On Tue, Nov 27, 2012 at 02:55:11PM +0000, Daniel P. Berrange wrote:
On Tue, Nov 27, 2012 at 03:39:16PM +0100, Peter Krempa wrote:
To make this function callable from code that doesn't have the conn object, call the conn-dependant code only if conn was provided. --- src/util/virauth.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/util/virauth.c b/src/util/virauth.c index 6d9935d..738b3c5 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -205,7 +205,8 @@ virAuthGetUsername(virConnectPtr conn, }
- +/* if this function is called with conn == NULL, the code requesting + * the password from the config file is skipped */ char * virAuthGetPassword(virConnectPtr conn, virConnectAuthPtr auth, @@ -218,10 +219,12 @@ virAuthGetPassword(virConnectPtr conn, char *prompt; char *ret = NULL;
- if (virAuthGetCredential(conn, servicename, "password", &ret) < 0) - return NULL; - if (ret != NULL) - return ret; + if (conn) { + if (virAuthGetCredential(conn, servicename, "password", &ret) < 0) + return NULL; + if (ret != NULL) + return ret; + }
memset(&cred, 0, sizeof(virConnectCredential));
NACK, I don't think this is right. The libssh2 code that is using this must have a virConnectPtr instance somewhere in its callstack. We should fix the code to pass the connection in where needed, not skip this.
Or probably better is to change the API signature to take a virURIPtr instead of a virConnectPtr, since the URI is the things that's really wanted here. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|