From: Erik Skultety Date: Tue, 9 Aug 2016 11:57:41 +0000 (+0200) Subject: virt-admin: Properly fix the default session daemon URI to admin server X-Git-Tag: v2.2.0-rc1~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e5e7f3a5b7a9a7325ad4ac719abd469cd7f8a45;p=thirdparty%2Flibvirt.git virt-admin: Properly fix the default session daemon URI to admin server Commit 30ce2f0e tried to fix the issue with an incorrect session URI to admin server but it messed up the checks: if (geteuid == 0 && VIR_STRDUP(*uristr, "libvirtd:///system") < 0) return -1; else if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0) return -1; So if a client executed with root privileges tries to connect, its euid is checked (true) and the correct URI is successfully copied to @uristr (false), therefore the 'else' branch is taken and @uristr is replaced by the session URI which for root results in: Failed to connect socket to '/root/.cache/libvirt/libvirt-admin-sock': No such file or directory Signed-off-by: Erik Skultety --- diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index 4552e84a6e..03245b636f 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -179,11 +179,13 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr) * we set the default admin server URI to 'libvirtd:///system' or * 'libvirtd:///session' depending on the process's EUID. */ - if (geteuid() == 0 && - VIR_STRDUP(*uristr, "libvirtd:///system") < 0) + if (geteuid() == 0) { + if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0) return -1; - else if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0) + } else { + if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0) return -1; + } } }