aboutsummaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-04-19 15:34:35 +0100
committerDaniel Berrange <berrange@dhcp-159.gsslab.fab.redhat.com>2012-04-19 17:03:10 +0100
commit2223ea984cb9484cdcdcb8732c04072e84b40dd4 (patch)
treecdd7e734b4790ed631434846a732608ab81028ed /daemon
parentnwfilter: Fix support for trusted DHCP servers (diff)
downloadlibvirt-2223ea984cb9484cdcdcb8732c04072e84b40dd4.tar.gz
libvirt-2223ea984cb9484cdcdcb8732c04072e84b40dd4.tar.bz2
libvirt-2223ea984cb9484cdcdcb8732c04072e84b40dd4.zip
The policy kit and HAL node device drivers both require a
DBus connection. The HAL device code further requires that the DBus connection is integrated with the event loop and provides such glue logic itself. The forthcoming FirewallD integration also requires a dbus connection with event loop integration. Thus we need to pull the current event loop glue out of the HAL driver. Thus we create src/util/virdbus.{c,h} files. This contains just one method virDBusGetSystemBus() which obtains a handle to the single shared system bus instance, with event glue automagically setup.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/Makefile.am3
-rw-r--r--daemon/libvirtd.c4
-rw-r--r--daemon/remote.c8
3 files changed, 8 insertions, 7 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 5d9f5d75e..24cce8f86 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -94,7 +94,7 @@ libvirtd_SOURCES = $(DAEMON_SOURCES)
#-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
libvirtd_CFLAGS = \
$(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
- $(XDR_CFLAGS) $(POLKIT_CFLAGS) \
+ $(XDR_CFLAGS) $(POLKIT_CFLAGS) $(DBUS_CFLAGS) \
$(WARN_CFLAGS) \
$(COVERAGE_CFLAGS) \
-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
@@ -108,6 +108,7 @@ libvirtd_LDADD = \
$(LIBXML_LIBS) \
$(GNUTLS_LIBS) \
$(SASL_LIBS) \
+ $(DBUS_LIBS) \
$(POLKIT_LIBS)
if WITH_DTRACE_PROBES
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index ce931d4a1..b098f6a56 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -812,7 +812,6 @@ int main(int argc, char **argv) {
struct daemonConfig *config;
bool privileged = geteuid() == 0 ? true : false;
bool implicit_conf = false;
- bool use_polkit_dbus;
char *run_dir = NULL;
mode_t old_umask;
@@ -1008,8 +1007,6 @@ int main(int argc, char **argv) {
goto cleanup;
}
- use_polkit_dbus = config->auth_unix_rw == REMOTE_AUTH_POLKIT ||
- config->auth_unix_ro == REMOTE_AUTH_POLKIT;
if (!(srv = virNetServerNew(config->min_workers,
config->max_workers,
config->prio_workers,
@@ -1018,7 +1015,6 @@ int main(int argc, char **argv) {
config->keepalive_count,
!!config->keepalive_required,
config->mdns_adv ? config->mdns_name : NULL,
- use_polkit_dbus,
remoteClientInitHook))) {
ret = VIR_DAEMON_ERR_INIT;
goto cleanup;
diff --git a/daemon/remote.c b/daemon/remote.c
index b71ffa2a1..16a8a0579 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -45,7 +45,7 @@
#include "virnetserver.h"
#include "virfile.h"
#include "virtypedparam.h"
-
+#include "virdbus.h"
#include "remote_protocol.h"
#include "qemu_protocol.h"
@@ -2672,6 +2672,7 @@ remoteDispatchAuthPolkit(virNetServerPtr server,
char *ident = NULL;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
+ DBusConnection *sysbus;
virMutexLock(&priv->lock);
@@ -2697,10 +2698,13 @@ remoteDispatchAuthPolkit(virNetServerPtr server,
goto authfail;
}
+ if (!(sysbus = virDBusGetSystemBus()))
+ goto authfail;
+
VIR_INFO("Checking PID %lld running as %d",
(long long) callerPid, callerUid);
dbus_error_init(&err);
- if (!(pkcaller = polkit_caller_new_from_pid(virNetServerGetDBusConn(server),
+ if (!(pkcaller = polkit_caller_new_from_pid(sysbus,
callerPid, &err))) {
VIR_ERROR(_("Failed to lookup policy kit caller: %s"), err.message);
dbus_error_free(&err);