[systemd-commits] 4 commits - Makefile.am TODO src/core src/getty-generator src/login src/shared units/.gitignore units/console-getty.service.m4.in

Lennart Poettering lennart at kemper.freedesktop.org
Sat Apr 21 17:42:24 PDT 2012


 Makefile.am                           |    2 +
 TODO                                  |    3 ++
 src/core/condition.c                  |   10 +------
 src/getty-generator/getty-generator.c |    2 -
 src/login/loginctl.c                  |    4 +-
 src/login/logind-dbus.c               |   13 +++++++--
 src/shared/util.c                     |   27 ++++++++++++++++++-
 src/shared/util.h                     |    2 +
 units/.gitignore                      |    1 
 units/console-getty.service.m4.in     |   47 ++++++++++++++++++++++++++++++++++
 10 files changed, 96 insertions(+), 15 deletions(-)

New commits:
commit d1122ad5e3222cc17bfb556c23273598a5fb60fa
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 02:30:13 2012 +0200

    login: assing /dev/console logins to seat0

diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index b8143b6..3fe6c87 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -351,16 +351,25 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
                         vtnr = (uint32_t) v;
                 else if (vtnr != (uint32_t) v)
                         return -EINVAL;
+        } else if (tty_is_console(tty)) {
+
+                if (!s)
+                        s = m->vtconsole;
+                else if (s != m->vtconsole)
+                        return -EINVAL;
+
+                if (vtnr != 0)
+                        return -EINVAL;
 
         } else if (!isempty(tty) && s && seat_is_vtconsole(s))
                 return -EINVAL;
 
         if (s) {
                 if (seat_can_multi_session(s)) {
-                        if (vtnr <= 0 || vtnr > 63)
+                        if (vtnr > 63)
                                 return -EINVAL;
                 } else {
-                        if (vtnr > 0)
+                        if (vtnr != 0)
                                 return -EINVAL;
                 }
         }
diff --git a/src/shared/util.c b/src/shared/util.c
index 43948cc..def576d 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4287,6 +4287,15 @@ bool tty_is_vc(const char *tty) {
         return vtnr_from_tty(tty) >= 0;
 }
 
