From: yuelongguang Date: Mon, 13 Jun 2016 09:29:57 +0000 (+0800) Subject: add default mapping of credentials to machine X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=743db933ed6bbcdd3ca87dd43c8164f6992bc89e;p=libvirt.git add default mapping of credentials to machine In the auth config file, it is currently required to have an entry for each hostname to connect to, eg [auth-libvirt-prod1.example.com] credentials=prod This is inconvenient when there are large numbers of machines all with the same credentials. Add support for a default entry: [auth-default] credentials=prod --- diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 6064e4ad85..b58937c375 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -121,6 +121,13 @@ int virAuthConfigLookup(virAuthConfigPtr auth, if (virAsprintf(&authgroup, "auth-%s-%s", service, hostname) < 0) goto cleanup; + if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { + VIR_FREE(authgroup); + if (virAsprintf(&authgroup, "auth-%s-%s", service, "default") < 0){ + goto cleanup; + } + } + if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { ret = 0; goto cleanup;