]> xenbits.xensource.com Git - libvirt.git/commitdiff
admin: Fix the default uri for session daemon to libvirtd:///session
authorErik Skultety <eskultet@redhat.com>
Fri, 29 Jul 2016 11:57:59 +0000 (13:57 +0200)
committerErik Skultety <eskultet@redhat.com>
Tue, 9 Aug 2016 11:25:22 +0000 (13:25 +0200)
Just like we decide on which URI we go with based on EUID for qemu in remote
driver, do a similar thing for admin except we do not spawn a daemon in this
case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356858

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/libvirt-admin.c

index 4bf29b14a4cb2d4ee45d93b81dc8b73d304d85e3..4552e84a6e71c6746c0c944310258a2c5036e70b 100644 (file)
@@ -176,10 +176,14 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr)
             /* Since we can't probe connecting via any hypervisor driver as libvirt
              * does, if no explicit URI was given and neither the environment
              * variable, nor the configuration parameter had previously been set,
-             * we set the default admin server URI to 'libvirtd://system'.
+             * we set the default admin server URI to 'libvirtd:///system' or
+             * 'libvirtd:///session' depending on the process's EUID.
              */
-            if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
-                return -1;
+            if (geteuid() == 0 &&
+                VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
+                    return -1;
+            else if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0)
+                    return -1;
         }
     }