]> git.proxmox.com Git - systemd.git/commitdiff
New upstream version 251.3
authorMichael Biebl <biebl@debian.org>
Wed, 13 Jul 2022 16:44:03 +0000 (18:44 +0200)
committerMichael Biebl <biebl@debian.org>
Wed, 13 Jul 2022 16:44:03 +0000 (18:44 +0200)
59 files changed:
.gitignore
hwdb.d/70-analyzers.hwdb
man/systemctl.xml
meson.build
src/analyze/analyze-security.c
src/basic/hashmap.c
src/basic/set.h
src/basic/time-util.c
src/basic/virt.c
src/boot/efi/xbootldr.c
src/core/load-fragment.c
src/core/main.c
src/core/namespace.c
src/core/systemd.pc.in
src/coredump/coredump.c
src/dissect/dissect.c
src/fundamental/sha256.c
src/home/homework-luks.c
src/journal-remote/microhttpd-util.c
src/kernel-install/kernel-install.in
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd/sd-device/sd-device.c
src/libsystemd/sd-event/sd-event.c
src/libsystemd/sd-event/test-event.c
src/libsystemd/sd-id128/id128-util.c
src/libsystemd/sd-journal/journal-verify.c
src/libsystemd/sd-journal/sd-journal.c
src/network/netdev/l2tp-tunnel.c
src/network/netdev/macsec.c
src/network/netdev/wireguard.c
src/network/networkctl.c
src/nspawn/nspawn-settings.c
src/nspawn/nspawn.c
src/resolve/resolved-bus.c
src/resolve/resolved-dns-cache.c
src/resolve/resolved-dns-packet.c
src/resolve/resolved-dns-packet.h
src/resolve/resolved-dns-transaction.c
src/rpm/macros.systemd.in
src/shared/dissect-image.c
src/shared/dns-domain.c
src/shared/json.c
src/shared/logs-show.c
src/shared/seccomp-util.c
src/shared/utmp-wtmp.h
src/sysext/sysext.c
src/systemctl/systemctl-list-unit-files.c
src/systemctl/systemctl-show.c
src/systemctl/systemctl.c
src/test/test-dns-domain.c
src/test/test-loop-block.c
src/test/test-sd-hwdb.c
src/test/test-set.c
src/test/test-time-util.c
src/tmpfiles/tmpfiles.c
src/udev/udev-rules.c
test/units/testsuite-04.sh
units/modprobe@.service
units/systemd-udev-trigger.service

index 976376625dda94e7b3ce488eeace3570e8928cde..7b6d0a376e976ada9d7b8ba250b4e472c6dd1a07 100644 (file)
@@ -36,3 +36,4 @@ __pycache__/
 # Ignore any mkosi config files with "local" in the name
 /mkosi.default.d/**/*local*.conf
 /tags
+.dir-locals-2.el
index 899ece3a01297dd678a459a372827bc46d251771..0a1911507a22e608e5d53f4bb1372200825195df 100644 (file)
@@ -29,7 +29,6 @@ usb:v1679p3001*
 
 # Power Delivery Analyzers
 usb:v1679p6003*
-usb:v0483pDF11*
  ID_SIGNAL_ANALYZER=1
 
 ###########################################################
index 963eb9ec3adf0b833b03a431a8b14f866c0904a9..b050030f822fee44dfa2fa7eb81a41c27d1494ca 100644 (file)
@@ -221,7 +221,7 @@ Sun 2017-02-26 20:57:49 EST  2h 3min left  Sun 2017-02-26 11:56:36 EST  6h ago
 
               <programlisting>$ systemctl status bluetooth
 ● bluetooth.service - Bluetooth service
-   Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
+   Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; preset: enabled)
    Active: active (running) since Wed 2017-01-04 13:54:04 EST; 1 weeks 0 days ago
      Docs: man:bluetoothd(8)
  Main PID: 930 (bluetoothd)
@@ -237,29 +237,31 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: Current Time Service could not be
 Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output error (5)
 </programlisting>
 
-            <para>The dot ("●") uses color on supported terminals to summarize the unit state at a glance. Along with
-            its color, its shape varies according to its state: <literal>inactive</literal> or
-            <literal>maintenance</literal> is a white circle ("○"), <literal>active</literal> is a green dot ("●"),
-            <literal>deactivating</literal> is a white dot, <literal>failed</literal> or <literal>error</literal> is
-            a red cross ("×"), and <literal>reloading</literal> is a green clockwise circle arrow ("↻").
-            </para>
-
-            <para>The "Loaded:" line in the output will show <literal>loaded</literal> if the unit has been loaded into
-            memory. Other possible values for "Loaded:" include: <literal>error</literal> if there was a problem
-            loading it, <literal>not-found</literal> if no unit file was found for this unit,
-            <literal>bad-setting</literal> if an essential unit file setting could not be parsed and
-            <literal>masked</literal> if the unit file has been masked. Along with showing the path to the unit file,
-            this line will also show the enablement state.  Enabled commands start at boot.  See the full table of
-            possible enablement states — including the definition of <literal>masked</literal> — in the documentation
-            for the <command>is-enabled</command> command.
+            <para>The dot ("●") uses color on supported terminals to summarize the unit state at a
+            glance. Along with its color, its shape varies according to its state:
+            <literal>inactive</literal> or <literal>maintenance</literal> is a white circle ("○"),
+            <literal>active</literal> is a green dot ("●"), <literal>deactivating</literal> is a white dot,
+            <literal>failed</literal> or <literal>error</literal> is a red cross ("×"), and
+            <literal>reloading</literal> is a green clockwise circle arrow ("↻").</para>
+
+            <para>The "Loaded:" line in the output will show <literal>loaded</literal> if the unit has been
+            loaded into memory. Other possible values for "Loaded:" include: <literal>error</literal> if
+            there was a problem loading it, <literal>not-found</literal> if no unit file was found for this
+            unit, <literal>bad-setting</literal> if an essential unit file setting could not be parsed and
+            <literal>masked</literal> if the unit file has been masked. Along with showing the path to the
+            unit file, this line will also show the enablement state.  Enabled units are included in the
+            dependency network between units, and thus are started at boot or via some other form of
+            activation.  See the full table of possible enablement states — including the definition of
+            <literal>masked</literal> — in the documentation for the <command>is-enabled</command> command.
             </para>
 
             <para>The "Active:" line shows active state.  The value is usually <literal>active</literal> or
-            <literal>inactive</literal>. Active could mean started, bound, plugged in, etc depending on the unit type.
-            The unit could also be in process of changing states, reporting a state of <literal>activating</literal> or
-            <literal>deactivating</literal>. A special <literal>failed</literal> state is entered when the service
-            failed in some way, such as a crash, exiting with an error code or timing out. If the failed state is
-            entered the cause will be logged for later reference.</para>
+            <literal>inactive</literal>. Active could mean started, bound, plugged in, etc depending on the
+            unit type.  The unit could also be in process of changing states, reporting a state of
+            <literal>activating</literal> or <literal>deactivating</literal>. A special
+            <literal>failed</literal> state is entered when the service failed in some way, such as a crash,
+            exiting with an error code or timing out. If the failed state is entered the cause will be logged
+            for later reference.</para>
             </example>
 
           </listitem>
index 36cbfa48938d1725870f4c199f4c6359b8c136b0..9c170acc0aa4e7dc7a2714fbc0671e221084652b 100644 (file)
@@ -169,6 +169,7 @@ pkgsysconfdir = sysconfdir / 'systemd'
 userunitdir = prefixdir / 'lib/systemd/user'
 userpresetdir = prefixdir / 'lib/systemd/user-preset'
 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
+usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
 sysusersdir = prefixdir / 'lib/sysusers.d'
 sysctldir = prefixdir / 'lib/sysctl.d'
 binfmtdir = prefixdir / 'lib/binfmt.d'
@@ -278,6 +279,7 @@ conf.set_quoted('SYSTEM_SYSVINIT_PATH',                       sysvinit_path)
 conf.set_quoted('SYSTEM_SYSVRCND_PATH',                       sysvrcnd_path)
 conf.set_quoted('SYSUSERS_DIR',                               sysusersdir)
 conf.set_quoted('TMPFILES_DIR',                               tmpfilesdir)
+conf.set_quoted('USER_TMPFILES_DIR',                          usertmpfilesdir)
 conf.set_quoted('UDEVLIBEXECDIR',                             udevlibexecdir)
 conf.set_quoted('UDEV_HWDB_DIR',                              udevhwdbdir)
 conf.set_quoted('UDEV_RULES_DIR',                             udevrulesdir)