+bool tty_is_console(const char *tty) {
+        assert(tty);
+
+        if (startswith(tty, "/dev/"))
+                tty += 5;
+
+        return streq(tty, "console");
+}
+
 int vtnr_from_tty(const char *tty) {
         int i, r;
 
diff --git a/src/shared/util.h b/src/shared/util.h
index 76bc7b3..35ba005 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -415,6 +415,7 @@ char *fstab_node_to_udev_node(const char *p);
 
 bool tty_is_vc(const char *tty);
 bool tty_is_vc_resolve(const char *tty);
+bool tty_is_console(const char *tty);
 int vtnr_from_tty(const char *tty);
 const char *default_term_for_tty(const char *tty);
 

commit 337eebb936be1da1215535e866965ce54c82d755
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 02:15:22 2012 +0200

    container: spawn a getty instead of a sulogin in a container

diff --git a/Makefile.am b/Makefile.am
index 22a04d4..ab7fca6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -304,6 +304,7 @@ nodist_systemunit_DATA = \
 	units/getty at .service \
 	units/serial-getty at .service \
 	units/console-shell.service \
+	units/console-getty.service \
 	units/systemd-initctl.service \
 	units/systemd-shutdownd.service \
 	units/systemd-modules-load.service \
@@ -339,6 +340,7 @@ EXTRA_DIST += \
 	units/getty at .service.m4 \
 	units/serial-getty at .service.m4 \
 	units/console-shell.service.m4.in \
+	units/console-getty.service.m4.in \
 	units/rescue.service.m4.in \
 	units/systemd-initctl.service.in \
 	units/systemd-shutdownd.service.in \
diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
index 58ad8a6..13dca7d 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -116,7 +116,7 @@ int main(int argc, char *argv[]) {
         if (detect_container(NULL) > 0) {
                 log_debug("Automatically adding console shell.");
 
-                if (add_symlink("console-shell.service", "console-shell.service") < 0)
+                if (add_symlink("console-getty.service", "console-getty.service") < 0)
                         r = EXIT_FAILURE;
 
                 /* Don't add any further magic if we are in a container */
diff --git a/units/.gitignore b/units/.gitignore
index eda676a..16cbf2d 100644
--- a/units/.gitignore
+++ b/units/.gitignore
@@ -1,3 +1,4 @@
+/console-getty.service
 /systemd-journald.service
 user at .service
 systemd-logind.service
diff --git a/units/console-getty.service.m4.in b/units/console-getty.service.m4.in
new file mode 100644
index 0000000..9473d61
--- /dev/null
+++ b/units/console-getty.service.m4.in
@@ -0,0 +1,47 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Console Getty
+After=systemd-user-sessions.service plymouth-quit-wait.service
+m4_ifdef(`TARGET_FEDORA',
+After=rc-local.service
+)m4_dnl
+m4_ifdef(`TARGET_ARCH',
+After=rc-local.service
+)m4_dnl
+m4_ifdef(`TARGET_FRUGALWARE',
+After=local.service
+)m4_dnl
+m4_ifdef(`TARGET_ALTLINUX',
+After=rc-local.service
+)m4_dnl
+m4_ifdef(`TARGET_MANDRIVA',
+After=rc-local.service
+)m4_dnl
+m4_ifdef(`TARGET_MAGEIA',
+After=rc-local.service
+)m4_dnl
+Before=getty.target
+
+[Service]
+ExecStart=-/sbin/agetty --noclear -s console 115200,38400,9600
+Restart=always
+RestartSec=0
+UtmpIdentifier=cons
+TTYPath=/dev/console
+TTYReset=yes
+TTYVHangup=yes
+KillMode=process
+IgnoreSIGPIPE=no
+
+# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
+# terminates cleanly.
+KillSignal=SIGHUP
+
+[Install]
+WantedBy=getty.target

commit cc1368e3b3585ab822d76e00945ed4c064047530
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 02:03:08 2012 +0200

    loginctl: avoid segfault for kill-session and kill-user commands
    
    As reported by Mantas MikulÄ—nas.
    
    http://lists.freedesktop.org/archives/systemd-devel/2012-April/004993.html

diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 3ec8057..18f56f0 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1260,7 +1260,7 @@ static int kill_session(DBusConnection *bus, char **args, unsigned n) {
                 if (!dbus_message_append_args(m,
                                               DBUS_TYPE_STRING, &args[i],
                                               DBUS_TYPE_STRING, &arg_kill_who,
-                                              DBUS_TYPE_INT32, arg_signal,
+                                              DBUS_TYPE_INT32, &arg_signal,
                                               DBUS_TYPE_INVALID)) {
                         log_error("Could not append arguments to message.");
                         ret = -ENOMEM;
@@ -1464,7 +1464,7 @@ static int kill_user(DBusConnection *bus, char **args, unsigned n) {
                 u = (uint32_t) uid;
                 if (!dbus_message_append_args(m,
                                               DBUS_TYPE_UINT32, &u,
-                                              DBUS_TYPE_INT32, arg_signal,
+                                              DBUS_TYPE_INT32, &arg_signal,
                                               DBUS_TYPE_INVALID)) {
                         log_error("Could not append arguments to message.");
                         ret = -ENOMEM;

commit 3d9a412243035beeaaf3465a62065444a5adf21c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 01:59:11 2012 +0200

    util: fix tty_is_vc_resolve() in a container where /sys/class/tty/console/active is misleading

diff --git a/TODO b/TODO
index a008fe6..62b5ebf 100644
--- a/TODO
+++ b/TODO
@@ -20,6 +20,9 @@ Bugfixes:
 * properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
 
 Features:
+
+* Add pretty name for seats in logind
+
 * nspawn wants dev_setup() for /dev/fd/ and friends?
 
 * selinux: merge systemd selinux access controls (dwalsh)
diff --git a/src/core/condition.c b/src/core/condition.c
index 3b246f1..5d44039 100644
--- a/src/core/condition.c
+++ b/src/core/condition.c
@@ -223,14 +223,8 @@ bool condition_test(Condition *c) {
         case CONDITION_PATH_IS_MOUNT_POINT:
                 return (path_is_mount_point(c->parameter, true) > 0) == !c->negate;
 
-        case CONDITION_PATH_IS_READ_WRITE: {
-                struct statvfs st;
-
-                if (statvfs(c->parameter, &st) < 0)
-                        return c->negate;
-
-                return !(st.f_flag & ST_RDONLY) == !c->negate;
-        }
+        case CONDITION_PATH_IS_READ_WRITE:
+                return (path_is_read_only_fs(c->parameter) > 0) == c->negate;
 
         case CONDITION_DIRECTORY_NOT_EMPTY: {
                 int k;
diff --git a/src/shared/util.c b/src/shared/util.c
index 15c7f4d..43948cc 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -56,6 +56,7 @@
 #include <glob.h>
 #include <grp.h>
 #include <sys/mman.h>
+#include <sys/statvfs.h>
 
 #include "macro.h"
 #include "util.h"
@@ -4319,8 +4320,10 @@ bool tty_is_vc_resolve(const char *tty) {
         if (startswith(tty, "/dev/"))
                 tty += 5;
 
-        /* Resolve where /dev/console is pointing to */
-        if (streq(tty, "console"))
+        /* Resolve where /dev/console is pointing to, if /sys is
+         * actually ours (i.e. not read-only-mounted which is a sign
+         * for container setups) */
+        if (streq(tty, "console") && path_is_read_only_fs("/sys") <= 0)
                 if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
                         /* If multiple log outputs are configured the
                          * last one is what /dev/console points to */
@@ -6145,3 +6148,14 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
 
         return 0;
 }
+
+int path_is_read_only_fs(const char *path) {
+        struct statvfs st;
+
+        assert(path);
+
+        if (statvfs(path, &st) < 0)
+                return -errno;
+
+        return !!(st.f_flag & ST_RDONLY);
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index efb2c7d..76bc7b3 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -350,6 +350,7 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
 ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
 
 int path_is_mount_point(const char *path, bool allow_symlink);
+int path_is_read_only_fs(const char *path);
 
 bool is_device_path(const char *path);
 



More information about the systemd-commits mailing list