[systemd-commits] 6 commits - Makefile.am src/dbus.c src/hostnamed.c src/localed.c src/logind-acl.c src/logind.c src/logind.h src/timedated.c units/getty at .service.m4

Lennart Poettering lennart at kemper.freedesktop.org
Mon Jun 27 15:26:43 PDT 2011


 Makefile.am             |   19 ++++++--------
 src/dbus.c              |   28 ++++++++++-----------
 src/hostnamed.c         |   13 +++++++--
 src/localed.c           |   13 +++++++--
 src/logind-acl.c        |   15 ++++++-----
 src/logind.c            |   63 +++++++++++++++++++++++++++++++++++++++++++-----
 src/logind.h            |    1 
 src/timedated.c         |   13 +++++++--
 units/getty at .service.m4 |    2 -
 9 files changed, 119 insertions(+), 48 deletions(-)

New commits:
commit 21308c654dda82726f634fc695529d3af33e6fb6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 28 00:26:34 2011 +0200

    logind: kill a session as soon as its pipe fd gets EOF

diff --git a/src/logind.c b/src/logind.c
index 701ef49..8507c2e 100644
--- a/src/logind.c
+++ b/src/logind.c
@@ -771,7 +771,7 @@ static void manager_pipe_notify_eof(Manager *m, int fd) {
         assert(s->pipe_fd == fd);
         session_unset_pipe_fd(s);
 
-        session_add_to_gc_queue(s);
+        session_stop(s);
 }
 
 static int manager_connect_bus(Manager *m) {
diff --git a/src/logind.h b/src/logind.h
index 5c513b4..be8bb1d 100644
--- a/src/logind.h
+++ b/src/logind.h
@@ -39,7 +39,6 @@
  * direct client API
  * D-Bus method: AttachDevices(seat, devices[]);
  * D-Bus method: SetLinger(user, bool b);
- * kill cgroup immediately when fd is EOF.
  *
  * non-local X11 server
  * reboot/shutdown halt management

commit d0a522eb312a0f6014e756d3fc066efc37fceaf7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 28 00:26:10 2011 +0200

    logind: autospawn gettys when necessary

diff --git a/Makefile.am b/Makefile.am
index bfc1079..dc1a87e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1513,26 +1513,23 @@ endif
 		$(LN_S) graphical.target runlevel5.target && \
 		$(LN_S) reboot.target runlevel6.target )
 	( cd $(DESTDIR)$(systemunitdir) && \
-		rm -f default.target ctrl-alt-del.target dbus-org.freedesktop.hostname1.service dbus-org.freedesktop.locale1.service dbus-org.freedesktop.timedate1.service dbus-org.freedesktop.login1.service && \
+		rm -f default.target ctrl-alt-del.target dbus-org.freedesktop.hostname1.service dbus-org.freedesktop.locale1.service dbus-org.freedesktop.timedate1.service dbus-org.freedesktop.login1.service autovt-getty at .service && \
 		$(LN_S) graphical.target default.target && \
 		$(LN_S) reboot.target ctrl-alt-del.target && \
                 $(LN_S) systemd-hostnamed.service dbus-org.freedesktop.hostname1.service && \
                 $(LN_S) systemd-localed.service dbus-org.freedesktop.locale1.service && \
                 $(LN_S) systemd-timedated.service dbus-org.freedesktop.timedate1.service && \
-                $(LN_S) systemd-logind.service dbus-org.freedesktop.login1.service )
+                $(LN_S) systemd-logind.service dbus-org.freedesktop.login1.service && \
+                $(LN_S) getty at .service autovt-getty at .service )
 	( cd $(DESTDIR)$(systemunitdir)/multi-user.target.wants && \
-		rm -f getty.target systemd-user-sessions.service systemd-ask-password-wall.path && \
+		rm -f getty.target systemd-user-sessions.service systemd-ask-password-wall.path systemd-logind.service && \
 		$(LN_S) ../getty.target getty.target && \
 		$(LN_S) ../systemd-user-sessions.service systemd-user-sessions.service && \
-		$(LN_S) ../systemd-ask-password-wall.path systemd-ask-password-wall.path )
+		$(LN_S) ../systemd-ask-password-wall.path systemd-ask-password-wall.path && \
+                $(LN_S) ../systemd-logind.service systemd-logind.service )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/getty.target.wants && \
-		rm -f getty at tty1.service getty at tty2.service getty at tty3.service getty at tty4.service getty at tty5.service getty at tty6.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty1.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty2.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty3.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty4.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty5.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty6.service )
+		rm -f getty at tty1.service && \
+		$(LN_S) $(systemunitdir)/getty at .service getty at tty1.service )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/multi-user.target.wants && \
 		rm -f remote-fs.target && \
 		$(LN_S) $(systemunitdir)/remote-fs.target remote-fs.target )
