summaryrefslogtreecommitdiff
path: root/src/cgroups-agent.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-08-06 03:21:50 +0200
committerLennart Poettering <lennart@poettering.net>2010-08-06 03:21:50 +0200
commit3c661fadd5e0d74acc7596024db31be00c53b448 (patch)
treeab14830c6eef7b0e03a909e3df1873683a7c5ea3 /src/cgroups-agent.c
parent2e81c8a55785d33e48c6d512e094a3a7dd0bf900 (diff)
cgroup: if the system bus cannot be found, send cgroup empty msg directly to init proces
Diffstat (limited to 'src/cgroups-agent.c')
-rw-r--r--src/cgroups-agent.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/cgroups-agent.c b/src/cgroups-agent.c
index d3db151b18..a1eac1459e 100644
--- a/src/cgroups-agent.c
+++ b/src/cgroups-agent.c
@@ -22,6 +22,7 @@
#include <dbus/dbus.h>
#include "log.h"
+#include "dbus-common.h"
int main(int argc, char *argv[]) {
DBusError error;
@@ -36,9 +37,25 @@ int main(int argc, char *argv[]) {
goto finish;
}
+ log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
+ log_parse_environment();
+
+ /* If possible we go via the system bus, to make sure that
+ * session instances get the messages. If not possible we talk
+ * to the system instance directly. */
if (!(bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) {
- log_error("Failed to get D-Bus connection: %s", error.message);
- goto finish;
+
+ dbus_error_free(&error);
+
+ if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
+ log_error("Failed to get D-Bus connection: %s", error.message);
+ goto finish;
+ }
+
+ if (bus_check_peercred(bus) < 0) {
+ log_error("Bus owner not root.");
+ goto finish;
+ }
}
if (!(m = dbus_message_new_signal("/org/freedesktop/systemd1/agent", "org.freedesktop.systemd1.Agent", "Released"))) {