[systemd-commits] 6 commits - TODO man/.gitignore src/core src/login src/shared src/update-utmp

Lennart Poettering lennart at kemper.freedesktop.org
Mon Sep 17 10:12:01 PDT 2012


 TODO                          |    2 -
 man/.gitignore                |    1 
 src/core/main.c               |   39 +++++++++++++++++------
 src/core/manager.c            |    5 +--
 src/login/logind.c            |    5 ++-
 src/shared/hwclock.c          |    1 
 src/shared/util.c             |   69 +++++++++++++++++-------------------------
 src/shared/util.h             |    6 +--
 src/update-utmp/update-utmp.c |    2 -
 9 files changed, 70 insertions(+), 60 deletions(-)

New commits:
commit d4d882e5cefb6b16d84e651a00a9e98914d54bd6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 17 19:11:48 2012 +0200

    logind: make VT reservation logic compatible with containers

diff --git a/src/login/logind.c b/src/login/logind.c
index f72eb49..3f71f5b 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -1006,7 +1006,10 @@ static int manager_reserve_vt(Manager *m) {
 
         m->reserve_vt_fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
         if (m->reserve_vt_fd < 0) {
-                log_warning("Failed to pin reserved VT: %m");
+
+                /* Don't complain on VT-less systems */
+                if (errno != ENOENT)
+                        log_warning("Failed to pin reserved VT: %m");
                 return -errno;
         }
 

commit c9999773927020a011f1d14ea03ae41431217b89
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 17 18:28:40 2012 +0200

    main: newer kernels return EINVAL if we invoke reboot() in a container lacking perms, deal with it

diff --git a/src/core/manager.c b/src/core/manager.c
index b0357b7..cf06917 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -138,8 +138,9 @@ static int enable_special_signals(Manager *m) {
         assert(m);
 
         /* Enable that we get SIGINT on control-alt-del. In containers
-         * this will fail with EPERM, so ignore that. */
-        if (reboot(RB_DISABLE_CAD) < 0 && errno != EPERM)
+         * this will fail with EPERM (older) or EINVAL (newer), so
+         * ignore that. */
+        if (reboot(RB_DISABLE_CAD) < 0 && errno != EPERM && errno != EINVAL)
                 log_warning("Failed to enable ctrl-alt-del handling: %m");
 
         fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);

commit 669bec5d170c7b6cec5194179d2c14244c06817c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 17 18:23:10 2012 +0200

    util: various cleanups for printing boot status

diff --git a/src/shared/util.c b/src/shared/util.c
index 27b6683..84f8565 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3488,10 +3488,10 @@ cpu_set_t* cpu_set_malloc(unsigned *ncpus) {
         }
 }
 
