]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #17444 from BtbN/fix_ib_dhcp4
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 29 Oct 2020 18:27:29 +0000 (19:27 +0100)
committerGitHub <noreply@github.com>
Thu, 29 Oct 2020 18:27:29 +0000 (19:27 +0100)
networkd: fix DHCP on InfiniBand interfaces

59 files changed:
hwdb.d/60-sensor.hwdb
man/org.freedesktop.hostname1.xml
man/systemd.special.xml
meson.build
src/basic/MurmurHash2.c
src/basic/MurmurHash2.h
src/basic/gunicode.c
src/basic/gunicode.h
src/basic/memory-util.c
src/basic/siphash24.c
src/basic/siphash24.h
src/basic/sort-util.c
src/basic/static-destruct.h
src/boot/efi/crc32.c
src/boot/efi/crc32.h
src/boot/efi/random-seed.c
src/boot/efi/sha256.c
src/cryptsetup/cryptsetup-generator.c
src/home/homectl-recovery-key.c
src/home/user-record-sign.c
src/journal-remote/journal-upload.h
src/journal/journal-qrcode.c [deleted file]
src/journal/journal-qrcode.h [deleted file]
src/journal/journalctl.c
src/journal/lookup3.c
src/journal/lookup3.h
src/journal/meson.build
src/libsystemd-network/test-sd-dhcp-lease.c
src/libsystemd/sd-bus/test-bus-address.c
src/libsystemd/sd-event/sd-event.c
src/network/netdev/wireguard.h
src/network/test-network-tables.c
src/resolve/resolved-dns-cache.c
src/resolve/resolved-dns-packet.c
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-rr.c
src/resolve/resolved-dns-search-domain.c
src/resolve/resolved-dns-stub.c
src/resolve/resolved-dns-transaction.c
src/resolve/resolved-dns-zone.c
src/resolve/resolved-dnssd-bus.h
src/resolve/resolved-dnssd.h
src/resolve/resolved-etc-hosts.c
src/resolve/resolved-link.c
src/shared/binfmt-util.c
src/shared/dm-util.c
src/shared/initreq.h
src/shared/linux/nl80211.h
src/shared/meson.build
src/shared/pam-util.c
src/shared/pe-header.h
src/shared/qrcode-util.c
src/shared/qrcode-util.h
src/test/meson.build
src/test/test-qrcode-util.c [new file with mode: 0644]
src/test/test-sd-hwdb.c
src/time-wait-sync/time-wait-sync.c
units/initrd-cryptsetup.target [deleted file]
units/meson.build

index 7079736a8faa718c05ebd851727575a822eaafca..16edca57aae1be9198d61c903254968f71935265 100644 (file)
@@ -650,6 +650,14 @@ sensor:modalias:acpi:KIOX000A*:dmi:*:rvnPOV:rnI102A:*
 sensor:modalias:i2c:bmc150_accel:dmi:bvnINSYDECorp.:*:svnInsyde:pnBayTrail:*:rvn105B:rn0E57:*
  ACCEL_MOUNT_MATRIX=1, 0, 0; 0, -1, 0; 0, 0, 1
 
+#########################################
+# Predia
+#########################################
+
+# Predia Basic tablet, most DMI strings are generic, match on BIOS version
+sensor:modalias:acpi:BOSC0200*:dmi:bvnINSYDECorp.:bvrMx.WT107.KUBNGEA*svnInsyde:pnCherryTrail:*
+ ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1
+
 #########################################
 # Prowise
 #########################################
