]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #12140 from poettering/copy-early
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Mar 2019 14:02:50 +0000 (15:02 +0100)
committerGitHub <noreply@github.com>
Fri, 29 Mar 2019 14:02:50 +0000 (15:02 +0100)
chattr/copy.c fixes

TODO
src/analyze/analyze.c
src/core/load-fragment.c
src/fsck/fsck.c
src/journal/journal-file.h
src/journal/journald-context.h
src/journal/journald-wall.h
src/libsystemd/sd-bus/bus-internal.h
src/network/netdev/wireguard.c
src/shared/seccomp-util.c

diff --git a/TODO b/TODO
index cdcfeca72d0f2be520b89c474a2f47069ddb5018..61cf38e974fbc8467fcbbf52df1d02deedb638f5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -21,6 +21,12 @@ Janitorial Clean-ups:
 
 Features:
 
+* tweak journald context caching. In addition to caching per-process attributes
+  keyed by PID, cache per-cgroup attributes (i.e. the various xattrs we read)
+  keyed by cgroup path, and guarded by ctime changes. This should provide us
+  with a nice speed-up on services that have many processes running in the same
+  cgroup.
+
 * clean up sleep.c:
   - Use CLOCK_BOOTTIME_ALARM for waking up s2h instead of RTC ioctls
   - Parse sleep.conf only once, and parse its whole contents so that we don't
@@ -61,9 +67,6 @@ Features:
 
 * bootctl,sd-boot: actually honour the "architecture" key
 
-* when a socket unit is spawned with an AF_UNIX path in /var/run, complain and
-  patch it to use /run instead
-
 * set memory.oom.group in cgroup v2 for all leaf cgroups (kernel v4.19+)
 
 * add a new syscall group "@esoteric" for more esoteric stuff such as bpf() and
