mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
remote: refactor how unprivileged user session connection is identified
Currently the VIR_DRV_OPEN_REMOTE_USER flag is only set when we identify that we're connecting to a local libvirtd daemon. We would like to be able to set that even if connecting to a remote libvirtd daemon. This entails refactoring the conditional check. One subtle change is that the VIR_DRV_OPEN_REMOTE_USER is now set when the test+XXX:// URI is used, even if a servername is present. This has no effect in this patch, but will later. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
5a148ce846
commit
00d172545f
@ -1345,26 +1345,36 @@ remoteConnectOpen(virConnectPtr conn,
|
|||||||
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If no servername is given, and no +XXX
|
* User session daemon is used for
|
||||||
* transport is listed, or transport is unix,
|
*
|
||||||
* and path is /session, and uid is unprivileged
|
* - Any URI with /session suffix
|
||||||
* then auto-spawn a daemon.
|
* - Test driver, if a protocol is given
|
||||||
|
*
|
||||||
|
* provided we are running non-root
|
||||||
*/
|
*/
|
||||||
if (conn->uri &&
|
if (conn->uri &&
|
||||||
!conn->uri->server &&
|
|
||||||
conn->uri->path &&
|
conn->uri->path &&
|
||||||
conn->uri->scheme &&
|
conn->uri->scheme &&
|
||||||
(transport == NULL || STREQ(transport, "unix")) &&
|
|
||||||
(STREQ(conn->uri->path, "/session") ||
|
(STREQ(conn->uri->path, "/session") ||
|
||||||
STRPREFIX(conn->uri->scheme, "test+")) &&
|
STRPREFIX(conn->uri->scheme, "test+")) &&
|
||||||
geteuid() > 0) {
|
geteuid() > 0) {
|
||||||
VIR_DEBUG("Auto-spawn user daemon instance");
|
VIR_DEBUG("User session daemon required");
|
||||||
rflags |= VIR_DRV_OPEN_REMOTE_USER;
|
rflags |= VIR_DRV_OPEN_REMOTE_USER;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Furthermore if no servername is given, and no +XXX
|
||||||
|
* transport is listed, or transport is unix,
|
||||||
|
* and uid is unprivileged then auto-spawn a daemon.
|
||||||
|
*/
|
||||||
if (!virIsSUID() &&
|
if (!virIsSUID() &&
|
||||||
|
!conn->uri->server &&
|
||||||
|
(transport == NULL || STREQ(transport, "unix")) &&
|
||||||
(!autostart ||
|
(!autostart ||
|
||||||
STRNEQ(autostart, "0")))
|
STRNEQ(autostart, "0"))) {
|
||||||
|
VIR_DEBUG("Try daemon autostart");
|
||||||
rflags |= VIR_DRV_OPEN_REMOTE_AUTOSTART;
|
rflags |= VIR_DRV_OPEN_REMOTE_AUTOSTART;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If URI is NULL, then do a UNIX connection possibly auto-spawning
|
* If URI is NULL, then do a UNIX connection possibly auto-spawning
|
||||||
|
Loading…
Reference in New Issue
Block a user