index 6b2341e48c08217531e872ee809cb2ecf4195325..ab49c0b3e216335318a920a132e0ebbc78c17869 100644 (file)
@@ -260,7 +260,8 @@ node /org/freedesktop/hostname1 {
       <interfacename>org.freedesktop.hostname1.set-hostname</interfacename>. For
       <function>SetStaticHostname()</function> and <function>SetPrettyHostname()</function> it is
       <interfacename>org.freedesktop.hostname1.set-static-hostname</interfacename>. For
-      <function>SetIconName()</function> and <function>SetChassis()</function> it is
+      <function>SetIconName()</function>, <function>SetChassis()</function>, <function>SetDeployment()</function>
+      and <function>SetLocation()</function> it is
       <interfacename>org.freedesktop.hostname1.set-machine-info</interfacename>.</para>
     </refsect2>
   </refsect1>
index fe40da7fbe25568dfe35de9e2a88997dbc19ef47..1434ead7d5e8c74ad001cc175664045c14230144 100644 (file)
@@ -41,7 +41,6 @@
     <filename>hybrid-sleep.target</filename>,
     <filename>suspend-then-hibernate.target</filename>,
     <filename>initrd.target</filename>,
-    <filename>initrd-cryptsetup.target</filename>,
     <filename>initrd-fs.target</filename>,
     <filename>initrd-root-device.target</filename>,
     <filename>initrd-root-fs.target</filename>,
         <varlistentry>
           <term><filename>cryptsetup.target</filename></term>
           <listitem>
-            <para>A target that pulls in setup services for local encrypted block devices.
-            See <filename>remote-cryptsetup.target</filename> below for the equivalent target for remote
-            volumes, and <filename>initrd-cryptsetup.target</filename> below for the equivalent target in the
-            initrd.</para>
+            <para>A target that pulls in setup services for all
+            encrypted block devices.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
         <varlistentry>
           <term><filename>initrd.target</filename></term>
           <listitem>
-            <para>This is the default target in the initrd, similar to <filename>default.target</filename>
+            <para>This is the default target in the initramfs, similar to <filename>default.target</filename>
             in the main system. It is used to mount the real root and transition to it. See
             <citerefentry><refentrytitle>bootup</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
             more discussion.</para>
           </listitem>
         </varlistentry>
-        <varlistentry>
-          <term><filename>initrd-cryptsetup.target</filename></term>
-          <listitem>
-            <para>A target that pulls in setup services for all encrypted block devices. See
-            <filename>cryptsetup.target</filename> and <filename>remote-cryptsetup.target</filename> for the
-            equivalent targets in the real root.</para>
-          </listitem>
-        </varlistentry>
         <varlistentry>
           <term><filename>initrd-fs.target</filename></term>
           <listitem>
             <para>Similar to <filename>cryptsetup.target</filename>, but for encrypted
             devices which are accessed over the network. It is used for
             <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>8</manvolnum></citerefentry>
-            entries marked with <option>_netdev</option>.
-            See <filename>cryptsetup.target</filename> for the equivalent target for local volumes, and
-            <filename>initrd-cryptsetup.target</filename> for the equivalent target in the initrd.</para>
+            entries marked with <option>_netdev</option>.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
index 1abcac27f49f52666d0812dbcd57763dc51aaf1c..5cfc24c2d6d5b47331d5c9a906245e9cfc679143 100644 (file)
@@ -1561,21 +1561,11 @@ meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
 
 includes = include_directories('src/basic',
                                'src/boot',
+                               'src/core',
                                'src/home',
-                               'src/shared',
-                               'src/systemd',
                                'src/journal',
                                'src/journal-remote',
-                               'src/nspawn',
-                               'src/resolve',
-                               'src/timesync',
-                               'src/time-wait-sync',
-                               'src/login',
-                               'src/udev',
-                               'src/libudev',
-                               'src/core',
-                               'src/shutdown',
-                               'src/xdg-autostart-generator',
+                               'src/libsystemd-network',
                                'src/libsystemd/sd-bus',
                                'src/libsystemd/sd-device',
                                'src/libsystemd/sd-event',
@@ -1584,7 +1574,17 @@ includes = include_directories('src/basic',
                                'src/libsystemd/sd-netlink',
                                'src/libsystemd/sd-network',
                                'src/libsystemd/sd-resolve',
-                               'src/libsystemd-network',
+                               'src/libudev',
+                               'src/login',
+                               'src/nspawn',
+                               'src/resolve',
+                               'src/shared',
+                               'src/shutdown',
+                               'src/systemd',
+                               'src/time-wait-sync',
+                               'src/timesync',
+                               'src/udev',
+                               'src/xdg-autostart-generator',
                                '.')
 
 add_project_arguments('-include', 'config.h', language : 'c')
index 5859af0a81b622e60ccbc580f18c2a1529902751..43a89a0820bf10b76aa8cf22d8da3891b8bb2285 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LicenseRef-murmurhash2-public-domain */
 //-----------------------------------------------------------------------------
 // MurmurHash2 was written by Austin Appleby, and is placed in the public
 // domain. The author hereby disclaims copyright to this source code.
index 1aef3afba0648a245fc8bcb986293f5a3d2a2b35..5758b860398dba7c1740ad86b76f709f299452e9 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LicenseRef-murmurhash2-public-domain */
 //-----------------------------------------------------------------------------
 // MurmurHash2 was written by Austin Appleby, and is placed in the public
 // domain. The author hereby disclaims copyright to this source code.
index c51b1a7a18108fd3e47f8a0dd1395527ce4806e1..02637d74e91d06d176b4894629a6b717e43531ea 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /* gunicode.c - Unicode manipulation functions
  *
  *  Copyright (C) 1999, 2000 Tom Tromey
index a16b7b6ff1b0deaa082564372519bda40c3d4d6f..765077db83200962b25d8781b6f1a27449f7f624 100644 (file)
@@ -1,10 +1,10 @@
-#pragma once
-
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /* gunicode.h - Unicode manipulation functions
  *
  *  Copyright (C) 1999, 2000 Tom Tromey
  *  Copyright Â© 2000, 2005 Red Hat, Inc.
  */
+#pragma once
 
 #include <stdbool.h>
 #include <stdint.h>
index 5f327ef0d7aaacf3abaa6b7f197e6f5d41e533fd..0a5cf2797d0fbfab4620f6b24f8be090d106ee25 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <unistd.h>
 
 #include "memory-util.h"
index 61180819b1bf0f995cddb9ca2ee9f02e1be9bb28..7c61eb145d9ddd3e080cc294d5827a9365ffc616 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: CC0-1.0 */
+
 /*
    SipHash reference C implementation
 
@@ -10,7 +12,7 @@
    worldwide. This software is distributed without any warranty.
 
    You should have received a copy of the CC0 Public Domain Dedication along with
-   this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
+   this software. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
 
    (Minimal changes made by Lennart Poettering, to make clean for inclusion in systemd)
    (Refactored by Tom Gundersen to split up in several functions and follow systemd
index fe43256882eccf86fe112310c11de5887247f9e1..90a6de00e4f2f531849989e705b6c2f6b207fc19 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: CC0-1.0 */
+
 #pragma once
 
 #include <inttypes.h>
index 5cf0d1d49b6c2da05e7c82482dd166c34e8e1229..77342c4bdc6761875c5456df0d05ff65f0124c71 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include "sort-util.h"
 #include "alloc-util.h"
 
index 8fbc07c5876a8b67bcd80a67120462438f799d01..fbb8fa087b90773549152a061c35aa4f70066c0b 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #pragma once
 
 #include "alloc-util.h"
index 46b9aeea9070afff4537ef944875a40677d67f43..5dfd3db265f7f03fbc500bfa96bd60004414200f 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LicenseRef-crc32-no-restriction */
 /* This is copied from util-linux, which in turn copied in the version from Gary S. Brown */
 
 /*
index 64150ee948cbfd903d00f84317a4724788f15d84..3af543b84e5241ded57ffaadc905c734e2a8dbf2 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LicenseRef-crc32-no-restriction */
 #pragma once
 
 #include <efi.h>
index cc747993b8bbdf4787f9a0d111c74911529ea9e1..6e2a6f1d32fe08d095639c4daee97d2ac389c6cb 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <efi.h>
 #include <efilib.h>
 
index 40da636dc712aaa0372dafe8ce595136a27bd200..005e1902d4bed5d42c92e5109ecc8e2f3c22c085 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 /* Stolen from glibc and converted to UEFI style. In glibc it comes with the following copyright blurb: */
 
 /* Functions to compute SHA256 message digest of files or memory blocks.
index 13e9f3aedd01416133c75523e8c031865b76c93c..df589ec3e4a9d78f15f376ed5f2860ced3475bb2 100644 (file)
@@ -455,16 +455,10 @@ static int create_disk(
                 }
         }
 
-        const char *target;
-        if (in_initrd())
-                target = "initrd-cryptsetup.target";
-        else if (netdev)
-                target = "remote-cryptsetup.target";
-        else
-                target = "cryptsetup.target";
-
         if (!nofail)
-                fprintf(f, "Before=%s\n", target);
+                fprintf(f,
+                        "Before=%s\n",
+                        netdev ? "remote-cryptsetup.target" : "cryptsetup.target");
 
         if (password && !keydev) {
                 r = print_dependencies(f, password);
@@ -527,7 +521,8 @@ static int create_disk(
                 return log_error_errno(r, "Failed to write unit file %s: %m", n);
 
         if (!noauto) {
-                r = generator_add_symlink(arg_dest, target,
+                r = generator_add_symlink(arg_dest,
+                                          netdev ? "remote-cryptsetup.target" : "cryptsetup.target",
                                           nofail ? "wants" : "requires", n);
                 if (r < 0)
                         return r;
index c63d3415f4bb3878e393a6297ef9fe2740772f1f..3311205db50bbebe5b7d9f67ffd3f02005eb7e11 100644 (file)
@@ -1,17 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#if HAVE_QRENCODE
-#include <qrencode.h>
-#include "qrcode-util.h"
-#endif
-
-#include "dlfcn-util.h"
 #include "errno-util.h"
 #include "homectl-recovery-key.h"
 #include "libcrypt-util.h"
 #include "locale-util.h"
 #include "memory-util.h"
 #include "modhex.h"
+#include "qrcode-util.h"
 #include "random-util.h"
 #include "strv.h"
 #include "terminal-util.h"
@@ -140,48 +135,6 @@ static int add_secret(JsonVariant **v, const char *password) {
         return 0;
 }
 
-static int print_qr_code(const char *secret) {
-#if HAVE_QRENCODE
-        QRcode* (*sym_QRcode_encodeString)(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
-        void (*sym_QRcode_free)(QRcode *qrcode);
-        _cleanup_(dlclosep) void *dl = NULL;
-        QRcode* qr;
-        int r;
-
-        /* If this is not an UTF-8 system or ANSI colors aren't supported/disabled don't print any QR
-         * codes */
-        if (!is_locale_utf8() || !colors_enabled())
-                return -EOPNOTSUPP;
-
-        dl = dlopen("libqrencode.so.4", RTLD_LAZY);
-        if (!dl)
-                return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
-                                       "QRCODE support is not installed: %s", dlerror());
-
-        r = dlsym_many_and_warn(
-                        dl,
-                        LOG_DEBUG,
-                        &sym_QRcode_encodeString, "QRcode_encodeString",
-                        &sym_QRcode_free, "QRcode_free",
-                        NULL);
-        if (r < 0)
-                return r;
-
-        qr = sym_QRcode_encodeString(secret, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
-        if (!qr)
-                return -ENOMEM;
-
-        fprintf(stderr, "\nYou may optionally scan the recovery key off screen:\n\n");
-
-        write_qrcode(stderr, qr);
-
-        fputc('\n', stderr);
-
-        sym_QRcode_free(qr);
-#endif
-        return 0;
-}
-
 int identity_add_recovery_key(JsonVariant **v) {
         _cleanup_(erase_and_freep) char *password = NULL, *hashed = NULL;
         int r;
@@ -240,7 +193,7 @@ int identity_add_recovery_key(JsonVariant **v) {
               "whenever authentication is requested.\n", stderr);
         fflush(stderr);
 
-        print_qr_code(password);
+        (void) print_qrcode(stderr, "You may optionally scan the recovery key off screen", password);
 
         return 0;
 }
index 91f86399976d2887d2a65c2f3172ede071a80d7a..6ef0c27c5465436f07e76ba4cc99f0c0e72040d3 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <openssl/pem.h>
 
 #include "fd-util.h"
index 4994cd8391dd5d147b842d93d4b1cd056aba56f3..95af35db054d57fbc6637f0fa7bbf5b09da84903 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #pragma once
 
 #include <inttypes.h>
diff --git a/src/journal/journal-qrcode.c b/src/journal/journal-qrcode.c
deleted file mode 100644 (file)
index e8a7655..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-#include <errno.h>
-#include <qrencode.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "alloc-util.h"
-#include "dlfcn-util.h"
-#include "fd-util.h"
-#include "fileio.h"
-#include "journal-qrcode.h"
-#include "locale-util.h"
-#include "macro.h"
-#include "qrcode-util.h"
-#include "terminal-util.h"
-
-int print_qr_code(
-                FILE *output,
-                const char *prefix_text,
-                const void *seed,
-                size_t seed_size,
-                uint64_t start,
-                uint64_t interval,
-                const char *hn,
-                sd_id128_t machine) {
-
-        QRcode* (*sym_QRcode_encodeString)(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
-        void (*sym_QRcode_free)(QRcode *qrcode);
-        _cleanup_(dlclosep) void *dl = NULL;
-        _cleanup_free_ char *url = NULL;
-        _cleanup_fclose_ FILE *f = NULL;
-        size_t url_size = 0;
-        QRcode* qr;
-        int r;
-
-        assert(seed);
-        assert(seed_size > 0);
-
-        /* If this is not an UTF-8 system or ANSI colors aren't supported/disabled don't print any QR
-         * codes */
-        if (!is_locale_utf8() || !colors_enabled())
-                return -EOPNOTSUPP;
-
-        dl = dlopen("libqrencode.so.4", RTLD_LAZY);
-        if (!dl)
-                return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
-                                       "QRCODE support is not installed: %s", dlerror());
-
-        r = dlsym_many_and_warn(
-                        dl,
-                        LOG_DEBUG,
-                        &sym_QRcode_encodeString, "QRcode_encodeString",
-                        &sym_QRcode_free, "QRcode_free",
-                        NULL);
-        if (r < 0)
-                return r;
-
-        f = open_memstream_unlocked(&url, &url_size);
-        if (!f)
-                return -ENOMEM;
-
-        fputs("fss://", f);
-
-        for (size_t i = 0; i < seed_size; i++) {
-                if (i > 0 && i % 3 == 0)
-                        fputc('-', f);
-                fprintf(f, "%02x", ((uint8_t*) seed)[i]);
-        }
-
-        fprintf(f, "/%"PRIx64"-%"PRIx64"?machine=" SD_ID128_FORMAT_STR,
-                start,
-                interval,
-                SD_ID128_FORMAT_VAL(machine));
-
-        if (hn)
-                fprintf(f, ";hostname=%s", hn);
-
-        r = fflush_and_check(f);
-        if (r < 0)
-                return r;
-
-        f = safe_fclose(f);
-
-        qr = sym_QRcode_encodeString(url, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
-        if (!qr)
-                return -ENOMEM;
-
-        if (prefix_text)
-                fputs(prefix_text, output);
-
-        write_qrcode(output, qr);
-
-        sym_QRcode_free(qr);
-        return 0;
-}
diff --git a/src/journal/journal-qrcode.h b/src/journal/journal-qrcode.h
deleted file mode 100644 (file)
index 24ae9d3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-#pragma once
-
-#include <inttypes.h>
-#include <stdio.h>
-
-#include "sd-id128.h"
-
-int print_qr_code(FILE *f, const char *prefix_text, const void *seed, size_t seed_size, uint64_t start, uint64_t interval, const char *hn, sd_id128_t machine);
index e43e9d1afac95000f1d7f590bb0f4b2edf2c120b..8bc0aa22dea5bed2f24ef04edaec0449be73b466 100644 (file)
@@ -43,7 +43,6 @@
 #include "io-util.h"
 #include "journal-def.h"
 #include "journal-internal.h"
-#include "journal-qrcode.h"
 #include "journal-util.h"
 #include "journal-vacuum.h"
 #include "journal-verify.h"
@@ -60,6 +59,7 @@
 #include "path-util.h"
 #include "pcre2-dlopen.h"
 #include "pretty-print.h"
+#include "qrcode-util.h"
 #include "random-util.h"
 #include "rlimit-util.h"
 #include "set.h"
@@ -1779,6 +1779,55 @@ static int add_syslog_identifier(sd_journal *j) {
         return 0;
 }
 
+#if HAVE_GCRYPT
+static int format_journal_url(
+                const void *seed,
+                size_t seed_size,
+                uint64_t start,
+                uint64_t interval,
+                const char *hn,
+                sd_id128_t machine,
+                bool full,
+                char **ret_url) {
+        _cleanup_free_ char *url = NULL;
+        _cleanup_fclose_ FILE *f = NULL;
+        size_t url_size = 0;
+        int r;
+
+        assert(seed);
+        assert(seed_size > 0);
+
+        f = open_memstream_unlocked(&url, &url_size);
+        if (!f)
+                return -ENOMEM;
+
+        if (full)
+                fputs("fss://", f);
+
+        for (size_t i = 0; i < seed_size; i++) {
+                if (i > 0 && i % 3 == 0)
+                        fputc('-', f);
+                fprintf(f, "%02x", ((uint8_t*) seed)[i]);
+        }
+
+        fprintf(f, "/%"PRIx64"-%"PRIx64, start, interval);
+
+        if (full) {
+                fprintf(f, "?machine=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(machine));
+                if (hn)
+                        fprintf(f, ";hostname=%s", hn);
+        }
+
+        r = fflush_and_check(f);
+        if (r < 0)
+                return r;
+
+        f = safe_fclose(f);
+        *ret_url = TAKE_PTR(url);
+        return 0;
+}
+#endif
+
 static int setup_keys(void) {
 #if HAVE_GCRYPT
         size_t mpk_size, seed_size, state_size;
@@ -1893,7 +1942,11 @@ static int setup_keys(void) {
 
         k = mfree(k);
 
-        _cleanup_free_ char *hn = NULL;
+        _cleanup_free_ char *hn = NULL, *key = NULL;
+
+        r = format_journal_url(seed, seed_size, n, arg_interval, hn, machine, false, &key);
+        if (r < 0)
+                return r;
 
         if (on_tty()) {
                 hn = gethostname_malloc();
@@ -1925,21 +1978,19 @@ static int setup_keys(void) {
                 fflush(stderr);
         }
 
-        for (size_t i = 0; i < seed_size; i++) {
-                if (i > 0 && i % 3 == 0)
-                        putchar('-');
-                printf("%02x", ((uint8_t*) seed)[i]);
-        }
-        printf("/%llx-%llx\n", (unsigned long long) n, (unsigned long long) arg_interval);
+        puts(key);
 
         if (on_tty()) {
                 fprintf(stderr, "%s", ansi_normal());
 #if HAVE_QRENCODE
-                (void) print_qr_code(stderr,
-                                     "\nTo transfer the verification key to your phone scan the QR code below:\n",
-                                     seed, seed_size,
-                                     n, arg_interval,
-                                     hn, machine);
+                _cleanup_free_ char *url = NULL;
+                r = format_journal_url(seed, seed_size, n, arg_interval, hn, machine, true, &url);
+                if (r < 0)
+                        return r;
+
+                (void) print_qrcode(stderr,
+                                    "To transfer the verification key to your phone scan the QR code below",
+                                    url);
 #endif
         }
 
index 74c80b724df30494b6c694515e7ca8f715de6d25..39967f21cdcecf3e2645921c7ad802a976143fc9 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LicenseRef-lookup3-public-domain */
 /* Slightly modified by Lennart Poettering, to avoid name clashes, and
  * unexport a few functions. */
 
index 0a01269e433980b1c89f933e5f06521d70e2728f..04e493e95eacb6d26e0e256f1aef214052d9065b 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LicenseRef-lookup3-public-domain */
 #pragma once
 
 #include <inttypes.h>
index 3a590bdc6c50777a4033359d2a05f3a793b543c0..215ba949e7764a2d90b09948f9cdb6d34dbf4d55 100644 (file)
@@ -107,11 +107,6 @@ journalctl_sources = files('''
         pcre2-dlopen.h
 '''.split())
 
-if conf.get('HAVE_QRENCODE') == 1
-        journalctl_sources += files('journal-qrcode.c',
-                                    'journal-qrcode.h')
-endif
-
 install_data('journald.conf',
              install_dir : pkgsysconfdir)
 
index 534cc7856401db6fb750ff3b332511c90fc70747..91eaf814e4041048ed278ba1b347d20849fb8faa 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <errno.h>
 
 #include "dhcp-lease-internal.h"
index 70a6df10f96e2f34fd0050defbe39c0f2e56e7a7..1316d376e13cd803ae4ea9a42f0a96c28428b1df 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include "sd-bus.h"
 
 #include "bus-internal.h"
index 5e770c83b7af85ec104b49db9941e645c7df47ad..50ee29ae97968ea44b99f1b10c8abe7cdf8353c5 100644 (file)
@@ -701,6 +701,33 @@ static void event_gc_signal_data(sd_event *e, const int64_t *priority, int sig)
                 event_unmask_signal_data(e, d, sig);
 }
 
+static void event_source_pp_prioq_reshuffle(sd_event_source *s) {
+        assert(s);
+
+        /* Reshuffles the pending + prepare prioqs. Called whenever the dispatch order changes, i.e. when
+         * they are enabled/disabled or marked pending and such. */
+
+        if (s->pending)
+                prioq_reshuffle(s->event->pending, s, &s->pending_index);
+
+        if (s->prepare)
+                prioq_reshuffle(s->event->prepare, s, &s->prepare_index);
+}
+
+static void event_source_time_prioq_reshuffle(sd_event_source *s) {
+        struct clock_data *d;
+
+        assert(s);
+        assert(EVENT_SOURCE_IS_TIME(s->type));
+
+        /* Called whenever the event source's timer ordering properties changed, i.e. time, accuracy,
+         * pending, enable state. Makes sure the two prioq's are ordered properly again. */
+        assert_se(d = event_get_clock_data(s->event, s->type));
+        prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
+        prioq_reshuffle(d->latest, s, &s->time.latest_index);
+        d->needs_rearm = true;
+}
+
 static void source_disconnect(sd_event_source *s) {
         sd_event *event;
 
@@ -907,16 +934,8 @@ static int source_set_pending(sd_event_source *s, bool b) {
         } else
                 assert_se(prioq_remove(s->event->pending, s, &s->pending_index));
 
-        if (EVENT_SOURCE_IS_TIME(s->type)) {
-                struct clock_data *d;
-
-                d = event_get_clock_data(s->event, s->type);
-                assert(d);
-
-                prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
-                prioq_reshuffle(d->latest, s, &s->time.latest_index);
-                d->needs_rearm = true;
-        }
+        if (EVENT_SOURCE_IS_TIME(s->type))
+                event_source_time_prioq_reshuffle(s);
 
         if (s->type == SOURCE_SIGNAL && !b) {
                 struct signal_data *d;
@@ -2207,11 +2226,7 @@ _public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority)
         } else
                 s->priority = priority;
 
-        if (s->pending)
-                prioq_reshuffle(s->event->pending, s, &s->pending_index);
-
-        if (s->prepare)
-                prioq_reshuffle(s->event->prepare, s, &s->prepare_index);
+        event_source_pp_prioq_reshuffle(s);
 
         if (s->type == SOURCE_EXIT)
                 prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
@@ -2237,189 +2252,182 @@ _public_ int sd_event_source_get_enabled(sd_event_source *s, int *m) {
         return s->enabled != SD_EVENT_OFF;
 }
 
-_public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
+static int event_source_disable(sd_event_source *s) {
         int r;
 
-        assert_return(s, -EINVAL);
-        assert_return(IN_SET(m, SD_EVENT_OFF, SD_EVENT_ON, SD_EVENT_ONESHOT), -EINVAL);
-        assert_return(!event_pid_changed(s->event), -ECHILD);
-
-        /* If we are dead anyway, we are fine with turning off
-         * sources, but everything else needs to fail. */
-        if (s->event->state == SD_EVENT_FINISHED)
-                return m == SD_EVENT_OFF ? 0 : -ESTALE;
-
-        if (s->enabled == m)
-                return 0;
+        assert(s);
+        assert(s->enabled != SD_EVENT_OFF);
 
-        if (m == SD_EVENT_OFF) {
+        /* Unset the pending flag when this event source is disabled */
+        if (!IN_SET(s->type, SOURCE_DEFER, SOURCE_EXIT)) {
+                r = source_set_pending(s, false);
+                if (r < 0)
+                        return r;
+        }
 
-                /* Unset the pending flag when this event source is disabled */
-                if (!IN_SET(s->type, SOURCE_DEFER, SOURCE_EXIT)) {
-                        r = source_set_pending(s, false);
-                        if (r < 0)
-                                return r;
-                }
+        s->enabled = SD_EVENT_OFF;
 
-                switch (s->type) {
+        switch (s->type) {
 
-                case SOURCE_IO:
-                        source_io_unregister(s);
-                        s->enabled = m;
-                        break;
+        case SOURCE_IO:
+                source_io_unregister(s);
+                break;
 
-                case SOURCE_TIME_REALTIME:
-                case SOURCE_TIME_BOOTTIME:
-                case SOURCE_TIME_MONOTONIC:
-                case SOURCE_TIME_REALTIME_ALARM:
-                case SOURCE_TIME_BOOTTIME_ALARM: {
-                        struct clock_data *d;
+        case SOURCE_TIME_REALTIME:
+        case SOURCE_TIME_BOOTTIME:
+        case SOURCE_TIME_MONOTONIC:
+        case SOURCE_TIME_REALTIME_ALARM:
+        case SOURCE_TIME_BOOTTIME_ALARM:
+                event_source_time_prioq_reshuffle(s);
+                break;
 
-                        s->enabled = m;
-                        d = event_get_clock_data(s->event, s->type);
-                        assert(d);
+        case SOURCE_SIGNAL:
+                event_gc_signal_data(s->event, &s->priority, s->signal.sig);
+                break;
 
-                        prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
-                        prioq_reshuffle(d->latest, s, &s->time.latest_index);
-                        d->needs_rearm = true;
-                        break;
-                }
+        case SOURCE_CHILD:
+                assert(s->event->n_enabled_child_sources > 0);
+                s->event->n_enabled_child_sources--;
 
-                case SOURCE_SIGNAL:
-                        s->enabled = m;
+                if (EVENT_SOURCE_WATCH_PIDFD(s))
+                        source_child_pidfd_unregister(s);
+                else
+                        event_gc_signal_data(s->event, &s->priority, SIGCHLD);
+                break;
 
-                        event_gc_signal_data(s->event, &s->priority, s->signal.sig);
-                        break;
+        case SOURCE_EXIT:
+                prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
+                break;
 
-                case SOURCE_CHILD:
-                        s->enabled = m;
+        case SOURCE_DEFER:
+        case SOURCE_POST:
+        case SOURCE_INOTIFY:
+                break;
 
-                        assert(s->event->n_enabled_child_sources > 0);
-                        s->event->n_enabled_child_sources--;
+        default:
+                assert_not_reached("Wut? I shouldn't exist.");
+        }
 
-                        if (EVENT_SOURCE_WATCH_PIDFD(s))
-                                source_child_pidfd_unregister(s);
-                        else
-                                event_gc_signal_data(s->event, &s->priority, SIGCHLD);
+        return 0;
+}
 
-                        break;
+static int event_source_enable(sd_event_source *s, int m) {
+        int r;
 
-                case SOURCE_EXIT:
-                        s->enabled = m;
-                        prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
-                        break;
+        assert(s);
+        assert(IN_SET(m, SD_EVENT_ON, SD_EVENT_ONESHOT));
+        assert(s->enabled == SD_EVENT_OFF);
 
-                case SOURCE_DEFER:
-                case SOURCE_POST:
-                case SOURCE_INOTIFY:
-                        s->enabled = m;
-                        break;
+        /* Unset the pending flag when this event source is enabled */
+        if (!IN_SET(s->type, SOURCE_DEFER, SOURCE_EXIT)) {
+                r = source_set_pending(s, false);
+                if (r < 0)
+                        return r;
+        }
 
-                default:
-                        assert_not_reached("Wut? I shouldn't exist.");
-                }
+        s->enabled = m;
 
-        } else {
+        switch (s->type) {
 
-                /* Unset the pending flag when this event source is enabled */
-                if (s->enabled == SD_EVENT_OFF && !IN_SET(s->type, SOURCE_DEFER, SOURCE_EXIT)) {
-                        r = source_set_pending(s, false);
-                        if (r < 0)
-                                return r;
+        case SOURCE_IO:
+                r = source_io_register(s, m, s->io.events);
+                if (r < 0) {
+                        s->enabled = SD_EVENT_OFF;
+                        return r;
                 }
 
-                switch (s->type) {
-
-                case SOURCE_IO:
-                        r = source_io_register(s, m, s->io.events);
-                        if (r < 0)
-                                return r;
+                break;
 
-                        s->enabled = m;
-                        break;
+        case SOURCE_TIME_REALTIME:
+        case SOURCE_TIME_BOOTTIME:
+        case SOURCE_TIME_MONOTONIC:
+        case SOURCE_TIME_REALTIME_ALARM:
+        case SOURCE_TIME_BOOTTIME_ALARM:
+                event_source_time_prioq_reshuffle(s);
+                break;
 
-                case SOURCE_TIME_REALTIME:
-                case SOURCE_TIME_BOOTTIME:
-                case SOURCE_TIME_MONOTONIC:
-                case SOURCE_TIME_REALTIME_ALARM:
-                case SOURCE_TIME_BOOTTIME_ALARM: {
-                        struct clock_data *d;
+        case SOURCE_SIGNAL:
+                r = event_make_signal_data(s->event, s->signal.sig, NULL);
+                if (r < 0) {
+                        s->enabled = SD_EVENT_OFF;
+                        event_gc_signal_data(s->event, &s->priority, s->signal.sig);
+                        return r;
+                }
 
-                        s->enabled = m;
-                        d = event_get_clock_data(s->event, s->type);
-                        assert(d);
+                break;
 
-                        prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
-                        prioq_reshuffle(d->latest, s, &s->time.latest_index);
-                        d->needs_rearm = true;
-                        break;
-                }
+        case SOURCE_CHILD:
+                s->event->n_enabled_child_sources++;
 
-                case SOURCE_SIGNAL:
+                if (EVENT_SOURCE_WATCH_PIDFD(s)) {
+                        /* yes, we have pidfd */
 
-                        s->enabled = m;
+                        r = source_child_pidfd_register(s, s->enabled);
+                        if (r < 0) {
+                                s->enabled = SD_EVENT_OFF;
+                                s->event->n_enabled_child_sources--;
+                                return r;
+                        }
+                } else {
+                        /* no pidfd, or something other to watch for than WEXITED */
 
-                        r = event_make_signal_data(s->event, s->signal.sig, NULL);
+                        r = event_make_signal_data(s->event, SIGCHLD, NULL);
                         if (r < 0) {
                                 s->enabled = SD_EVENT_OFF;
-                                event_gc_signal_data(s->event, &s->priority, s->signal.sig);
+                                s->event->n_enabled_child_sources--;
+                                event_gc_signal_data(s->event, &s->priority, SIGCHLD);
                                 return r;
                         }
+                }
 
-                        break;
+                break;
 
-                case SOURCE_CHILD:
+        case SOURCE_EXIT:
+                prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
+                break;
 
-                        if (s->enabled == SD_EVENT_OFF)
-                                s->event->n_enabled_child_sources++;
+        case SOURCE_DEFER:
+        case SOURCE_POST:
+        case SOURCE_INOTIFY:
+                break;
 
-                        s->enabled = m;
+        default:
+                assert_not_reached("Wut? I shouldn't exist.");
+        }
 
-                        if (EVENT_SOURCE_WATCH_PIDFD(s)) {
-                                /* yes, we have pidfd */
+        return 0;
+}
 
-                                r = source_child_pidfd_register(s, s->enabled);
-                                if (r < 0) {
-                                        s->enabled = SD_EVENT_OFF;
-                                        s->event->n_enabled_child_sources--;
-                                        return r;
-                                }
-                        } else {
-                                /* no pidfd, or something other to watch for than WEXITED */
+_public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
+        int r;
 
-                                r = event_make_signal_data(s->event, SIGCHLD, NULL);
-                                if (r < 0) {
-                                        s->enabled = SD_EVENT_OFF;
-                                        s->event->n_enabled_child_sources--;
-                                        event_gc_signal_data(s->event, &s->priority, SIGCHLD);
-                                        return r;
-                                }
-                        }
+        assert_return(s, -EINVAL);
+        assert_return(IN_SET(m, SD_EVENT_OFF, SD_EVENT_ON, SD_EVENT_ONESHOT), -EINVAL);
+        assert_return(!event_pid_changed(s->event), -ECHILD);
 
-                        break;
+        /* If we are dead anyway, we are fine with turning off sources, but everything else needs to fail. */
+        if (s->event->state == SD_EVENT_FINISHED)
+                return m == SD_EVENT_OFF ? 0 : -ESTALE;
 
-                case SOURCE_EXIT:
-                        s->enabled = m;
-                        prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
-                        break;
+        if (s->enabled == m) /* No change? */
+                return 0;
 
-                case SOURCE_DEFER:
-                case SOURCE_POST:
-                case SOURCE_INOTIFY:
+        if (m == SD_EVENT_OFF)
+                r = event_source_disable(s);
+        else {
+                if (s->enabled != SD_EVENT_OFF) {
+                        /* Switching from "on" to "oneshot" or back? If that's the case, we can take a shortcut, the
+                         * event source is already enabled after all. */
                         s->enabled = m;
-                        break;
-
-                default:
-                        assert_not_reached("Wut? I shouldn't exist.");
+                        return 0;
                 }
-        }
-
-        if (s->pending)
-                prioq_reshuffle(s->event->pending, s, &s->pending_index);
 
-        if (s->prepare)
-                prioq_reshuffle(s->event->prepare, s, &s->prepare_index);
+                r = event_source_enable(s, m);
+        }
+        if (r < 0)
+                return r;
 
+        event_source_pp_prioq_reshuffle(s);
         return 0;
 }
 
@@ -2434,7 +2442,6 @@ _public_ int sd_event_source_get_time(sd_event_source *s, uint64_t *usec) {
 }
 
 _public_ int sd_event_source_set_time(sd_event_source *s, uint64_t usec) {
-        struct clock_data *d;
         int r;
 
         assert_return(s, -EINVAL);
@@ -2448,13 +2455,7 @@ _public_ int sd_event_source_set_time(sd_event_source *s, uint64_t usec) {
 
         s->time.next = usec;
 
-        d = event_get_clock_data(s->event, s->type);
-        assert(d);
-
-        prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
-        prioq_reshuffle(d->latest, s, &s->time.latest_index);
-        d->needs_rearm = true;
-
+        event_source_time_prioq_reshuffle(s);
         return 0;
 }
 
@@ -2486,7 +2487,6 @@ _public_ int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *use
 }
 
 _public_ int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec) {
-        struct clock_data *d;
         int r;
 
         assert_return(s, -EINVAL);
@@ -2504,12 +2504,7 @@ _public_ int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec
 
         s->time.accuracy = usec;
 
-        d = event_get_clock_data(s->event, s->type);
-        assert(d);
-
-        prioq_reshuffle(d->latest, s, &s->time.latest_index);
-        d->needs_rearm = true;
-
+        event_source_time_prioq_reshuffle(s);
         return 0;
 }
 
@@ -2888,9 +2883,7 @@ static int process_timer(
                 if (r < 0)
                         return r;
 
-                prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
-                prioq_reshuffle(d->latest, s, &s->time.latest_index);
-                d->needs_rearm = true;
+                event_source_time_prioq_reshuffle(s);
         }
 
         return 0;
index 61113113e4bc98a682ec6bd3e013f271410eb574..e2c06f037763b3999f7bd895071de40ba77d9f30 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #pragma once
 
 typedef struct Wireguard Wireguard;
index 25b9396397752b4c35eb40fd1e0e9126933874a7..7743c63d4a7b51127dd091f860cf0652f4d807dc 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include "bond.h"
 #include "dhcp6-internal.h"
 #include "dhcp6-protocol.h"
index 683f11375159998ac7924b549dfa08c54fa712ed..2c243811718e1319b2482ac4092754ff3fa7d3e4 100644 (file)
@@ -436,20 +436,22 @@ static int dns_cache_put_positive(
 
         dns_cache_make_space(c, 1);
 
-        i = new0(DnsCacheItem, 1);
+        i = new(DnsCacheItem, 1);
         if (!i)
                 return -ENOMEM;
 
-        i->type = DNS_CACHE_POSITIVE;
-        i->key = dns_resource_key_ref(rr->key);
-        i->rr = dns_resource_record_ref(rr);
-        i->until = calculate_until(rr, (uint32_t) -1, timestamp, false);
-        i->authenticated = authenticated;
-        i->shared_owner = shared_owner;
-        i->ifindex = ifindex;
-        i->owner_family = owner_family;
-        i->owner_address = *owner_address;
-        i->prioq_idx = PRIOQ_IDX_NULL;
+        *i = (DnsCacheItem) {
+                .type = DNS_CACHE_POSITIVE,
+                .key = dns_resource_key_ref(rr->key),
+                .rr = dns_resource_record_ref(rr),
+                .until = calculate_until(rr, (uint32_t) -1, timestamp, false),
+                .authenticated = authenticated,
+                .shared_owner = shared_owner,
+                .ifindex = ifindex,
+                .owner_family = owner_family,
+                .owner_address = *owner_address,
+                .prioq_idx = PRIOQ_IDX_NULL,
+        };
 
         r = dns_cache_link_item(c, i);
         if (r < 0)
@@ -521,21 +523,23 @@ static int dns_cache_put_negative(
 
         dns_cache_make_space(c, 1);
 
-        i = new0(DnsCacheItem, 1);
+        i = new(DnsCacheItem, 1);
         if (!i)
                 return -ENOMEM;
 
-        i->type =
-                rcode == DNS_RCODE_SUCCESS ? DNS_CACHE_NODATA :
-                rcode == DNS_RCODE_NXDOMAIN ? DNS_CACHE_NXDOMAIN : DNS_CACHE_RCODE;
-        i->until =
-                i->type == DNS_CACHE_RCODE ? timestamp + CACHE_TTL_STRANGE_RCODE_USEC :
-                calculate_until(soa, nsec_ttl, timestamp, true);
-        i->authenticated = authenticated;
-        i->owner_family = owner_family;
-        i->owner_address = *owner_address;
-        i->prioq_idx = PRIOQ_IDX_NULL;
-        i->rcode = rcode;
+        *i = (DnsCacheItem) {
+                .type =
+                        rcode == DNS_RCODE_SUCCESS ? DNS_CACHE_NODATA :
+                        rcode == DNS_RCODE_NXDOMAIN ? DNS_CACHE_NXDOMAIN : DNS_CACHE_RCODE,
+                .until =
+                        i->type == DNS_CACHE_RCODE ? timestamp + CACHE_TTL_STRANGE_RCODE_USEC :
+                        calculate_until(soa, nsec_ttl, timestamp, true),
+                .authenticated = authenticated,
+                .owner_family = owner_family,
+                .owner_address = *owner_address,
+                .prioq_idx = PRIOQ_IDX_NULL,
+                .rcode = rcode,
+        };
 
         if (i->type == DNS_CACHE_NXDOMAIN) {
                 /* NXDOMAIN entries should apply equally to all types, so we use ANY as
index 62240399925709b174aad3780c9e9bcdb4127ef2..05fa88ec892cb5e7039fe1bda92f64b6f1bc5602 100644 (file)
@@ -75,12 +75,16 @@ int dns_packet_new(
         if (!p)
                 return -ENOMEM;
 
-        p->size = p->rindex = DNS_PACKET_HEADER_SIZE;
-        p->allocated = a;
-        p->max_size = max_size;
-        p->protocol = protocol;
-        p->opt_start = p->opt_size = (size_t) -1;
-        p->n_ref = 1;
+        *p = (DnsPacket) {
+                .n_ref = 1,
+                .protocol = protocol,
+                .size = DNS_PACKET_HEADER_SIZE,
+                .rindex = DNS_PACKET_HEADER_SIZE,
+                .allocated = a,
+                .max_size = max_size,
+                .opt_start = (size_t) -1,
+                .opt_size = (size_t) -1,
+        };
 
         *ret = p;
 
index 1eff893b21de6126bf824ac50f95b5772640fe88..ef54c04ab0cc85b223606cf9ed4cfbfd1f60967e 100644 (file)
@@ -21,12 +21,14 @@ static int dns_query_candidate_new(DnsQueryCandidate **ret, DnsQuery *q, DnsScop
         assert(q);
         assert(s);
 
-        c = new0(DnsQueryCandidate, 1);
+        c = new(DnsQueryCandidate, 1);
         if (!c)
                 return -ENOMEM;
 
-        c->query = q;
-        c->scope = s;
+        *c = (DnsQueryCandidate) {
+                .query = q,
+                .scope = s,
+        };
 
         LIST_PREPEND(candidates_by_query, q->candidates, c);
         LIST_PREPEND(candidates_by_scope, s->query_candidates, c);
@@ -413,17 +415,19 @@ int dns_query_new(
         if (m->n_dns_queries >= QUERIES_MAX)
                 return -EBUSY;
 
-        q = new0(DnsQuery, 1);
+        q = new(DnsQuery, 1);
         if (!q)
                 return -ENOMEM;
 
-        q->question_utf8 = dns_question_ref(question_utf8);
-        q->question_idna = dns_question_ref(question_idna);
-        q->ifindex = ifindex;
-        q->flags = flags;
-        q->answer_dnssec_result = _DNSSEC_RESULT_INVALID;
-        q->answer_protocol = _DNS_PROTOCOL_INVALID;
-        q->answer_family = AF_UNSPEC;
+        *q = (DnsQuery) {
+                .question_utf8 = dns_question_ref(question_utf8),
+                .question_idna = dns_question_ref(question_idna),
+                .ifindex = ifindex,
+                .flags = flags,
+                .answer_dnssec_result = _DNSSEC_RESULT_INVALID,
+                .answer_protocol = _DNS_PROTOCOL_INVALID,
+                .answer_family = AF_UNSPEC,
+        };
 
         /* First dump UTF8  question */
         DNS_QUESTION_FOREACH(key, question_utf8)
index 63ed9ebf10cdabf4de72daabb6f210ed602637b7..9ca7ad96fd2fa1380c58873d673d6b6bb80481a4 100644 (file)
@@ -97,14 +97,16 @@ DnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char
 
         assert(name);
 
-        k = new0(DnsResourceKey, 1);
+        k = new(DnsResourceKey, 1);
         if (!k)
                 return NULL;
 
-        k->n_ref = 1;
-        k->class = class;
-        k->type = type;
-        k->_name = name;
+        *k = (DnsResourceKey) {
+                .n_ref = 1,
+                .class = class,
+                .type = type,
+                ._name = name,
+        };
 
         return k;
 }
@@ -372,14 +374,17 @@ bool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b) {
 DnsResourceRecord* dns_resource_record_new(DnsResourceKey *key) {
         DnsResourceRecord *rr;
 
-        rr = new0(DnsResourceRecord, 1);
+        rr = new(DnsResourceRecord, 1);
         if (!rr)
                 return NULL;
 
-        rr->n_ref = 1;
-        rr->key = dns_resource_key_ref(key);
-        rr->expiry = USEC_INFINITY;
-        rr->n_skip_labels_signer = rr->n_skip_labels_source = (unsigned) -1;
+        *rr = (DnsResourceRecord) {
+                .n_ref = 1,
+                .key = dns_resource_key_ref(key),
+                .expiry = USEC_INFINITY,
+                .n_skip_labels_signer = (unsigned) -1,
+                .n_skip_labels_source = (unsigned) -1,
+        };
 
         return rr;
 }
index 425a46334948c7531cc37877c69f06c52fe7135a..420c9298144013eb16276b9b7794cfaf2a38fcc2 100644 (file)
@@ -33,14 +33,16 @@ int dns_search_domain_new(
                         return -E2BIG;
         }
 
-        d = new0(DnsSearchDomain, 1);
+        d = new(DnsSearchDomain, 1);
         if (!d)
                 return -ENOMEM;
 
-        d->n_ref = 1;
-        d->manager = m;
-        d->type = type;
-        d->name = TAKE_PTR(normalized);
+        *d = (DnsSearchDomain) {
+                .n_ref = 1,
+                .manager = m,
+                .type = type,
+                .name = TAKE_PTR(normalized),
+        };
 
         switch (type) {
 
index 445fa86dd1fca6e060438f7ba6f4e82eccfedab3..6fdd26399ee221e02dfb60d23323d3099ac12518 100644 (file)
@@ -15,6 +15,9 @@
  * IP and UDP header sizes */
 #define ADVERTISE_DATAGRAM_SIZE_MAX (65536U-14U-20U-8U)
 
+/* On the extra stubs, use a more conservative choice */
+#define ADVERTISE_EXTRA_DATAGRAM_SIZE_MAX DNS_PACKET_UNICAST_SIZE_LARGE_MAX
+
 static int manager_dns_stub_fd_extra(Manager *m, DnsStubListenerExtra *l, int type);
 
 static void dns_stub_listener_extra_hash_func(const DnsStubListenerExtra *a, struct siphash *state) {
@@ -155,14 +158,15 @@ static int dns_stub_finish_reply_packet(
                 bool tc,        /* set the Truncated bit? */
                 bool add_opt,   /* add an OPT RR to this packet? */
                 bool edns0_do,  /* set the EDNS0 DNSSEC OK bit? */
-                bool ad) {      /* set the DNSSEC authenticated data bit? */
+                bool ad,        /* set the DNSSEC authenticated data bit? */
+                uint16_t max_udp_size) { /* The maximum UDP datagram size to advertise to clients */
 
         int r;
 
         assert(p);
 
         if (add_opt) {
-                r = dns_packet_append_opt(p, ADVERTISE_DATAGRAM_SIZE_MAX, edns0_do, /* include_rfc6975 = */ false, rcode, NULL);
+                r = dns_packet_append_opt(p, max_udp_size, edns0_do, /* include_rfc6975 = */ false, rcode, NULL);
                 if (r == -EMSGSIZE) /* Hit the size limit? then indicate truncation */
                         tc = true;
                 else if (r < 0)
@@ -245,7 +249,15 @@ static int dns_stub_send_failure(
         if (r < 0)
                 return log_debug_errno(r, "Failed to make failure packet: %m");
 
-        r = dns_stub_finish_reply_packet(reply, DNS_PACKET_ID(p), rcode, false, !!p->opt, DNS_PACKET_DO(p), authenticated);
+        r = dns_stub_finish_reply_packet(
+                        reply,
+                        DNS_PACKET_ID(p),
+                        rcode,
+                        /* truncated = */ false,
+                        !!p->opt,
+                        DNS_PACKET_DO(p),
+                        authenticated,
+                        l ? ADVERTISE_EXTRA_DATAGRAM_SIZE_MAX : ADVERTISE_DATAGRAM_SIZE_MAX);
         if (r < 0)
                 return log_debug_errno(r, "Failed to build failure packet: %m");
 
@@ -290,7 +302,8 @@ static void dns_stub_query_complete(DnsQuery *q) {
                                 truncated,
                                 !!q->request_dns_packet->opt,
                                 DNS_PACKET_DO(q->request_dns_packet),
-                                dns_query_fully_authenticated(q));
+                                dns_query_fully_authenticated(q),
+                                q->stub_listener_extra ? ADVERTISE_EXTRA_DATAGRAM_SIZE_MAX : ADVERTISE_DATAGRAM_SIZE_MAX);
                 if (r < 0) {
                         log_debug_errno(r, "Failed to finish reply packet: %m");
                         break;
index 36f57eae629e27a02188000d02a2cdcca0148ce1..15f349d623ecb13de5e4d3bec76ec8d5882e0e00 100644 (file)
@@ -194,19 +194,20 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key)
         if (r < 0)
                 return r;
 
-        t = new0(DnsTransaction, 1);
+        t = new(DnsTransaction, 1);
         if (!t)
                 return -ENOMEM;
 
-        t->dns_udp_fd = -1;
-        t->answer_source = _DNS_TRANSACTION_SOURCE_INVALID;
-        t->answer_dnssec_result = _DNSSEC_RESULT_INVALID;
-        t->answer_nsec_ttl = (uint32_t) -1;
-        t->key = dns_resource_key_ref(key);
-        t->current_feature_level = _DNS_SERVER_FEATURE_LEVEL_INVALID;
-        t->clamp_feature_level = _DNS_SERVER_FEATURE_LEVEL_INVALID;
-
-        t->id = pick_new_id(s->manager);
+        *t = (DnsTransaction) {
+                .dns_udp_fd = -1,
+                .answer_source = _DNS_TRANSACTION_SOURCE_INVALID,
+                .answer_dnssec_result = _DNSSEC_RESULT_INVALID,
+                .answer_nsec_ttl = (uint32_t) -1,
+                .key = dns_resource_key_ref(key),
+                .current_feature_level = _DNS_SERVER_FEATURE_LEVEL_INVALID,
+                .clamp_feature_level = _DNS_SERVER_FEATURE_LEVEL_INVALID,
+                .id = pick_new_id(s->manager),
+        };
 
         r = hashmap_put(s->manager->dns_transactions, UINT_TO_PTR(t->id), t);
         if (r < 0) {
@@ -1112,58 +1113,52 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
         if (r > 0) /* Transaction got restarted... */
                 return;
 
-        if (IN_SET(t->scope->protocol, DNS_PROTOCOL_DNS, DNS_PROTOCOL_LLMNR, DNS_PROTOCOL_MDNS)) {
-
-                /* When dealing with protocols other than mDNS only consider responses with
-                 * equivalent query section to the request. For mDNS this check doesn't make
-                 * sense, because the section 6 of RFC6762 states that "Multicast DNS responses MUST NOT
-                 * contain any questions in the Question Section". */
-                if (t->scope->protocol != DNS_PROTOCOL_MDNS) {
-                        r = dns_packet_is_reply_for(p, t->key);
-                        if (r < 0)
-                                goto fail;
-                        if (r == 0) {
-                                dns_transaction_complete(t, DNS_TRANSACTION_INVALID_REPLY);
-                                return;
-                        }
+        /* When dealing with protocols other than mDNS only consider responses with equivalent query section
+         * to the request. For mDNS this check doesn't make sense, because the section 6 of RFC6762 states
+         * that "Multicast DNS responses MUST NOT contain any questions in the Question Section". */
+        if (t->scope->protocol != DNS_PROTOCOL_MDNS) {
+                r = dns_packet_is_reply_for(p, t->key);
+                if (r < 0)
+                        goto fail;
+                if (r == 0) {
+                        dns_transaction_complete(t, DNS_TRANSACTION_INVALID_REPLY);
+                        return;
                 }
+        }
 
-                /* Install the answer as answer to the transaction */
-                dns_answer_unref(t->answer);
-                t->answer = dns_answer_ref(p->answer);
-                t->answer_rcode = DNS_PACKET_RCODE(p);
-                t->answer_dnssec_result = _DNSSEC_RESULT_INVALID;
-                t->answer_authenticated = false;
+        /* Install the answer as answer to the transaction */
+        dns_answer_unref(t->answer);
+        t->answer = dns_answer_ref(p->answer);
+        t->answer_rcode = DNS_PACKET_RCODE(p);
+        t->answer_dnssec_result = _DNSSEC_RESULT_INVALID;
+        t->answer_authenticated = false;
 
-                r = dns_transaction_fix_rcode(t);
-                if (r < 0)
-                        goto fail;
+        r = dns_transaction_fix_rcode(t);
+        if (r < 0)
+                goto fail;
 
-                /* Block GC while starting requests for additional DNSSEC RRs */
-                t->block_gc++;
-                r = dns_transaction_request_dnssec_keys(t);
-                t->block_gc--;
+        /* Block GC while starting requests for additional DNSSEC RRs */
+        t->block_gc++;
+        r = dns_transaction_request_dnssec_keys(t);
+        t->block_gc--;
 
-                /* Maybe the transaction is ready for GC'ing now? If so, free it and return. */
-                if (!dns_transaction_gc(t))
-                        return;
+        /* Maybe the transaction is ready for GC'ing now? If so, free it and return. */
+        if (!dns_transaction_gc(t))
+                return;
 
-                /* Requesting additional keys might have resulted in
-                 * this transaction to fail, since the auxiliary
-                 * request failed for some reason. If so, we are not
-                 * in pending state anymore, and we should exit
-                 * quickly. */
-                if (t->state != DNS_TRANSACTION_PENDING)
-                        return;
-                if (r < 0)
-                        goto fail;
-                if (r > 0) {
-                        /* There are DNSSEC transactions pending now. Update the state accordingly. */
-                        t->state = DNS_TRANSACTION_VALIDATING;
-                        dns_transaction_close_connection(t);
-                        dns_transaction_stop_timeout(t);
-                        return;
-                }
+        /* Requesting additional keys might have resulted in this transaction to fail, since the auxiliary
+         * request failed for some reason. If so, we are not in pending state anymore, and we should exit
+         * quickly. */
+        if (t->state != DNS_TRANSACTION_PENDING)
+                return;
+        if (r < 0)
+                goto fail;
+        if (r > 0) {
+                /* There are DNSSEC transactions pending now. Update the state accordingly. */
+                t->state = DNS_TRANSACTION_VALIDATING;
+                dns_transaction_close_connection(t);
+                dns_transaction_stop_timeout(t);
+                return;
         }
 
         dns_transaction_process_dnssec(t);
index f8e1491f8be603364ec5bebbeab19ef42ccf1581..44554d8cdb6522dc90e7d6c9ff655000ec84a5b3 100644 (file)
@@ -231,13 +231,15 @@ int dns_zone_put(DnsZone *z, DnsScope *s, DnsResourceRecord *rr, bool probe) {
         if (r < 0)
                 return r;
 
-        i = new0(DnsZoneItem, 1);
+        i = new(DnsZoneItem, 1);
         if (!i)
                 return -ENOMEM;
 
-        i->scope = s;
-        i->rr = dns_resource_record_ref(rr);
-        i->probing_enabled = probe;
+        *i = (DnsZoneItem) {
+                .scope = s,
+                .rr = dns_resource_record_ref(rr),
+                .probing_enabled = probe,
+        };
 
         r = dns_zone_link_item(z, i);
         if (r < 0)
index 403455e89f4439d81cbe999eea2215ee7c9c9ecd..e51c9ac1457619987e4da749b8706615b59498d6 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #pragma once
 
 #include "sd-bus.h"
index 304bd890c95f007bf0980e9734c695ca945b6318..faba11ca53c7e743ac486005bee3e6592f1e41ad 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #pragma once
 
 #include "list.h"
index 6a7f7499572cfc9592e64ab7233468960e9654ee..4a748d4b64d364fcb3d7c91ee084522ad9ff46b1 100644 (file)
@@ -80,11 +80,13 @@ static int parse_line(EtcHosts *hosts, unsigned nr, const char *line) {
                         if (r < 0)
                                 return log_oom();
 
-                        item = new0(EtcHostsItem, 1);
+                        item = new(EtcHostsItem, 1);
                         if (!item)
                                 return log_oom();
 
-                        item->address = address;
+                        *item = (EtcHostsItem) {
+                                .address = address,
+                        };
 
                         r = hashmap_put(hosts->by_address, &item->address, item);
                         if (r < 0) {
index 79d84dde1fa55ba0decdaa52069d14f972a06a89..6215d2bf464ab279f1b70b48534c8b40d2bb33f8 100644 (file)
@@ -818,14 +818,16 @@ int link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr
         assert(l);
         assert(in_addr);
 
-        a = new0(LinkAddress, 1);
+        a = new(LinkAddress, 1);
         if (!a)
                 return -ENOMEM;
 
-        a->family = family;
-        a->in_addr = *in_addr;
+        *a = (LinkAddress) {
+                .family = family,
+                .in_addr = *in_addr,
+                .link = l,
+        };
 
-        a->link = l;
         LIST_PREPEND(addresses, l->addresses, a);
         l->n_addresses++;
 
index 0229726b42d59abd8f381dc5809c3a20e87460fb..c673c0435d80b8dc1a847db3b8654528084bbcde 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <sys/stat.h>
 #include <sys/statvfs.h>
 #include <sys/vfs.h>
index 7efcb6b2aae432599a511819eb5f90ee743a15b5..cfb13bad4c9d474224f73a2929df71bc476449c2 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <fcntl.h>
 #include <linux/dm-ioctl.h>
 #include <sys/ioctl.h>
index 1d7ff81df1f2131c6929016249fd75a50939b3d5..1bf5b8edd7f04445802614223e402ef96e7cfd6c 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2+ */
 /*
  * initreq.h   Interface to talk to init through /dev/initctl.
  *
index b065c1fe4df5d5d71da9c204e97c0c5bc142c57b..65edfff1ca4bda0112d7e3e7755242e2369ed8fa 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: MIT */
+
 #ifndef __LINUX_NL80211_H
 #define __LINUX_NL80211_H
 /*
index 0ed216f1aaa2358cd0008d1a3627771daef961c3..260ee5a8b633e0912d0c8ccaf047c96affe4cbbd 100644 (file)
@@ -195,6 +195,8 @@ shared_sources = files('''
         ptyfwd.h
         pwquality-util.c
         pwquality-util.h
+        qrcode-util.c
+        qrcode-util.h
         reboot-util.c
         reboot-util.h
         resize-fs.c
@@ -304,13 +306,6 @@ if conf.get('HAVE_PAM') == 1
 '''.split())
 endif
 
-if conf.get('HAVE_QRENCODE') == 1
-        shared_sources += files('''
-        qrcode-util.c
-        qrcode-util.h
-'''.split())
-endif
-
 generate_ip_protocol_list = find_program('generate-ip-protocol-list.sh')
 ip_protocol_list_txt = custom_target(
         'ip-protocol-list.txt',
index f000798ce0683825b8dc2dad25d753e9f1f9d416..ff44df7762dbb0ef9e08228207c7fd8f7431710a 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include <security/pam_ext.h>
 #include <syslog.h>
 #include <stdlib.h>
index a3629175239e26744ab811570d149dfd7c1512f4..13cb1d8a15c64a8c2093aa0d5cd58f5769e9ee2b 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #pragma once
 
 #include <inttypes.h>
index a545daaef3fe4af8eead1002515532da6a3f4e6e..96d3df493ab53291b1dce5fe2043c4bee71ae5e0 100644 (file)
@@ -1,25 +1,29 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include "qrcode-util.h"
+
+#if HAVE_QRENCODE
+#include <qrencode.h>
+
+#include "dlfcn-util.h"
+#include "locale-util.h"
 #include "terminal-util.h"
 
 #define ANSI_WHITE_ON_BLACK "\033[40;37;1m"
 
 static void print_border(FILE *output, unsigned width) {
-        unsigned x, y;
-
         /* Four rows of border */
-        for (y = 0; y < 4; y += 2) {
+        for (unsigned y = 0; y < 4; y += 2) {
                 fputs(ANSI_WHITE_ON_BLACK, output);
 
-                for (x = 0; x < 4 + width + 4; x++)
+                for (unsigned x = 0; x < 4 + width + 4; x++)
                         fputs("\342\226\210", output);
 
                 fputs(ANSI_NORMAL "\n", output);
         }
 }
 
-void write_qrcode(FILE *output, QRcode *qr) {
-        unsigned x, y;
-
+static void write_qrcode(FILE *output, QRcode *qr) {
         assert(qr);
 
         if (!output)
@@ -27,17 +31,15 @@ void write_qrcode(FILE *output, QRcode *qr) {
 
         print_border(output, qr->width);
 
-        for (y = 0; y < (unsigned) qr->width; y += 2) {
-                const uint8_t *row1, *row2;
-
-                row1 = qr->data + qr->width * y;
-                row2 = row1 + qr->width;
+        for (unsigned y = 0; y < (unsigned) qr->width; y += 2) {
+                const uint8_t *row1 = qr->data + qr->width * y;
+                const uint8_t *row2 = row1 + qr->width;
 
                 fputs(ANSI_WHITE_ON_BLACK, output);
-                for (x = 0; x < 4; x++)
+                for (unsigned x = 0; x < 4; x++)
                         fputs("\342\226\210", output);
 
-                for (x = 0; x < (unsigned) qr->width; x ++) {
+                for (unsigned x = 0; x < (unsigned) qr->width; x++) {
                         bool a, b;
 
                         a = row1[x] & 1;
@@ -53,7 +55,7 @@ void write_qrcode(FILE *output, QRcode *qr) {
                                 fputs("\342\226\210", output);
                 }
 
-                for (x = 0; x < 4; x++)
+                for (unsigned x = 0; x < 4; x++)
                         fputs("\342\226\210", output);
                 fputs(ANSI_NORMAL "\n", output);
         }
@@ -61,3 +63,45 @@ void write_qrcode(FILE *output, QRcode *qr) {
         print_border(output, qr->width);
         fflush(output);
 }
+
+int print_qrcode(FILE *out, const char *header, const char *string) {
+        QRcode* (*sym_QRcode_encodeString)(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
+        void (*sym_QRcode_free)(QRcode *qrcode);
+        _cleanup_(dlclosep) void *dl = NULL;
+        QRcode* qr;
+        int r;
+
+        /* If this is not an UTF-8 system or ANSI colors aren't supported/disabled don't print any QR
+         * codes */
+        if (!is_locale_utf8() || !colors_enabled())
+                return -EOPNOTSUPP;
+
+        dl = dlopen("libqrencode.so.4", RTLD_LAZY);
+        if (!dl)
+                return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
+                                       "QRCODE support is not installed: %s", dlerror());
+
+        r = dlsym_many_and_warn(
+                        dl,
+                        LOG_DEBUG,
+                        &sym_QRcode_encodeString, "QRcode_encodeString",
+                        &sym_QRcode_free, "QRcode_free",
+                        NULL);
+        if (r < 0)
+                return r;
+
+        qr = sym_QRcode_encodeString(string, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
+        if (!qr)
+                return -ENOMEM;
+
+        if (header)
+                fprintf(out, "\n%s:\n\n", header);
+
+        write_qrcode(out, qr);
+
+        fputc('\n', out);
+
+        sym_QRcode_free(qr);
+        return 0;
+}
+#endif
index 9a21ffd7fe654b0355d73082b89a630795d3219b..036c3f7f90d959aba492c29c78d64c08f583be8a 100644 (file)
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-#pragma once
 
-#if HAVE_QRENCODE
-#include <qrencode.h>
+#pragma once
 #include <stdio.h>
+#include <errno.h>
 
-void write_qrcode(FILE *output, QRcode *qr);
+#if HAVE_QRENCODE
+int print_qrcode(FILE *out, const char *header, const char *string);
+#else
+static inline int print_qrcode(FILE *out, const char *header, const char *string) {
+        return -EOPNOTSUPP;
+}
 #endif
index daf62eb539a481d63374dcdc0e3a61fe41572005..e4ce8ac51aeec203b7807c928bf57abedfde6f88 100644 (file)
@@ -819,6 +819,10 @@ tests += [
         [['src/test/test-psi-util.c'],
          [],
          []],
+
+        [['src/test/test-qrcode-util.c'],
+         [libshared],
+         [libdl]],
 ]
 
 ############################################################
diff --git a/src/test/test-qrcode-util.c b/src/test/test-qrcode-util.c
new file mode 100644 (file)
index 0000000..c4e2894
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include "locale-util.h"
+#include "main-func.h"
+#include "qrcode-util.h"
+#include "tests.h"
+
+static int run(int argc, char **argv) {
+        int r;
+
+        test_setup_logging(LOG_DEBUG);
+
+        assert_se(setenv("SYSTEMD_COLORS", "1", 1) == 0); /* Force the qrcode to be printed */
+
+        r = print_qrcode(stdout, "This should say \"TEST\"", "TEST");
+        if (r == -EOPNOTSUPP)
+                return log_tests_skipped("not supported");
+        if (r < 0)
+                return log_error_errno(r, "Failed to print QR code: %m");
+        return 0;
+}
+
+DEFINE_MAIN_FUNCTION(run);
index eb34d8eab2d83cfaf286b5e7e25abedcd03085bd..8746a841d432abb6a1b625bb216551ace4ee0cf3 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
 #include "sd-hwdb.h"
 
 #include "alloc-util.h"
index 96072445f6efe4b9eac9250cf6a3d94e4dc52e47..02053e77087c2cc3c196728103f05f53cd8822c4 100644 (file)
@@ -1,11 +1,5 @@
-/*
- * systemd service to wait until kernel realtime clock is synchronized
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
+/* SPDX-License-Identifier: LGPL-2.1+ */
+/* systemd service to wait until kernel realtime clock is synchronized */
 
 #include <errno.h>
 #include <stdbool.h>
diff --git a/units/initrd-cryptsetup.target b/units/initrd-cryptsetup.target
deleted file mode 100644 (file)
index 2a2938c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#  SPDX-License-Identifier: LGPL-2.1+
-#
-#  This file is part of systemd.
-#
-#  systemd is free software; you can redistribute it and/or modify it
-#  under the terms of the GNU Lesser General Public License as published by
-#  the Free Software Foundation; either version 2.1 of the License, or
-#  (at your option) any later version.
-
-[Unit]
-Description=Initrd Encrypted Volumes
-Documentation=man:systemd.special(7)
-OnFailure=emergency.target
-OnFailureJobMode=replace-irreversibly
-AssertPathExists=/etc/initrd-release
-DefaultDependencies=no
-Conflicts=shutdown.target
index a55e71786888525566770968b58e8c2688e3c4c2..2f09590736e69c25c5d9178726b47feca7c8620d 100644 (file)
@@ -22,14 +22,12 @@ units = [
          'multi-user.target.wants/'],
         ['getty-pre.target',                    ''],
         ['graphical.target',                    '',
-         (with_runlevels ? 'runlevel5.target default.target' : 'default.target')],
+         'default.target' + (with_runlevels ? ' runlevel5.target' : '')],
         ['halt.target',                         ''],
         ['hibernate.target',                    'ENABLE_HIBERNATE'],
         ['hybrid-sleep.target',                 'ENABLE_HIBERNATE'],
         ['suspend-then-hibernate.target',       'ENABLE_HIBERNATE'],
         ['initrd-cleanup.service',              'ENABLE_INITRD'],
-        ['initrd-cryptsetup.target',            'HAVE_LIBCRYPTSETUP ENABLE_INITRD',
-         'sysinit.target.wants/'],
         ['initrd-fs.target',                    'ENABLE_INITRD'],
         ['initrd-parse-etc.service',            'ENABLE_INITRD'],
         ['initrd-root-device.target',           'ENABLE_INITRD'],
@@ -61,8 +59,9 @@ units = [
          'sysinit.target.wants/'],
         ['proc-sys-fs-binfmt_misc.mount',       'ENABLE_BINFMT'],
         ['reboot.target',                       '',
-         (with_runlevels ? 'runlevel6.target ctrl-alt-del.target' : 'ctrl-alt-del.target')],
-        ['remote-cryptsetup.target',            'HAVE_LIBCRYPTSETUP'],
+         'ctrl-alt-del.target' + (with_runlevels ? ' runlevel6.target' : '')],
+        ['remote-cryptsetup.target',            'HAVE_LIBCRYPTSETUP',
+         'initrd-root-device.target.wants/'],
         ['remote-fs-pre.target',                ''],
         ['remote-fs.target',                    ''],
         ['rescue.target',                       '',