index 5b4d4caf46af3e06c6241b755d826d1252ba2db1..9255f4cb896f8a8178229179553f8c8663c76987 100644 (file)
@@ -105,7 +105,7 @@ typedef struct SecurityInfo {
         Set *system_call_architectures;
 
         bool system_call_filter_allow_list;
-        Hashmap *system_call_filter;
+        Set *system_call_filter;
 
         mode_t _umask;
 } SecurityInfo;
@@ -172,8 +172,7 @@ static SecurityInfo *security_info_free(SecurityInfo *i) {
 
         strv_free(i->supplementary_groups);
         set_free(i->system_call_architectures);
-
-        hashmap_free(i->system_call_filter);
+        set_free(i->system_call_filter);
 
         return mfree(i);
 }
@@ -567,12 +566,10 @@ static int assess_system_call_architectures(
         return 0;
 }
 
-static bool syscall_names_in_filter(Hashmap *s, bool allow_list, const SyscallFilterSet *f, const char **ret_offending_syscall) {
+static bool syscall_names_in_filter(Set *s, bool allow_list, const SyscallFilterSet *f, const char **ret_offending_syscall) {
         const char *syscall;
 
         NULSTR_FOREACH(syscall, f->value) {
-                int id;
-
                 if (syscall[0] == '@') {
                         const SyscallFilterSet *g;
 
@@ -584,11 +581,10 @@ static bool syscall_names_in_filter(Hashmap *s, bool allow_list, const SyscallFi
                 }
 
                 /* Let's see if the system call actually exists on this platform, before complaining */
-                id = seccomp_syscall_resolve_name(syscall);
-                if (id < 0)
+                if (seccomp_syscall_resolve_name(syscall) < 0)
                         continue;
 
-                if (hashmap_contains(s, syscall) != allow_list) {
+                if (set_contains(s, syscall) == allow_list) {
                         log_debug("Offending syscall filter item: %s", syscall);
                         if (ret_offending_syscall)
                                 *ret_offending_syscall = syscall;
@@ -619,7 +615,7 @@ static int assess_system_call_filter(
         uint64_t b;
         int r;
 
-        if (!info->system_call_filter_allow_list && hashmap_isempty(info->system_call_filter)) {
+        if (!info->system_call_filter_allow_list && set_isempty(info->system_call_filter)) {
                 r = free_and_strdup(&d, "Service does not filter system calls");
                 b = 10;
         } else {
@@ -2139,9 +2135,8 @@ static int property_read_system_call_filter(
                 if (r == 0)
                         break;
 
-                /* The actual ExecContext stores the system call id as the map value, which we don't
-                 * need. So we assign NULL to all values here. */
-                r = hashmap_put_strdup(&info->system_call_filter, name, NULL);
+                /* ignore errno or action after colon */
+                r = set_put_strndup(&info->system_call_filter, name, strchrnul(name, ':') - name);
                 if (r < 0)
                         return r;
         }
@@ -2589,14 +2584,24 @@ static int get_security_info(Unit *u, ExecContext *c, CGroupContext *g, Security
                         if (set_put_strdup(&info->system_call_architectures, name) < 0)
                                 return log_oom();
                 }
-#endif
 
                 info->system_call_filter_allow_list = c->syscall_allow_list;
-                if (c->syscall_filter) {
-                        info->system_call_filter = hashmap_copy(c->syscall_filter);
-                        if (!info->system_call_filter)
+
+                void *id, *num;
+                HASHMAP_FOREACH_KEY(num, id, c->syscall_filter) {
+                        _cleanup_free_ char *name = NULL;
+
+                        if (info->system_call_filter_allow_list && PTR_TO_INT(num) >= 0)
+                                continue;
+
+                        name = seccomp_syscall_resolve_num_arch(SCMP_ARCH_NATIVE, PTR_TO_INT(id) - 1);
+                        if (!name)
+                                continue;
+
+                        if (set_ensure_consume(&info->system_call_filter, &string_hash_ops_free, TAKE_PTR(name)) < 0)
                                 return log_oom();
                 }
+#endif
         }
 
         if (g) {
index e33d6c30733d3f52864bf7f90692e6858aec775f..62380b0e4a152546428f9b429286918a03a489fe 100644 (file)
@@ -1842,7 +1842,7 @@ int _hashmap_put_strdup_full(Hashmap **h, const struct hash_ops *hash_ops, const
         return r;
 }
 
-int _set_put_strdup_full(Set **s, const struct hash_ops *hash_ops, const char *p  HASHMAP_DEBUG_PARAMS) {
+int _set_put_strndup_full(Set **s, const struct hash_ops *hash_ops, const char *p, size_t n  HASHMAP_DEBUG_PARAMS) {
         char *c;
         int r;
 
@@ -1853,10 +1853,13 @@ int _set_put_strdup_full(Set **s, const struct hash_ops *hash_ops, const char *p
         if (r < 0)
                 return r;
 
-        if (set_contains(*s, (char*) p))
-                return 0;
+        if (n == SIZE_MAX) {
+                if (set_contains(*s, (char*) p))
+                        return 0;
 
-        c = strdup(p);
+                c = strdup(p);
+        } else
+                c = strndup(p, n);
         if (!c)
                 return -ENOMEM;
 
@@ -1869,7 +1872,7 @@ int _set_put_strdupv_full(Set **s, const struct hash_ops *hash_ops, char **l  HA
         assert(s);
 
         STRV_FOREACH(i, l) {
-                r = _set_put_strdup_full(s, hash_ops, *i  HASHMAP_DEBUG_PASS_ARGS);
+                r = _set_put_strndup_full(s, hash_ops, *i, SIZE_MAX  HASHMAP_DEBUG_PASS_ARGS);
                 if (r < 0)
                         return r;
 
index 243a747e98c53de44a6fbf8e4be9b1746616b83a..52cf63e2ddaefa289f6e88665a36a5811b14352b 100644 (file)
@@ -127,9 +127,12 @@ int _set_ensure_consume(Set **s, const struct hash_ops *hash_ops, void *key  HAS
 
 int set_consume(Set *s, void *value);
 
-int _set_put_strdup_full(Set **s, const struct hash_ops *hash_ops, const char *p  HASHMAP_DEBUG_PARAMS);
-#define set_put_strdup_full(s, hash_ops, p) _set_put_strdup_full(s, hash_ops, p  HASHMAP_DEBUG_SRC_ARGS)
-#define set_put_strdup(s, p) set_put_strdup_full(s, &string_hash_ops_free, p)
+int _set_put_strndup_full(Set **s, const struct hash_ops *hash_ops, const char *p, size_t n  HASHMAP_DEBUG_PARAMS);
+#define set_put_strndup_full(s, hash_ops, p, n) _set_put_strndup_full(s, hash_ops, p, n  HASHMAP_DEBUG_SRC_ARGS)
+#define set_put_strdup_full(s, hash_ops, p) set_put_strndup_full(s, hash_ops, p, SIZE_MAX)
+#define set_put_strndup(s, p, n) set_put_strndup_full(s, &string_hash_ops_free, p, n)
+#define set_put_strdup(s, p) set_put_strndup(s, p, SIZE_MAX)
+
 int _set_put_strdupv_full(Set **s, const struct hash_ops *hash_ops, char **l  HASHMAP_DEBUG_PARAMS);
 #define set_put_strdupv_full(s, hash_ops, l) _set_put_strdupv_full(s, hash_ops, l  HASHMAP_DEBUG_SRC_ARGS)
 #define set_put_strdupv(s, l) set_put_strdupv_full(s, &string_hash_ops_free, l)
index c309369406ce39e96e3d0dc0fdfc8446d23577d9..0ad8de4b9ac677b85808683c4702a0879b0d3bf2 100644 (file)
@@ -591,7 +591,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
                         t = b;
                 }
 
-                n = MIN((size_t) k, l);
+                n = MIN((size_t) k, l-1);
 
                 l -= n;
                 p += n;
index c7ae2afc0069f5982fa6b697754612c21519f6a1..5cc1011ae8eea90e6f1adc8703a6d59301ea8e86 100644 (file)
@@ -436,18 +436,22 @@ Virtualization detect_vm(void) {
 
         /* We have to use the correct order here:
          *
-         * → First, try to detect Oracle Virtualbox and Amazon EC2 Nitro, even if they use KVM, as well as Xen even if
-         *   it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also since it runs as a user-process
-         *   nested inside other VMs. Also check for Xen now, because Xen PV mode does not override CPUID when nested
-         *   inside another hypervisor.
+         * → First, try to detect Oracle Virtualbox, Amazon EC2 Nitro, and Parallels, even if they use KVM,
+         *   as well as Xen even if it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also
+         *   since it runs as a user-process nested inside other VMs. Also check for Xen now, because Xen PV
+         *   mode does not override CPUID when nested inside another hypervisor.
          *
-         * → Second, try to detect from CPUID, this will report KVM for whatever software is used even if info in DMI is
-         *   overwritten.
+         * → Second, try to detect from CPUID, this will report KVM for whatever software is used even if
+         *   info in DMI is overwritten.
          *
          * → Third, try to detect from DMI. */
 
         dmi = detect_vm_dmi();
-        if (IN_SET(dmi, VIRTUALIZATION_ORACLE, VIRTUALIZATION_XEN, VIRTUALIZATION_AMAZON)) {
+        if (IN_SET(dmi,
+                   VIRTUALIZATION_ORACLE,
+                   VIRTUALIZATION_XEN,
+                   VIRTUALIZATION_AMAZON,
+                   VIRTUALIZATION_PARALLELS)) {
                 v = dmi;
                 goto finish;
         }
index 793e3949b24140e355e5bd2b108a4bfb9a9d2ebe..f73b5eeb202ff609789034c86c5aee45fce1dd62 100644 (file)
@@ -35,7 +35,7 @@ static BOOLEAN verify_gpt(union GptHeaderBuffer *gpt_header_buffer, EFI_LBA lba_
         h = &gpt_header_buffer->gpt_header;
 
         /* Some superficial validation of the GPT header */
-        if (CompareMem(&h->Header.Signature, "EFI PART", sizeof(h->Header.Signature) != 0))
+        if (CompareMem(&h->Header.Signature, "EFI PART", sizeof(h->Header.Signature)) != 0)
                 return FALSE;
 
         if (h->Header.HeaderSize < 92 || h->Header.HeaderSize > 512)
index 3ff6eae8fcead70372fba074553462131d90f688..11991ecdc0c3a27caf5862a3fdf1a3dc5d4c9537 100644 (file)
@@ -4211,11 +4211,16 @@ int config_parse_io_device_weight(
         r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || isempty(p)) {
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to extract device path and weight from '%s', ignoring.", rvalue);
                 return 0;
         }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid device path or weight specified in '%s', ignoring.", rvalue);
+                return 0;
+        }
 
         r = unit_path_printf(userdata, path, &resolved);
         if (r < 0) {
@@ -4280,11 +4285,16 @@ int config_parse_io_device_latency(
         r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || isempty(p)) {
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to extract device path and latency from '%s', ignoring.", rvalue);
                 return 0;
         }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid device path or latency specified in '%s', ignoring.", rvalue);
+                return 0;
+        }
 
         r = unit_path_printf(userdata, path, &resolved);
         if (r < 0) {
@@ -4350,11 +4360,16 @@ int config_parse_io_limit(
         r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || isempty(p)) {
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
                 return 0;
         }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid device node or bandwidth specified in '%s', ignoring.", rvalue);
+                return 0;
+        }
 
         r = unit_path_printf(userdata, path, &resolved);
         if (r < 0) {
@@ -4435,11 +4450,16 @@ int config_parse_blockio_device_weight(
         r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || isempty(p)) {
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to extract device node and weight from '%s', ignoring.", rvalue);
                 return 0;
         }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid device node or weight specified in '%s', ignoring.", rvalue);
+                return 0;
+        }
 
         r = unit_path_printf(userdata, path, &resolved);
         if (r < 0) {
@@ -4508,11 +4528,16 @@ int config_parse_blockio_bandwidth(
         r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || isempty(p)) {
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
                 return 0;
         }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid device node or bandwidth specified in '%s', ignoring.", rvalue);
+                return 0;
+        }
 
         r = unit_path_printf(userdata, path, &resolved);
         if (r < 0) {
@@ -4728,8 +4753,12 @@ int config_parse_set_credential(
         r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || !p) {
-                log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract credential name, ignoring: %s", rvalue);
+                return 0;
+        }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax, ignoring: %s", rvalue);
                 return 0;
         }
 
@@ -5208,7 +5237,7 @@ int config_parse_bind_paths(
                                 if (r == -ENOMEM)
                                         return log_oom();
                                 if (r < 0) {
-                                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s: %s", lvalue, rvalue);
+                                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
                                         return 0;
                                 }
 
@@ -5858,6 +5887,7 @@ int config_parse_bpf_foreign_program(
                 void *userdata) {
         _cleanup_free_ char *resolved = NULL, *word = NULL;
         CGroupContext *c = data;
+        const char *p = rvalue;
         Unit *u = userdata;
         int attach_type, r;
 
@@ -5872,13 +5902,17 @@ int config_parse_bpf_foreign_program(
                 return 0;
         }
 
-        r = extract_first_word(&rvalue, &word, ":", 0);
+        r = extract_first_word(&p, &word, ":", 0);
         if (r == -ENOMEM)
                 return log_oom();
-        if (r <= 0 || isempty(rvalue)) {
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse foreign BPF program, ignoring: %s", rvalue);
                 return 0;
         }
+        if (r == 0 || isempty(p)) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax in %s=, ignoring: %s", lvalue, rvalue);
+                return 0;
+        }
 
         attach_type = bpf_cgroup_attach_type_from_string(word);
         if (attach_type < 0) {
@@ -5886,9 +5920,9 @@ int config_parse_bpf_foreign_program(
                 return 0;
         }
 
-        r = unit_path_printf(u, rvalue, &resolved);
+        r = unit_path_printf(u, p, &resolved);
         if (r < 0) {
-                log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue);
+                log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %s", p, rvalue);
                 return 0;
         }
 
index 409b84a0064c258135933a7f8f378b839059abf0..0cf2df6fab64c19e9de9139061b41a7251d17783 100644 (file)
@@ -2118,11 +2118,9 @@ static int initialize_runtime(
                         write_container_id();
                 }
 
-                if (arg_watchdog_device) {
-                        r = watchdog_set_device(arg_watchdog_device);
-                        if (r < 0)
-                                log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m", arg_watchdog_device);
-                }
+                r = watchdog_set_device(arg_watchdog_device);
+                if (r < 0)
+                        log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m", arg_watchdog_device);
         } else {
                 _cleanup_free_ char *p = NULL;
 
@@ -2377,8 +2375,8 @@ static void reset_arguments(void) {
         arg_reboot_watchdog = 10 * USEC_PER_MINUTE;
         arg_kexec_watchdog = 0;
         arg_pretimeout_watchdog = 0;
-        arg_early_core_pattern = NULL;
-        arg_watchdog_device = NULL;
+        arg_early_core_pattern = mfree(arg_early_core_pattern);
+        arg_watchdog_device = mfree(arg_watchdog_device);
         arg_watchdog_pretimeout_governor = mfree(arg_watchdog_pretimeout_governor);
 
         arg_default_environment = strv_free(arg_default_environment);
index 926aa961741ae70fc5c5e3e923b95f448d548605..32568718033aceea39822215039a9f2d2c859d87 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/loop.h>
 #include <sched.h>
 #include <stdio.h>
+#include <sys/file.h>
 #include <sys/mount.h>
 #include <unistd.h>
 #include <linux/fs.h>
@@ -928,7 +929,7 @@ static int mount_private_dev(MountEntry *m) {
 
         r = label_fix_container(dev, "/dev", 0);
         if (r < 0) {
-                log_debug_errno(errno, "Failed to fix label of '%s' as /dev: %m", dev);
+                log_debug_errno(r, "Failed to fix label of '%s' as /dev: %m", dev);
                 goto fail;
         }
 
index fc0f8c34fac4106cc445f4cfd3d88e9583a16961..693433b34b87a3afba0068f85d73e33a165f2a2e 100644 (file)
@@ -65,6 +65,8 @@ systemdshutdowndir=${systemd_shutdown_dir}
 tmpfiles_dir=${prefix}/lib/tmpfiles.d
 tmpfilesdir=${tmpfiles_dir}
 
+user_tmpfiles_dir=${prefix}/share/user-tmpfiles.d
+
 sysusers_dir=${rootprefix}/lib/sysusers.d
 sysusersdir=${sysusers_dir}
 
index 003d4f74d16cbe15c61e887e03cb3c3761db1a6f..fc1b7bb4345996fd3645fc15ca9ab76a40f51821 100644 (file)
@@ -512,8 +512,8 @@ static int save_external_coredump(
 
         if (truncated)
                 log_struct(LOG_INFO,
-                           LOG_MESSAGE("Core file was truncated to %zu bytes.", max_size),
-                           "SIZE_LIMIT=%zu", max_size,
+                           LOG_MESSAGE("Core file was truncated to %"PRIu64" bytes.", max_size),
+                           "SIZE_LIMIT=%"PRIu64, max_size,
                            "MESSAGE_ID=" SD_MESSAGE_TRUNCATED_CORE_STR);
 
         r = fix_permissions(fd, tmp, fn, context, uid);
index bd94a755db7029cdb6dd03112b0501f45b501b76..a7f5f3c59f1547d89df43972b38c871d95c99fe0 100644 (file)
@@ -4,6 +4,7 @@
 #include <getopt.h>
 #include <linux/loop.h>
 #include <stdio.h>
+#include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 
index cd16aec4dd0f70fe178c82a4e8dddd70630f3d13..58b1a80d339ebd299f98ee484e857744716490ee 100644 (file)
@@ -58,7 +58,7 @@
 #  define UNALIGNED_P(p) (((size_t) p) % sizeof(uint32_t) != 0)
 # endif
 #else
-# define UNALIGNED_P(p) false
+# define UNALIGNED_P(p) sd_false
 #endif
 
 /* This array contains the bytes used to pad the buffer to the next
index 17c2f4f4e2ce386e56da74a1730c0bedb5e27e1e..11360c470fe063066b5a3a4e1a4834a2c91e6948 100644 (file)
@@ -1603,7 +1603,7 @@ int home_activate_luks(
 }
 
 int home_deactivate_luks(UserRecord *h, HomeSetup *setup) {
-        bool we_detached;
+        bool we_detached = false;
         int r;
 
         assert(h);
@@ -1619,10 +1619,8 @@ int home_deactivate_luks(UserRecord *h, HomeSetup *setup) {
                 r = acquire_open_luks_device(h, setup, /* graceful= */ true);
                 if (r < 0)
                         return log_error_errno(r, "Failed to initialize cryptsetup context for %s: %m", setup->dm_name);
-                if (r == 0) {
+                if (r == 0)
                         log_debug("LUKS device %s has already been detached.", setup->dm_name);
-                        we_detached = false;
-                }
         }
 
         if (setup->crypt_device) {
@@ -1631,10 +1629,9 @@ int home_deactivate_luks(UserRecord *h, HomeSetup *setup) {
                 cryptsetup_enable_logging(setup->crypt_device);
 
                 r = sym_crypt_deactivate_by_name(setup->crypt_device, setup->dm_name, 0);
-                if (ERRNO_IS_DEVICE_ABSENT(r) || r == -EINVAL) {
+                if (ERRNO_IS_DEVICE_ABSENT(r) || r == -EINVAL)
                         log_debug_errno(r, "LUKS device %s is already detached.", setup->dm_node);
-                        we_detached = false;
-                } else if (r < 0)
+                else if (r < 0)
                         return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", setup->dm_node);
                 else {
                         log_info("LUKS device detaching completed.");
index 48e4b1414cb38a2a20f849ce72094ae8b97b5c33..271e304273b1a3ef9538d309eb8ac5e613d0f0cd 100644 (file)
@@ -298,7 +298,7 @@ int check_permissions(struct MHD_Connection *connection, int *code, char **hostn
 }
 
 #else
-int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
+_noreturn_ int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
         assert_not_reached();
 }
 
index a41a56a3d82c607e7328644b0d292786c096b53d..cf1b81b55be2c94cb5a09b9a13c0ff6aa353a4f1 100755 (executable)
@@ -83,7 +83,7 @@ if [ "${0##*/}" = "installkernel" ]; then
     # kernel's install.sh invokes us as
     #   /sbin/installkernel <version> <vmlinuz> <map> <installation-dir>
     # We ignore the last two arguments.
-    set -- "$1"
+    set -- "${1:?}" "${2:?}"
 else
     COMMAND="$1"
     [ $# -ge 1 ] && shift
index 8de7c671df35d944a0e2e9112a8640720054e85f..a81ce8377cf5e2b6b8ef9750819006ea00b944ec 100644 (file)
@@ -819,7 +819,7 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void
                 break;
 
         default:
-                log_debug("Ignoring option DHCP option %"PRIu8" while parsing.", code);
+                log_debug("Ignoring DHCP option %"PRIu8" while parsing.", code);
                 break;
         }
 
index aaf951ced89863f3aa5807c476c712a0abe91d19..62531b9564b7e2120cd228c30d5ff8bc6f0e0a11 100644 (file)
@@ -1589,6 +1589,9 @@ _public_ int sd_device_get_is_initialized(sd_device *device) {
         assert_return(device, -EINVAL);
 
         r = device_read_db(device);
+        if (r == -ENOENT)
+                /* The device may be already removed or renamed. */
+                return false;
         if (r < 0)
                 return r;
 
index e5d370d4f3c1259c076f5fbf98e8948e4c23769c..29203791afbd19f7556d31b350fdb5aeef43e4a3 100644 (file)
@@ -3874,7 +3874,7 @@ _public_ int sd_event_prepare(sd_event *e) {
 
         event_close_inode_data_fds(e);
 
-        if (event_next_pending(e) || e->need_process_child)
+        if (event_next_pending(e) || e->need_process_child || !LIST_IS_EMPTY(e->inotify_data_buffered))
                 goto pending;
 
         e->state = SD_EVENT_ARMED;
index ea29def3d5f91124cc9b0f0f2baf198c52a49a4c..cc3b84cf46f542213abbea4bfca68d7908b94f8e 100644 (file)
@@ -757,4 +757,56 @@ TEST(inotify_self_destroy) {
         assert_se(sd_event_loop(e) >= 0);
 }
 
+struct inotify_process_buffered_data_context {
+        const char *path[2];
+        unsigned i;
+};
+
+static int inotify_process_buffered_data_handler(sd_event_source *s, const struct inotify_event *ev, void *userdata) {
+        struct inotify_process_buffered_data_context *c = ASSERT_PTR(userdata);
+        const char *description;
+
+        assert_se(sd_event_source_get_description(s, &description) >= 0);
+
+        assert_se(c->i < 2);
+        assert_se(streq(c->path[c->i], description));
+        c->i++;
+
+        return 1;
+}
+
+TEST(inotify_process_buffered_data) {
+        _cleanup_(rm_rf_physical_and_freep) char *p = NULL, *q = NULL;
+        _cleanup_(sd_event_source_unrefp) sd_event_source *a = NULL, *b = NULL;
+        _cleanup_(sd_event_unrefp) sd_event *e = NULL;
+        _cleanup_free_ char *z = NULL;
+
+        /* For issue #23826 */
+
+        assert_se(sd_event_default(&e) >= 0);
+
+        assert_se(mkdtemp_malloc("/tmp/test-inotify-XXXXXX", &p) >= 0);
+        assert_se(mkdtemp_malloc("/tmp/test-inotify-XXXXXX", &q) >= 0);
+
+        struct inotify_process_buffered_data_context context = {
+                .path = { p, q },
+        };
+
+        assert_se(sd_event_add_inotify(e, &a, p, IN_CREATE, inotify_process_buffered_data_handler, &context) >= 0);
+        assert_se(sd_event_add_inotify(e, &b, q, IN_CREATE, inotify_process_buffered_data_handler, &context) >= 0);
+
+        assert_se(z = path_join(p, "aaa"));
+        assert_se(touch(z) >= 0);
+        z = mfree(z);
+        assert_se(z = path_join(q, "bbb"));
+        assert_se(touch(z) >= 0);
+        z = mfree(z);
+
+        assert_se(sd_event_run(e, 10 * USEC_PER_SEC) > 0);
+        assert_se(sd_event_prepare(e) > 0); /* issue #23826: this was 0. */
+        assert_se(sd_event_dispatch(e) > 0);
+        assert_se(sd_event_prepare(e) == 0);
+        assert_se(sd_event_wait(e, 0) == 0);
+}
+
 DEFINE_TEST_MAIN(LOG_DEBUG);
index e4a3bbd3ebe5b73085ea3c34b1f91da058a309da..af7ece0adfe31e03f7d21e1d36b397c42f961296 100644 (file)
@@ -26,8 +26,8 @@ bool id128_is_valid(const char *s) {
                         char c = s[i];
 
                         if (!(c >= '0' && c <= '9') &&
-                            !(c >= 'a' && c <= 'z') &&
-                            !(c >= 'A' && c <= 'Z'))
+                            !(c >= 'a' && c <= 'f') &&
+                            !(c >= 'A' && c <= 'F'))
                                 return false;
                 }
 
@@ -43,8 +43,8 @@ bool id128_is_valid(const char *s) {
                                         return false;
                         } else {
                                 if (!(c >= '0' && c <= '9') &&
-                                    !(c >= 'a' && c <= 'z') &&
-                                    !(c >= 'A' && c <= 'Z'))
+                                    !(c >= 'a' && c <= 'f') &&
+                                    !(c >= 'A' && c <= 'F'))
                                         return false;
                         }
                 }
index 149545039491d6f1defba379fa2f9d9eb1ed4541..543d7ed026d92c86874a2456a174bf6808ec9322 100644 (file)
@@ -280,7 +280,7 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
                         if (le64toh(o->entry.items[i].object_offset) == 0 ||
                             !VALID64(le64toh(o->entry.items[i].object_offset))) {
                                 error(offset,
-                                      "Invalid entry item (%"PRIu64"/%"PRIu64" offset: "OFSfmt,
+                                      "Invalid entry item (%"PRIu64"/%"PRIu64") offset: "OFSfmt,
                                       i, journal_file_entry_n_items(o),
                                       le64toh(o->entry.items[i].object_offset));
                                 return -EBADMSG;
@@ -670,6 +670,11 @@ static int verify_entry(
                         return -EBADMSG;
                 }
 
+                /* Pointer might have moved, reposition */
+                r = journal_file_move_to_object(f, OBJECT_DATA, q, &u);
+                if (r < 0)
+                        return r;
+
                 r = journal_file_move_to_entry_by_offset_for_data(f, u, p, DIRECTION_DOWN, NULL, NULL);
                 if (r < 0)
                         return r;
index 705a35de3f245e435704df8a1bdacdc5b35fb68e..296a6c6844acf41226e4c108cdc2c6689d8cab93 100644 (file)
@@ -990,6 +990,8 @@ _public_ int sd_journal_seek_cursor(sd_journal *j, const char *cursor) {
                 case 'b':
                         boot_id_set = true;
                         r = sd_id128_from_string(word + 2, &boot_id);
+                        if (r < 0)
+                                return r;
                         break;
 
                 case 'm':
index 05af5dbf8988d14dd4c102d14e46cfad171a6f7c..4c0bf925ef86df93821a4346c708aedc57b4efe0 100644 (file)
@@ -280,7 +280,7 @@ static int link_get_l2tp_local_address(Link *link, L2tpTunnel *t, union in_addr_
 static int l2tp_get_local_address(NetDev *netdev, union in_addr_union *ret) {
         Link *link = NULL;
         L2tpTunnel *t;
-        Address *a;
+        Address *a = NULL;
         int r;
 
         assert(netdev);
index 03ac92daaf17f2b0cd7286ea76de470ebc60fd10..c0ddab212af5452c91a33a8bc811990ad035ba1c 100644 (file)
@@ -970,8 +970,6 @@ static int macsec_read_key_file(NetDev *netdev, SecurityAssociation *sa) {
         if (!sa->key_file)
                 return 0;
 
-        (void) warn_file_is_world_accessible(sa->key_file, NULL, NULL, 0);
-
         r = read_full_file_full(
                         AT_FDCWD, sa->key_file, UINT64_MAX, SIZE_MAX,
                         READ_FULL_FILE_SECURE | READ_FULL_FILE_UNHEX | READ_FULL_FILE_WARN_WORLD_READABLE | READ_FULL_FILE_CONNECT_SOCKET,
index fc2c6288ae95b0d316cf5acd283cc3414ae90677..57949b76d1cf086a7a07648cf3223fe7f713c0ff 100644 (file)
@@ -1087,8 +1087,6 @@ static int wireguard_read_key_file(const char *filename, uint8_t dest[static WG_
 
         assert(dest);
 
-        (void) warn_file_is_world_accessible(filename, NULL, NULL, 0);
-
         r = read_full_file_full(
                         AT_FDCWD, filename, UINT64_MAX, SIZE_MAX,
                         READ_FULL_FILE_SECURE | READ_FULL_FILE_UNBASE64 | READ_FULL_FILE_WARN_WORLD_READABLE | READ_FULL_FILE_CONNECT_SOCKET,
index 8830f79eb7873eec4ee2d0b12b0dafb41b80f008..a8eb180a5d5edac5a49f83ca8a0660b56673c942 100644 (file)
@@ -2133,7 +2133,7 @@ static int link_status_one(
         if (info->has_tx_queues || info->has_rx_queues) {
                 r = table_add_many(table,
                                    TABLE_EMPTY,
-                                   TABLE_STRING, "Queue Length (Tx/Rx):");
+                                   TABLE_STRING, "Number of Queues (Tx/Rx):");
                 if (r < 0)
                         return table_log_add_error(r);
                 r = table_add_cell_stringf(table, NULL, "%" PRIu32 "/%" PRIu32, info->tx_queues, info->rx_queues);
index 3a5d72549a1a37779397e569ec87b9bb7c7cfa12..48daaa83e134d7ab9a24c7d692fe93a36bfc54f3 100644 (file)
@@ -623,6 +623,11 @@ int config_parse_private_users(
                 settings->userns_mode = USER_NAMESPACE_PICK;
                 settings->uid_shift = UID_INVALID;
                 settings->uid_range = UINT32_C(0x10000);
+        } else if (streq(rvalue, "identity")) {
+                /* identity: User namespacing on, UID range is 0:65536 */
+                settings->userns_mode = USER_NAMESPACE_FIXED;
+                settings->uid_shift = 0;
+                settings->uid_range = UINT32_C(0x10000);
         } else {
                 const char *range, *shift;
                 uid_t sh, rn;
index c5fd9783952882080edb8b049dc1f15e89f598f0..4ce80bba70f7cb094abd71e7db410f8049a12b59 100644 (file)
@@ -4137,8 +4137,8 @@ static int make_uid_map_string(
          * quadruplet, consisting of host and container UID + GID. */
 
         for (size_t i = 0; i < n_bind_user_uid; i++) {
-                uid_t payload_uid = bind_user_uid[i*2+offset],
-                        host_uid = bind_user_uid[i*2+offset+1];
+                uid_t payload_uid = bind_user_uid[i*4+offset],
+                        host_uid = bind_user_uid[i*4+offset+1];
 
                 assert(previous_uid <= payload_uid);
                 assert(payload_uid < arg_uid_range);
index 8207a0419674955a0ac724f1861f40c6d329b52a..478fea10659bcc02aef4d95ce1c5c903f013e016 100644 (file)
@@ -180,14 +180,8 @@ static int reply_query_state(DnsQuery *q) {
                         sd_bus_error_setf(&error, _BUS_ERROR_DNS "NXDOMAIN", "'%s' not found", dns_query_string(q));
                 else {
                         const char *rc, *n;
-                        char p[DECIMAL_STR_MAX(q->answer_rcode)];
-
-                        rc = dns_rcode_to_string(q->answer_rcode);
-                        if (!rc) {
-                                xsprintf(p, "%i", q->answer_rcode);
-                                rc = p;
-                        }
 
+                        rc = FORMAT_DNS_RCODE(q->answer_rcode);
                         n = strjoina(_BUS_ERROR_DNS, rc);
                         sd_bus_error_setf(&error, n, "Could not resolve '%s', server or network returned error %s", dns_query_string(q), rc);
                 }
index e7ab4e556937c10cc58bbfab6ce4b59f099946e8..409f1d046428113d14b58e7f985c19b173eaff31 100644 (file)
@@ -1106,7 +1106,7 @@ int dns_cache_lookup(
 
         if (found_rcode >= 0) {
                 log_debug("RCODE %s cache hit for %s",
-                          dns_rcode_to_string(found_rcode),
+                          FORMAT_DNS_RCODE(found_rcode),
                           dns_resource_key_to_string(key, key_str, sizeof(key_str)));
 
                 if (ret_rcode)
index d6fb4880b0c966c1ce59b93e09510f7495f2cb5c..473fc8c3a0c62b3dc27e487bba6693121fc5b619 100644 (file)
@@ -9,6 +9,7 @@
 #include "memory-util.h"
 #include "resolved-dns-packet.h"
 #include "set.h"
+#include "stdio-util.h"
 #include "string-table.h"
 #include "strv.h"
 #include "unaligned.h"
@@ -1251,8 +1252,9 @@ int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a, unsigned *completed) {
 
 int dns_packet_read(DnsPacket *p, size_t sz, const void **ret, size_t *start) {
         assert(p);
+        assert(p->rindex <= p->size);
 
-        if (p->rindex + sz > p->size)
+        if (sz > p->size - p->rindex)
                 return -EMSGSIZE;
 
         if (ret)
@@ -1389,7 +1391,7 @@ int dns_packet_read_string(DnsPacket *p, char **ret, size_t *start) {
         if (memchr(d, 0, c))
                 return -EBADMSG;
 
-        t = strndup(d, c);
+        t = memdup_suffix0(d, c);
         if (!t)
                 return -ENOMEM;
 
@@ -1592,17 +1594,19 @@ static int dns_packet_read_type_windows(DnsPacket *p, Bitmap **types, size_t siz
         _cleanup_(rewind_dns_packet) DnsPacketRewinder rewinder = REWINDER_INIT(p);
         int r;
 
-        while (p->rindex < rewinder.saved_rindex + size) {
+        while (p->rindex - rewinder.saved_rindex < size) {
                 r = dns_packet_read_type_window(p, types, NULL);
                 if (r < 0)
                         return r;
 
+                assert(p->rindex >= rewinder.saved_rindex);
+
                 /* don't read past end of current RR */
-                if (p->rindex > rewinder.saved_rindex + size)
+                if (p->rindex - rewinder.saved_rindex > size)
                         return -EBADMSG;
         }
 
-        if (p->rindex != rewinder.saved_rindex + size)
+        if (p->rindex - rewinder.saved_rindex != size)
                 return -EBADMSG;
 
         if (start)
@@ -1713,7 +1717,7 @@ int dns_packet_read_rr(
         if (r < 0)
                 return r;
 
-        if (p->rindex + rdlength > p->size)
+        if (rdlength > p->size - p->rindex)
                 return -EBADMSG;
 
         offset = p->rindex;
@@ -1757,7 +1761,7 @@ int dns_packet_read_rr(
                 } else {
                         DnsTxtItem *last = NULL;
 
-                        while (p->rindex < offset + rdlength) {
+                        while (p->rindex - offset < rdlength) {
                                 DnsTxtItem *i;
                                 const void *data;
                                 size_t sz;
@@ -1989,7 +1993,7 @@ int dns_packet_read_rr(
                 if (r < 0)
                         return r;
 
-                if (rdlength + offset < p->rindex)
+                if (rdlength < p->rindex - offset)
                         return -EBADMSG;
 
                 r = dns_packet_read_memdup(p, offset + rdlength - p->rindex,
@@ -2016,6 +2020,9 @@ int dns_packet_read_rr(
                 if (r < 0)
                         return r;
 
+                if (rdlength < p->rindex - offset)
+                        return -EBADMSG;
+
                 r = dns_packet_read_type_windows(p, &rr->nsec.types, offset + rdlength - p->rindex, NULL);
 
                 /* We accept empty NSEC bitmaps. The bit indicating the presence of the NSEC record itself
@@ -2061,6 +2068,9 @@ int dns_packet_read_rr(
                 if (r < 0)
                         return r;
 
+                if (rdlength < p->rindex - offset)
+                        return -EBADMSG;
+
                 r = dns_packet_read_type_windows(p, &rr->nsec3.types, offset + rdlength - p->rindex, NULL);
 
                 /* empty non-terminals can have NSEC3 records, so empty bitmaps are allowed */
@@ -2104,7 +2114,7 @@ int dns_packet_read_rr(
                 if (r < 0)
                         return r;
 
-                if (rdlength + offset < p->rindex)
+                if (rdlength < p->rindex - offset)
                         return -EBADMSG;
 
                 r = dns_packet_read_memdup(p,
@@ -2123,7 +2133,7 @@ int dns_packet_read_rr(
         }
         if (r < 0)
                 return r;
-        if (p->rindex != offset + rdlength)
+        if (p->rindex - offset != rdlength)
                 return -EBADMSG;
 
         if (ret)
@@ -2636,6 +2646,14 @@ static const char* const dns_rcode_table[_DNS_RCODE_MAX_DEFINED] = {
 };
 DEFINE_STRING_TABLE_LOOKUP(dns_rcode, int);
 
+const char *format_dns_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]) {
+        const char *p = dns_rcode_to_string(i);
+        if (p)
+                return p;
+
+        return snprintf_ok(buf, DECIMAL_STR_MAX(int), "%i", i);
+}
+
 static const char* const dns_protocol_table[_DNS_PROTOCOL_MAX] = {
         [DNS_PROTOCOL_DNS]   = "dns",
         [DNS_PROTOCOL_MDNS]  = "mdns",
index 95b0b506ea6e6c2f2b1977855ab4d8e0665a9c78..505e3e7ba940731fb7b4351c8726d9107ad072ed 100644 (file)
@@ -283,6 +283,8 @@ enum {
 
 const char* dns_rcode_to_string(int i) _const_;
 int dns_rcode_from_string(const char *s) _pure_;
+const char *format_dns_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]);
+#define FORMAT_DNS_RCODE(i) format_dns_rcode(i, (char [DECIMAL_STR_MAX(int)]) {})
 
 const char* dns_protocol_to_string(DnsProtocol p) _const_;
 DnsProtocol dns_protocol_from_string(const char *s) _pure_;
index 158e5b44b071af967777085e6300854cdff032a4..eee664057f38a247a8354fd76cd53592ae98a36d 100644 (file)
@@ -866,7 +866,7 @@ static int dns_transaction_dnssec_ready(DnsTransaction *t) {
 
                 case DNS_TRANSACTION_RCODE_FAILURE:
                         if (!IN_SET(dt->answer_rcode, DNS_RCODE_NXDOMAIN, DNS_RCODE_SERVFAIL)) {
-                                log_debug("Auxiliary DNSSEC RR query failed with rcode=%s.", dns_rcode_to_string(dt->answer_rcode));
+                                log_debug("Auxiliary DNSSEC RR query failed with rcode=%s.", FORMAT_DNS_RCODE(dt->answer_rcode));
                                 goto fail;
                         }
 
@@ -1051,7 +1051,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
 
         log_debug("Processing incoming packet of size %zu on transaction %" PRIu16" (rcode=%s).",
                   p->size,
-                  t->id, dns_rcode_to_string(DNS_PACKET_RCODE(p)));
+                  t->id, FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)));
 
         switch (t->scope->protocol) {
 
@@ -1139,7 +1139,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
                                         return;
 
                                 /* Give up, accept the rcode */
-                                log_debug("Server returned error: %s", dns_rcode_to_string(DNS_PACKET_RCODE(p)));
+                                log_debug("Server returned error: %s", FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)));
                                 break;
                         }
 
@@ -1153,7 +1153,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
                             t->clamp_feature_level_servfail < 0) {
                                 t->clamp_feature_level_servfail = t->current_feature_level;
                                 log_debug("Server returned error %s, retrying transaction.",
-                                          dns_rcode_to_string(DNS_PACKET_RCODE(p)));
+                                          FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)));
                         } else {
                                 /* Reduce this feature level by one and try again. */
                                 switch (t->current_feature_level) {
@@ -1169,7 +1169,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
                                 }
 
                                 log_debug("Server returned error %s, retrying transaction with reduced feature level %s.",
-                                          dns_rcode_to_string(DNS_PACKET_RCODE(p)),
+                                          FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)),
                                           dns_server_feature_level_to_string(t->clamp_feature_level_servfail));
                         }
 
@@ -1310,7 +1310,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
                 t->clamp_feature_level_nxdomain = DNS_SERVER_FEATURE_LEVEL_UDP;
 
                 log_debug("Server returned error %s in EDNS0 mode, retrying transaction with reduced feature level %s (DVE-2018-0001 mitigation)",
-                          dns_rcode_to_string(DNS_PACKET_RCODE(p)),
+                          FORMAT_DNS_RCODE(DNS_PACKET_RCODE(p)),
                           dns_server_feature_level_to_string(t->clamp_feature_level_nxdomain));
 
                 dns_transaction_retry(t, false /* use the same server */);
index caa2e45595058e0a24d825112d4885bb3ce74c1e..8880078b1b3cbe5aa7cbdc61fc86244e4b32e602 100644 (file)
@@ -17,6 +17,7 @@
 %_sysctldir {{SYSCTL_DIR}}
 %_sysusersdir {{SYSUSERS_DIR}}
 %_tmpfilesdir {{TMPFILES_DIR}}
+%_user_tmpfilesdir {{USER_TMPFILES_DIR}}
 %_environmentdir {{ENVIRONMENT_DIR}}
 %_modulesloaddir {{MODULESLOAD_DIR}}
 %_modprobedir {{MODPROBE_DIR}}
index 1ab88839aacfb9f8b9e33215bbbcc0b5305e2c65..a6f86ef43219d87de1611789a78aeabe98a70b6d 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/blkpg.h>
 #include <linux/dm-ioctl.h>
 #include <linux/loop.h>
+#include <sys/file.h>
 #include <sys/mount.h>
 #include <sys/prctl.h>
 #include <sys/wait.h>
index 0ae1de1c5b2817c8ba623d9312171040f1cd056d..261b01bd4363af835b4b8e61864ba5ba10895c6c 100644 (file)
@@ -1029,7 +1029,7 @@ static bool dns_service_name_label_is_valid(const char *label, size_t n) {
 int dns_service_split(const char *joined, char **_name, char **_type, char **_domain) {
         _cleanup_free_ char *name = NULL, *type = NULL, *domain = NULL;
         const char *p = joined, *q = NULL, *d = NULL;
-        char a[DNS_LABEL_MAX], b[DNS_LABEL_MAX], c[DNS_LABEL_MAX];
+        char a[DNS_LABEL_MAX+1], b[DNS_LABEL_MAX+1], c[DNS_LABEL_MAX+1];
         int an, bn, cn, r;
         unsigned x = 0;
 
index bcc109abc24293abfd6e061e5a43027b8675e226..13bc44a9edab61c5e666fb6c47476c578bc3956b 100644 (file)
@@ -1545,7 +1545,7 @@ static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const cha
         switch (json_variant_type(v)) {
 
         case JSON_VARIANT_REAL: {
-                locale_t loc;
+                locale_t loc, old_loc;
 
                 loc = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
                 if (loc == (locale_t) 0)
@@ -1554,7 +1554,9 @@ static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const cha
                 if (flags & JSON_FORMAT_COLOR)
                         fputs(ansi_highlight_blue(), f);
 
+                old_loc = uselocale(loc);
                 fprintf(f, "%.*e", DECIMAL_DIG, json_variant_real(v));
+                uselocale(old_loc);
 
                 if (flags & JSON_FORMAT_COLOR)
                         fputs(ANSI_NORMAL, f);
index acc1dc9b95194b41f7344defa46874e5fa9dd02f..89d420e3475dc441c4e1265f4b9baf9d58958ba5 100644 (file)
@@ -1494,7 +1494,7 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
         if (r == 0 && endswith(unit, ".slice")) {
                 const char *m5;
 
-                m5 = strjoina("_SYSTEMD_SLICE=", unit);
+                m5 = strjoina("_SYSTEMD_USER_SLICE=", unit);
 
                 /* Show all messages belonging to a slice */
                 (void)(
index b76189d6b37b931f91e014331d4dbfc3ecb22388..0996ca66254a83b14324b9bde3de0ad477d2be17 100644 (file)
@@ -928,6 +928,7 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
                 .name = "@known",
                 .help = "All known syscalls declared in the kernel",
                 .value =
+                "@obsolete\0"
 #include "syscall-list.h"
         },
 };
index 36e4203b4f7dd704a15eec21b15e1cb74f734104..188d011fdd71e24737c12616329579f7c93041d2 100644 (file)
@@ -59,7 +59,7 @@ static inline int utmp_wall(
                 const char *message,
                 const char *username,
                 const char *origin_tty,
-                bool (*match_tty)(const char *tty, void *userdata),
+                bool (*match_tty)(const char *tty, bool is_local, void *userdata),
                 void *userdata) {
         return 0;
 }
index 364af195e0dc631c8a48910183cf001a2378d921..a73006ec54c1ff7f214422f926b6904a6d73e359 100644 (file)
@@ -3,6 +3,7 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <linux/loop.h>
+#include <sys/file.h>
 #include <sys/mount.h>
 #include <unistd.h>
 
index 552e85a06b71c3d190ed96cb8808e59f314179f7..fa7a789b282b1bc3d6267895791ca323fdacaa9e 100644 (file)
@@ -54,7 +54,7 @@ static int output_unit_file_list(const UnitFileList *units, unsigned c) {
         _cleanup_(unit_file_presets_freep) UnitFilePresets presets = {};
         int r;
 
-        table = table_new("unit file", "state", "vendor preset");
+        table = table_new("unit file", "state", "preset");
         if (!table)
                 return log_oom();
 
index 1c0b0027347dcc8750019d192ab534a4da165a4e..c514109b170d82bf6cfec38a35203aacb845e147 100644 (file)
@@ -318,7 +318,7 @@ static void print_status_info(
                 bool *ellipsized) {
 
         const char *active_on, *active_off, *on, *off, *ss, *fs;
-        const char *enable_on, *enable_off, *enable_vendor_on, *enable_vendor_off;
+        const char *enable_on, *enable_off, *preset_on, *preset_off;
         _cleanup_free_ char *formatted_path = NULL;
         usec_t timestamp;
         const char *path;
@@ -331,7 +331,7 @@ static void print_status_info(
 
         format_active_state(i->active_state, &active_on, &active_off);
         format_enable_state(i->unit_file_state, &enable_on, &enable_off);
-        format_enable_state(i->unit_file_preset, &enable_vendor_on, &enable_vendor_off);
+        format_enable_state(i->unit_file_preset, &preset_on, &preset_off);
 
         const SpecialGlyph glyph = unit_active_state_to_glyph(unit_active_state_from_string(i->active_state));
 
@@ -366,8 +366,8 @@ static void print_status_info(
                        on, strna(i->load_state), off,
                        path,
                        enable_on, i->unit_file_state, enable_off,
-                       show_preset ? "; vendor preset: " : "",
-                       enable_vendor_on, show_preset ? i->unit_file_preset : "", enable_vendor_off);
+                       show_preset ? "; preset: " : "",
+                       preset_on, show_preset ? i->unit_file_preset : "", preset_off);
 
         } else if (path)
                 printf("     Loaded: %s%s%s (%s)\n",
index 97ec51b7d94dbc1f4d5b989a7260faa8210a5b0c..b0064f4af333c465755eeceae229264451371cf7 100644 (file)
@@ -277,14 +277,15 @@ static int systemctl_help(void) {
                "     --legend=BOOL       Enable/disable the legend (column headers and hints)\n"
                "     --no-pager          Do not pipe output into a pager\n"
                "     --no-ask-password   Do not ask for system passwords\n"
-               "     --global            Enable/disable/mask default user unit files globally\n"
-               "     --runtime           Enable/disable/mask unit files temporarily until next\n"
-               "                         reboot\n"
+               "     --global            Edit/enable/disable/mask default user unit files\n"
+               "                         globally\n"
+               "     --runtime           Edit/enable/disable/mask unit files temporarily until\n"
+               "                         next reboot\n"
                "  -f --force             When enabling unit files, override existing symlinks\n"
                "                         When shutting down, execute action immediately\n"
                "     --preset-mode=      Apply only enable, only disable, or all presets\n"
-               "     --root=PATH         Enable/disable/mask unit files in the specified root\n"
-               "                         directory\n"
+               "     --root=PATH         Edit/enable/disable/mask unit files in the specified\n"
+               "                         root directory\n"
                "  -n --lines=INTEGER     Number of journal entries to show\n"
                "  -o --output=STRING     Change journal output mode (short, short-precise,\n"
                "                             short-iso, short-iso-precise, short-full,\n"
index a6e0c8501e86ba4e92500cfd4930ef74d690fa11..cec38902e96e1eddcf7418fc8def47eb40f1d7b0 100644 (file)
@@ -540,6 +540,7 @@ TEST(dns_service_split) {
         test_dns_service_split_one("_foo._bar", NULL, "_foo._bar", ".", 0);
         test_dns_service_split_one("_meh._foo._bar", "_meh", "_foo._bar", ".", 0);
         test_dns_service_split_one("Wuff\\032Wuff._foo._bar.waldo.com", "Wuff Wuff", "_foo._bar", "waldo.com", 0);
+        test_dns_service_split_one("_Q._Q-------------------------------------------------------------", NULL, "_Q._Q-------------------------------------------------------------", ".", 0);
 }
 
 static void test_dns_name_change_suffix_one(const char *name, const char *old_suffix, const char *new_suffix, int r, const char *result) {
index d1793222f0ee07f8e8b72d06f135a687a488ddab..9179ef5d608cea244bfbb25f902e524905818468 100644 (file)
@@ -3,6 +3,7 @@
 #include <fcntl.h>
 #include <linux/loop.h>
 #include <pthread.h>
+#include <sys/file.h>
 
 #include "alloc-util.h"
 #include "dissect-image.h"
index 4251e2a80988eb4c802bb25b5579cda09adab9a6..5e139856f49ce80bef4ffef17f57db766bbc743f 100644 (file)
@@ -21,7 +21,7 @@ TEST(failed_enumerate) {
 }
 
 #define DELL_MODALIAS \
-        "evdev:atkbd:dmi:bvnXXX:bvrYYY:bdZZZ:svnDellXXX:pnYYY"
+        "evdev:atkbd:dmi:bvnXXX:bvrYYY:bdZZZ:svnDellXXX:pnYYY:"
 
 TEST(basic_enumerate) {
         _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
index 5c5c35f3a260adeeb619cacba607f3ed611b42d7..0fc9dffe239bbaab7cb654892d64b4e9847b5be8 100644 (file)
@@ -90,6 +90,27 @@ TEST(set_put) {
         assert_se(strv_length(t) == 3);
 }
 
+TEST(set_put_strndup) {
+        _cleanup_set_free_ Set *m = NULL;
+
+        assert_se(set_put_strndup(&m, "12345", 0) == 1);
+        assert_se(set_put_strndup(&m, "12345", 1) == 1);
+        assert_se(set_put_strndup(&m, "12345", 2) == 1);
+        assert_se(set_put_strndup(&m, "12345", 3) == 1);
+        assert_se(set_put_strndup(&m, "12345", 4) == 1);
+        assert_se(set_put_strndup(&m, "12345", 5) == 1);
+        assert_se(set_put_strndup(&m, "12345", 6) == 0);
+
+        assert_se(set_contains(m, ""));
+        assert_se(set_contains(m, "1"));
+        assert_se(set_contains(m, "12"));
+        assert_se(set_contains(m, "123"));
+        assert_se(set_contains(m, "1234"));
+        assert_se(set_contains(m, "12345"));
+
+        assert_se(set_size(m) == 6);
+}
+
 TEST(set_put_strdup) {
         _cleanup_set_free_ Set *m = NULL;
 
@@ -98,6 +119,10 @@ TEST(set_put_strdup) {
         assert_se(set_put_strdup(&m, "bbb") == 1);
         assert_se(set_put_strdup(&m, "bbb") == 0);
         assert_se(set_put_strdup(&m, "aaa") == 0);
+
+        assert_se(set_contains(m, "aaa"));
+        assert_se(set_contains(m, "bbb"));
+
         assert_se(set_size(m) == 2);
 }
 
@@ -106,6 +131,11 @@ TEST(set_put_strdupv) {
 
         assert_se(set_put_strdupv(&m, STRV_MAKE("aaa", "aaa", "bbb", "bbb", "aaa")) == 2);
         assert_se(set_put_strdupv(&m, STRV_MAKE("aaa", "aaa", "bbb", "bbb", "ccc")) == 1);
+
+        assert_se(set_contains(m, "aaa"));
+        assert_se(set_contains(m, "bbb"));
+        assert_se(set_contains(m, "ccc"));
+
         assert_se(set_size(m) == 3);
 }
 
index 86a60604da1ce25a230711504c53877356779bbc..0f6a2ff0443c7f44231fb3d859179dcedcfcd8e0 100644 (file)
@@ -238,6 +238,11 @@ TEST(format_timespan) {
         test_format_timespan_accuracy(1);
         test_format_timespan_accuracy(USEC_PER_MSEC);
         test_format_timespan_accuracy(USEC_PER_SEC);
+
+        /* See issue #23928. */
+        _cleanup_free_ char *buf;
+        assert_se(buf = new(char, 5));
+        assert_se(buf == format_timespan(buf, 5, 100005, 1000));
 }
 
 TEST(verify_timezone) {
index 94973c2aa5c231ebbc688466022f8ae9575f7705..d5db0304d5236910d2f835609e948498e7e365ef 100644 (file)
@@ -596,7 +596,7 @@ static int dir_cleanup(
                         continue;
                 if (r < 0) {
                         /* FUSE, NFS mounts, SELinux might return EACCES */
-                        r = log_full_errno(errno == EACCES ? LOG_DEBUG : LOG_ERR, errno,
+                        r = log_full_errno(r == -EACCES ? LOG_DEBUG : LOG_ERR, r,
                                            "statx(%s/%s) failed: %m", p, de->d_name);
                         continue;
                 }
index fa225476b64ce68ec2a0093f358b89902a195ed8..f95b751b75ae89388a5a8273b6d60a6ce7035dab 100644 (file)
@@ -1717,7 +1717,7 @@ static int udev_rule_apply_token_to_event(
                 return token->op == (match ? OP_MATCH : OP_NOMATCH);
         }
         case TK_M_PROGRAM: {
-                char buf[UDEV_PATH_SIZE], result[UDEV_LINE_SIZE];
+                char buf[UDEV_LINE_SIZE], result[UDEV_LINE_SIZE];
                 bool truncated;
                 size_t count;
 
@@ -1805,7 +1805,7 @@ static int udev_rule_apply_token_to_event(
         }
         case TK_M_IMPORT_PROGRAM: {
                 _cleanup_strv_free_ char **lines = NULL;
-                char buf[UDEV_PATH_SIZE], result[UDEV_LINE_SIZE];
+                char buf[UDEV_LINE_SIZE], result[UDEV_LINE_SIZE];
                 bool truncated;
 
                 (void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false, &truncated);
@@ -1873,7 +1873,7 @@ static int udev_rule_apply_token_to_event(
                 UdevBuiltinCommand cmd = PTR_TO_UDEV_BUILTIN_CMD(token->data);
                 assert(cmd >= 0 && cmd < _UDEV_BUILTIN_MAX);
                 unsigned mask = 1U << (int) cmd;
-                char buf[UDEV_PATH_SIZE];
+                char buf[UDEV_LINE_SIZE];
                 bool truncated;
 
                 if (udev_builtin_run_once(cmd)) {
@@ -2369,7 +2369,7 @@ static int udev_rule_apply_token_to_event(
         case TK_A_RUN_BUILTIN:
         case TK_A_RUN_PROGRAM: {
                 _cleanup_free_ char *cmd = NULL;
-                char buf[UDEV_PATH_SIZE];
+                char buf[UDEV_LINE_SIZE];
                 bool truncated;
 
                 if (event->run_final)
index 7521a6d2e5ae8d248b443a4c15267a900e40ee07..b5468cbea40f18367102181d3caabef13bd786c5 100755 (executable)
@@ -93,7 +93,7 @@ cmp /expected /output
 ID=$(systemd-id128 new)
 systemd-cat -t "$ID" bash -c 'echo parent; (echo child) & wait' &
 PID=$!
-wait %%
+wait $PID
 journalctl --sync
 # We can drop this grep when https://github.com/systemd/systemd/issues/13937
 # has a fix.
index cf8baf608463a1f1a2249b4a6f6fd4bea2148fec..85a2c08dee63bfac439f1e3ff286a8c5bd504ed7 100644 (file)
@@ -13,6 +13,7 @@ DefaultDependencies=no
 Before=sysinit.target
 Documentation=man:modprobe(8)
 ConditionCapability=CAP_SYS_MODULE
+StartLimitIntervalSec=0
 
 [Service]
 Type=oneshot
index 5e919950600bba882673d8fac19b9efda1fa3f3b..0175a148584535e8c8b25088b840bfbae2b52a9c 100644 (file)
@@ -19,4 +19,4 @@ ConditionPathIsReadWrite=/sys
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=-udevadm trigger --type=all --action=add --prioritized-subsystem=block,tpmrm
+ExecStart=-udevadm trigger --type=all --action=add --prioritized-subsystem=module,block,tpmrm,tty,net