index 87c5f0e43c8c028d9dd6427c6241d72e693b8fab..ac7cb0da630811057a3734b1974a3a3e2b5d37ee 100644 (file)
@@ -1519,9 +1519,15 @@ static int load_kernel_syscalls(Set **ret) {
         /* Let's read the available system calls from the list of available tracing events. Slightly dirty, but good
          * enough for analysis purposes. */
 
-        f = fopen("/sys/kernel/debug/tracing/available_events", "re");
-        if (!f)
-                return log_full_errno(IN_SET(errno, EPERM, EACCES, ENOENT) ? LOG_DEBUG : LOG_WARNING, errno, "Can't read open /sys/kernel/debug/tracing/available_events: %m");
+        f = fopen("/sys/kernel/tracing/available_events", "re");
+        if (!f) {
+                /* We tried the non-debugfs mount point and that didn't work. If it wasn't mounted, maybe the
+                 * old debugfs mount point works? */
+                f = fopen("/sys/kernel/debug/tracing/available_events", "re");
+                if (!f)
+                        return log_full_errno(IN_SET(errno, EPERM, EACCES, ENOENT) ? LOG_DEBUG : LOG_WARNING, errno,
+                                              "Can't read open tracefs' available_events file: %m");
+        }
 
         for (;;) {
                 _cleanup_free_ char *line = NULL;
index 2f62c7acb538081f4d0edfd00bb41cba957a3dac..5a819b0db783eb3d4e4902a52c3595796064183d 100644 (file)
@@ -312,23 +312,50 @@ int config_parse_unit_path_strv_printf(
                 if (r < 0)
                         return 0;
 
-                r = strv_push(x, k);
+                r = strv_consume(x, TAKE_PTR(k));
                 if (r < 0)
                         return log_oom();
-                k = NULL;
         }
 }
 
-int config_parse_socket_listen(const char *unit,
-                               const char *filename,
-                               unsigned line,
-                               const char *section,
-                               unsigned section_line,
-                               const char *lvalue,
-                               int ltype,
-                               const char *rvalue,
-                               void *data,
-                               void *userdata) {
+static int patch_var_run(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *lvalue,
+                char **path) {
+
+        const char *e;
+        char *z;
+
+        e = path_startswith(*path, "/var/run/");
+        if (!e)
+                return 0;
+
+        z = path_join("/run/", e);
+        if (!z)
+                return log_oom();
+
+        log_syntax(unit, LOG_NOTICE, filename, line, 0,
+                   "%s= references a path below legacy directory /var/run/, updating %s → %s; "
+                   "please update the unit file accordingly.", lvalue, *path, z);
+
+        free_and_replace(*path, z);
+
+        return 1;
+}
+
+int config_parse_socket_listen(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
         _cleanup_free_ SocketPort *p = NULL;
         SocketPort *tail;
@@ -365,6 +392,12 @@ int config_parse_socket_listen(const char *unit,
                 if (r < 0)
                         return 0;
 
+                if (ltype == SOCKET_FIFO) {
+                        r = patch_var_run(unit, filename, line, lvalue, &k);
+                        if (r < 0)
+                                return r;
+                }
+
                 free_and_replace(p->path, k);
                 p->type = ltype;
 
@@ -394,6 +427,12 @@ int config_parse_socket_listen(const char *unit,
                         return 0;
                 }
 
+                if (k[0] == '/') { /* Only for AF_UNIX file system sockets… */
+                        r = patch_var_run(unit, filename, line, lvalue, &k);
+                        if (r < 0)
+                                return r;
+                }
+
                 r = socket_address_parse_and_warn(&p->address, k);
                 if (r < 0) {
                         if (r != -EAFNOSUPPORT)
@@ -2695,7 +2734,9 @@ int config_parse_syscall_filter(
                         c->syscall_whitelist = true;
 
                         /* Accept default syscalls if we are on a whitelist */
-                        r = seccomp_parse_syscall_filter("@default", -1, c->syscall_filter, SECCOMP_PARSE_WHITELIST);
+                        r = seccomp_parse_syscall_filter(
+                                        "@default", -1, c->syscall_filter,
+                                        SECCOMP_PARSE_PERMISSIVE|SECCOMP_PARSE_WHITELIST);
                         if (r < 0)
                                 return r;
                 }
@@ -2722,9 +2763,12 @@ int config_parse_syscall_filter(
                         continue;
                 }
 
-                r = seccomp_parse_syscall_filter_full(name, num, c->syscall_filter,
-                                                      SECCOMP_PARSE_LOG|SECCOMP_PARSE_PERMISSIVE|(invert ? SECCOMP_PARSE_INVERT : 0)|(c->syscall_whitelist ? SECCOMP_PARSE_WHITELIST : 0),
-                                                      unit, filename, line);
+                r = seccomp_parse_syscall_filter_full(
+                                name, num, c->syscall_filter,
+                                SECCOMP_PARSE_LOG|SECCOMP_PARSE_PERMISSIVE|
+                                (invert ? SECCOMP_PARSE_INVERT : 0)|
+                                (c->syscall_whitelist ? SECCOMP_PARSE_WHITELIST : 0),
+                                unit, filename, line);
                 if (r < 0)
                         return r;
         }
@@ -4254,7 +4298,6 @@ int config_parse_pid_file(
         _cleanup_free_ char *k = NULL, *n = NULL;
         Unit *u = userdata;
         char **s = data;
-        const char *e;
         int r;
 
         assert(filename);
@@ -4284,20 +4327,11 @@ int config_parse_pid_file(
         if (r < 0)
                 return r;
 
-        e = path_startswith(n, "/var/run/");
-        if (e) {
-                char *z;
-
-                z = strjoin("/run/", e);
-                if (!z)
-                        return log_oom();
-
-                log_syntax(unit, LOG_NOTICE, filename, line, 0, "PIDFile= references path below legacy directory /var/run/, updating %s → %s; please update the unit file accordingly.", n, z);
-
-                free_and_replace(*s, z);
-        } else
-                free_and_replace(*s, n);
+        r = patch_var_run(unit, filename, line, lvalue, &n);
+        if (r < 0)
+                return r;
 
+        free_and_replace(*s, n);
         return 0;
 }
 
index 524327c4da04c87e6d38561e5731baef57756c37..8101f9ce95853284cf4260236dd22a06e1766d82 100644 (file)
@@ -265,6 +265,7 @@ static int fsck_progress_socket(void) {
 static int run(int argc, char *argv[]) {
         _cleanup_close_pair_ int progress_pipe[2] = { -1, -1 };
         _cleanup_(sd_device_unrefp) sd_device *dev = NULL;
+        _cleanup_free_ char *dpath = NULL;
         const char *device, *type;
         bool root_directory;
         struct stat st;
@@ -290,7 +291,11 @@ static int run(int argc, char *argv[]) {
                 return 0;
 
         if (argc > 1) {
-                device = argv[1];
+                dpath = strdup(argv[1]);
+                if (!dpath)
+                        return log_oom();
+
+                device = dpath;
 
                 if (stat(device, &st) < 0)
                         return log_error_errno(errno, "Failed to stat %s: %m", device);
index c9036d3e02eefce3a8cb05223e8396d22d763343..e1ea368999123c126f4966c9050d166cbad9342d 100644 (file)
@@ -2,6 +2,7 @@
 #pragma once
 
 #include <inttypes.h>
+#include <sys/uio.h>
 
 #if HAVE_GCRYPT
 #  include <gcrypt.h>
index c3a5df0d98a19b53e3290ca56c215f1204cff509..46f79fb5f7efea1f30b4878a45230d029c9f7e7d 100644 (file)
@@ -2,6 +2,7 @@
 #pragma once
 
 #include <inttypes.h>
+#include <sys/socket.h>
 #include <sys/types.h>
 
 #include "sd-id128.h"
index b73059af46663d109adcd2cff75c24601c57b583..026649eb7c9202a30402507dbc561b25f1ccea07 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
+#include <sys/socket.h>
+
 #include "journald-server.h"
 
 void server_forward_wall(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
index 5d6cce01685814bbfd0504a1e13c8cff1a7f138f..d7fcb9329b91ce7b4235344db13cf3cccafe0377 100644 (file)
@@ -211,7 +211,7 @@ struct sd_bus {
         bool connected_signal:1;
         bool close_on_exit:1;
 
-        int use_memfd:2;
+        signed int use_memfd:2;
 
         void *rbuffer;
         size_t rbuffer_size;
index 03eaac1f9cba59026fa1bf3eca52558dec27d766..5d9df16349c85228f0fb8c7928f3f3923f65d21c 100644 (file)
@@ -322,7 +322,7 @@ static int on_resolve_retry(sd_event_source *s, usec_t usec, void *userdata) {
  * increasing time in milliseconds to wait starting at 200ms and capped at 25 seconds.
  */
 static int exponential_backoff_milliseconds(unsigned n_retries) {
-        return (2 << MAX(n_retries, 7U)) * 100 * USEC_PER_MSEC;
+        return (2 << MIN(n_retries, 7U)) * 100 * USEC_PER_MSEC;
 }
 
 static int wireguard_resolve_handler(sd_resolve_query *q,
index 905be0f6a917f7d266ccefa4649c547d4fe68f54..ba3f433106bd20ee3c43467df8322e418de14f20 100644 (file)
@@ -291,6 +291,7 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
                 "pause\0"
                 "prlimit64\0"
                 "restart_syscall\0"
+                "rseq\0"
                 "rt_sigreturn\0"
                 "sched_yield\0"
                 "set_robust_list\0"