]> xenbits.xensource.com Git - libvirt.git/commitdiff
add default mapping of credentials to machine
authoryuelongguang <yuelongguang@le.com>
Mon, 13 Jun 2016 09:29:57 +0000 (17:29 +0800)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 16 Jun 2016 09:36:46 +0000 (10:36 +0100)
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

src/util/virauthconfig.c

index 6064e4ad858c980ab531f28a1bb7af04eb7f6d89..b58937c37530f292e1b58303219c12317008c877 100644 (file)
@@ -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;