diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3ee385c6e3..fc4c69615a 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3726,7 +3726,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn, if (virAuthConfigLookup(state->config, "libvirt", - conn->uri->server, + VIR_URI_SERVER(conn->uri), credname, &value) < 0) goto cleanup; diff --git a/src/util/virauth.c b/src/util/virauth.c index 0d92a1d70a..6d9935d6e5 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -130,7 +130,7 @@ virAuthGetCredential(virConnectPtr conn, if (virAuthConfigLookup(config, servicename, - conn->uri->server, + VIR_URI_SERVER(conn->uri), credname, &tmp) < 0) goto cleanup; diff --git a/src/util/viruri.h b/src/util/viruri.h index aabd89454c..3cfc7d39d9 100644 --- a/src/util/viruri.h +++ b/src/util/viruri.h @@ -60,4 +60,6 @@ char *virURIFormatParams(virURIPtr uri); void virURIFree(virURIPtr uri); +# define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server : "localhost") + #endif /* __VIR_URI_H__ */