summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-14 03:10:09 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-14 03:12:25 +0100
commit91b22f21f3824c1766d34f622c5bbb70cbe881a8 (patch)
treedb29bcf8e6c77ea521fa2f8185339c50c606af35
parent88213476187cafc86bea2276199891873000588d (diff)
core: move abstract namespace sockets to /dev/.run
Now that we have /dev/.run there's no need to use abstract namespace sockets. So, let's move things to /dev/.run, to make things more easily discoverable and improve compat with chroot() and fs namespacing.
-rw-r--r--man/systemd.xml8
-rw-r--r--src/cgroups-agent.c15
-rw-r--r--src/dbus-common.c12
-rw-r--r--src/dbus.c2
-rw-r--r--src/execute.c4
-rw-r--r--src/execute.h2
-rw-r--r--src/manager.c15
-rw-r--r--src/service.c2
-rw-r--r--src/systemctl.c4
-rw-r--r--units/systemd-logger.socket2
-rw-r--r--units/systemd-shutdownd.socket2
11 files changed, 46 insertions, 22 deletions
diff --git a/man/systemd.xml b/man/systemd.xml
index 6b1a4c9d98..5a4c4ab9c5 100644
--- a/man/systemd.xml
+++ b/man/systemd.xml
@@ -1024,7 +1024,7 @@
<variablelist>
<varlistentry>
- <term><filename>@/org/freedesktop/systemd1/notify</filename></term>
+ <term><filename>/var/run/systemd/notify</filename></term>
<listitem><para>Daemon status
notification socket. This is an AF_UNIX
@@ -1037,7 +1037,7 @@
</varlistentry>
<varlistentry>
- <term><filename>@/org/freedesktop/systemd1/logger</filename></term>
+ <term><filename>/var/run/systemd/logger</filename></term>
<listitem><para>Used internally by the
<filename>systemd-logger.service</filename>
@@ -1050,7 +1050,7 @@
</varlistentry>
<varlistentry>
- <term><filename>@/org/freedesktop/systemd1/shutdown</filename></term>
+ <term><filename>/var/run/systemd/shutdownd</filename></term>
<listitem><para>Used internally by the
<citerefentry><refentrytitle>shutdown</refentrytitle><manvolnum>8</manvolnum></citerefentry>
@@ -1061,7 +1061,7 @@
</varlistentry>
<varlistentry>
- <term><filename>@/org/freedesktop/systemd1/private</filename></term>
+ <term><filename>/var/run/systemd/private</filename></term>
<listitem><para>Used internally as
communication channel between
diff --git a/src/cgroups-agent.c b/src/cgroups-agent.c
index 7b4fca245d..18612eca3c 100644
--- a/src/cgroups-agent.c
+++ b/src/cgroups-agent.c
@@ -49,10 +49,19 @@ int main(int argc, char *argv[]) {
* this to avoid an activation loop when we start dbus when we
* are called when the dbus service is shut down. */
- if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
- log_error("Failed to get D-Bus connection: %s", bus_error_message(&error));
- goto finish;
+ if (!(bus = dbus_connection_open_private("unix:path=/dev/.run/systemd/private", &error))) {
+#ifndef LEGACY
+ dbus_error_free(&error);
+
+ /* Retry with the pre v21 socket name, to ease upgrades */
+ if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
+#endif
+ log_error("Failed to get D-Bus connection: %s", bus_error_message(&error));
+ goto finish;
+ }
+#ifndef LEGACY
}
+#endif
if (bus_check_peercred(bus) < 0) {
log_error("Bus owner not root.");
diff --git a/src/dbus-common.c b/src/dbus-common.c
index 25b718ec02..bb9cf2e2ab 100644
--- a/src/dbus-common.c
+++ b/src/dbus-common.c
@@ -104,8 +104,16 @@ int bus_connect(DBusBusType t, DBusConnection **_bus, bool *private, DBusError *
/* If we are root, then let's not go via the bus */
if (geteuid() == 0 && t == DBUS_BUS_SYSTEM) {
- if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", error)))
- return -EIO;
+
+ if (!(bus = dbus_connection_open_private("unix:path=/dev/.run/systemd/private", error))) {
+#ifndef LEGACY
+ dbus_error_free(error);
+
+ /* Retry with the pre v21 socket name, to ease upgrades */
+ if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", error)))
+#endif
+ return -EIO;
+ }
dbus_connection_set_exit_on_disconnect(bus, FALSE);
diff --git a/src/dbus.c b/src/dbus.c
index af03c5746c..31e776fc30 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -955,7 +955,7 @@ static int bus_init_private(Manager *m) {
if (getpid() != 1)
return 0;
- if (!(m->private_bus = dbus_server_listen("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
+ if (!(m->private_bus = dbus_server_listen("unix:path=/dev/.run/systemd/private", &error))) {
log_error("Failed to create private D-Bus server: %s", error.message);
r = -EIO;
goto fail;
diff --git a/src/execute.c b/src/execute.c
index ee05e99445..556ff9bda9 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -173,9 +173,9 @@ static int connect_logger_as(const ExecContext *context, ExecOutput output, cons
zero(sa);
sa.sa.sa_family = AF_UNIX;
- strncpy(sa.un.sun_path+1, LOGGER_SOCKET, sizeof(sa.un.sun_path)-1);
+ strncpy(sa.un.sun_path, LOGGER_SOCKET, sizeof(sa.un.sun_path));
- if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + sizeof(LOGGER_SOCKET) - 1) < 0) {
+ if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + sizeof(LOGGER_SOCKET) - 1) < 0) {
close_nointr_nofail(fd);
return -errno;
}
diff --git a/src/execute.h b/src/execute.h
index 2856d2f33d..e77cdcf0bb 100644
--- a/src/execute.h
+++ b/src/execute.h
@@ -40,7 +40,7 @@ struct CGroupBonding;
#include "util.h"
/* Abstract namespace! */
-#define LOGGER_SOCKET "/org/freedesktop/systemd1/logger"
+#define LOGGER_SOCKET "/dev/.run/systemd/logger"
/* This doesn't really belong here, but I couldn't find a better place to put this. */
#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
diff --git a/src/manager.c b/src/manager.c
index 8bbde7c38e..6ccb03fab4 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -66,7 +66,8 @@
#define GC_QUEUE_USEC_MAX (10*USEC_PER_SEC)
/* Where clients shall send notification messages to */
-#define NOTIFY_SOCKET "/org/freedesktop/systemd1/notify"
+#define NOTIFY_SOCKET_SYSTEM "/dev/.run/systemd/notify"
+#define NOTIFY_SOCKET_USER "@/org/freedesktop/systemd1/notify"
static int manager_setup_notify(Manager *m) {
union {
@@ -88,9 +89,12 @@ static int manager_setup_notify(Manager *m) {
sa.sa.sa_family = AF_UNIX;
if (getpid() != 1)
- snprintf(sa.un.sun_path+1, sizeof(sa.un.sun_path)-1, NOTIFY_SOCKET "/%llu", random_ull());
+ snprintf(sa.un.sun_path, sizeof(sa.un.sun_path), NOTIFY_SOCKET_USER "/%llu", random_ull());
else
- strncpy(sa.un.sun_path+1, NOTIFY_SOCKET, sizeof(sa.un.sun_path)-1);
+ strncpy(sa.un.sun_path, NOTIFY_SOCKET_SYSTEM, sizeof(sa.un.sun_path));
+
+ if (sa.un.sun_path[0] == '@')
+ sa.un.sun_path[0] = 0;
if (bind(m->notify_watch.fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1)) < 0) {
log_error("bind() failed: %m");
@@ -109,7 +113,10 @@ static int manager_setup_notify(Manager *m) {
if (epoll_ctl(m->epoll_fd, EPOLL_CTL_ADD, m->notify_watch.fd, &ev) < 0)
return -errno;
- if (!(m->notify_socket = strdup(sa.un.sun_path+1)))
+ if (sa.un.sun_path[0] == 0)
+ sa.un.sun_path[0] = '@';
+
+ if (!(m->notify_socket = strdup(sa.un.sun_path)))
return -ENOMEM;
log_debug("Using notification socket %s", m->notify_socket);
diff --git a/src/service.c b/src/service.c
index 70999f3545..e7a9e7c586 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1659,7 +1659,7 @@ static int service_spawn(
}
if (set_notify_socket)
- if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=@%s", s->meta.manager->notify_socket) < 0) {
+ if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", s->meta.manager->notify_socket) < 0) {
r = -ENOMEM;
goto fail;
}
diff --git a/src/systemctl.c b/src/systemctl.c
index b8af654e09..5db094fc15 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -5364,7 +5364,7 @@ static int send_shutdownd(usec_t t, char mode, bool warn, const char *message) {
zero(sockaddr);
sockaddr.sa.sa_family = AF_UNIX;
sockaddr.un.sun_path[0] = 0;
- strncpy(sockaddr.un.sun_path+1, "/org/freedesktop/systemd1/shutdownd", sizeof(sockaddr.un.sun_path)-1);
+ strncpy(sockaddr.un.sun_path, "/dev/.run/systemd/shutdownd", sizeof(sockaddr.un.sun_path));
zero(iovec);
iovec.iov_base = (char*) &c;
@@ -5372,7 +5372,7 @@ static int send_shutdownd(usec_t t, char mode, bool warn, const char *message) {
zero(msghdr);
msghdr.msg_name = &sockaddr;
- msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + 1 + sizeof("/org/freedesktop/systemd1/shutdownd") - 1;
+ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + sizeof("/dev/.run/systemd/shutdownd") - 1;
msghdr.msg_iov = &iovec;
msghdr.msg_iovlen = 1;
diff --git a/units/systemd-logger.socket b/units/systemd-logger.socket
index 57244a2878..5cf6a9b0bf 100644
--- a/units/systemd-logger.socket
+++ b/units/systemd-logger.socket
@@ -13,4 +13,4 @@ DefaultDependencies=no
Before=sockets.target
[Socket]
-ListenStream=@/org/freedesktop/systemd1/logger
+ListenStream=/dev/.run/systemd/logger
diff --git a/units/systemd-shutdownd.socket b/units/systemd-shutdownd.socket
index 0df24cff77..6faf36f0e2 100644
--- a/units/systemd-shutdownd.socket
+++ b/units/systemd-shutdownd.socket
@@ -13,4 +13,4 @@ DefaultDependencies=no
Before=sockets.target
[Socket]
-ListenDatagram=@/org/freedesktop/systemd1/shutdownd
+ListenDatagram=/dev/.run/systemd/shutdownd