diff --git a/src/logind.c b/src/logind.c
index 3100fd2..701ef49 100644
--- a/src/logind.c
+++ b/src/logind.c
@@ -652,7 +652,13 @@ static int vt_is_busy(int vtnr) {
 
         assert(vtnr >= 1);
 
-        fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
+        /* We explicitly open /dev/tty1 here instead of /dev/tty0. If
+         * we'd open the latter we'd open the foreground tty which
+         * hence would be unconditionally busy. By opening /dev/tty1
+         * we avoid this. Since tty1 is special and needs to be an
+         * explicitly loaded getty or DM this is safe. */
+
+        fd = open_terminal("/dev/tty1", O_RDWR|O_NOCTTY|O_CLOEXEC);
         if (fd < 0)
                 return -errno;
 
@@ -668,16 +674,61 @@ static int vt_is_busy(int vtnr) {
 
 int manager_spawn_autovt(Manager *m, int vtnr) {
         int r;
+        DBusMessage *message = NULL, *reply = NULL;
+        char *name = NULL;
+        const char *mode = "fail";
+        DBusError error;
 
         assert(m);
 
+        dbus_error_init(&error);
+
         r = vt_is_busy(vtnr);
         if (r != 0)
                 return r;
 
-        /* ... */
+        message = dbus_message_new_method_call("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartUnit");
+        if (!message) {
+                log_error("Could not allocate message.");
+                r = -ENOMEM;
+                goto finish;
+        }
+
+        if (asprintf(&name, "autovt-getty at tty%i.service", vtnr) < 0) {
+                log_error("Could not allocate service name.");
+                r = -ENOMEM;
+                goto finish;
+        }
 
-        return 0;
+        if (!dbus_message_append_args(message,
+                                      DBUS_TYPE_STRING, &name,
+                                      DBUS_TYPE_STRING, &mode,
+                                      DBUS_TYPE_INVALID)) {
+                log_error("Could not attach target and flag information to message.");
+                r = -ENOMEM;
+                goto finish;
+        }
+
+        reply = dbus_connection_send_with_reply_and_block(m->bus, message, -1, &error);
+        if (!reply) {
+                log_error("Failed to start unit: %s", bus_error_message(&error));
+                goto finish;
+        }
+
+        r = 0;
+
+finish:
+        free(name);
+
+        if (message)
+                dbus_message_unref(message);
+
+        if (reply)
+                dbus_message_unref(reply);
+
+        dbus_error_free(&error);
+
+        return r;
 }
 
 void manager_cgroup_notify_empty(Manager *m, const char *cgroup) {
diff --git a/units/getty at .service.m4 b/units/getty at .service.m4
index bfceb39..b111567 100644
--- a/units/getty at .service.m4
+++ b/units/getty at .service.m4
@@ -51,4 +51,4 @@ Environment=LANG= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MES
 KillSignal=SIGHUP
 
 [Install]
-Alias=getty.target.wants/getty at tty1.service getty.target.wants/getty at tty2.service getty.target.wants/getty at tty3.service getty.target.wants/getty at tty4.service getty.target.wants/getty at tty5.service getty.target.wants/getty at tty6.service
+Alias=getty.target.wants/getty at tty1.service

commit 734b933ace7aac5d9c1d7507f9d30f73390ce102
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Jun 27 23:27:57 2011 +0200

    logind: when enumerating acl devices for seat0, don't set a tag

diff --git a/src/logind-acl.c b/src/logind-acl.c
index 5ea6818..7571093 100644
--- a/src/logind-acl.c
+++ b/src/logind-acl.c
@@ -233,9 +233,11 @@ int devnode_acl_all(struct udev *udev,
         if (r < 0)
                 goto finish;
 
-        r = udev_enumerate_add_match_tag(e, seat);
-        if (r < 0)
-                goto finish;
+        if (!streq(seat, "seat0")) {
+                r = udev_enumerate_add_match_tag(e, seat);
+                if (r < 0)
+                        goto finish;
+        }
 
         r = udev_enumerate_scan_devices(e);
         if (r < 0)

commit ce0f7c97d2302c73832034aac1107e2378c2eeed
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Jun 27 23:20:56 2011 +0200

    logind: fix ACL code allocation

diff --git a/src/logind-acl.c b/src/logind-acl.c
index 3df104f..5ea6818 100644
--- a/src/logind-acl.c
+++ b/src/logind-acl.c
@@ -54,7 +54,7 @@ static int find_acl(acl_t acl, uid_t uid, acl_entry_t *entry) {
                         return -errno;
 
                 b = *u == uid;
-                free(u);
+                acl_free(u);
 
                 if (b) {
                         *entry = i;
@@ -262,14 +262,15 @@ int devnode_acl_all(struct udev *udev,
                 }
 
                 node = udev_device_get_devnode(d);
-                udev_device_unref(d);
-
                 if (!node) {
+                        udev_device_unref(d);
                         r = -ENOMEM;
                         goto finish;
                 }
 
                 r = devnode_acl(node, flush, del, old_uid, add, new_uid);
+                udev_device_unref(d);
+
                 if (r < 0)
                         goto finish;
         }

commit add10b5ae7636137f530e15efdf7af075d6361eb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Jun 27 23:15:57 2011 +0200

    dbus: fix name allocation logic

diff --git a/src/hostnamed.c b/src/hostnamed.c
index c6b63cd..7b2ce69 100644
--- a/src/hostnamed.c
+++ b/src/hostnamed.c
@@ -524,8 +524,15 @@ static int connect_bus(DBusConnection **_bus) {
                 goto fail;
         }
 
-        if (dbus_bus_request_name(bus, "org.freedesktop.hostname1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) {
-                log_error("Failed to register name on bus: %s", error.message);
+        r = dbus_bus_request_name(bus, "org.freedesktop.hostname1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error);
+        if (dbus_error_is_set(&error)) {
+                log_error("Failed to register name on bus: %s", bus_error_message(&error));
+                r = -EEXIST;
+                goto fail;
+        }
+
+        if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+                log_error("Failed to acquire name.");
                 r = -EEXIST;
                 goto fail;
         }
diff --git a/src/localed.c b/src/localed.c
index 5efee0b..93e4e9b 100644
--- a/src/localed.c
+++ b/src/localed.c
@@ -540,8 +540,15 @@ static int connect_bus(DBusConnection **_bus) {
                 goto fail;
         }
 
-        if (dbus_bus_request_name(bus, "org.freedesktop.locale1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) {
-                log_error("Failed to register name on bus: %s", error.message);
+        r = dbus_bus_request_name(bus, "org.freedesktop.locale1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error);
+        if (dbus_error_is_set(&error)) {
+                log_error("Failed to register name on bus: %s", bus_error_message(&error));
+                r = -EEXIST;
+                goto fail;
+        }
+
+        if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+                log_error("Failed to acquire name.");
                 r = -EEXIST;
                 goto fail;
         }
diff --git a/src/timedated.c b/src/timedated.c
index 097e0a0..55cc904 100644
--- a/src/timedated.c
+++ b/src/timedated.c
@@ -543,8 +543,15 @@ static int connect_bus(DBusConnection **_bus) {
                 goto fail;
         }
 
-        if (dbus_bus_request_name(bus, "org.freedesktop.timedate1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) < 0) {
-                log_error("Failed to register name on bus: %s", error.message);
+        r = dbus_bus_request_name(bus, "org.freedesktop.timedate1", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error);
+        if (dbus_error_is_set(&error)) {
+                log_error("Failed to register name on bus: %s", bus_error_message(&error));
+                r = -EEXIST;
+                goto fail;
+        }
+
+        if (r != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)  {
+                log_error("Failed to acquire name.");
                 r = -EEXIST;
                 goto fail;
         }

commit a2e5283217b9e1e636ab3272e8d36e724a78cf6a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Jun 27 23:15:30 2011 +0200

    dbus: use bus_error_message() where applicable

diff --git a/src/dbus.c b/src/dbus.c
index 764c65c..6690690 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -332,7 +332,7 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
                                            DBUS_TYPE_STRING, &old_owner,
                                            DBUS_TYPE_STRING, &new_owner,
                                            DBUS_TYPE_INVALID))
-                        log_error("Failed to parse NameOwnerChanged message: %s", error.message);
+                        log_error("Failed to parse NameOwnerChanged message: %s", bus_error_message(&error));
                 else  {
                         if (set_remove(BUS_CONNECTION_SUBSCRIBED(m, connection), (char*) name))
                                 log_debug("Subscription client vanished: %s (left: %u)", name, set_size(BUS_CONNECTION_SUBSCRIBED(m, connection)));
@@ -351,7 +351,7 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
                 if (!dbus_message_get_args(message, &error,
                                            DBUS_TYPE_STRING, &name,
                                            DBUS_TYPE_INVALID))
-                        log_error("Failed to parse ActivationRequest message: %s", error.message);
+                        log_error("Failed to parse ActivationRequest message: %s", bus_error_message(&error));
                 else  {
                         int r;
                         Unit *u;
@@ -482,7 +482,7 @@ static DBusHandlerResult private_bus_message_filter(DBusConnection *connection,
                 if (!dbus_message_get_args(message, &error,
                                            DBUS_TYPE_STRING, &cgroup,
                                            DBUS_TYPE_INVALID))
-                        log_error("Failed to parse Released message: %s", error.message);
+                        log_error("Failed to parse Released message: %s", bus_error_message(&error));
                 else
                         cgroup_notify_empty(m, cgroup);
 
@@ -540,7 +540,7 @@ static void request_name_pending_cb(DBusPendingCall *pending, void *userdata) {
         case DBUS_MESSAGE_TYPE_ERROR:
 
                 assert_se(dbus_set_error_from_message(&error, reply));
-                log_warning("RequestName() failed: %s", error.message);
+                log_warning("RequestName() failed: %s", bus_error_message(&error));
                 break;
 
         case DBUS_MESSAGE_TYPE_METHOD_RETURN: {
@@ -550,7 +550,7 @@ static void request_name_pending_cb(DBusPendingCall *pending, void *userdata) {
                                            &error,
                                            DBUS_TYPE_UINT32, &r,
                                            DBUS_TYPE_INVALID)) {
-                        log_error("Failed to parse RequestName() reply: %s", error.message);
+                        log_error("Failed to parse RequestName() reply: %s", bus_error_message(&error));
                         break;
                 }
 
@@ -637,7 +637,7 @@ static void query_name_list_pending_cb(DBusPendingCall *pending, void *userdata)
         case DBUS_MESSAGE_TYPE_ERROR:
 
                 assert_se(dbus_set_error_from_message(&error, reply));
-                log_warning("ListNames() failed: %s", error.message);
+                log_warning("ListNames() failed: %s", bus_error_message(&error));
                 break;
 
         case DBUS_MESSAGE_TYPE_METHOD_RETURN: {
@@ -782,7 +782,7 @@ static int bus_init_system(Manager *m) {
                 m->system_bus = m->api_bus;
         else {
                 if (!(m->system_bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) {
-                        log_debug("Failed to get system D-Bus connection, retrying later: %s", error.message);
+                        log_debug("Failed to get system D-Bus connection, retrying later: %s", bus_error_message(&error));
                         r = 0;
                         goto fail;
                 }
@@ -806,7 +806,7 @@ static int bus_init_system(Manager *m) {
                                    &error);
 
                 if (dbus_error_is_set(&error)) {
-                        log_error("Failed to register match: %s", error.message);
+                        log_error("Failed to register match: %s", bus_error_message(&error));
                         r = -EIO;
                         goto fail;
                 }
@@ -844,7 +844,7 @@ static int bus_init_api(Manager *m) {
                 m->api_bus = m->system_bus;
         else {
                 if (!(m->api_bus = dbus_bus_get_private(m->running_as == MANAGER_USER ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error))) {
-                        log_debug("Failed to get API D-Bus connection, retrying later: %s", error.message);
+                        log_debug("Failed to get API D-Bus connection, retrying later: %s", bus_error_message(&error));
                         r = 0;
                         goto fail;
                 }
@@ -872,7 +872,7 @@ static int bus_init_api(Manager *m) {
                            &error);
 
         if (dbus_error_is_set(&error)) {
-                log_error("Failed to register match: %s", error.message);
+                log_error("Failed to register match: %s", bus_error_message(&error));
                 r = -EIO;
                 goto fail;
         }
@@ -887,7 +887,7 @@ static int bus_init_api(Manager *m) {
                            &error);
 
         if (dbus_error_is_set(&error)) {
-                log_error("Failed to register match: %s", error.message);
+                log_error("Failed to register match: %s", bus_error_message(&error));
                 r = -EIO;
                 goto fail;
         }
@@ -936,7 +936,7 @@ static int bus_init_private(Manager *m) {
 
         unlink("/run/systemd/private");
         if (!(m->private_bus = dbus_server_listen("unix:path=/run/systemd/private", &error))) {
-                log_error("Failed to create private D-Bus server: %s", error.message);
+                log_error("Failed to create private D-Bus server: %s", bus_error_message(&error));
                 r = -EIO;
                 goto fail;
         }
@@ -1113,7 +1113,7 @@ static void query_pid_pending_cb(DBusPendingCall *pending, void *userdata) {
         case DBUS_MESSAGE_TYPE_ERROR:
 
                 assert_se(dbus_set_error_from_message(&error, reply));
-                log_warning("GetConnectionUnixProcessID() failed: %s", error.message);
+                log_warning("GetConnectionUnixProcessID() failed: %s", bus_error_message(&error));
                 break;
 
         case DBUS_MESSAGE_TYPE_METHOD_RETURN: {
@@ -1123,7 +1123,7 @@ static void query_pid_pending_cb(DBusPendingCall *pending, void *userdata) {
                                            &error,
                                            DBUS_TYPE_UINT32, &r,
                                            DBUS_TYPE_INVALID)) {
-                        log_error("Failed to parse GetConnectionUnixProcessID() reply: %s", error.message);
+                        log_error("Failed to parse GetConnectionUnixProcessID() reply: %s", bus_error_message(&error));
                         break;
                 }
 
diff --git a/src/hostnamed.c b/src/hostnamed.c
index d05c902..c6b63cd 100644
--- a/src/hostnamed.c
+++ b/src/hostnamed.c
@@ -513,7 +513,7 @@ static int connect_bus(DBusConnection **_bus) {
 
         bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
         if (!bus) {
-                log_error("Failed to get system D-Bus connection: %s", error.message);
+                log_error("Failed to get system D-Bus connection: %s", bus_error_message(&error));
                 r = -ECONNREFUSED;
                 goto fail;
         }
diff --git a/src/localed.c b/src/localed.c
index 353e88e..5efee0b 100644
--- a/src/localed.c
+++ b/src/localed.c
@@ -529,7 +529,7 @@ static int connect_bus(DBusConnection **_bus) {
 
         bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
         if (!bus) {
-                log_error("Failed to get system D-Bus connection: %s", error.message);
+                log_error("Failed to get system D-Bus connection: %s", bus_error_message(&error));
                 r = -ECONNREFUSED;
                 goto fail;
         }
diff --git a/src/logind.c b/src/logind.c
index 863b163..3100fd2 100644
--- a/src/logind.c
+++ b/src/logind.c
@@ -736,7 +736,7 @@ static int manager_connect_bus(Manager *m) {
 
         m->bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
         if (!m->bus) {
-                log_error("Failed to get system D-Bus connection: %s", error.message);
+                log_error("Failed to get system D-Bus connection: %s", bus_error_message(&error));
                 r = -ECONNREFUSED;
                 goto fail;
         }
@@ -759,7 +759,7 @@ static int manager_connect_bus(Manager *m) {
                            &error);
 
         if (dbus_error_is_set(&error)) {
-                log_error("Failed to register match: %s", error.message);
+                log_error("Failed to register match: %s", bus_error_message(&error));
                 r = -EIO;
                 goto fail;
         }
diff --git a/src/timedated.c b/src/timedated.c
index a6ec262..097e0a0 100644
--- a/src/timedated.c
+++ b/src/timedated.c
@@ -532,7 +532,7 @@ static int connect_bus(DBusConnection **_bus) {
 
         bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
         if (!bus) {
-                log_error("Failed to get system D-Bus connection: %s", error.message);
+                log_error("Failed to get system D-Bus connection: %s", bus_error_message(&error));
                 r = -ECONNREFUSED;
                 goto fail;
         }



More information about the systemd-commits mailing list