-void status_vprintf(const char *status, bool ellipse, const char *format, va_list ap) {
-        char *s = NULL;
+int status_vprintf(const char *status, bool ellipse, const char *format, va_list ap) {
         static const char status_indent[] = "         "; /* "[" STATUS "] " */
-        int fd = -1;
+        _cleanup_free_ char *s = NULL;
+        _cleanup_close_ int fd = -1;
         struct iovec iovec[5];
         int n = 0;
 
@@ -3501,11 +3501,11 @@ void status_vprintf(const char *status, bool ellipse, const char *format, va_lis
          * optional and go exclusively to the console. */
 
         if (vasprintf(&s, format, ap) < 0)
-                goto finish;
+                return log_oom();
 
         fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
         if (fd < 0)
-                goto finish;
+                return fd;
 
         if (ellipse) {
                 char *e;
@@ -3516,7 +3516,7 @@ void status_vprintf(const char *status, bool ellipse, const char *format, va_lis
                 if (c <= 0)
                         c = 80;
 
-                sl = status ? strlen(status_indent) : 0;
+                sl = status ? sizeof(status_indent)-1 : 0;
 
                 emax = c - sl - 1;
                 if (emax < 3)
@@ -3543,53 +3543,40 @@ void status_vprintf(const char *status, bool ellipse, const char *format, va_lis
         IOVEC_SET_STRING(iovec[n++], s);
         IOVEC_SET_STRING(iovec[n++], "\n");
 
-        writev(fd, iovec, n);
-
-finish:
-        free(s);
+        if (writev(fd, iovec, n) < 0)
+                return -errno;
 
-        if (fd >= 0)
-                close_nointr_nofail(fd);
+        return 0;
 }
 
-void status_printf(const char *status, bool ellipse, const char *format, ...) {
+int status_printf(const char *status, bool ellipse, const char *format, ...) {
         va_list ap;
+        int r;
 
         assert(format);
 
         va_start(ap, format);
-        status_vprintf(status, ellipse, format, ap);
+        r = status_vprintf(status, ellipse, format, ap);
         va_end(ap);
+
+        return r;
 }
 
-void status_welcome(void) {
-        char *pretty_name = NULL, *ansi_color = NULL;
-        const char *const_pretty = NULL, *const_color = NULL;
+int status_welcome(void) {
         int r;
-
-        if ((r = parse_env_file("/etc/os-release", NEWLINE,
-                                "PRETTY_NAME", &pretty_name,
-                                "ANSI_COLOR", &ansi_color,
-                                NULL)) < 0) {
-
-                if (r != -ENOENT)
-                        log_warning("Failed to read /etc/os-release: %s", strerror(-r));
-        }
-
-        if (!pretty_name && !const_pretty)
-                const_pretty = "Linux";
-
-        if (!ansi_color && !const_color)
-                const_color = "1";
-
-        status_printf(NULL,
-                      false,
-                      "\nWelcome to \x1B[%sm%s\x1B[0m!\n",
-                      const_color ? const_color : ansi_color,
-                      const_pretty ? const_pretty : pretty_name);
-
-        free(ansi_color);
-        free(pretty_name);
+        _cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL;
+
+        r = parse_env_file("/etc/os-release", NEWLINE,
+                           "PRETTY_NAME", &pretty_name,
+                           "ANSI_COLOR", &ansi_color,
+                           NULL);
+        if (r < 0 && r != -ENOENT)
+                log_warning("Failed to read /etc/os-release: %s", strerror(-r));
+
+        return status_printf(NULL, false,
+                             "\nWelcome to \x1B[%sm%s\x1B[0m!\n",
+                             isempty(ansi_color) ? "1" : ansi_color,
+                             isempty(pretty_name) ? "Linux" : pretty_name);
 }
 
 char *replace_env(const char *format, char **env) {
diff --git a/src/shared/util.h b/src/shared/util.h
index 1a607cf..71b5c52 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -370,9 +370,9 @@ int pipe_eof(int fd);
 
 cpu_set_t* cpu_set_malloc(unsigned *ncpus);
 
-void status_vprintf(const char *status, bool ellipse, const char *format, va_list ap);
-void status_printf(const char *status, bool ellipse, const char *format, ...);
-void status_welcome(void);
+int status_vprintf(const char *status, bool ellipse, const char *format, va_list ap);
+int status_printf(const char *status, bool ellipse, const char *format, ...);
+int status_welcome(void);
 
 int fd_columns(int fd);
 unsigned columns(void);

commit 84b98e6f5e059515fcfe2677e798f01463cbdd2f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 17 17:47:09 2012 +0200

    git: update .gitignore

diff --git a/man/.gitignore b/man/.gitignore
new file mode 100644
index 0000000..cf8c17c
--- /dev/null
+++ b/man/.gitignore
@@ -0,0 +1 @@
+/systemd.directives.xml

commit 19876c9b3de85f3b82dc3b8bbcaf3297b0d51edf
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 17 17:45:18 2012 +0200

    utmp: read the right timestamp

diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c
index 67c5788..a311280 100644
--- a/src/update-utmp/update-utmp.c
+++ b/src/update-utmp/update-utmp.c
@@ -48,7 +48,7 @@ typedef struct Context {
 static usec_t get_startup_time(Context *c) {
         const char
                 *interface = "org.freedesktop.systemd1.Manager",
-                *property = "StartupTimestamp";
+                *property = "UserspaceTimestamp";
 
         usec_t t = 0;
         DBusMessage *reply = NULL;

commit a866073d35dea05e6f3e56328d3eb6436943e7e6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 17 17:42:13 2012 +0200

    main: when transitioning from initrd to the main system log to kmsg
    
    When the new PID is invoked the journal socket from the initrd might
    still be around. Due to the default log target being journal we'd log to
    that initially when the new main systemd initializes even if the kernel
    command line included a directive to redirect systemd's logging
    elsewhere.
    
    With this fix we initially always log to kmsg now, if we are PID1, and
    only after parsing the kernel cmdline try to open the journal if that's
    desired.
    
    (The effective benefit of this is that SELinux performance data is now
    logged again to kmsg like it used to be.)

diff --git a/TODO b/TODO
index 10f43d7..ec31f1d 100644
--- a/TODO
+++ b/TODO
@@ -28,8 +28,6 @@ F18:
 
 * refuse automount triggers when automount is queued for stop, much like we refuse socket triggers when sockets are queued for stop
 
-* perfomance messages for selinux are gone from debug log?
-
 * There's something wrong with escaping unit names: http://lists.freedesktop.org/archives/systemd-devel/2012-August/006292.html
 
 * logind: different policy actions for idle, suspend, shutdown blockers: allow idle blockers by default, don't allow suspend blockers by default
diff --git a/src/core/main.c b/src/core/main.c
index 199383e..9d2d551 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1285,10 +1285,15 @@ int main(int argc, char *argv[]) {
         saved_argc = argc;
 
         log_show_color(isatty(STDERR_FILENO) > 0);
-        log_show_location(false);
-        log_set_max_level(LOG_INFO);
 
-        if (getpid() == 1) {
+        if (getpid() == 1 && detect_container(NULL) <= 0) {
+
+                /* Running outside of a container as PID 1 */
+                arg_running_as = MANAGER_SYSTEM;
+                make_null_stdio();
+                log_set_target(LOG_TARGET_KMSG);
+                log_open();
+
                 if (in_initrd()) {
                         char *rd_timestamp = NULL;
 
@@ -1302,11 +1307,6 @@ int main(int argc, char *argv[]) {
                         }
                 }
 
-                arg_running_as = MANAGER_SYSTEM;
-
-                make_null_stdio();
-                log_set_target(detect_container(NULL) > 0 ? LOG_TARGET_JOURNAL : LOG_TARGET_JOURNAL_OR_KMSG);
-
                 if (!skip_setup) {
                         if (selinux_setup(&loaded_policy) < 0)
                                 goto finish;
@@ -1314,8 +1314,6 @@ int main(int argc, char *argv[]) {
                                 goto finish;
                 }
 
-                log_open();
-
                 if (label_init(NULL) < 0)
                         goto finish;
 
@@ -1339,7 +1337,28 @@ int main(int argc, char *argv[]) {
                                         log_error("Failed to set the kernel's time zone, ignoring: %s", strerror(-r));
                         }
                 }
+
+                /* Set the default for later on, but don't actually
+                 * open the logs like this for now. Note that if we
+                 * are transitioning from the initrd there might still
+                 * be journal fd open, and we shouldn't attempt
+                 * opening that before we parsed /proc/cmdline which
+                 * might redirect output elsewhere. */
+                log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
+
+        } else if (getpid() == 1) {
+
+                /* Running inside a container, as PID 1 */
+                arg_running_as = MANAGER_SYSTEM;
+                log_set_target(LOG_TARGET_CONSOLE);
+                log_open();
+
+                /* For the later on, see above... */
+                log_set_target(LOG_TARGET_JOURNAL);
+
         } else {
+
+                /* Running as user instance */
                 arg_running_as = MANAGER_USER;
                 log_set_target(LOG_TARGET_AUTO);
                 log_open();
diff --git a/src/shared/hwclock.c b/src/shared/hwclock.c
index d9d5600..67eb2ef 100644
--- a/src/shared/hwclock.c
+++ b/src/shared/hwclock.c
@@ -154,6 +154,7 @@ int hwclock_set_time(const struct tm *tm) {
 
         return err;
 }
+
 int hwclock_is_localtime(void) {
         FILE *f;
         bool local = false;



More information about the systemd-commits mailing list