[systemd-commits] 8 commits - Makefile.am src/journal src/network src/shared src/test src/timesync

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Wed Nov 26 21:27:19 PST 2014


 Makefile.am                      |   14 ++-
 src/journal/coredump.c           |  151 +++++++++++++++++++++++++++++++++++++-
 src/journal/journalctl.c         |    2 
 src/network/networkd-route.c     |   32 ++++----
 src/shared/unit-name.c           |   51 ++++++------
 src/shared/util.c                |  154 ++++++++++++++++++++++++---------------
 src/shared/util.h                |    1 
 src/test/test-util.c             |    5 +
 src/timesync/timesyncd-manager.c |   20 +++--
 9 files changed, 321 insertions(+), 109 deletions(-)

New commits:
commit 0c124f8b2c93d2c7d6eefca3bdc59b28250fc077
Author: Ivan Shapovalov <intelfx100 at gmail.com>
Date:   Tue Nov 25 21:58:14 2014 +0300

    unit-name: fix escaping logic in unit_name_mangle_with_suffix()
    
    Make screened character set consistent with unit_name_mangle() by splitting off
    the escaping loop into a separate function.
    
    Before this fix, unit names such as `foo at bar.target` would get transformed
    into `foo\x40bar.target` when unit_name_mangle_with_suffix() is used.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=86711

diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c
index 2ef8545..6c6d7f4 100644
--- a/src/shared/unit-name.c
+++ b/src/shared/unit-name.c
@@ -243,6 +243,30 @@ static char *do_escape(const char *f, char *t) {
         return t;
 }
 
