[systemd-commits] 3 commits - src/dbus-common.c src/initctl.c src/manager.c src/socket-util.c src/systemctl.c src/test-loopback.c

Lennart Poettering lennart at kemper.freedesktop.org
Sat Jul 10 18:49:36 PDT 2010


 src/dbus-common.c   |    2 +-
 src/initctl.c       |    8 ++------
 src/manager.c       |    2 +-
 src/socket-util.c   |   10 +++-------
 src/systemctl.c     |   10 +++++++---
 src/test-loopback.c |    1 +
 6 files changed, 15 insertions(+), 18 deletions(-)

New commits:
commit dce3acd2e2447a9de642768f86e39d7c9d5bee81
Merge: b12c1e7... 17bb738...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Jul 11 03:49:22 2010 +0200

    Merge branch 'master' of ssh://git.freedesktop.org/git/systemd

commit b12c1e7cf744a5e28db5a29e89377496893c1ab8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Jul 11 02:23:11 2010 +0200

    socket: pass minimal abstract socket names

diff --git a/src/manager.c b/src/manager.c
index d26541d..6dfef71 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -89,7 +89,7 @@ static int manager_setup_notify(Manager *m) {
         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;
         }
diff --git a/src/socket-util.c b/src/socket-util.c
index 5463ffb..e6e3784 100644
--- a/src/socket-util.c
+++ b/src/socket-util.c
@@ -101,7 +101,7 @@ int socket_address_parse(SocketAddress *a, const char *s) {
 
                 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 {
 
@@ -198,11 +198,7 @@ int socket_address_verify(const SocketAddress *a) {
 
                         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 */
@@ -437,7 +433,7 @@ bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) {
                         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;
                 }
 
commit b574246b4f8e4eb86c29c38c7df47b541b68188a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Jul 11 02:22:46 2010 +0200

    dbus: use private connections wherever possible

diff --git a/src/dbus-common.c b/src/dbus-common.c
index 11d989d..267ab26 100644
--- a/src/dbus-common.c
+++ b/src/dbus-common.c
@@ -62,7 +62,7 @@ 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("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) {
diff --git a/src/initctl.c b/src/initctl.c
index 7241acb..83a560a 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -232,7 +232,7 @@ static void server_done(Server *s) {
                 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);
         }
 }
@@ -297,14 +297,10 @@ static int server_init(Server *s, unsigned n_sockets) {
                 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;
 
diff --git a/src/systemctl.c b/src/systemctl.c
index 799f57d..d904717 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -3056,7 +3056,7 @@ static int talk_upstart(void) {
         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;
@@ -3120,8 +3120,10 @@ finish:
         if (reply)
                 dbus_message_unref(reply);
 
-        if (bus)
+        if (bus) {
+                dbus_connection_close(bus);
                 dbus_connection_unref(bus);
+        }
 
         dbus_error_free(&error);
 
@@ -3444,8 +3446,10 @@ int main(int argc, char*argv[]) {
 
 finish:
 
-        if (bus)
+        if (bus) {
+                dbus_connection_close(bus);
                 dbus_connection_unref(bus);
+        }
 
         dbus_error_free(&error);
 
diff --git a/src/test-loopback.c b/src/test-loopback.c
index 478f2f6..7444987 100644
--- a/src/test-loopback.c
+++ b/src/test-loopback.c
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
+#include <fcntl.h>
 
 #include "loopback-setup.h"
 #include "util.h"


More information about the systemd-commits mailing list