/* If we are root, then let's not go via the bus */
if (geteuid() == 0 && t == DBUS_BUS_SYSTEM) {
- if (!(bus = dbus_connection_open("unix:abstract=/org/freedesktop/systemd1/private", error)))
+ if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", error)))
return -EIO;
if (bus_check_peercred(bus) < 0) {
close_nointr_nofail(s->epoll_fd);
if (s->bus) {
- dbus_connection_set_exit_on_disconnect(s->bus, FALSE);
+ dbus_connection_close(s->bus);
dbus_connection_unref(s->bus);
}
}
s->n_fifos ++;
}
- if (!(s->bus = dbus_connection_open("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
+ if (bus_connect(DBUS_BUS_SYSTEM, &s->bus, NULL, &error) < 0) {
log_error("Failed to get D-Bus connection: %s", error.message);
goto fail;
}
- if ((r = bus_check_peercred(s->bus)) < 0) {
- log_error("Bus connection failed peer credential check: %s", strerror(-r));
- goto fail;
- }
return 0;
else
strncpy(sa.un.sun_path+1, NOTIFY_SOCKET, sizeof(sa.un.sun_path)-1);
- if (bind(m->notify_watch.fd, &sa.sa, sizeof(sa)) < 0) {
+ if (bind(m->notify_watch.fd, &sa.sa, sizeof(sa_family_t) + 1 + strlen(sa.un.sun_path+1)) < 0) {
log_error("bind() failed: %m");
return -errno;
}
a->sockaddr.un.sun_family = AF_UNIX;
memcpy(a->sockaddr.un.sun_path+1, s+1, l);
- a->size = sizeof(struct sockaddr_un);
+ a->size = sizeof(sa_family_t) + 1 + l;
} else {
if (a->size > sizeof(sa_family_t)) {
- if (a->sockaddr.un.sun_path[0] == 0) {
- /* abstract */
- if (a->size != sizeof(struct sockaddr_un))
- return -EINVAL;
- } else {
+ if (a->sockaddr.un.sun_path[0] != 0) {
char *e;
/* path */
if (strncmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0)
return false;
} else {
- if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0)
+ if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, a->size) != 0)
return false;
}
if (utmp_get_runlevel(&previous, NULL) < 0)
previous = 'N';
- if (!(bus = dbus_connection_open("unix:abstract=/com/ubuntu/upstart", &error))) {
+ if (!(bus = dbus_connection_open_private("unix:abstract=/com/ubuntu/upstart", &error))) {
if (dbus_error_has_name(&error, DBUS_ERROR_NO_SERVER)) {
r = 0;
goto finish;
if (reply)
dbus_message_unref(reply);
- if (bus)
+ if (bus) {
+ dbus_connection_close(bus);
dbus_connection_unref(bus);
+ }
dbus_error_free(&error);
finish:
- if (bus)
+ if (bus) {
+ dbus_connection_close(bus);
dbus_connection_unref(bus);
+ }
dbus_error_free(&error);
#include <errno.h>
#include <string.h>
#include <stdio.h>
+#include <fcntl.h>
#include "loopback-setup.h"
#include "util.h"