+static char *do_escape_mangle(const char *f, enum unit_name_mangle allow_globs, char *t) {
+        const char *valid_chars;
+
+        assert(f);
+        assert(IN_SET(allow_globs, MANGLE_GLOB, MANGLE_NOGLOB));
+        assert(t);
+
+        /* We'll only escape the obvious characters here, to play
+         * safe. */
+
+        valid_chars = allow_globs == MANGLE_GLOB ? "@" VALID_CHARS "[]!-*?" : "@" VALID_CHARS;
+
+        for (; *f; f++) {
+                if (*f == '/')
+                        *(t++) = '-';
+                else if (!strchr(valid_chars, *f))
+                        t = do_escape_char(*f, t);
+                else
+                        *(t++) = *f;
+        }
+
+        return t;
+}
+
 char *unit_name_escape(const char *f) {
         char *r, *t;
 
@@ -482,11 +506,9 @@ int unit_name_from_dbus_path(const char *path, char **name) {
  *  sensible unit name.
  */
 char *unit_name_mangle(const char *name, enum unit_name_mangle allow_globs) {
-        const char *valid_chars, *f;
         char *r, *t;
 
         assert(name);
-        assert(IN_SET(allow_globs, MANGLE_GLOB, MANGLE_NOGLOB));
 
         if (is_device_path(name))
                 return unit_name_from_path(name, ".device");
@@ -494,23 +516,11 @@ char *unit_name_mangle(const char *name, enum unit_name_mangle allow_globs) {
         if (path_is_absolute(name))
                 return unit_name_from_path(name, ".mount");
 
-        /* We'll only escape the obvious characters here, to play
-         * safe. */
-
-        valid_chars = allow_globs == MANGLE_GLOB ? "@" VALID_CHARS "[]!-*?" : "@" VALID_CHARS;
-
         r = new(char, strlen(name) * 4 + strlen(".service") + 1);
         if (!r)
                 return NULL;
 
-        for (f = name, t = r; *f; f++) {
-                if (*f == '/')
-                        *(t++) = '-';
-                else if (!strchr(valid_chars, *f))
-                        t = do_escape_char(*f, t);
-                else
-                        *(t++) = *f;
-        }
+        t = do_escape_mangle(name, allow_globs, r);
 
         if (unit_name_to_type(name) < 0)
                 strcpy(t, ".service");
@@ -526,10 +536,8 @@ char *unit_name_mangle(const char *name, enum unit_name_mangle allow_globs) {
  */
 char *unit_name_mangle_with_suffix(const char *name, enum unit_name_mangle allow_globs, const char *suffix) {
         char *r, *t;
-        const char *f;
 
         assert(name);
-        assert(IN_SET(allow_globs, MANGLE_GLOB, MANGLE_NOGLOB));
         assert(suffix);
         assert(suffix[0] == '.');
 
@@ -537,14 +545,7 @@ char *unit_name_mangle_with_suffix(const char *name, enum unit_name_mangle allow
         if (!r)
                 return NULL;
 
-        for (f = name, t = r; *f; f++) {
-                if (*f == '/')
-                        *(t++) = '-';
-                else if (!strchr(VALID_CHARS, *f))
-                        t = do_escape_char(*f, t);
-                else
-                        *(t++) = *f;
-        }
+        t = do_escape_mangle(name, allow_globs, r);
 
         if (!endswith(name, suffix))
                 strcpy(t, suffix);

commit 59059b4a0769dd042a92159e7d35d2fea62f795d
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Nov 26 23:31:35 2014 -0500

    coredump: use openat

diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index e820c6f..e80b2f7 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -478,21 +478,25 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
  */
 static int compose_open_fds(pid_t pid, char **open_fds) {
         _cleanup_fclose_ FILE *stream = NULL;
-        char path[PATH_MAX], line[LINE_MAX];
         size_t ignored_size;
-        const char *fddelim = "";
+        const char *fddelim = "", *path;
         struct dirent *dent = NULL;
         _cleanup_closedir_ DIR *proc_fd_dir = NULL;
+        _cleanup_close_ int proc_fdinfo_fd = -1;
         int r = 0;
 
         assert(pid >= 0);
         assert(open_fds != NULL);
 
-        sprintf(path, "/proc/"PID_FMT"/fd", pid);
+        path = procfs_file_alloca(pid, "fd");
         proc_fd_dir = opendir(path);
+        if (!proc_fd_dir)
+                return -errno;
 
-        if (proc_fd_dir == NULL)
-                return -ENOENT;
+        proc_fdinfo_fd = openat(dirfd(proc_fd_dir), "../fdinfo",
+                                O_DIRECTORY|O_NOFOLLOW|O_CLOEXEC|O_PATH);
+        if (proc_fdinfo_fd < 0)
+                return -errno;
 
         stream = open_memstream(open_fds, &ignored_size);
         if (!stream)
@@ -500,18 +504,14 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
 
         for (dent = readdir(proc_fd_dir); dent != NULL; dent = readdir(proc_fd_dir)) {
                 _cleanup_free_ char *fdname = NULL;
+                int fd;
                 _cleanup_fclose_ FILE *fdinfo = NULL;
+                char line[LINE_MAX];
 
                 if (dent->d_name[0] == '.' || strcmp(dent->d_name, "..") == 0)
                         continue;
 
-                /* Too long path is unlikely a path to valid file descriptor in /proc/[pid]/fd */
-                /* Skip it. */
-                r = snprintf(path, sizeof(path), "/proc/"PID_FMT"/fd/%s", pid, dent->d_name);
-                if (r >= (int)sizeof(path))
-                        continue;
-
-                r = readlink_malloc(path, &fdname);
+                r = readlinkat_malloc(dirfd(proc_fd_dir), dent->d_name, &fdname);
                 if (r < 0)
                         return r;
 
@@ -519,16 +519,15 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
                 fddelim = "\n";
 
                 /* Use the directory entry from /proc/[pid]/fd with /proc/[pid]/fdinfo */
-
-                /* Too long path is unlikely a path to valid file descriptor info in /proc/[pid]/fdinfo */
-                /* Skip it. */
-                r = snprintf(path, sizeof(path), "/proc/"PID_FMT"/fdinfo/%s", pid, dent->d_name);
-                if (r >= (int)sizeof(path))
+                fd = openat(proc_fdinfo_fd, dent->d_name, O_NOFOLLOW|O_CLOEXEC|O_RDONLY);
+                if (fd < 0)
                         continue;
 
-                fdinfo = fopen(path, "re");
-                if (fdinfo == NULL)
+                fdinfo = fdopen(fd, "re");
+                if (fdinfo == NULL) {
+                        close(fd);
                         continue;
+                }
 
                 while(fgets(line, sizeof(line), fdinfo) != NULL)
                         fprintf(stream, "%s%s",

commit 70af7b8ada43d15edcd16f1f5157c447c388933c
Author: Andrej Manduch <amanduch at gmail.com>
Date:   Tue Nov 25 20:47:49 2014 +0100

    journalctl: print all possible lines immediately with --follow + --since
    
    When I tryed to run journalctl with --follow and --since arguments it
    behaved very strangely.
    First It prints logs from what I specified in --since argument, then
    printed 10 lines (as is default in --follow) and when app put something
    new in to log journalctl printed everithing from the last printed line.
    
    How to reproduce:
    1. run: journalctl -m --since 14:00 --follow
    Then you'll see 10 lines of logs since 14:00. After that wait until some
    app add something in the journal or just run `systemd-cat echo test`
    2. After that journalctl will print every single line since 14:00 and will
    follow as expected.
    
    As long as --since and --follow will eventually print all relevant
    lines, I seen no reason why not to print them right away and not after
    first new message in journal.
    
    Relevant bugzillas:
            https://bugs.freedesktop.org/show_bug.cgi?id=71546
            https://bugs.freedesktop.org/show_bug.cgi?id=64291

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index b168d1e..904880b 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -712,7 +712,7 @@ static int parse_argv(int argc, char *argv[]) {
                         assert_not_reached("Unhandled option");
                 }
 
-        if (arg_follow && !arg_no_tail && arg_lines == ARG_LINES_DEFAULT)
+        if (arg_follow && !arg_no_tail && !arg_since && arg_lines == ARG_LINES_DEFAULT)
                 arg_lines = 10;
 
         if (!!arg_directory + !!arg_file + !!arg_machine > 1) {

commit 3f132692e305ec9adf1779551cb89088de0188e8
Author: Jakub Filak <jfilak at redhat.com>
Date:   Tue Nov 25 07:37:48 2014 +0100

    coredump: collect all /proc data useful for bug reporting
    
    /proc/[pid]:
    - status
    - maps
    - limits
    - cgroup
    - cwd
    - root
    - environ
    - fd/ & fdinfo/ joined in open_fds

diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 26a2010..e820c6f 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -36,6 +36,7 @@
 
 #include "log.h"
 #include "util.h"
+#include "fileio.h"
 #include "strv.h"
 #include "macro.h"
 #include "mkdir.h"
@@ -461,24 +462,103 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
         return 0;
 }
 
+/* Joins /proc/[pid]/fd/ and /proc/[pid]/fdinfo/ into the following lines:
+ * 0:/dev/pts/23
+ * pos:    0
+ * flags:  0100002
+ *
+ * 1:/dev/pts/23
+ * pos:    0
+ * flags:  0100002
+ *
+ * 2:/dev/pts/23
+ * pos:    0
+ * flags:  0100002
+ * EOF
+ */
+static int compose_open_fds(pid_t pid, char **open_fds) {
+        _cleanup_fclose_ FILE *stream = NULL;
+        char path[PATH_MAX], line[LINE_MAX];
+        size_t ignored_size;
+        const char *fddelim = "";
+        struct dirent *dent = NULL;
+        _cleanup_closedir_ DIR *proc_fd_dir = NULL;
+        int r = 0;
+
+        assert(pid >= 0);
+        assert(open_fds != NULL);
+
+        sprintf(path, "/proc/"PID_FMT"/fd", pid);
+        proc_fd_dir = opendir(path);
+
+        if (proc_fd_dir == NULL)
+                return -ENOENT;
+
+        stream = open_memstream(open_fds, &ignored_size);
+        if (!stream)
+                return -ENOMEM;
+
+        for (dent = readdir(proc_fd_dir); dent != NULL; dent = readdir(proc_fd_dir)) {
+                _cleanup_free_ char *fdname = NULL;
+                _cleanup_fclose_ FILE *fdinfo = NULL;
+
+                if (dent->d_name[0] == '.' || strcmp(dent->d_name, "..") == 0)
+                        continue;
+
+                /* Too long path is unlikely a path to valid file descriptor in /proc/[pid]/fd */
+                /* Skip it. */
+                r = snprintf(path, sizeof(path), "/proc/"PID_FMT"/fd/%s", pid, dent->d_name);
+                if (r >= (int)sizeof(path))
+                        continue;
+
+                r = readlink_malloc(path, &fdname);
+                if (r < 0)
+                        return r;
+
+                fprintf(stream, "%s%s:%s\n", fddelim, dent->d_name, fdname);
+                fddelim = "\n";
+
+                /* Use the directory entry from /proc/[pid]/fd with /proc/[pid]/fdinfo */
+
+                /* Too long path is unlikely a path to valid file descriptor info in /proc/[pid]/fdinfo */
+                /* Skip it. */
+                r = snprintf(path, sizeof(path), "/proc/"PID_FMT"/fdinfo/%s", pid, dent->d_name);
+                if (r >= (int)sizeof(path))
+                        continue;
+
+                fdinfo = fopen(path, "re");
+                if (fdinfo == NULL)
+                        continue;
+
+                while(fgets(line, sizeof(line), fdinfo) != NULL)
+                        fprintf(stream, "%s%s",
+                                line, strchr(line, '\n') == NULL ? "\n" : "");
+        }
+
+        return 0;
+}
+
 int main(int argc, char* argv[]) {
 
         _cleanup_free_ char *core_pid = NULL, *core_uid = NULL, *core_gid = NULL, *core_signal = NULL,
                 *core_timestamp = NULL, *core_comm = NULL, *core_exe = NULL, *core_unit = NULL,
                 *core_session = NULL, *core_message = NULL, *core_cmdline = NULL, *coredump_data = NULL,
-                *core_slice = NULL, *core_cgroup = NULL, *core_owner_uid = NULL,
+                *core_slice = NULL, *core_cgroup = NULL, *core_owner_uid = NULL, *core_open_fds = NULL,
+                *core_proc_status = NULL, *core_proc_maps = NULL, *core_proc_limits = NULL, *core_proc_cgroup = NULL,
+                *core_cwd = NULL, *core_root = NULL, *core_environ = NULL,
                 *exe = NULL, *comm = NULL, *filename = NULL;
         const char *info[_INFO_LEN];
 
         _cleanup_close_ int coredump_fd = -1;
 
-        struct iovec iovec[18];
+        struct iovec iovec[26];
         off_t coredump_size;
         int r, j = 0;
         uid_t uid, owner_uid;
         gid_t gid;
         pid_t pid;
         char *t;
+        const char *p;
 
         /* Make sure we never enter a loop */
         prctl(PR_SET_DUMPABLE, 0);
@@ -638,6 +718,74 @@ int main(int argc, char* argv[]) {
                         IOVEC_SET_STRING(iovec[j++], core_cgroup);
         }
 
+        if (compose_open_fds(pid, &t) >= 0) {
+                core_open_fds = strappend("COREDUMP_OPEN_FDS=", t);
+                free(t);
+
+                if (core_open_fds)
+                        IOVEC_SET_STRING(iovec[j++], core_open_fds);
+        }
+
+        p = procfs_file_alloca(pid, "status");
+        if (read_full_file(p, &t, NULL) >= 0) {
+                core_proc_status = strappend("COREDUMP_PROC_STATUS=", t);
+                free(t);
+
+                if (core_proc_status)
+                        IOVEC_SET_STRING(iovec[j++], core_proc_status);
+        }
+
+        p = procfs_file_alloca(pid, "maps");
+        if (read_full_file(p, &t, NULL) >= 0) {
+                core_proc_maps = strappend("COREDUMP_PROC_MAPS=", t);
+                free(t);
+
+                if (core_proc_maps)
+                        IOVEC_SET_STRING(iovec[j++], core_proc_maps);
+        }
+
+        p = procfs_file_alloca(pid, "limits");
+        if (read_full_file(p, &t, NULL) >= 0) {
+                core_proc_limits = strappend("COREDUMP_PROC_LIMITS=", t);
+                free(t);
+
+                if (core_proc_limits)
+                        IOVEC_SET_STRING(iovec[j++], core_proc_limits);
+        }
+
+        p = procfs_file_alloca(pid, "cgroup");
+        if (read_full_file(p, &t, NULL) >=0) {
+                core_proc_cgroup = strappend("COREDUMP_PROC_CGROUP=", t);
+                free(t);
+
+                if (core_proc_cgroup)
+                        IOVEC_SET_STRING(iovec[j++], core_proc_cgroup);
+        }
+
+        if (get_process_cwd(pid, &t) >= 0) {
+                core_cwd = strappend("COREDUMP_CWD=", t);
+                free(t);
+
+                if (core_cwd)
+                        IOVEC_SET_STRING(iovec[j++], core_cwd);
+        }
+
+        if (get_process_root(pid, &t) >= 0) {
+                core_root = strappend("COREDUMP_ROOT=", t);
+                free(t);
+
+                if (core_root)
+                        IOVEC_SET_STRING(iovec[j++], core_root);
+        }
+
+        if (get_process_environ(pid, &t) >= 0) {
+                core_environ = strappend("COREDUMP_ENVIRON=", t);
+                free(t);
+
+                if (core_environ)
+                        IOVEC_SET_STRING(iovec[j++], core_environ);
+        }
+
         core_timestamp = strjoin("COREDUMP_TIMESTAMP=", info[INFO_TIMESTAMP], "000000", NULL);
         if (core_timestamp)
                 IOVEC_SET_STRING(iovec[j++], core_timestamp);

commit c593bb360edd96fa6cd42f09e934f76c94f84473
Author: Jakub Filak <jfilak at redhat.com>
Date:   Tue Nov 25 07:37:47 2014 +0100

    util: add function getting proc environ
    
    On the contrary of env, the added function returns all characters
    cescaped, because it improves reproducibility.

diff --git a/src/shared/util.c b/src/shared/util.c
index b1ba0ed..e987abc 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -174,6 +174,69 @@ char* first_word(const char *s, const char *word) {
         return (char*) p;
 }
 
+static size_t cescape_char(char c, char *buf) {
+        char * buf_old = buf;
+
+        switch (c) {
+
+                case '\a':
+                        *(buf++) = '\\';
+                        *(buf++) = 'a';
+                        break;
+                case '\b':
+                        *(buf++) = '\\';
+                        *(buf++) = 'b';
+                        break;
+                case '\f':
+                        *(buf++) = '\\';
+                        *(buf++) = 'f';
+                        break;
+                case '\n':
+                        *(buf++) = '\\';
+                        *(buf++) = 'n';
+                        break;
+                case '\r':
+                        *(buf++) = '\\';
+                        *(buf++) = 'r';
+                        break;
+                case '\t':
+                        *(buf++) = '\\';
+                        *(buf++) = 't';
+                        break;
+                case '\v':
+                        *(buf++) = '\\';
+                        *(buf++) = 'v';
+                        break;
+                case '\\':
+                        *(buf++) = '\\';
+                        *(buf++) = '\\';
+                        break;
+                case '"':
+                        *(buf++) = '\\';
+                        *(buf++) = '"';
+                        break;
+                case '\'':
+                        *(buf++) = '\\';
+                        *(buf++) = '\'';
+                        break;
+
+                default:
+                        /* For special chars we prefer octal over
+                         * hexadecimal encoding, simply because glib's
+                         * g_strescape() does the same */
+                        if ((c < ' ') || (c >= 127)) {
+                                *(buf++) = '\\';
+                                *(buf++) = octchar((unsigned char) c >> 6);
+                                *(buf++) = octchar((unsigned char) c >> 3);
+                                *(buf++) = octchar((unsigned char) c);
+                        } else
+                                *(buf++) = c;
+                        break;
+        }
+
+        return buf - buf_old;
+}
+
 int close_nointr(int fd) {
         assert(fd >= 0);
 
@@ -892,6 +955,39 @@ int get_process_root(pid_t pid, char **root) {
         return get_process_link_contents(p, root);
 }
 
+int get_process_environ(pid_t pid, char **environ) {
+        _cleanup_fclose_ FILE *f = NULL;
+        _cleanup_free_ char *outcome = NULL;
+        int c;
+        const char *p;
+        size_t allocated = 0, sz = 0;
+
+        assert(pid >= 0);
+        assert(environ);
+
+        p = procfs_file_alloca(pid, "environ");
+
+        f = fopen(p, "re");
+        if (!f)
+                return -errno;
+
+        while ((c = fgetc(f)) != EOF) {
+                if (!GREEDY_REALLOC(outcome, allocated, sz + 5))
+                        return -ENOMEM;
+
+                if (c == '\0')
+                        outcome[sz++] = '\n';
+                else
+                        sz += cescape_char(c, outcome + sz);
+        }
+
+        outcome[sz] = '\0';
+        *environ = outcome;
+        outcome = NULL;
+
+        return 0;
+}
+
 char *strnappend(const char *s, const char *suffix, size_t b) {
         size_t a;
         char *r;
@@ -1271,63 +1367,7 @@ char *cescape(const char *s) {
                 return NULL;
 
         for (f = s, t = r; *f; f++)
-
-                switch (*f) {
-
-                case '\a':
-                        *(t++) = '\\';
-                        *(t++) = 'a';
-                        break;
-                case '\b':
-                        *(t++) = '\\';
-                        *(t++) = 'b';
-                        break;
-                case '\f':
-                        *(t++) = '\\';
-                        *(t++) = 'f';
-                        break;
-                case '\n':
-                        *(t++) = '\\';
-                        *(t++) = 'n';
-                        break;
-                case '\r':
-                        *(t++) = '\\';
-                        *(t++) = 'r';
-                        break;
-                case '\t':
-                        *(t++) = '\\';
-                        *(t++) = 't';
-                        break;
-                case '\v':
-                        *(t++) = '\\';
-                        *(t++) = 'v';
-                        break;
-                case '\\':
-                        *(t++) = '\\';
-                        *(t++) = '\\';
-                        break;
-                case '"':
-                        *(t++) = '\\';
-                        *(t++) = '"';
-                        break;
-                case '\'':
-                        *(t++) = '\\';
-                        *(t++) = '\'';
-                        break;
-
-                default:
-                        /* For special chars we prefer octal over
-                         * hexadecimal encoding, simply because glib's
-                         * g_strescape() does the same */
-                        if ((*f < ' ') || (*f >= 127)) {
-                                *(t++) = '\\';
-                                *(t++) = octchar((unsigned char) *f >> 6);
-                                *(t++) = octchar((unsigned char) *f >> 3);
-                                *(t++) = octchar((unsigned char) *f);
-                        } else
-                                *(t++) = *f;
-                        break;
-                }
+                t += cescape_char(*f, t);
 
         *t = 0;
 
diff --git a/src/shared/util.h b/src/shared/util.h
index 13a0b96..d36a632 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -297,6 +297,7 @@ int get_process_gid(pid_t pid, gid_t *gid);
 int get_process_capeff(pid_t pid, char **capeff);
 int get_process_cwd(pid_t pid, char **cwd);
 int get_process_root(pid_t pid, char **root);
+int get_process_environ(pid_t pid, char **environ);
 
 char hexchar(int x) _const_;
 int unhexchar(char c) _const_;
diff --git a/src/test/test-util.c b/src/test/test-util.c
index b33e15a..1602aa6 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -491,6 +491,7 @@ static void test_u64log2(void) {
 static void test_get_process_comm(void) {
         struct stat st;
         _cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL, *cwd = NULL, *root = NULL;
+        _cleanup_free_ char *env = NULL;
         unsigned long long b;
         pid_t e;
         uid_t u;
@@ -543,6 +544,10 @@ static void test_get_process_comm(void) {
         assert_se(r >= 0 || r == -EACCES);
         log_info("pid1 root: '%s'", root);
 
+        r = get_process_environ(me, &env);
+        assert_se(r >= 0 || r == -EACCES);
+        log_info("self strlen(environ): '%zd'", strlen(env));
+
         assert_se(get_ctty_devnr(1, &h) == -ENOENT);
 
         getenv_for_pid(1, "PATH", &i);

commit 59580681f5f950335b5ec40bb4c4a70dca6b2830
Author: Gavin Li <git at thegavinli.com>
Date:   Mon Nov 24 15:51:31 2014 -0800

    networkd: route - allow routes without a gateway
    
    For IPv6, the kernel returns EINVAL if a route is added with the
    RTA_GATEWAY attribute set to in6addr_any (::). A route without a
    gateway is useful in some situations, such as layer 3 tunneling
    (sit, gre, etc.).
    
    This patch prevents the RTA_GATEWAY attribute from being added
    when route.in_addr is ip6addr_any (::).

diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 10d8cd9..82c9e00 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -118,13 +118,15 @@ int route_drop(Route *route, Link *link,
                 return r;
         }
 
-        if (route->family == AF_INET)
-                r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
-        else if (route->family == AF_INET6)
-                r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
-        if (r < 0) {
-                log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
-                return r;
+        if (!in_addr_is_null(route->family, &route->in_addr)) {
+                if (route->family == AF_INET)
+                        r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
+                else if (route->family == AF_INET6)
+                        r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
+                if (r < 0) {
+                        log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
+                        return r;
+                }
         }
 
         if (route->dst_prefixlen) {
@@ -203,13 +205,15 @@ int route_configure(Route *route, Link *link,
                 return r;
         }
 
-        if (route->family == AF_INET)
-                r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
-        else if (route->family == AF_INET6)
-                r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
-        if (r < 0) {
-                log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
-                return r;
+        if (!in_addr_is_null(route->family, &route->in_addr)) {
+                if (route->family == AF_INET)
+                        r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
+                else if (route->family == AF_INET6)
+                        r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
+                if (r < 0) {
+                        log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
+                        return r;
+                }
         }
 
         if (route->dst_prefixlen) {

commit bedd083aaedb3bbb14ef579a047bf4b4fed56d9b
Author: Łukasz Stelmach <l.stelmach at samsung.com>
Date:   Wed Nov 26 09:17:50 2014 +0100

    build-sys: do not install tmpfiles and sysusers files by default

diff --git a/Makefile.am b/Makefile.am
index ddd0df1..65bb176 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2039,7 +2039,6 @@ nodist_tmpfiles_DATA = \
 dist_tmpfiles_DATA = \
 	tmpfiles.d/systemd.conf \
 	tmpfiles.d/systemd-nologin.conf \
-	tmpfiles.d/systemd-remote.conf \
 	tmpfiles.d/tmp.conf \
 	tmpfiles.d/x11.conf \
 	tmpfiles.d/var.conf
@@ -2094,8 +2093,7 @@ SYSINIT_TARGET_WANTS += \
 	systemd-sysusers.service
 
 dist_sysusers_DATA = \
-	sysusers.d/systemd.conf \
-	sysusers.d/systemd-remote.conf
+	sysusers.d/systemd.conf
 
 nodist_sysusers_DATA = \
 	sysusers.d/basic.conf
@@ -3839,6 +3837,16 @@ systemd_journal_remote_CFLAGS = \
 systemd_journal_remote_LDADD += \
 	$(MICROHTTPD_LIBS)
 
+if ENABLE_SYSUSERS
+dist_sysusers_DATA += \
+	sysusers.d/systemd-remote.conf
+endif
+
+if ENABLE_TMPFILES
+dist_tmpfiles_DATA += \
+	tmpfiles.d/systemd-remote.conf
+endif
+
 if HAVE_GNUTLS
 systemd_journal_remote_LDADD += \
 	$(GNUTLS_LIBS)

commit 7b6288914b3b57e1c33c740eb705c5a6dd2655ca
Author: Sean Young <sean at mess.org>
Date:   Wed Nov 26 09:33:30 2014 +0000

    timesyncd: do not keep listening socket open forever
    
    This also makes the source port less predicatable.

diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 3ae01eb..03cfb24 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -132,6 +132,7 @@ struct ntp_msg {
 
 static int manager_arm_timer(Manager *m, usec_t next);
 static int manager_clock_watch_setup(Manager *m);
+static int manager_listen_setup(Manager *m);
 
 static double ntp_ts_short_to_d(const struct ntp_ts_short *ts) {
         return be16toh(ts->sec) + (be16toh(ts->frac) / 65536.0);
@@ -184,6 +185,14 @@ static int manager_send_request(Manager *m) {
 
         m->event_timeout = sd_event_source_unref(m->event_timeout);
 
+        if (m->server_socket < 0) {
+                r = manager_listen_setup(m);
+                if (r < 0) {
+                        log_warning("Failed to setup connection socket: %s", strerror(-r));
+                        return r;
+                }
+        }
+
         /*
          * Set transmit timestamp, remember it; the server will send that back
          * as the origin timestamp and we have an indication that this is the
@@ -250,7 +259,6 @@ static int manager_arm_timer(Manager *m, usec_t next) {
         int r;
 
         assert(m);
-        assert(m->event_receive);
 
         if (next == 0) {
                 m->event_timer = sd_event_source_unref(m->event_timer);
@@ -610,6 +618,10 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
         m->pending = false;
         m->retry_interval = 0;
 
+        /* Stop listening */
+        m->event_receive = sd_event_source_unref(m->event_receive);
+        m->server_socket = safe_close(m->server_socket);
+
         /* announce leap seconds */
         if (NTP_FIELD_LEAP(ntpmsg.field) & NTP_LEAP_PLUSSEC)
                 leap_sec = 1;
@@ -741,12 +753,6 @@ static int manager_begin(Manager *m) {
         log_info("Using NTP server %s (%s).", strna(pretty), m->current_server_name->string);
         sd_notifyf(false, "STATUS=Using Time Server %s (%s).", strna(pretty), m->current_server_name->string);
 
-        r = manager_listen_setup(m);
-        if (r < 0) {
-                log_warning("Failed to setup connection socket: %s", strerror(-r));
-                return r;
-        }
-
         r = manager_clock_watch_setup(m);
         if (r < 0)
                 return r;



More information about the systemd-commits mailing list