diff --git a/.kres.yaml b/.kres.yaml index 1a24c2a67..80e56a0fe 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -10,7 +10,6 @@ spec: - containerd - cryptsetup - dosfstools - - eudev - fhs - flannel-cni - grub @@ -37,6 +36,7 @@ spec: - sd-boot - socat - syslinux + - systemd-udevd - util-linux - xfsprogs # - kernel & dependent packages (out of tree kernel modules) diff --git a/Makefile b/Makefile index 927a9f1dd..8e4adeea9 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,6 @@ TARGETS += cni TARGETS += containerd TARGETS += cryptsetup TARGETS += dosfstools -TARGETS += eudev TARGETS += fhs TARGETS += flannel-cni TARGETS += grub @@ -79,6 +78,7 @@ TARGETS += runc TARGETS += sd-boot TARGETS += socat TARGETS += syslinux +TARGETS += systemd-udevd TARGETS += util-linux TARGETS += xfsprogs TARGETS += kernel diff --git a/Pkgfile b/Pkgfile index e8b7e7f79..7721571a1 100644 --- a/Pkgfile +++ b/Pkgfile @@ -31,10 +31,10 @@ vars: drbd_sha256: 016127238d5e0585130ec9558d991347e5360fb3c075283c62ea67f661bcd66b drbd_sha512: 437e50d588b37aece7583eed06236c82931a41ab69f6835853fbeaf05125e4d5e0d1a81f501971e6773f86703d71d604ee3e1f0634faa9a03c3379d8297ed1cc - # renovate: datasource=github-releases depName=eudev-project/eudev - eudev_version: v3.2.14 - eudev_sha256: c340e6c51dfc5531ac0c0fa84a34b72162acf525f9023eb9cf4931b782c8f177 - eudev_sha512: b2d5e0d13e30c83cd15a12ada868242354691bb51eda365ace14b1b1a3942c2d0c9db7ba4ed89a3d4c87572f1f29d10d887fe45a8d257a88cba88270e75b3baf + # renovate: datasource=github-releases extractVersion=^v(?.*)$ depName=systemd/systemd + systemd_version: 256.6 + systemd_sha256: c085f162dec001407dd32f00abbf20b7e6ed7043dcfaf8ed954787d86707f409 + systemd_sha512: 99d0fad02cab3559e081dabc2797d1d66bbc21daf9aaec847aeb6bce289456ff9c8599a34563c9bfa3826db36ae9ab30836b09bae00bf1a410b54d0bad9bd4dc # renovate: datasource=github-releases depName=flannel-io/cni-plugin flannel_cni_version: v1.5.1-flannel2 diff --git a/cryptsetup/pkg.yaml b/cryptsetup/pkg.yaml index 276703636..1a679fd4d 100644 --- a/cryptsetup/pkg.yaml +++ b/cryptsetup/pkg.yaml @@ -3,7 +3,8 @@ variant: scratch shell: /toolchain/bin/bash dependencies: - stage: base - - stage: eudev # dependency for libdevmapper + - stage: systemd-udevd # dependency for libdevmapper + - stage: libcap # dependency for libudev - stage: lvm2 # libdevmapper - stage: util-linux # libuuid - stage: libpopt @@ -17,6 +18,7 @@ steps: sha512: "{{ .cryptsetup_sha512 }}" env: PKG_CONFIG_PATH: /usr/lib/pkgconfig + LIBS: -lcap prepare: - | tar -xzf cryptsetup.tar.gz --strip-components=1 diff --git a/eudev/pkg.yaml b/eudev/pkg.yaml deleted file mode 100644 index 8ab9fb118..000000000 --- a/eudev/pkg.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: eudev -variant: scratch -shell: /toolchain/bin/bash -dependencies: - - stage: base - - stage: util-linux -steps: - - sources: - - url: https://github.com/gentoo/eudev/archive/refs/tags/{{ .eudev_version }}.tar.gz - destination: eudev.tar.gz - sha256: "{{ .eudev_sha256 }}" - sha512: "{{ .eudev_sha512 }}" - prepare: - - | - tar -xzf eudev.tar.gz --strip-components=1 - - # Required by gperf. - cp /toolchain/lib/libstdc++* /lib - - mkdir -p /usr/bin \ - && ln -sf /toolchain/bin/env /usr/bin/env - - autoreconf -f -i -s - - cat > config.cache << "EOF" - HAVE_BLKID=1 - BLKID_LIBS="-lblkid" - EOF - - mkdir build - cd build - - ../configure \ - --prefix=/usr \ - --libexecdir=/usr/libexec \ - --sbindir=/sbin \ - --disable-manpages \ - --disable-hwdb \ - --disable-selinux - build: - - | - cd build - make -j $(nproc) - install: - - | - cd build - make install DESTDIR=/rootfs - - # cleanup non-relevant rules - rm -f /rootfs/usr/lib/udev/rules.d/{60-cdrom_id.rules,60-persistent-alsa.rules,60-persistent-v4l.rules,64-btrfs.rules,70-joystick.rules,70-mouse.rules,70-touchpad.rules,78-sound-card.rules,80-net-name-slot.rules} - - # Azure csi support - cp /pkg/files/66-azure.rules /rootfs/usr/lib/udev/rules.d/66-azure.rules -finalize: - - from: /rootfs - to: / diff --git a/lvm2/pkg.yaml b/lvm2/pkg.yaml index 99440b9ca..4401db031 100644 --- a/lvm2/pkg.yaml +++ b/lvm2/pkg.yaml @@ -4,7 +4,8 @@ shell: /toolchain/bin/bash dependencies: - stage: base - stage: libaio - - stage: eudev + - stage: systemd-udevd + - stage: libcap # dependency for libudev - stage: util-linux steps: - sources: @@ -12,6 +13,8 @@ steps: destination: lvm2.tar.gz sha256: "{{ .lvm2_sha256 }}" sha512: "{{ .lvm2_sha512 }}" + env: + LIBS: -lcap prepare: - | tar -xzf lvm2.tar.gz --strip-components=1 diff --git a/reproducibility/pkg.yaml b/reproducibility/pkg.yaml index 83e7c2beb..d6109a8d3 100644 --- a/reproducibility/pkg.yaml +++ b/reproducibility/pkg.yaml @@ -10,7 +10,6 @@ dependencies: - stage: containerd - stage: cryptsetup - stage: dosfstools - - stage: eudev - stage: fhs - stage: flannel-cni - stage: grub @@ -28,6 +27,7 @@ dependencies: - stage: libselinux - stage: libsepol - stage: liburcu + - stage: systemd-udevd # linux-firmware can be ignored from reproducibility test since it's a tarball downloaded and extracted (no build happens) # - stage: linux-firmware - stage: lvm2 diff --git a/eudev/files/66-azure.rules b/systemd-udevd/files/66-azure.rules similarity index 100% rename from eudev/files/66-azure.rules rename to systemd-udevd/files/66-azure.rules diff --git a/systemd-udevd/patches/0001-chore-musl-headers-compatibility-for-udev.patch b/systemd-udevd/patches/0001-chore-musl-headers-compatibility-for-udev.patch new file mode 100644 index 000000000..fc7ecd245 --- /dev/null +++ b/systemd-udevd/patches/0001-chore-musl-headers-compatibility-for-udev.patch @@ -0,0 +1,88 @@ +From bc049f17be6eca828cc84861877d26092fea71a1 Mon Sep 17 00:00:00 2001 +From: Dmitry Sharshakov +Date: Sat, 28 Sep 2024 19:09:54 +0200 +Subject: [PATCH] chore: musl headers compatibility for udev + +Signed-off-by: Dmitry Sharshakov +--- + src/basic/linux/if.h | 2 +- + src/basic/linux/if_ether.h | 2 +- + src/basic/linux/libc-compat.h | 10 +++++++--- + src/basic/linux/netdevice.h | 2 +- + 4 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/basic/linux/if.h b/src/basic/linux/if.h +index e79f5c8ceb..7a885ea299 100644 +--- a/src/basic/linux/if.h ++++ b/src/basic/linux/if.h +@@ -130,10 +130,10 @@ enum net_device_flags { + #define IFF_LOWER_UP IFF_LOWER_UP + #define IFF_DORMANT IFF_DORMANT + #define IFF_ECHO IFF_ECHO +-#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ + + #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\ + IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) ++#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ + + #define IF_GET_IFACE 0x0001 /* for querying only */ + #define IF_GET_PROTO 0x0002 +diff --git a/src/basic/linux/if_ether.h b/src/basic/linux/if_ether.h +index 69e0457eb2..4bf6341acf 100644 +--- a/src/basic/linux/if_ether.h ++++ b/src/basic/linux/if_ether.h +@@ -166,7 +166,7 @@ + + /* allow libcs like musl to deactivate this, glibc does not implement this. */ + #ifndef __UAPI_DEF_ETHHDR +-#define __UAPI_DEF_ETHHDR 1 ++#define __UAPI_DEF_ETHHDR 0 + #endif + + #if __UAPI_DEF_ETHHDR +diff --git a/src/basic/linux/libc-compat.h b/src/basic/linux/libc-compat.h +index 8254c937c9..3e06d3eabb 100644 +--- a/src/basic/linux/libc-compat.h ++++ b/src/basic/linux/libc-compat.h +@@ -172,18 +172,22 @@ + * unsupported C libraries a way to opt out of any kernel definition. */ + #else /* !defined(__GLIBC__) */ + ++#ifndef NI_IDN ++#define NI_IDN 0 ++#endif ++ + /* Definitions for if.h */ + #ifndef __UAPI_DEF_IF_IFCONF +-#define __UAPI_DEF_IF_IFCONF 1 ++#define __UAPI_DEF_IF_IFCONF 0 + #endif + #ifndef __UAPI_DEF_IF_IFMAP +-#define __UAPI_DEF_IF_IFMAP 1 ++#define __UAPI_DEF_IF_IFMAP 0 + #endif + #ifndef __UAPI_DEF_IF_IFNAMSIZ + #define __UAPI_DEF_IF_IFNAMSIZ 1 + #endif + #ifndef __UAPI_DEF_IF_IFREQ +-#define __UAPI_DEF_IF_IFREQ 1 ++#define __UAPI_DEF_IF_IFREQ 0 + #endif + /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ + #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS +diff --git a/src/basic/linux/netdevice.h b/src/basic/linux/netdevice.h +index f3770c5b0f..6125206f33 100644 +--- a/src/basic/linux/netdevice.h ++++ b/src/basic/linux/netdevice.h +@@ -31,7 +31,7 @@ + #include + #include + +- ++#undef MAX_ADDR_LEN + #define MAX_ADDR_LEN 32 /* Largest hardware address length */ + + /* Initial net device group. All devices belong to group 0 by default. */ +-- +2.46.1 + diff --git a/systemd-udevd/patches/0004-missing_type.h-add-comparison_fn_t.patch b/systemd-udevd/patches/0004-missing_type.h-add-comparison_fn_t.patch new file mode 100644 index 000000000..bdafe1ff4 --- /dev/null +++ b/systemd-udevd/patches/0004-missing_type.h-add-comparison_fn_t.patch @@ -0,0 +1,60 @@ +From 34b7e1ed3b9a896db6fad435fd141c385c7337d1 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 13:55:12 +0800 +Subject: [PATCH 04/27] missing_type.h: add comparison_fn_t + +Make it work with musl where comparison_fn_t and is not provided. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Alex Kiernan +[Rebased for v244] +Signed-off-by: Chen Qi +[Rebased for v242] +Signed-off-by: Andrej Valek +[Rebased for v250, Drop __compare_fn_t] +Signed-off-by: Jiaqing Zhao +--- + src/basic/missing_type.h | 4 ++++ + src/basic/sort-util.h | 1 + + src/libsystemd/sd-journal/catalog.c | 1 + + 3 files changed, 6 insertions(+) + +diff --git a/src/basic/missing_type.h b/src/basic/missing_type.h +index 1d17705c35..fc33b76ec1 100644 +--- a/src/basic/missing_type.h ++++ b/src/basic/missing_type.h +@@ -10,3 +10,7 @@ + #if !HAVE_CHAR16_T + # define char16_t uint16_t + #endif ++ ++#ifndef __GLIBC__ ++typedef int (*comparison_fn_t)(const void *, const void *); ++#endif +diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h +index 9c818bd747..ef10c8be2c 100644 +--- a/src/basic/sort-util.h ++++ b/src/basic/sort-util.h +@@ -4,6 +4,7 @@ + #include + + #include "macro.h" ++#include "missing_type.h" + + /* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the + * external type __compar_fn_t, but doesn't do anything similar for __compar_d_fn_t. Let's hence do that +diff --git a/src/libsystemd/sd-journal/catalog.c b/src/libsystemd/sd-journal/catalog.c +index a0b673f65f..29dd2fee16 100644 +--- a/src/libsystemd/sd-journal/catalog.c ++++ b/src/libsystemd/sd-journal/catalog.c +@@ -29,6 +29,7 @@ + #include "string-util.h" + #include "strv.h" + #include "tmpfile-util.h" ++#include "missing_type.h" + + const char * const catalog_file_dirs[] = { + "/usr/local/lib/systemd/catalog/", +-- +2.45.1 diff --git a/systemd-udevd/patches/0005-add-fallback-parse_printf_format-implementation.patch b/systemd-udevd/patches/0005-add-fallback-parse_printf_format-implementation.patch new file mode 100644 index 000000000..7262dc19d --- /dev/null +++ b/systemd-udevd/patches/0005-add-fallback-parse_printf_format-implementation.patch @@ -0,0 +1,433 @@ +From 4a4005583e2debe491850229aa5ae2a97770532d Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Sat, 22 May 2021 20:26:24 +0200 +Subject: [PATCH 05/27] add fallback parse_printf_format implementation + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Emil Renner Berthing +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +[rebased for systemd 243] +Signed-off-by: Scott Murray +--- + meson.build | 1 + + src/basic/meson.build | 5 + + src/basic/parse-printf-format.c | 273 +++++++++++++++++++++++ + src/basic/parse-printf-format.h | 57 +++++ + src/basic/stdio-util.h | 2 +- + src/libsystemd/sd-journal/journal-send.c | 2 +- + 6 files changed, 338 insertions(+), 2 deletions(-) + create mode 100644 src/basic/parse-printf-format.c + create mode 100644 src/basic/parse-printf-format.h + +diff --git a/meson.build b/meson.build +index 52723bef09..e20bf3af8a 100644 +--- a/meson.build ++++ b/meson.build +@@ -753,6 +753,7 @@ foreach header : ['crypt.h', + 'linux/memfd.h', + 'linux/time_types.h', + 'linux/vm_sockets.h', ++ 'printf.h', + 'sys/auxv.h', + 'sys/sdt.h', + 'threads.h', +diff --git a/src/basic/meson.build b/src/basic/meson.build +index 9a214575a5..b49b6ade56 100644 +--- a/src/basic/meson.build ++++ b/src/basic/meson.build +@@ -189,6 +189,11 @@ endforeach + + basic_sources += generated_gperf_headers + ++if conf.get('HAVE_PRINTF_H') != 1 ++ basic_sources += [files('parse-printf-format.c')] ++endif ++ ++ + ############################################################ + + arch_list = [ +diff --git a/src/basic/parse-printf-format.c b/src/basic/parse-printf-format.c +new file mode 100644 +index 0000000000..49437e5445 +--- /dev/null ++++ b/src/basic/parse-printf-format.c +@@ -0,0 +1,273 @@ ++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ ++ ++/*** ++ This file is part of systemd. ++ ++ Copyright 2014 Emil Renner Berthing ++ ++ With parts from the musl C library ++ Copyright 2005-2014 Rich Felker, et al. ++ ++ 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. ++ ++ systemd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public License ++ along with systemd; If not, see . ++***/ ++ ++#include ++#include ++ ++#include "parse-printf-format.h" ++ ++static const char *consume_nonarg(const char *fmt) ++{ ++ do { ++ if (*fmt == '\0') ++ return fmt; ++ } while (*fmt++ != '%'); ++ return fmt; ++} ++ ++static const char *consume_num(const char *fmt) ++{ ++ for (;*fmt >= '0' && *fmt <= '9'; fmt++) ++ /* do nothing */; ++ return fmt; ++} ++ ++static const char *consume_argn(const char *fmt, size_t *arg) ++{ ++ const char *p = fmt; ++ size_t val = 0; ++ ++ if (*p < '1' || *p > '9') ++ return fmt; ++ do { ++ val = 10*val + (*p++ - '0'); ++ } while (*p >= '0' && *p <= '9'); ++ ++ if (*p != '$') ++ return fmt; ++ *arg = val; ++ return p+1; ++} ++ ++static const char *consume_flags(const char *fmt) ++{ ++ while (1) { ++ switch (*fmt) { ++ case '#': ++ case '0': ++ case '-': ++ case ' ': ++ case '+': ++ case '\'': ++ case 'I': ++ fmt++; ++ continue; ++ } ++ return fmt; ++ } ++} ++ ++enum state { ++ BARE, ++ LPRE, ++ LLPRE, ++ HPRE, ++ HHPRE, ++ BIGLPRE, ++ ZTPRE, ++ JPRE, ++ STOP ++}; ++ ++enum type { ++ NONE, ++ PTR, ++ INT, ++ UINT, ++ ULLONG, ++ LONG, ++ ULONG, ++ SHORT, ++ USHORT, ++ CHAR, ++ UCHAR, ++ LLONG, ++ SIZET, ++ IMAX, ++ UMAX, ++ PDIFF, ++ UIPTR, ++ DBL, ++ LDBL, ++ MAXTYPE ++}; ++ ++static const short pa_types[MAXTYPE] = { ++ [NONE] = PA_INT, ++ [PTR] = PA_POINTER, ++ [INT] = PA_INT, ++ [UINT] = PA_INT, ++ [ULLONG] = PA_INT | PA_FLAG_LONG_LONG, ++ [LONG] = PA_INT | PA_FLAG_LONG, ++ [ULONG] = PA_INT | PA_FLAG_LONG, ++ [SHORT] = PA_INT | PA_FLAG_SHORT, ++ [USHORT] = PA_INT | PA_FLAG_SHORT, ++ [CHAR] = PA_CHAR, ++ [UCHAR] = PA_CHAR, ++ [LLONG] = PA_INT | PA_FLAG_LONG_LONG, ++ [SIZET] = PA_INT | PA_FLAG_LONG, ++ [IMAX] = PA_INT | PA_FLAG_LONG_LONG, ++ [UMAX] = PA_INT | PA_FLAG_LONG_LONG, ++ [PDIFF] = PA_INT | PA_FLAG_LONG_LONG, ++ [UIPTR] = PA_INT | PA_FLAG_LONG, ++ [DBL] = PA_DOUBLE, ++ [LDBL] = PA_DOUBLE | PA_FLAG_LONG_DOUBLE ++}; ++ ++#define S(x) [(x)-'A'] ++#define E(x) (STOP + (x)) ++ ++static const unsigned char states[]['z'-'A'+1] = { ++ { /* 0: bare types */ ++ S('d') = E(INT), S('i') = E(INT), ++ S('o') = E(UINT),S('u') = E(UINT),S('x') = E(UINT), S('X') = E(UINT), ++ S('e') = E(DBL), S('f') = E(DBL), S('g') = E(DBL), S('a') = E(DBL), ++ S('E') = E(DBL), S('F') = E(DBL), S('G') = E(DBL), S('A') = E(DBL), ++ S('c') = E(CHAR),S('C') = E(INT), ++ S('s') = E(PTR), S('S') = E(PTR), S('p') = E(UIPTR),S('n') = E(PTR), ++ S('m') = E(NONE), ++ S('l') = LPRE, S('h') = HPRE, S('L') = BIGLPRE, ++ S('z') = ZTPRE, S('j') = JPRE, S('t') = ZTPRE ++ }, { /* 1: l-prefixed */ ++ S('d') = E(LONG), S('i') = E(LONG), ++ S('o') = E(ULONG),S('u') = E(ULONG),S('x') = E(ULONG),S('X') = E(ULONG), ++ S('e') = E(DBL), S('f') = E(DBL), S('g') = E(DBL), S('a') = E(DBL), ++ S('E') = E(DBL), S('F') = E(DBL), S('G') = E(DBL), S('A') = E(DBL), ++ S('c') = E(INT), S('s') = E(PTR), S('n') = E(PTR), ++ S('l') = LLPRE ++ }, { /* 2: ll-prefixed */ ++ S('d') = E(LLONG), S('i') = E(LLONG), ++ S('o') = E(ULLONG),S('u') = E(ULLONG), ++ S('x') = E(ULLONG),S('X') = E(ULLONG), ++ S('n') = E(PTR) ++ }, { /* 3: h-prefixed */ ++ S('d') = E(SHORT), S('i') = E(SHORT), ++ S('o') = E(USHORT),S('u') = E(USHORT), ++ S('x') = E(USHORT),S('X') = E(USHORT), ++ S('n') = E(PTR), ++ S('h') = HHPRE ++ }, { /* 4: hh-prefixed */ ++ S('d') = E(CHAR), S('i') = E(CHAR), ++ S('o') = E(UCHAR),S('u') = E(UCHAR), ++ S('x') = E(UCHAR),S('X') = E(UCHAR), ++ S('n') = E(PTR) ++ }, { /* 5: L-prefixed */ ++ S('e') = E(LDBL),S('f') = E(LDBL),S('g') = E(LDBL), S('a') = E(LDBL), ++ S('E') = E(LDBL),S('F') = E(LDBL),S('G') = E(LDBL), S('A') = E(LDBL), ++ S('n') = E(PTR) ++ }, { /* 6: z- or t-prefixed (assumed to be same size) */ ++ S('d') = E(PDIFF),S('i') = E(PDIFF), ++ S('o') = E(SIZET),S('u') = E(SIZET), ++ S('x') = E(SIZET),S('X') = E(SIZET), ++ S('n') = E(PTR) ++ }, { /* 7: j-prefixed */ ++ S('d') = E(IMAX), S('i') = E(IMAX), ++ S('o') = E(UMAX), S('u') = E(UMAX), ++ S('x') = E(UMAX), S('X') = E(UMAX), ++ S('n') = E(PTR) ++ } ++}; ++ ++size_t parse_printf_format(const char *fmt, size_t n, int *types) ++{ ++ size_t i = 0; ++ size_t last = 0; ++ ++ memset(types, 0, n); ++ ++ while (1) { ++ size_t arg; ++ unsigned int state; ++ ++ fmt = consume_nonarg(fmt); ++ if (*fmt == '\0') ++ break; ++ if (*fmt == '%') { ++ fmt++; ++ continue; ++ } ++ arg = 0; ++ fmt = consume_argn(fmt, &arg); ++ /* flags */ ++ fmt = consume_flags(fmt); ++ /* width */ ++ if (*fmt == '*') { ++ size_t warg = 0; ++ fmt = consume_argn(fmt+1, &warg); ++ if (warg == 0) ++ warg = ++i; ++ if (warg > last) ++ last = warg; ++ if (warg <= n && types[warg-1] == NONE) ++ types[warg-1] = INT; ++ } else ++ fmt = consume_num(fmt); ++ /* precision */ ++ if (*fmt == '.') { ++ fmt++; ++ if (*fmt == '*') { ++ size_t parg = 0; ++ fmt = consume_argn(fmt+1, &parg); ++ if (parg == 0) ++ parg = ++i; ++ if (parg > last) ++ last = parg; ++ if (parg <= n && types[parg-1] == NONE) ++ types[parg-1] = INT; ++ } else { ++ if (*fmt == '-') ++ fmt++; ++ fmt = consume_num(fmt); ++ } ++ } ++ /* length modifier and conversion specifier */ ++ state = BARE; ++ do { ++ unsigned char c = *fmt++; ++ ++ if (c < 'A' || c > 'z') ++ continue; ++ state = states[state]S(c); ++ if (state == 0) ++ continue; ++ } while (state < STOP); ++ ++ if (state == E(NONE)) ++ continue; ++ ++ if (arg == 0) ++ arg = ++i; ++ if (arg > last) ++ last = arg; ++ if (arg <= n) ++ types[arg-1] = state - STOP; ++ } ++ ++ if (last > n) ++ last = n; ++ for (i = 0; i < last; i++) ++ types[i] = pa_types[types[i]]; ++ ++ return last; ++} +diff --git a/src/basic/parse-printf-format.h b/src/basic/parse-printf-format.h +new file mode 100644 +index 0000000000..47be7522d7 +--- /dev/null ++++ b/src/basic/parse-printf-format.h +@@ -0,0 +1,57 @@ ++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ ++ ++/*** ++ This file is part of systemd. ++ ++ Copyright 2014 Emil Renner Berthing ++ ++ With parts from the GNU C Library ++ Copyright 1991-2014 Free Software Foundation, Inc. ++ ++ 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. ++ ++ systemd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public License ++ along with systemd; If not, see . ++***/ ++ ++#pragma once ++ ++#include "config.h" ++ ++#if HAVE_PRINTF_H ++#include ++#else ++ ++#include ++ ++enum { /* C type: */ ++ PA_INT, /* int */ ++ PA_CHAR, /* int, cast to char */ ++ PA_WCHAR, /* wide char */ ++ PA_STRING, /* const char *, a '\0'-terminated string */ ++ PA_WSTRING, /* const wchar_t *, wide character string */ ++ PA_POINTER, /* void * */ ++ PA_FLOAT, /* float */ ++ PA_DOUBLE, /* double */ ++ PA_LAST ++}; ++ ++/* Flag bits that can be set in a type returned by `parse_printf_format'. */ ++#define PA_FLAG_MASK 0xff00 ++#define PA_FLAG_LONG_LONG (1 << 8) ++#define PA_FLAG_LONG_DOUBLE PA_FLAG_LONG_LONG ++#define PA_FLAG_LONG (1 << 9) ++#define PA_FLAG_SHORT (1 << 10) ++#define PA_FLAG_PTR (1 << 11) ++ ++size_t parse_printf_format(const char *fmt, size_t n, int *types); ++ ++#endif /* HAVE_PRINTF_H */ +diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h +index 0a2239d022..43a765dacd 100644 +--- a/src/basic/stdio-util.h ++++ b/src/basic/stdio-util.h +@@ -1,12 +1,12 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + #pragma once + +-#include + #include + #include + #include + + #include "macro.h" ++#include "parse-printf-format.h" + + _printf_(3, 4) + static inline char* snprintf_ok(char *buf, size_t len, const char *format, ...) { +diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c +index 7d02b57d7b..75e8e08add 100644 +--- a/src/libsystemd/sd-journal/journal-send.c ++++ b/src/libsystemd/sd-journal/journal-send.c +@@ -2,7 +2,6 @@ + + #include + #include +-#include + #include + #include + #include +@@ -28,6 +27,7 @@ + #include "stdio-util.h" + #include "string-util.h" + #include "tmpfile-util.h" ++#include "parse-printf-format.h" + + #define SNDBUF_SIZE (8*1024*1024) + +-- +2.45.1 diff --git a/systemd-udevd/patches/0006-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch b/systemd-udevd/patches/0006-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch new file mode 100644 index 000000000..073f7b26a --- /dev/null +++ b/systemd-udevd/patches/0006-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch @@ -0,0 +1,155 @@ +From ed836c3478e1193e99e37d50db96d124796a3322 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 14:56:21 +0800 +Subject: [PATCH 06/27] don't fail if GLOB_BRACE and GLOB_ALTDIRFUNC is not + defined + +If the standard library doesn't provide brace +expansion users just won't get it. + +Dont use GNU GLOB extentions on non-glibc systems + +Conditionalize use of GLOB_ALTDIRFUNC + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj +Signed-off-by: Chen Qi +[rebased for systemd 243] +Signed-off-by: Scott Murray +--- + src/basic/glob-util.c | 12 ++++++++++++ + src/test/test-glob-util.c | 16 ++++++++++++++++ + src/tmpfiles/tmpfiles.c | 10 ++++++++++ + 3 files changed, 38 insertions(+) + +diff --git a/src/basic/glob-util.c b/src/basic/glob-util.c +index 802ca8c655..23818a67c6 100644 +--- a/src/basic/glob-util.c ++++ b/src/basic/glob-util.c +@@ -12,6 +12,12 @@ + #include "path-util.h" + #include "strv.h" + ++/* Don't fail if the standard library ++ * doesn't provide brace expansion */ ++#ifndef GLOB_BRACE ++#define GLOB_BRACE 0 ++#endif ++ + static void closedir_wrapper(void* v) { + (void) closedir(v); + } +@@ -19,6 +25,7 @@ static void closedir_wrapper(void* v) { + int safe_glob(const char *path, int flags, glob_t *pglob) { + int k; + ++#ifdef GLOB_ALTDIRFUNC + /* We want to set GLOB_ALTDIRFUNC ourselves, don't allow it to be set. */ + assert(!(flags & GLOB_ALTDIRFUNC)); + +@@ -32,9 +39,14 @@ int safe_glob(const char *path, int flags, glob_t *pglob) { + pglob->gl_lstat = lstat; + if (!pglob->gl_stat) + pglob->gl_stat = stat; ++#endif + + errno = 0; ++#ifdef GLOB_ALTDIRFUNC + k = glob(path, flags | GLOB_ALTDIRFUNC, NULL, pglob); ++#else ++ k = glob(path, flags, NULL, pglob); ++#endif + if (k == GLOB_NOMATCH) + return -ENOENT; + if (k == GLOB_NOSPACE) +diff --git a/src/test/test-glob-util.c b/src/test/test-glob-util.c +index 49d71f15c7..0a49ebcc17 100644 +--- a/src/test/test-glob-util.c ++++ b/src/test/test-glob-util.c +@@ -34,6 +34,12 @@ TEST(glob_first) { + ASSERT_NULL(first); + } + ++/* Don't fail if the standard library ++ * doesn't provide brace expansion */ ++#ifndef GLOB_BRACE ++#define GLOB_BRACE 0 ++#endif ++ + TEST(glob_exists) { + char name[] = "/tmp/test-glob_exists.XXXXXX"; + int fd = -EBADF; +@@ -61,11 +67,13 @@ TEST(glob_no_dot) { + const char *fn; + + _cleanup_globfree_ glob_t g = { ++#ifdef GLOB_ALTDIRFUNC + .gl_closedir = closedir_wrapper, + .gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot, + .gl_opendir = (void *(*)(const char *)) opendir, + .gl_lstat = lstat, + .gl_stat = stat, ++#endif + }; + + int r; +@@ -73,11 +81,19 @@ TEST(glob_no_dot) { + assert_se(mkdtemp(template)); + + fn = strjoina(template, "/*"); ++#ifdef GLOB_ALTDIRFUNC + r = glob(fn, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g); ++#else ++ r = glob(fn, GLOB_NOSORT|GLOB_BRACE, NULL, &g); ++#endif + assert_se(r == GLOB_NOMATCH); + + fn = strjoina(template, "/.*"); ++#ifdef GLOB_ALTDIRFUNC + r = glob(fn, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g); ++#else ++ r = glob(fn, GLOB_NOSORT|GLOB_BRACE, NULL, &g); ++#endif + assert_se(r == GLOB_NOMATCH); + + (void) rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL); +diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c +index 807925f199..b4f86fc611 100644 +--- a/src/tmpfiles/tmpfiles.c ++++ b/src/tmpfiles/tmpfiles.c +@@ -73,6 +73,12 @@ + #include "user-util.h" + #include "virt.h" + ++/* Don't fail if the standard library ++ * doesn't provide brace expansion */ ++#ifndef GLOB_BRACE ++#define GLOB_BRACE 0 ++#endif ++ + /* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates + * them in the file system. This is intended to be used to create + * properly owned directories beneath /tmp, /var/tmp, /run, which are +@@ -2570,7 +2576,9 @@ finish: + + static int glob_item(Context *c, Item *i, action_t action) { + _cleanup_globfree_ glob_t g = { ++#ifdef GLOB_ALTDIRFUNC + .gl_opendir = (void *(*)(const char *)) opendir_nomod, ++#endif + }; + int r; + +@@ -2598,7 +2606,9 @@ static int glob_item_recursively( + fdaction_t action) { + + _cleanup_globfree_ glob_t g = { ++#ifdef GLOB_ALTDIRFUNC + .gl_opendir = (void *(*)(const char *)) opendir_nomod, ++#endif + }; + int r; + +-- +2.45.1 diff --git a/systemd-udevd/patches/0008-Use-uintmax_t-for-handling-rlim_t.patch b/systemd-udevd/patches/0008-Use-uintmax_t-for-handling-rlim_t.patch new file mode 100644 index 000000000..ed3347fb7 --- /dev/null +++ b/systemd-udevd/patches/0008-Use-uintmax_t-for-handling-rlim_t.patch @@ -0,0 +1,105 @@ +From 41abe1a4136babfe5df63e9561dcf29d3c8fe6e9 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 15:12:41 +0800 +Subject: [PATCH 08/27] Use uintmax_t for handling rlim_t + +PRIu{32,64} is not right format to represent rlim_t type +therefore use %ju and typecast the rlim_t variables to +uintmax_t. + +Fixes portablility errors like + +execute.c:3446:36: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'rlim_t {aka long long unsigned int}' [-Werror=format=] +| fprintf(f, "%s%s: " RLIM_FMT "\n", +| ^~~~~~~~ +| prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max); +| ~~~~~~~~~~~~~~~~~~~~~~ + +Upstream-Status: Denied [https://github.com/systemd/systemd/pull/7199] + +Signed-off-by: Khem Raj +[Rebased for v241] +Signed-off-by: Chen Qi +--- + src/basic/format-util.h | 8 +------- + src/basic/rlimit-util.c | 12 ++++++------ + src/core/execute.c | 4 ++-- + 3 files changed, 9 insertions(+), 15 deletions(-) + +diff --git a/src/basic/format-util.h b/src/basic/format-util.h +index ba7cff6a8b..2736abb07b 100644 +--- a/src/basic/format-util.h ++++ b/src/basic/format-util.h +@@ -42,13 +42,7 @@ assert_cc(sizeof(gid_t) == sizeof(uint32_t)); + # error Unknown timex member size + #endif + +-#if SIZEOF_RLIM_T == 8 +-# define RLIM_FMT "%" PRIu64 +-#elif SIZEOF_RLIM_T == 4 +-# define RLIM_FMT "%" PRIu32 +-#else +-# error Unknown rlim_t size +-#endif ++#define RLIM_FMT "%ju" + + #if SIZEOF_DEV_T == 8 + # define DEV_FMT "%" PRIu64 +diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c +index a9f7b87f28..059c67731d 100644 +--- a/src/basic/rlimit-util.c ++++ b/src/basic/rlimit-util.c +@@ -47,7 +47,7 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) { + fixed.rlim_max == highest.rlim_max) + return 0; + +- log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", rlim->rlim_max, rlimit_to_string(resource), fixed.rlim_max); ++ log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", (uintmax_t)rlim->rlim_max, rlimit_to_string(resource), (uintmax_t)fixed.rlim_max); + + return RET_NERRNO(setrlimit(resource, &fixed)); + } +@@ -310,13 +310,13 @@ int rlimit_format(const struct rlimit *rl, char **ret) { + if (rl->rlim_cur >= RLIM_INFINITY && rl->rlim_max >= RLIM_INFINITY) + r = free_and_strdup(&s, "infinity"); + else if (rl->rlim_cur >= RLIM_INFINITY) +- r = asprintf(&s, "infinity:" RLIM_FMT, rl->rlim_max); ++ r = asprintf(&s, "infinity:" RLIM_FMT, (uintmax_t)rl->rlim_max); + else if (rl->rlim_max >= RLIM_INFINITY) +- r = asprintf(&s, RLIM_FMT ":infinity", rl->rlim_cur); ++ r = asprintf(&s, RLIM_FMT ":infinity", (uintmax_t)rl->rlim_cur); + else if (rl->rlim_cur == rl->rlim_max) +- r = asprintf(&s, RLIM_FMT, rl->rlim_cur); ++ r = asprintf(&s, RLIM_FMT, (uintmax_t)rl->rlim_cur); + else +- r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, rl->rlim_cur, rl->rlim_max); ++ r = asprintf(&s, RLIM_FMT ":" RLIM_FMT, (uintmax_t)rl->rlim_cur, (uintmax_t)rl->rlim_max); + if (r < 0) + return -ENOMEM; + +@@ -425,7 +425,7 @@ int rlimit_nofile_safe(void) { + rl.rlim_max = MIN(rl.rlim_max, (rlim_t) read_nr_open()); + rl.rlim_cur = MIN((rlim_t) FD_SETSIZE, rl.rlim_max); + if (setrlimit(RLIMIT_NOFILE, &rl) < 0) +- return log_debug_errno(errno, "Failed to lower RLIMIT_NOFILE's soft limit to " RLIM_FMT ": %m", rl.rlim_cur); ++ return log_debug_errno(errno, "Failed to lower RLIMIT_NOFILE's soft limit to " RLIM_FMT ": %m", (uintmax_t)rl.rlim_cur); + + return 1; + } +diff --git a/src/core/execute.c b/src/core/execute.c +index 513e95e09d..0e269617f8 100644 +--- a/src/core/execute.c ++++ b/src/core/execute.c +@@ -1067,9 +1067,9 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { + for (unsigned i = 0; i < RLIM_NLIMITS; i++) + if (c->rlimit[i]) { + fprintf(f, "%sLimit%s: " RLIM_FMT "\n", +- prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max); ++ prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_max); + fprintf(f, "%sLimit%sSoft: " RLIM_FMT "\n", +- prefix, rlimit_to_string(i), c->rlimit[i]->rlim_cur); ++ prefix, rlimit_to_string(i), (uintmax_t)c->rlimit[i]->rlim_cur); + } + + if (c->ioprio_set) { +-- +2.45.1 diff --git a/systemd-udevd/patches/0009-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch b/systemd-udevd/patches/0009-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch new file mode 100644 index 000000000..ea18d4023 --- /dev/null +++ b/systemd-udevd/patches/0009-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch @@ -0,0 +1,98 @@ +From 8af5d1e3c0dc7e71f7a4aee0f539a5d772d47354 Mon Sep 17 00:00:00 2001 +From: Andre McCurdy +Date: Tue, 10 Oct 2017 14:33:30 -0700 +Subject: [PATCH 09/27] don't pass AT_SYMLINK_NOFOLLOW flag to faccessat() + +Avoid using AT_SYMLINK_NOFOLLOW flag. It doesn't seem like the right +thing to do and it's not portable (not supported by musl). See: + + http://lists.landley.net/pipermail/toybox-landley.net/2014-September/003610.html + http://www.openwall.com/lists/musl/2015/02/05/2 + +Note that laccess() is never passing AT_EACCESS so a lot of the +discussion in the links above doesn't apply. Note also that +(currently) all systemd callers of laccess() pass mode as F_OK, so +only check for existence of a file, not access permissions. +Therefore, in this case, the only distiction between faccessat() +with (flag == 0) and (flag == AT_SYMLINK_NOFOLLOW) is the behaviour +for broken symlinks; laccess() on a broken symlink will succeed with +(flag == AT_SYMLINK_NOFOLLOW) and fail (flag == 0). + +The laccess() macros was added to systemd some time ago and it's not +clear if or why it needs to return success for broken symlinks. Maybe +just historical and not actually necessary or desired behaviour? + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Andre McCurdy +--- + src/basic/fs-util.h | 21 ++++++++++++++++++++- + src/shared/base-filesystem.c | 6 +++--- + 2 files changed, 23 insertions(+), 4 deletions(-) + +diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h +index 3e2db95304..d5747416b0 100644 +--- a/src/basic/fs-util.h ++++ b/src/basic/fs-util.h +@@ -49,8 +49,27 @@ int futimens_opath(int fd, const struct timespec ts[2]); + int fd_warn_permissions(const char *path, int fd); + int stat_warn_permissions(const char *path, const struct stat *st); + ++/* ++ Avoid using AT_SYMLINK_NOFOLLOW flag. It doesn't seem like the right thing to ++ do and it's not portable (not supported by musl). See: ++ ++ http://lists.landley.net/pipermail/toybox-landley.net/2014-September/003610.html ++ http://www.openwall.com/lists/musl/2015/02/05/2 ++ ++ Note that laccess() is never passing AT_EACCESS so a lot of the discussion in ++ the links above doesn't apply. Note also that (currently) all systemd callers ++ of laccess() pass mode as F_OK, so only check for existence of a file, not ++ access permissions. Therefore, in this case, the only distiction between ++ faccessat() with (flag == 0) and (flag == AT_SYMLINK_NOFOLLOW) is the ++ behaviour for broken symlinks; laccess() on a broken symlink will succeed ++ with (flag == AT_SYMLINK_NOFOLLOW) and fail (flag == 0). ++ ++ The laccess() macros was added to systemd some time ago and it's not clear if ++ or why it needs to return success for broken symlinks. Maybe just historical ++ and not actually necessary or desired behaviour? ++*/ + #define laccess(path, mode) \ +- RET_NERRNO(faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW)) ++ RET_NERRNO(faccessat(AT_FDCWD, (path), (mode), 0)) + + int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode); + +diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c +index a4e2dae245..67aa8ea1f2 100644 +--- a/src/shared/base-filesystem.c ++++ b/src/shared/base-filesystem.c +@@ -145,7 +145,7 @@ int base_filesystem_create_fd(int fd, const char *root, uid_t uid, gid_t gid) { + /* The "root" parameter is decoration only – it's only used as part of log messages */ + + for (size_t i = 0; i < ELEMENTSOF(table); i++) { +- if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0) ++ if (faccessat(fd, table[i].dir, F_OK, 0) >= 0) + continue; + + if (table[i].target) { /* Create as symlink? */ +@@ -153,7 +153,7 @@ int base_filesystem_create_fd(int fd, const char *root, uid_t uid, gid_t gid) { + + /* check if one of the targets exists */ + NULSTR_FOREACH(s, table[i].target) { +- if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0) ++ if (faccessat(fd, s, F_OK, 0) < 0) + continue; + + /* check if a specific file exists at the target path */ +@@ -164,7 +164,7 @@ int base_filesystem_create_fd(int fd, const char *root, uid_t uid, gid_t gid) { + if (!p) + return log_oom(); + +- if (faccessat(fd, p, F_OK, AT_SYMLINK_NOFOLLOW) < 0) ++ if (faccessat(fd, p, F_OK, 0) < 0) + continue; + } + +-- +2.45.1 diff --git a/systemd-udevd/patches/0010-Define-glibc-compatible-basename-for-non-glibc-syste.patch b/systemd-udevd/patches/0010-Define-glibc-compatible-basename-for-non-glibc-syste.patch new file mode 100644 index 000000000..a13cc0268 --- /dev/null +++ b/systemd-udevd/patches/0010-Define-glibc-compatible-basename-for-non-glibc-syste.patch @@ -0,0 +1,33 @@ +From ea8e85d92f67a7af8577a4ce7c67c7aaee65d10c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 27 May 2018 08:36:44 -0700 +Subject: [PATCH 10/27] Define glibc compatible basename() for non-glibc + systems + +Fixes builds with musl, even though systemd is adamant about +using non-posix basename implementation, we have a way out + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj +--- + src/basic/string-util.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/basic/string-util.h b/src/basic/string-util.h +index ff5efbcf55..d1a6bb0e76 100644 +--- a/src/basic/string-util.h ++++ b/src/basic/string-util.h +@@ -26,6 +26,10 @@ + #define URI_UNRESERVED ALPHANUMERICAL "-._~" /* [RFC3986] */ + #define URI_VALID URI_RESERVED URI_UNRESERVED /* [RFC3986] */ + ++#if !defined(__GLIBC__) ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static inline char* strstr_ptr(const char *haystack, const char *needle) { + if (!haystack || !needle) + return NULL; +-- +2.45.1 diff --git a/systemd-udevd/patches/0011-Do-not-disable-buffering-when-writing-to-oom_score_a.patch b/systemd-udevd/patches/0011-Do-not-disable-buffering-when-writing-to-oom_score_a.patch new file mode 100644 index 000000000..160905d0e --- /dev/null +++ b/systemd-udevd/patches/0011-Do-not-disable-buffering-when-writing-to-oom_score_a.patch @@ -0,0 +1,40 @@ +From 7c8634c441401b034cd4bcf4b916a7042076fca8 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Wed, 4 Jul 2018 15:00:44 +0800 +Subject: [PATCH 11/27] Do not disable buffering when writing to oom_score_adj + +On musl, disabling buffering when writing to oom_score_adj will +cause the following error. + + Failed to adjust OOM setting: Invalid argument + +This error appears for systemd-udevd.service and dbus.service. +This is because kernel receives '-' instead of the whole '-900' +if buffering is disabled. + +This is libc implementation specific, as glibc does not have this issue. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +[rebased for systemd 243] +Signed-off-by: Scott Murray +--- + src/basic/process-util.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index c9d968dee0..7d6d3ce7db 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -1816,7 +1816,7 @@ int set_oom_score_adjust(int value) { + xsprintf(t, "%i", value); + + return write_string_file("/proc/self/oom_score_adj", t, +- WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); ++ WRITE_STRING_FILE_VERIFY_ON_FAILURE); + } + + int get_oom_score_adjust(int *ret) { +-- +2.45.1 diff --git a/systemd-udevd/patches/0012-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch b/systemd-udevd/patches/0012-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch new file mode 100644 index 000000000..25c767650 --- /dev/null +++ b/systemd-udevd/patches/0012-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch @@ -0,0 +1,75 @@ +From 4a2df0bba1741914617ca1271e2bc68a5d9e5dac Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Tue, 10 Jul 2018 15:40:17 +0800 +Subject: [PATCH 12/27] distinguish XSI-compliant strerror_r from GNU-specifi + strerror_r + +XSI-compliant strerror_r and GNU-specifi strerror_r are different. + + int strerror_r(int errnum, char *buf, size_t buflen); + /* XSI-compliant */ + + char *strerror_r(int errnum, char *buf, size_t buflen); + /* GNU-specific */ + +We need to distinguish between them. Otherwise, we'll get an int value +assigned to (char *) variable, resulting in segment fault. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/libsystemd/sd-bus/bus-error.c | 11 ++++++++++- + src/libsystemd/sd-journal/journal-send.c | 5 +++++ + 2 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c +index f415797700..a5c6e9a3bd 100644 +--- a/src/libsystemd/sd-bus/bus-error.c ++++ b/src/libsystemd/sd-bus/bus-error.c +@@ -410,7 +410,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) { + return; + + errno = 0; ++#ifndef __GLIBC__ ++ strerror_r(error, m, k); ++ x = m; ++#else + x = strerror_r(error, m, k); ++#endif + if (errno == ERANGE || strlen(x) >= k - 1) { + free(m); + k *= 2; +@@ -595,8 +600,12 @@ const char* _bus_error_message(const sd_bus_error *e, int error, char buf[static + + if (e && e->message) + return e->message; +- ++#ifndef __GLIBC__ ++ strerror_r(abs(error), buf, ERRNO_BUF_LEN); ++ return buf; ++#else + return strerror_r(abs(error), buf, ERRNO_BUF_LEN); ++#endif + } + + static bool map_ok(const sd_bus_error_map *map) { +diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c +index 75e8e08add..41e5c7c2b8 100644 +--- a/src/libsystemd/sd-journal/journal-send.c ++++ b/src/libsystemd/sd-journal/journal-send.c +@@ -361,7 +361,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove + char* j; + + errno = 0; ++#ifndef __GLIBC__ ++ strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); ++ j = buffer + 8 + k; ++#else + j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); ++#endif + if (errno == 0) { + char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1]; + +-- +2.45.1 diff --git a/systemd-udevd/patches/0013-avoid-redefinition-of-prctl_mm_map-structure.patch b/systemd-udevd/patches/0013-avoid-redefinition-of-prctl_mm_map-structure.patch new file mode 100644 index 000000000..ca69bbd47 --- /dev/null +++ b/systemd-udevd/patches/0013-avoid-redefinition-of-prctl_mm_map-structure.patch @@ -0,0 +1,31 @@ +From 846b8f16cf07d9187261e06701a75eb208caa707 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Mon, 25 Feb 2019 15:44:54 +0800 +Subject: [PATCH 13/27] avoid redefinition of prctl_mm_map structure + +Fix the following compile failure: +error: redefinition of 'struct prctl_mm_map' + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/basic/missing_prctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/basic/missing_prctl.h b/src/basic/missing_prctl.h +index 2c9f9f6c50..65a984b564 100644 +--- a/src/basic/missing_prctl.h ++++ b/src/basic/missing_prctl.h +@@ -1,7 +1,9 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + #pragma once + ++#ifdef __GLIBC__ + #include ++#endif + + #include "macro.h" + +-- +2.45.1 diff --git a/systemd-udevd/patches/0014-do-not-disable-buffer-in-writing-files.patch b/systemd-udevd/patches/0014-do-not-disable-buffer-in-writing-files.patch new file mode 100644 index 000000000..cec5b441a --- /dev/null +++ b/systemd-udevd/patches/0014-do-not-disable-buffer-in-writing-files.patch @@ -0,0 +1,571 @@ +From 88694101bcac461c39049962ce97ce579cc07e13 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Fri, 1 Mar 2019 15:22:15 +0800 +Subject: [PATCH 14/27] do not disable buffer in writing files + +Do not disable buffer in writing files, otherwise we get +failure at boot for musl like below. + + [!!!!!!] Failed to allocate manager object. + +And there will be other failures, critical or not critical. +This is specific to musl. + +Upstream-Status: Inappropriate [musl] + +Signed-off-by: Chen Qi +[Rebased for v242] +Signed-off-by: Andrej Valek +[rebased for systemd 243] +Signed-off-by: Scott Murray +[rebased for systemd 254] +Signed-off-by: Chen Qi +[rebased for systemd 255.1] +--- + src/basic/cgroup-util.c | 12 ++++++------ + src/basic/namespace-util.c | 4 ++-- + src/basic/procfs-util.c | 4 ++-- + src/basic/sysctl-util.c | 2 +- + src/binfmt/binfmt.c | 6 +++--- + src/core/cgroup.c | 2 +- + src/core/main.c | 2 +- + src/core/smack-setup.c | 8 ++++---- + src/home/homework.c | 2 +- + src/libsystemd/sd-device/sd-device.c | 2 +- + src/nspawn/nspawn-cgroup.c | 2 +- + src/nspawn/nspawn.c | 6 +++--- + src/shared/binfmt-util.c | 2 +- + src/shared/cgroup-setup.c | 6 +++--- + src/shared/coredump-util.c | 4 ++-- + src/shared/hibernate-util.c | 4 ++-- + src/shared/smack-util.c | 2 +- + src/shared/watchdog.c | 2 +- + src/sleep/sleep.c | 4 ++-- + src/storagetm/storagetm.c | 24 ++++++++++++------------ + src/udev/udev-rules.c | 1 - + src/vconsole/vconsole-setup.c | 2 +- + 22 files changed, 51 insertions(+), 52 deletions(-) + +diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c +index 553ee6075a..a3704baf6a 100644 +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -457,7 +457,7 @@ int cg_kill_kernel_sigkill(const char *path) { + if (r < 0) + return r; + +- r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(killfile, "1", 0); + if (r < 0) + return log_debug_errno(r, "Failed to write to cgroup.kill for cgroup '%s': %m", path); + +@@ -885,7 +885,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { + + sc = strstrip(contents); + if (isempty(sc)) { +- r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, agent, 0); + if (r < 0) + return r; + } else if (!path_equal(sc, agent)) +@@ -903,7 +903,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { + + sc = strstrip(contents); + if (streq(sc, "0")) { +- r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, "1", 0); + if (r < 0) + return r; + +@@ -930,7 +930,7 @@ int cg_uninstall_release_agent(const char *controller) { + if (r < 0) + return r; + +- r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, "0", 0); + if (r < 0) + return r; + +@@ -940,7 +940,7 @@ int cg_uninstall_release_agent(const char *controller) { + if (r < 0) + return r; + +- r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, "", 0); + if (r < 0) + return r; + +@@ -1833,7 +1833,7 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri + if (r < 0) + return r; + +- return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); ++ return write_string_file(p, value, 0); + } + + int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) { +diff --git a/src/basic/namespace-util.c b/src/basic/namespace-util.c +index 5b4e43f921..42a84ded55 100644 +--- a/src/basic/namespace-util.c ++++ b/src/basic/namespace-util.c +@@ -325,12 +325,12 @@ int userns_acquire(const char *uid_map, const char *gid_map) { + freeze(); + + xsprintf(path, "/proc/" PID_FMT "/uid_map", pid); +- r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(path, uid_map, 0); + if (r < 0) + return log_debug_errno(r, "Failed to write UID map: %m"); + + xsprintf(path, "/proc/" PID_FMT "/gid_map", pid); +- r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(path, gid_map, 0); + if (r < 0) + return log_debug_errno(r, "Failed to write GID map: %m"); + +diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c +index d7cfcd9105..58fb5918a3 100644 +--- a/src/basic/procfs-util.c ++++ b/src/basic/procfs-util.c +@@ -63,13 +63,13 @@ int procfs_tasks_set_limit(uint64_t limit) { + * decrease it, as threads-max is the much more relevant sysctl. */ + if (limit > pid_max-1) { + sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ +- r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); + if (r < 0) + return r; + } + + sprintf(buffer, "%" PRIu64, limit); +- r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); + if (r < 0) { + uint64_t threads_max; + +diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c +index 9a1933f579..7d6fc65ee1 100644 +--- a/src/basic/sysctl-util.c ++++ b/src/basic/sysctl-util.c +@@ -58,7 +58,7 @@ int sysctl_write(const char *property, const char *value) { + + log_debug("Setting '%s' to '%s'", p, value); + +- return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); ++ return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); + } + + int sysctl_writef(const char *property, const char *format, ...) { +diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c +index d21f3f79ff..258607cc7e 100644 +--- a/src/binfmt/binfmt.c ++++ b/src/binfmt/binfmt.c +@@ -30,7 +30,7 @@ static bool arg_unregister = false; + + static int delete_rule(const char *rulename) { + const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename); +- return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ return write_string_file(fn, "-1", 0); + } + + static int apply_rule(const char *filename, unsigned line, const char *rule) { +@@ -58,7 +58,7 @@ static int apply_rule(const char *filename, unsigned line, const char *rule) { + if (r >= 0) + log_debug("%s:%u: Rule '%s' deleted.", filename, line, rulename); + +- r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); + if (r < 0) + return log_error_errno(r, "%s:%u: Failed to add binary format '%s': %m", + filename, line, rulename); +@@ -248,7 +248,7 @@ static int run(int argc, char *argv[]) { + return r; + + /* Flush out all rules */ +- r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); + if (r < 0) + log_warning_errno(r, "Failed to flush binfmt_misc rules, ignoring: %m"); + else +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 34fd2a250c..cb1a6d01eb 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -5173,7 +5173,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) { + freezer_state_to_string(u->freezer_state), + freezer_state_to_string(next)); + +- r = write_string_file(path, one_zero(target == FREEZER_FROZEN), WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(path, one_zero(target == FREEZER_FROZEN), 0); + if (r < 0) + return r; + +diff --git a/src/core/main.c b/src/core/main.c +index 4b8a315d86..051a31ba84 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -1789,7 +1789,7 @@ static void initialize_core_pattern(bool skip_setup) { + if (getpid_cached() != 1) + return; + +- r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); + if (r < 0) + log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", + arg_early_core_pattern); +diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c +index 7ea902b6f9..1aef2988d0 100644 +--- a/src/core/smack-setup.c ++++ b/src/core/smack-setup.c +@@ -321,17 +321,17 @@ int mac_smack_setup(bool *loaded_policy) { + } + + #if HAVE_SMACK_RUN_LABEL +- r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); +- r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); + r = write_string_file("/sys/fs/smackfs/netlabel", +- "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); ++ "0.0.0.0/0 " SMACK_RUN_LABEL, 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); +- r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); + if (r < 0) + log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); + #endif +diff --git a/src/home/homework.c b/src/home/homework.c +index 482db23dbc..ed6b8d271f 100644 +--- a/src/home/homework.c ++++ b/src/home/homework.c +@@ -302,8 +302,8 @@ static void drop_caches_now(void) { + /* Drop file system caches now. See https://docs.kernel.org/admin-guide/sysctl/vm.html + * for details. We write "3" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but + * not more. */ ++ r = write_string_file("/proc/sys/vm/drop_caches", "3\n", 0); + +- r = write_string_file("/proc/sys/vm/drop_caches", "3\n", WRITE_STRING_FILE_DISABLE_BUFFER); + if (r < 0) + log_warning_errno(r, "Failed to drop caches, ignoring: %m"); + else +diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c +index d8d151835c..268cb65ec7 100644 +--- a/src/libsystemd/sd-device/sd-device.c ++++ b/src/libsystemd/sd-device/sd-device.c +@@ -2499,7 +2499,7 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, + if (!value) + return -ENOMEM; + +- r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); ++ r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); + if (r < 0) { + /* On failure, clear cache entry, as we do not know how it fails. */ + device_remove_cached_sysattr_value(device, sysattr); +diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c +index 4f28b4a225..c93c2c33b5 100644 +--- a/src/nspawn/nspawn-cgroup.c ++++ b/src/nspawn/nspawn-cgroup.c +@@ -93,7 +93,7 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) { + fn = strjoina(tree, cgroup, "/cgroup.procs"); + + sprintf(pid_string, PID_FMT, pid); +- r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); ++ r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); + if (r < 0) { + log_error_errno(r, "Failed to move process: %m"); + goto finish; +diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c +index 5842d3ba8f..44ff9d946c 100644 +--- a/src/nspawn/nspawn.c ++++ b/src/nspawn/nspawn.c +@@ -2741,7 +2741,7 @@ static int reset_audit_loginuid(void) { + if (streq(p, "4294967295")) + return 0; + +- r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/self/loginuid", "4294967295", 0); + if (r < 0) { + log_error_errno(r, + "Failed to reset audit login UID. This probably means that your kernel is too\n" +@@ -4450,7 +4450,7 @@ static int setup_uid_map( + return log_oom(); + + xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); +- r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(uid_map, s, 0); + if (r < 0) + return log_error_errno(r, "Failed to write UID map: %m"); + +@@ -4460,7 +4460,7 @@ static int setup_uid_map( + return log_oom(); + + xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); +- r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(uid_map, s, 0); + if (r < 0) + return log_error_errno(r, "Failed to write GID map: %m"); + +diff --git a/src/shared/binfmt-util.c b/src/shared/binfmt-util.c +index a26175474b..1413a9c72c 100644 +--- a/src/shared/binfmt-util.c ++++ b/src/shared/binfmt-util.c +@@ -46,7 +46,7 @@ int disable_binfmt(void) { + return 0; + } + +- r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); + if (r < 0) + return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m"); + +diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c +index 093b6d0d22..89d0ac612b 100644 +--- a/src/shared/cgroup-setup.c ++++ b/src/shared/cgroup-setup.c +@@ -364,7 +364,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) { + + xsprintf(c, PID_FMT "\n", pid); + +- r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(fs, c, 0); + if (r == -EOPNOTSUPP && cg_is_threaded(path) > 0) + /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */ + return -EUCLEAN; +@@ -395,7 +395,7 @@ int cg_fd_attach(int fd, pid_t pid) { + + xsprintf(c, PID_FMT "\n", pid); + +- return write_string_file_at(fd, "cgroup.procs", c, WRITE_STRING_FILE_DISABLE_BUFFER); ++ return write_string_file_at(fd, "cgroup.procs", c, 0); + } + + int cg_attach_fallback(const char *controller, const char *path, pid_t pid) { +@@ -974,7 +974,7 @@ int cg_enable_everywhere( + return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); + } + +- r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_stream(f, s, 0); + if (r < 0) { + log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", + FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); +diff --git a/src/shared/coredump-util.c b/src/shared/coredump-util.c +index 805503f366..01a7ccb291 100644 +--- a/src/shared/coredump-util.c ++++ b/src/shared/coredump-util.c +@@ -163,7 +163,7 @@ int set_coredump_filter(uint64_t value) { + xsprintf(t, "0x%"PRIx64, value); + + return write_string_file("/proc/self/coredump_filter", t, +- WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); ++ 0); + } + + /* Turn off core dumps but only if we're running outside of a container. */ +@@ -173,7 +173,7 @@ void disable_coredumps(void) { + if (detect_container() > 0) + return; + +- r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); + if (r < 0) + log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); + } +diff --git a/src/shared/hibernate-util.c b/src/shared/hibernate-util.c +index 7c21157580..06ab74b04c 100644 +--- a/src/shared/hibernate-util.c ++++ b/src/shared/hibernate-util.c +@@ -495,7 +495,7 @@ int write_resume_config(dev_t devno, uint64_t offset, const char *device) { + + /* We write the offset first since it's safer. Note that this file is only available in 4.17+, so + * fail gracefully if it doesn't exist and we're only overwriting it with 0. */ +- r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/power/resume_offset", offset_str, 0); + if (r == -ENOENT) { + if (offset != 0) + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), +@@ -511,7 +511,7 @@ int write_resume_config(dev_t devno, uint64_t offset, const char *device) { + log_debug("Wrote resume_offset=%s for device '%s' to /sys/power/resume_offset.", + offset_str, device); + +- r = write_string_file("/sys/power/resume", devno_str, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/power/resume", devno_str, 0); + if (r < 0) + return log_error_errno(r, + "Failed to write device '%s' (%s) to /sys/power/resume: %m", +diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c +index 1f88e724d0..feb18b320a 100644 +--- a/src/shared/smack-util.c ++++ b/src/shared/smack-util.c +@@ -113,7 +113,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) { + return 0; + + p = procfs_file_alloca(pid, "attr/current"); +- r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(p, label, 0); + if (r < 0) + return r; + +diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c +index 810c5b5206..be0d127ff3 100644 +--- a/src/shared/watchdog.c ++++ b/src/shared/watchdog.c +@@ -93,7 +93,7 @@ static int watchdog_set_pretimeout_governor(const char *governor) { + + r = write_string_file(sys_fn, + governor, +- WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); ++ WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); + if (r < 0) + return log_error_errno(r, "Failed to set watchdog pretimeout_governor to '%s': %m", governor); + +diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c +index 0402bb07f3..a6cbb45340 100644 +--- a/src/sleep/sleep.c ++++ b/src/sleep/sleep.c +@@ -139,7 +139,7 @@ static int write_state(int fd, char * const *states) { + if (k < 0) + return RET_GATHER(r, k); + +- k = write_string_stream(f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); ++ k = write_string_stream(f, *state, 0); + if (k >= 0) { + log_debug("Using sleep state '%s'.", *state); + return 0; +@@ -157,7 +157,7 @@ static int write_mode(const char *path, char * const *modes) { + assert(path); + + STRV_FOREACH(mode, modes) { +- r = write_string_file(path, *mode, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file(path, *mode, 0); + if (r >= 0) { + log_debug("Using sleep mode '%s' for %s.", *mode, path); + return 0; +diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c +index 1bb8eec316..cf9b4c4a21 100644 +--- a/src/storagetm/storagetm.c ++++ b/src/storagetm/storagetm.c +@@ -186,7 +186,7 @@ static int nvme_subsystem_unlink(NvmeSubsystem *s) { + if (!enable_fn) + return log_oom(); + +- r = write_string_file_at(namespaces_fd, enable_fn, "0", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(namespaces_fd, enable_fn, "0", 0); + if (r < 0) + log_warning_errno(r, "Failed to disable namespace '%s' of NVME subsystem '%s', ignoring: %m", e->d_name, s->name); + +@@ -254,7 +254,7 @@ static int nvme_subsystem_write_metadata(int subsystem_fd, sd_device *device) { + _cleanup_free_ char *truncated = strndup(w, 40); /* kernel refuses more than 40 chars (as per nvme spec) */ + + /* The default string stored in 'attr_model' is "Linux" btw. */ +- r = write_string_file_at(subsystem_fd, "attr_model", truncated, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(subsystem_fd, "attr_model", truncated, 0); + if (r < 0) + log_warning_errno(r, "Failed to set model of subsystem to '%s', ignoring: %m", w); + } +@@ -268,7 +268,7 @@ static int nvme_subsystem_write_metadata(int subsystem_fd, sd_device *device) { + return log_oom(); + + /* The default string stored in 'attr_firmware' is `uname -r` btw, but truncated to 8 chars. */ +- r = write_string_file_at(subsystem_fd, "attr_firmware", truncated, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(subsystem_fd, "attr_firmware", truncated, 0); + if (r < 0) + log_warning_errno(r, "Failed to set model of subsystem to '%s', ignoring: %m", truncated); + } +@@ -295,7 +295,7 @@ static int nvme_subsystem_write_metadata(int subsystem_fd, sd_device *device) { + if (!truncated) + return log_oom(); + +- r = write_string_file_at(subsystem_fd, "attr_serial", truncated, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(subsystem_fd, "attr_serial", truncated, 0); + if (r < 0) + log_warning_errno(r, "Failed to set serial of subsystem to '%s', ignoring: %m", truncated); + } +@@ -345,7 +345,7 @@ static int nvme_namespace_write_metadata(int namespace_fd, sd_device *device, co + id = id128_digest(j, l); + } + +- r = write_string_file_at(namespace_fd, "device_uuid", SD_ID128_TO_UUID_STRING(id), WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(namespace_fd, "device_uuid", SD_ID128_TO_UUID_STRING(id), 0); + if (r < 0) + log_warning_errno(r, "Failed to set uuid of namespace to '%s', ignoring: %m", SD_ID128_TO_UUID_STRING(id)); + +@@ -408,7 +408,7 @@ static int nvme_subsystem_add(const char *node, int consumed_fd, sd_device *devi + if (subsystem_fd < 0) + return log_error_errno(subsystem_fd, "Failed to create NVME subsystem '%s': %m", j); + +- r = write_string_file_at(subsystem_fd, "attr_allow_any_host", "1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(subsystem_fd, "attr_allow_any_host", "1", 0); + if (r < 0) + return log_error_errno(r, "Failed to set 'attr_allow_any_host' flag: %m"); + +@@ -423,11 +423,11 @@ static int nvme_subsystem_add(const char *node, int consumed_fd, sd_device *devi + + /* We use /proc/$PID/fd/$FD rather than /proc/self/fd/$FD, because this string is visible to others + * via configfs, and by including the PID it's clear to who the stuff belongs. */ +- r = write_string_file_at(namespace_fd, "device_path", FORMAT_PROC_PID_FD_PATH(0, fd), WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(namespace_fd, "device_path", FORMAT_PROC_PID_FD_PATH(0, fd), 0); + if (r < 0) + return log_error_errno(r, "Failed to write 'device_path' attribute: %m"); + +- r = write_string_file_at(namespace_fd, "enable", "1", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(namespace_fd, "enable", "1", 0); + if (r < 0) + return log_error_errno(r, "Failed to write 'enable' attribute: %m"); + +@@ -557,19 +557,19 @@ static int nvme_port_add_portnr( + return 0; + } + +- r = write_string_file_at(port_fd, "addr_adrfam", af_to_ipv4_ipv6(ip_family), WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(port_fd, "addr_adrfam", af_to_ipv4_ipv6(ip_family), 0); + if (r < 0) + return log_error_errno(r, "Failed to set address family on NVME port %" PRIu16 ": %m", portnr); + +- r = write_string_file_at(port_fd, "addr_trtype", "tcp", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(port_fd, "addr_trtype", "tcp", 0); + if (r < 0) + return log_error_errno(r, "Failed to set transport type on NVME port %" PRIu16 ": %m", portnr); + +- r = write_string_file_at(port_fd, "addr_trsvcid", fname, WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(port_fd, "addr_trsvcid", fname, 0); + if (r < 0) + return log_error_errno(r, "Failed to set IP port on NVME port %" PRIu16 ": %m", portnr); + +- r = write_string_file_at(port_fd, "addr_traddr", ip_family == AF_INET6 ? "::" : "0.0.0.0", WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file_at(port_fd, "addr_traddr", ip_family == AF_INET6 ? "::" : "0.0.0.0", 0); + if (r < 0) + return log_error_errno(r, "Failed to set IP address on NVME port %" PRIu16 ": %m", portnr); + +diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c +index 581bbaf345..cdf648a2d1 100644 +--- a/src/udev/udev-rules.c ++++ b/src/udev/udev-rules.c +@@ -2706,7 +2706,6 @@ static int udev_rule_apply_token_to_event( + log_event_debug(dev, token, "Writing ATTR{'%s'}=\"%s\".", buf, value); + r = write_string_file(buf, value, + WRITE_STRING_FILE_VERIFY_ON_FAILURE | +- WRITE_STRING_FILE_DISABLE_BUFFER | + WRITE_STRING_FILE_AVOID_NEWLINE | + WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); + if (r < 0) +diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c +index ba742dda69..6f20e81615 100644 +--- a/src/vconsole/vconsole-setup.c ++++ b/src/vconsole/vconsole-setup.c +@@ -277,7 +277,7 @@ static int toggle_utf8_vc(const char *name, int fd, bool utf8) { + static int toggle_utf8_sysfs(bool utf8) { + int r; + +- r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); ++ r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); + if (r < 0) + return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); + +-- +2.45.1 diff --git a/systemd-udevd/patches/0016-Handle-missing-gshadow.patch b/systemd-udevd/patches/0016-Handle-missing-gshadow.patch new file mode 100644 index 000000000..1428185bb --- /dev/null +++ b/systemd-udevd/patches/0016-Handle-missing-gshadow.patch @@ -0,0 +1,171 @@ +From 8b540d8240bbc3f917de9ca8d3b62f28c3424d91 Mon Sep 17 00:00:00 2001 +From: Alex Kiernan +Date: Tue, 10 Mar 2020 11:05:20 +0000 +Subject: [PATCH 16/27] Handle missing gshadow + +gshadow usage is now present in the userdb code. Mask all uses of it to +allow compilation on musl + +Upstream-Status: Inappropriate [musl specific] +Signed-off-by: Alex Kiernan +[Rebased for v247] +Signed-off-by: Luca Boccassi +--- + src/shared/user-record-nss.c | 20 ++++++++++++++++++++ + src/shared/user-record-nss.h | 4 ++++ + src/shared/userdb.c | 7 ++++++- + 3 files changed, 30 insertions(+), 1 deletion(-) + +diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c +index ffb5721466..4d01815c8c 100644 +--- a/src/shared/user-record-nss.c ++++ b/src/shared/user-record-nss.c +@@ -286,8 +286,10 @@ int nss_group_to_group_record( + if (isempty(grp->gr_name)) + return -EINVAL; + ++#if ENABLE_GSHADOW + if (sgrp && !streq_ptr(sgrp->sg_namp, grp->gr_name)) + return -EINVAL; ++#endif + + g = group_record_new(); + if (!g) +@@ -303,6 +305,7 @@ int nss_group_to_group_record( + + g->gid = grp->gr_gid; + ++#if ENABLE_GSHADOW + if (sgrp) { + if (looks_like_hashed_password(utf8_only(sgrp->sg_passwd))) { + g->hashed_password = strv_new(sgrp->sg_passwd); +@@ -318,6 +321,7 @@ int nss_group_to_group_record( + if (r < 0) + return r; + } ++#endif + + r = json_build(&g->json, JSON_BUILD_OBJECT( + JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(g->group_name)), +@@ -344,6 +348,7 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re + assert(ret_sgrp); + assert(ret_buffer); + ++#if ENABLE_GSHADOW + for (;;) { + _cleanup_free_ char *buf = NULL; + struct sgrp sgrp, *result; +@@ -372,6 +377,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re + buflen *= 2; + buf = mfree(buf); + } ++#else ++ return -ESRCH; ++#endif + } + + int nss_group_record_by_name( +@@ -382,7 +390,9 @@ int nss_group_record_by_name( + _cleanup_free_ char *sbuf = NULL; + _cleanup_free_ struct group *result = NULL; + bool incomplete = false; ++#if ENABLE_GSHADOW + struct sgrp sgrp, *sresult = NULL; ++#endif + int r; + + assert(name); +@@ -391,6 +401,7 @@ int nss_group_record_by_name( + if (r < 0) + return r; + ++#if ENABLE_GSHADOW + if (with_shadow) { + r = nss_sgrp_for_group(result, &sgrp, &sbuf); + if (r < 0) { +@@ -402,6 +413,9 @@ int nss_group_record_by_name( + incomplete = true; + + r = nss_group_to_group_record(result, sresult, ret); ++#else ++ r = nss_group_to_group_record(result, NULL, ret); ++#endif + if (r < 0) + return r; + +@@ -418,13 +432,16 @@ int nss_group_record_by_gid( + _cleanup_free_ char *sbuf = NULL; + _cleanup_free_ struct group *result = NULL; + bool incomplete = false; ++#if ENABLE_GSHADOW + struct sgrp sgrp, *sresult = NULL; ++#endif + int r; + + r = getgrgid_malloc(gid, &result); + if (r < 0) + return r; + ++#if ENABLE_GSHADOW + if (with_shadow) { + r = nss_sgrp_for_group(result, &sgrp, &sbuf); + if (r < 0) { +@@ -436,6 +453,9 @@ int nss_group_record_by_gid( + incomplete = true; + + r = nss_group_to_group_record(result, sresult, ret); ++#else ++ r = nss_group_to_group_record(result, NULL, ret); ++#endif + if (r < 0) + return r; + +diff --git a/src/shared/user-record-nss.h b/src/shared/user-record-nss.h +index 22ab04d6ee..4e52e7a911 100644 +--- a/src/shared/user-record-nss.h ++++ b/src/shared/user-record-nss.h +@@ -2,7 +2,11 @@ + #pragma once + + #include ++#if ENABLE_GSHADOW + #include ++#else ++struct sgrp; ++#endif + #include + #include + +diff --git a/src/shared/userdb.c b/src/shared/userdb.c +index 75dece3442..5628e1410f 100644 +--- a/src/shared/userdb.c ++++ b/src/shared/userdb.c +@@ -1038,13 +1038,15 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) { + if (gr) { + _cleanup_free_ char *buffer = NULL; + bool incomplete = false; ++#if ENABLE_GSHADOW + struct sgrp sgrp; +- ++#endif + if (streq_ptr(gr->gr_name, "root")) + iterator->synthesize_root = false; + if (gr->gr_gid == GID_NOBODY) + iterator->synthesize_nobody = false; + ++#if ENABLE_GSHADOW + if (!FLAGS_SET(iterator->flags, USERDB_SUPPRESS_SHADOW)) { + r = nss_sgrp_for_group(gr, &sgrp, &buffer); + if (r < 0) { +@@ -1057,6 +1059,9 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) { + } + + r = nss_group_to_group_record(gr, r >= 0 ? &sgrp : NULL, ret); ++#else ++ r = nss_group_to_group_record(gr, NULL, ret); ++#endif + if (r < 0) + return r; + +-- +2.45.1 diff --git a/systemd-udevd/patches/0017-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch b/systemd-udevd/patches/0017-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch new file mode 100644 index 000000000..a7a641e0a --- /dev/null +++ b/systemd-udevd/patches/0017-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch @@ -0,0 +1,42 @@ +From 45bb63a1727097683acad23f270968026671ec6a Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 12 Apr 2021 23:44:53 -0700 +Subject: [PATCH 17/27] missing_syscall.h: Define MIPS ABI defines for musl + +musl does not define _MIPS_SIM_ABI32, _MIPS_SIM_NABI32, _MIPS_SIM_ABI64 +unlike glibc where these are provided by libc headers, therefore define +them here in case they are undefined + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + src/basic/missing_syscall.h | 6 ++++++ + src/shared/base-filesystem.c | 1 + + 2 files changed, 7 insertions(+) + +--- a/src/basic/missing_syscall.h ++++ b/src/basic/missing_syscall.h +@@ -20,6 +20,12 @@ + #include + #endif + ++#ifndef _MIPS_SIM_ABI32 ++#define _MIPS_SIM_ABI32 1 ++#define _MIPS_SIM_NABI32 2 ++#define _MIPS_SIM_ABI64 3 ++#endif ++ + #include "macro.h" + #include "missing_keyctl.h" + #include "missing_sched.h" +--- a/src/shared/base-filesystem.c ++++ b/src/shared/base-filesystem.c +@@ -20,6 +20,7 @@ + #include "string-util.h" + #include "umask-util.h" + #include "user-util.h" ++#include "missing_syscall.h" + + typedef struct BaseFilesystem { + const char *dir; /* directory or symlink to create */ diff --git a/systemd-udevd/patches/0019-Adjust-for-musl-headers.patch b/systemd-udevd/patches/0019-Adjust-for-musl-headers.patch new file mode 100644 index 000000000..fde6e1646 --- /dev/null +++ b/systemd-udevd/patches/0019-Adjust-for-musl-headers.patch @@ -0,0 +1,525 @@ +From 585e04673da62a8bf50e00fd6c1ae9ffc66c3b2f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 21 Jan 2022 22:19:37 -0800 +Subject: [PATCH 19/27] Adjust for musl headers + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj + +[Rebased for v255.1] +Signed-off-by: Chen Qi +--- + src/libsystemd-network/sd-dhcp6-client.c | 2 +- + src/network/netdev/bareudp.c | 2 +- + src/network/netdev/batadv.c | 2 +- + src/network/netdev/bond.c | 2 +- + src/network/netdev/bridge.c | 3 ++- + src/network/netdev/dummy.c | 2 +- + src/network/netdev/geneve.c | 2 +- + src/network/netdev/ifb.c | 2 +- + src/network/netdev/ipoib.c | 2 +- + src/network/netdev/ipvlan.c | 2 +- + src/network/netdev/macsec.c | 2 +- + src/network/netdev/macvlan.c | 2 +- + src/network/netdev/netdev.c | 2 +- + src/network/netdev/netdevsim.c | 2 +- + src/network/netdev/nlmon.c | 2 +- + src/network/netdev/tunnel.c | 2 +- + src/network/netdev/vcan.c | 2 +- + src/network/netdev/veth.c | 2 +- + src/network/netdev/vlan.c | 2 +- + src/network/netdev/vrf.c | 2 +- + src/network/netdev/vxcan.c | 2 +- + src/network/netdev/vxlan.c | 2 +- + src/network/netdev/wireguard.c | 2 +- + src/network/netdev/xfrm.c | 2 +- + src/network/networkd-dhcp-common.c | 3 ++- + src/network/networkd-dhcp-prefix-delegation.c | 3 ++- + src/network/networkd-dhcp-server.c | 2 +- + src/network/networkd-dhcp4.c | 2 +- + src/network/networkd-ipv6ll.c | 2 +- + src/network/networkd-link.c | 2 +- + src/network/networkd-ndisc.c | 2 +- + src/network/networkd-setlink.c | 2 +- + src/network/networkd-sysctl.c | 2 +- + src/shared/linux/ethtool.h | 3 ++- + src/shared/netif-util.c | 2 +- + src/udev/udev-builtin-net_id.c | 2 +- + 36 files changed, 40 insertions(+), 36 deletions(-) + +diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c +index 3e992d7cad..c7e1ff4dbf 100644 +--- a/src/libsystemd-network/sd-dhcp6-client.c ++++ b/src/libsystemd-network/sd-dhcp6-client.c +@@ -5,7 +5,7 @@ + + #include + #include +-#include ++//#include + #include + + #include "sd-dhcp6-client.h" +diff --git a/src/network/netdev/bareudp.c b/src/network/netdev/bareudp.c +index 1df886573b..c8b6714726 100644 +--- a/src/network/netdev/bareudp.c ++++ b/src/network/netdev/bareudp.c +@@ -2,7 +2,7 @@ + * Copyright © 2020 VMware, Inc. */ + + #include +-#include ++//#include + + #include "bareudp.h" + #include "netlink-util.h" +diff --git a/src/network/netdev/batadv.c b/src/network/netdev/batadv.c +index 26da0231d4..2e8002af8c 100644 +--- a/src/network/netdev/batadv.c ++++ b/src/network/netdev/batadv.c +@@ -3,7 +3,7 @@ + #include + #include + #include +-#include ++//#include + + #include "batadv.h" + #include "fileio.h" +diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c +index 52a7f126b6..74ca0812db 100644 +--- a/src/network/netdev/bond.c ++++ b/src/network/netdev/bond.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include + + #include "alloc-util.h" + #include "bond.h" +diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c +index d426c0c501..14432adb95 100644 +--- a/src/network/netdev/bridge.c ++++ b/src/network/netdev/bridge.c +@@ -2,7 +2,8 @@ + + /* Make sure the net/if.h header is included before any linux/ one */ + #include +-#include ++#include ++//#include + #include + #include + +diff --git a/src/network/netdev/dummy.c b/src/network/netdev/dummy.c +index 00df1d2787..77b506b422 100644 +--- a/src/network/netdev/dummy.c ++++ b/src/network/netdev/dummy.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include ++//#include + + #include "dummy.h" + +diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c +index 22c2b00e1b..1d762c4911 100644 +--- a/src/network/netdev/geneve.c ++++ b/src/network/netdev/geneve.c +@@ -2,7 +2,7 @@ + + /* Make sure the net/if.h header is included before any linux/ one */ + #include +-#include ++//#include + #include + + #include "alloc-util.h" +diff --git a/src/network/netdev/ifb.c b/src/network/netdev/ifb.c +index d7ff44cb9e..e037629ae4 100644 +--- a/src/network/netdev/ifb.c ++++ b/src/network/netdev/ifb.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright © 2019 VMware, Inc. */ + +-#include ++//#include + + #include "ifb.h" + +diff --git a/src/network/netdev/ipoib.c b/src/network/netdev/ipoib.c +index d5fe299b7b..c9c8002eac 100644 +--- a/src/network/netdev/ipoib.c ++++ b/src/network/netdev/ipoib.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include ++//#include + #include + + #include "ipoib.h" +diff --git a/src/network/netdev/ipvlan.c b/src/network/netdev/ipvlan.c +index 51ae64341d..46460efabd 100644 +--- a/src/network/netdev/ipvlan.c ++++ b/src/network/netdev/ipvlan.c +@@ -3,7 +3,7 @@ + /* Make sure the net/if.h header is included before any linux/ one */ + #include + #include +-#include ++//#include + + #include "conf-parser.h" + #include "ipvlan.h" +diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c +index 4b9f19cc95..6c4951a7e6 100644 +--- a/src/network/netdev/macsec.c ++++ b/src/network/netdev/macsec.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include + #include + #include + #include +diff --git a/src/network/netdev/macvlan.c b/src/network/netdev/macvlan.c +index 21933d3970..a4ace19dc6 100644 +--- a/src/network/netdev/macvlan.c ++++ b/src/network/netdev/macvlan.c +@@ -3,7 +3,7 @@ + /* Make sure the net/if.h header is included before any linux/ one */ + #include + #include +-#include ++//#include + + #include "conf-parser.h" + #include "macvlan.h" +diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c +index 2b411425ba..fe00200135 100644 +--- a/src/network/netdev/netdev.c ++++ b/src/network/netdev/netdev.c +@@ -3,7 +3,7 @@ + /* Make sure the net/if.h header is included before any linux/ one */ + #include + #include +-#include ++//#include + #include + + #include "alloc-util.h" +diff --git a/src/network/netdev/netdevsim.c b/src/network/netdev/netdevsim.c +index 15d5c132f9..a3ffa48b15 100644 +--- a/src/network/netdev/netdevsim.c ++++ b/src/network/netdev/netdevsim.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include ++//#include + + #include "netdevsim.h" + +diff --git a/src/network/netdev/nlmon.c b/src/network/netdev/nlmon.c +index ff372092e6..eef66811f4 100644 +--- a/src/network/netdev/nlmon.c ++++ b/src/network/netdev/nlmon.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include ++//#include + + #include "nlmon.h" + +diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c +index db84e7cf6e..93d5642962 100644 +--- a/src/network/netdev/tunnel.c ++++ b/src/network/netdev/tunnel.c +@@ -2,7 +2,7 @@ + + #include + #include +-#include ++//#include + #include + #include + #include +diff --git a/src/network/netdev/vcan.c b/src/network/netdev/vcan.c +index 380547ee1e..137c1adf8a 100644 +--- a/src/network/netdev/vcan.c ++++ b/src/network/netdev/vcan.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include ++//#include + + #include "vcan.h" + +diff --git a/src/network/netdev/veth.c b/src/network/netdev/veth.c +index 78555286d1..e7eff072e4 100644 +--- a/src/network/netdev/veth.c ++++ b/src/network/netdev/veth.c +@@ -3,7 +3,7 @@ + /* Make sure the net/if.h header is included before any linux/ one */ + #include + #include +-#include ++//#include + #include + #include + +diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c +index 60e49a5b8a..266fd58813 100644 +--- a/src/network/netdev/vlan.c ++++ b/src/network/netdev/vlan.c +@@ -3,7 +3,7 @@ + /* Make sure the net/if.h header is included before any linux/ one */ + #include + #include +-#include ++//#include + #include + + #include "parse-util.h" +diff --git a/src/network/netdev/vrf.c b/src/network/netdev/vrf.c +index 24079a7203..33ff17ea82 100644 +--- a/src/network/netdev/vrf.c ++++ b/src/network/netdev/vrf.c +@@ -2,8 +2,8 @@ + + /* Make sure the net/if.h header is included before any linux/ one */ + #include +-#include + #include ++//#include + + #include "vrf.h" + +diff --git a/src/network/netdev/vxcan.c b/src/network/netdev/vxcan.c +index c0343f45b6..f9e718f40b 100644 +--- a/src/network/netdev/vxcan.c ++++ b/src/network/netdev/vxcan.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include + + #include "vxcan.h" + +diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c +index 37f65967a6..bdd8848a02 100644 +--- a/src/network/netdev/vxlan.c ++++ b/src/network/netdev/vxlan.c +@@ -3,7 +3,7 @@ + /* Make sure the net/if.h header is included before any linux/ one */ + #include + #include +-#include ++//#include + + #include "conf-parser.h" + #include "alloc-util.h" +diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c +index fed1be8d11..94b659fd23 100644 +--- a/src/network/netdev/wireguard.c ++++ b/src/network/netdev/wireguard.c +@@ -5,7 +5,7 @@ + + /* Make sure the net/if.h header is included before any linux/ one */ + #include +-#include ++//#include + #include + #include + #include +diff --git a/src/network/netdev/xfrm.c b/src/network/netdev/xfrm.c +index 905bfc0bdf..39e34dbb3b 100644 +--- a/src/network/netdev/xfrm.c ++++ b/src/network/netdev/xfrm.c +@@ -1,6 +1,6 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include ++//#include + + #include "missing_network.h" + #include "xfrm.h" +diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c +index 9f0268d934..8cd605ab4a 100644 +--- a/src/network/networkd-dhcp-common.c ++++ b/src/network/networkd-dhcp-common.c +@@ -1,7 +1,8 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include ++#include + + #include "bus-error.h" + #include "bus-locator.h" +diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c +index 2e660b7763..b8dd6240a0 100644 +--- a/src/network/networkd-dhcp-prefix-delegation.c ++++ b/src/network/networkd-dhcp-prefix-delegation.c +@@ -1,6 +1,5 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include + + #include "dhcp6-lease-internal.h" + #include "hashmap.h" +@@ -20,6 +19,8 @@ + #include "strv.h" + #include "tunnel.h" + ++#include ++ + bool link_dhcp_pd_is_enabled(Link *link) { + assert(link); + +diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c +index c35102af74..3be469ae16 100644 +--- a/src/network/networkd-dhcp-server.c ++++ b/src/network/networkd-dhcp-server.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include + #include + + #include "sd-dhcp-server.h" +diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c +index 4dd6044b18..15a598f9db 100644 +--- a/src/network/networkd-dhcp4.c ++++ b/src/network/networkd-dhcp4.c +@@ -3,7 +3,7 @@ + #include + #include + #include +-#include ++//#include + + #include "alloc-util.h" + #include "dhcp-client-internal.h" +diff --git a/src/network/networkd-ipv6ll.c b/src/network/networkd-ipv6ll.c +index 32229a3fc7..662a345d6e 100644 +--- a/src/network/networkd-ipv6ll.c ++++ b/src/network/networkd-ipv6ll.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include + + #include "in-addr-util.h" + #include "networkd-address.h" +diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c +index 6b0f09926a..81f44f6e6a 100644 +--- a/src/network/networkd-link.c ++++ b/src/network/networkd-link.c +@@ -4,7 +4,7 @@ + #include + #include + #include +-#include ++//#include + #include + #include + #include +diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c +index 7cafe1f6a3..07c293c9a6 100644 +--- a/src/network/networkd-ndisc.c ++++ b/src/network/networkd-ndisc.c +@@ -6,7 +6,7 @@ + #include + #include + #include +-#include ++//#include + + #include "sd-ndisc.h" + +diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c +index 058bc00ba1..bb0a430a0b 100644 +--- a/src/network/networkd-setlink.c ++++ b/src/network/networkd-setlink.c +@@ -2,7 +2,7 @@ + + #include + #include +-#include ++//#include + #include + + #include "missing_network.h" +diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c +index 68c23e0eb7..e177c49d9b 100644 +--- a/src/network/networkd-sysctl.c ++++ b/src/network/networkd-sysctl.c +@@ -2,7 +2,7 @@ + + #include + #include +-#include ++//#include + + #include "af-list.h" + #include "missing_network.h" +diff --git a/src/shared/linux/ethtool.h b/src/shared/linux/ethtool.h +index 3d1da515c0..3fca9a4faf 100644 +--- a/src/shared/linux/ethtool.h ++++ b/src/shared/linux/ethtool.h +@@ -16,7 +16,8 @@ + + #include + #include +-#include ++#include ++//#include + + #include /* for INT_MAX */ + +diff --git a/src/shared/netif-util.c b/src/shared/netif-util.c +index 8adc2c89c8..1977e28d7f 100644 +--- a/src/shared/netif-util.c ++++ b/src/shared/netif-util.c +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + + #include +-#include ++//#include + + #include "arphrd-util.h" + #include "device-util.h" +diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c +index 384a1f31cb..c94bb70afb 100644 +--- a/src/udev/udev-builtin-net_id.c ++++ b/src/udev/udev-builtin-net_id.c +@@ -19,7 +19,7 @@ + #include + #include + #include +-#include ++//#include + #include + #include + +-- +2.45.1 diff --git a/systemd-udevd/patches/0022-sd-event-Make-malloc_trim-conditional-on-glibc.patch b/systemd-udevd/patches/0022-sd-event-Make-malloc_trim-conditional-on-glibc.patch new file mode 100644 index 000000000..58b02976b --- /dev/null +++ b/systemd-udevd/patches/0022-sd-event-Make-malloc_trim-conditional-on-glibc.patch @@ -0,0 +1,38 @@ +From 4a3ed5aaaf108d3a07f24997698906e801ba2412 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 2 Aug 2023 12:06:27 -0700 +Subject: [PATCH 22/27] sd-event: Make malloc_trim() conditional on glibc + +musl does not have this API + +Upstream-Status: Inappropriate [musl-specific] +Signed-off-by: Khem Raj +--- + src/libsystemd/sd-event/sd-event.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c +index a1305ef014..b8a73da2a3 100644 +--- a/src/libsystemd/sd-event/sd-event.c ++++ b/src/libsystemd/sd-event/sd-event.c +@@ -1877,7 +1877,7 @@ _public_ int sd_event_add_exit( + } + + _public_ int sd_event_trim_memory(void) { +- int r; ++ int r = 0; + + /* A default implementation of a memory pressure callback. Simply releases our own allocation caches + * and glibc's. This is automatically used when people call sd_event_add_memory_pressure() with a +@@ -1891,7 +1891,9 @@ _public_ int sd_event_trim_memory(void) { + + usec_t before_timestamp = now(CLOCK_MONOTONIC); + hashmap_trim_pools(); ++#ifdef __GLIBC__ + r = malloc_trim(0); ++#endif + usec_t after_timestamp = now(CLOCK_MONOTONIC); + + if (r > 0) +-- +2.45.1 diff --git a/systemd-udevd/patches/0023-shared-Do-not-use-malloc_info-on-musl.patch b/systemd-udevd/patches/0023-shared-Do-not-use-malloc_info-on-musl.patch new file mode 100644 index 000000000..149254380 --- /dev/null +++ b/systemd-udevd/patches/0023-shared-Do-not-use-malloc_info-on-musl.patch @@ -0,0 +1,56 @@ +From d3880d167d8dfafbb8ee62f7737a869f9525f303 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 2 Aug 2023 12:20:40 -0700 +Subject: [PATCH 23/27] shared: Do not use malloc_info on musl + +Upstream-Status: Inappropriate [musl-specific] +Signed-off-by: Khem Raj +--- + src/shared/bus-util.c | 5 +++-- + src/shared/common-signal.c | 4 ++-- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c +index 30f9602b1e..5308f168db 100644 +--- a/src/shared/bus-util.c ++++ b/src/shared/bus-util.c +@@ -755,15 +755,16 @@ static int method_dump_memory_state_by_fd(sd_bus_message *message, void *userdat + _cleanup_close_ int fd = -EBADF; + size_t dump_size; + FILE *f; +- int r; ++ int r = 0; + + assert(message); + + f = memstream_init(&m); + if (!f) + return -ENOMEM; +- ++#ifdef __GLIBC__ + r = RET_NERRNO(malloc_info(/* options= */ 0, f)); ++#endif + if (r < 0) + return r; + +diff --git a/src/shared/common-signal.c b/src/shared/common-signal.c +index 8e70e365dd..9e782caec9 100644 +--- a/src/shared/common-signal.c ++++ b/src/shared/common-signal.c +@@ -65,12 +65,12 @@ int sigrtmin18_handler(sd_event_source *s, const struct signalfd_siginfo *si, vo + log_oom(); + break; + } +- ++#ifdef __GLIBC__ + if (malloc_info(0, f) < 0) { + log_error_errno(errno, "Failed to invoke malloc_info(): %m"); + break; + } +- ++#endif + (void) memstream_dump(LOG_INFO, &m); + break; + } +-- +2.45.1 diff --git a/systemd-udevd/patches/0024-avoid-missing-LOCK_EX-declaration.patch b/systemd-udevd/patches/0024-avoid-missing-LOCK_EX-declaration.patch new file mode 100644 index 000000000..3cfff7375 --- /dev/null +++ b/systemd-udevd/patches/0024-avoid-missing-LOCK_EX-declaration.patch @@ -0,0 +1,55 @@ +From ca2a736627f8ee8dd9dbbf5b3149d4c8493833ff Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Tue, 2 Jan 2024 11:03:27 +0800 +Subject: [PATCH 24/27] avoid missing LOCK_EX declaration + +This only happens on MUSL. Include sys/file.h to avoid compilation +error about missing LOCK_EX declaration. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/basic/fd-util.h | 1 + + src/core/exec-invoke.c | 1 + + src/shared/dev-setup.h | 1 + + 3 files changed, 3 insertions(+) + +diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h +index af17481dd8..fa20bfa30f 100644 +--- a/src/basic/fd-util.h ++++ b/src/basic/fd-util.h +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + + #include "macro.h" + #include "missing_fcntl.h" +diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c +index ee8db04e76..2aff654f0f 100644 +--- a/src/core/exec-invoke.c ++++ b/src/core/exec-invoke.c +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + + #if HAVE_PAM + #include +diff --git a/src/shared/dev-setup.h b/src/shared/dev-setup.h +index 5339bc4e5e..0697495f23 100644 +--- a/src/shared/dev-setup.h ++++ b/src/shared/dev-setup.h +@@ -2,6 +2,7 @@ + #pragma once + + #include ++#include + + int lock_dev_console(void); + +-- +2.45.1 diff --git a/systemd-udevd/patches/0025-include-signal.h-to-avoid-the-undeclared-error.patch b/systemd-udevd/patches/0025-include-signal.h-to-avoid-the-undeclared-error.patch new file mode 100644 index 000000000..646fac172 --- /dev/null +++ b/systemd-udevd/patches/0025-include-signal.h-to-avoid-the-undeclared-error.patch @@ -0,0 +1,26 @@ +From ecf124ab2e488a71741fe443ff4863f7ed172968 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Tue, 2 Jul 2024 22:18:47 -0700 +Subject: [PATCH 25/27] include signal.h to avoid the 'undeclared' error + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/basic/pidref.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/basic/pidref.h b/src/basic/pidref.h +index 9920ebb9b3..2fdd4ff50f 100644 +--- a/src/basic/pidref.h ++++ b/src/basic/pidref.h +@@ -1,6 +1,7 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + #pragma once + ++#include + #include "macro.h" + + /* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes continuously. */ +-- +2.45.1 diff --git a/systemd-udevd/patches/0026-undef-stdin-for-references-using-stdin-as-a-struct-m.patch b/systemd-udevd/patches/0026-undef-stdin-for-references-using-stdin-as-a-struct-m.patch new file mode 100644 index 000000000..acbb82033 --- /dev/null +++ b/systemd-udevd/patches/0026-undef-stdin-for-references-using-stdin-as-a-struct-m.patch @@ -0,0 +1,47 @@ +From 787606c6ff822fb3fe41ba951ee289bbf6d4def3 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Tue, 2 Jul 2024 22:44:31 -0700 +Subject: [PATCH 26/27] undef stdin for references using stdin as a struct + member + +In musl stdio.h, we have: +include/stdio.h:#define stdin (stdin) + +This causes error when a struct member is also named stdin. undef it. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/shared/edit-util.c | 2 ++ + src/systemctl/systemctl-edit.c | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/src/shared/edit-util.c b/src/shared/edit-util.c +index cfb2828f4e..1794a7b269 100644 +--- a/src/shared/edit-util.c ++++ b/src/shared/edit-util.c +@@ -3,6 +3,8 @@ + #include + #include + ++#undef stdin ++ + #include "alloc-util.h" + #include "copy.h" + #include "edit-util.h" +diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c +index 15398f8364..e7d53ca9a1 100644 +--- a/src/systemctl/systemctl-edit.c ++++ b/src/systemctl/systemctl-edit.c +@@ -13,6 +13,8 @@ + #include "systemctl.h" + #include "terminal-util.h" + ++#undef stdin ++ + int verb_cat(int argc, char *argv[], void *userdata) { + _cleanup_hashmap_free_ Hashmap *cached_id_map = NULL, *cached_name_map = NULL; + _cleanup_(lookup_paths_done) LookupPaths lp = {}; +-- +2.45.1 diff --git a/systemd-udevd/patches/0027-adjust-header-inclusion-order-to-avoid-redeclaration.patch b/systemd-udevd/patches/0027-adjust-header-inclusion-order-to-avoid-redeclaration.patch new file mode 100644 index 000000000..f3d650e88 --- /dev/null +++ b/systemd-udevd/patches/0027-adjust-header-inclusion-order-to-avoid-redeclaration.patch @@ -0,0 +1,75 @@ +From cf94d43572770007f95b832f477aa5a03624a1e5 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Tue, 2 Jul 2024 23:23:57 -0700 +Subject: [PATCH 27/27] adjust header inclusion order to avoid redeclaration + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/network/netdev/wireguard.c | 2 +- + src/network/networkd-bridge-mdb.c | 3 ++- + src/network/networkd-route.c | 6 +++--- + 3 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c +index 94b659fd23..a78ad5762d 100644 +--- a/src/network/netdev/wireguard.c ++++ b/src/network/netdev/wireguard.c +@@ -5,9 +5,9 @@ + + /* Make sure the net/if.h header is included before any linux/ one */ + #include ++#include + //#include + #include +-#include + #include + + #include "sd-resolve.h" +diff --git a/src/network/networkd-bridge-mdb.c b/src/network/networkd-bridge-mdb.c +index 7ff4a18846..fe1a9cf888 100644 +--- a/src/network/networkd-bridge-mdb.c ++++ b/src/network/networkd-bridge-mdb.c +@@ -2,7 +2,6 @@ + + /* Make sure the net/if.h header is included before any linux/ one */ + #include +-#include + + #include "netlink-util.h" + #include "networkd-bridge-mdb.h" +@@ -13,6 +12,8 @@ + #include "string-util.h" + #include "vlan-util.h" + ++#include ++ + #define STATIC_BRIDGE_MDB_ENTRIES_PER_NETWORK_MAX 1024U + + /* remove MDB entry. */ +diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c +index d596fd81e6..0dc0d2a7a3 100644 +--- a/src/network/networkd-route.c ++++ b/src/network/networkd-route.c +@@ -1,8 +1,5 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + +-#include +-#include +- + #include "alloc-util.h" + #include "event-util.h" + #include "netlink-util.h" +@@ -20,6 +17,9 @@ + #include "vrf.h" + #include "wireguard.h" + ++#include ++#include ++ + static Route* route_detach_impl(Route *route) { + assert(route); + assert(!!route->network + !!route->manager + !!route->wireguard <= 1); +-- +2.45.1 diff --git a/systemd-udevd/patches/0028-build-path.c-avoid-boot-time-segfault-for-musl.patch b/systemd-udevd/patches/0028-build-path.c-avoid-boot-time-segfault-for-musl.patch new file mode 100644 index 000000000..3ce494b15 --- /dev/null +++ b/systemd-udevd/patches/0028-build-path.c-avoid-boot-time-segfault-for-musl.patch @@ -0,0 +1,30 @@ +From 0e4379088b1cf607b605b785f6f23943ebeb6584 Mon Sep 17 00:00:00 2001 +From: Chen Qi +Date: Wed, 3 Jul 2024 07:18:42 -0700 +Subject: [PATCH 28/28] build-path.c: avoid boot time segfault for musl + +This function, at runtime, should return -ENOEXEC. For musl, it +somehow segfaults. I think it's related to getauxval, but it's +really does not matter, just return -ENOEXEC. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi +--- + src/basic/build-path.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/basic/build-path.c b/src/basic/build-path.c +index b5972658df..4ef551034e 100644 +--- a/src/basic/build-path.c ++++ b/src/basic/build-path.c +@@ -151,6 +151,7 @@ int get_build_exec_dir(char **ret) { + */ + + static int runpath_cached = -ERRNO_MAX-1; ++ return -ENOEXEC; + if (runpath_cached == -ERRNO_MAX-1) { + const char *runpath = NULL; + +-- +2.45.1 diff --git a/systemd-udevd/pkg.yaml b/systemd-udevd/pkg.yaml new file mode 100644 index 000000000..56adb9397 --- /dev/null +++ b/systemd-udevd/pkg.yaml @@ -0,0 +1,134 @@ +name: systemd-udevd +variant: scratch +shell: /toolchain/bin/bash +dependencies: + - stage: base + - stage: openssl # for pip + - stage: util-linux + - stage: libselinux + - stage: libcap # runtime-dependency of systemd-hwdb + - stage: libsepol # runtime-dependency of systemd-hwdb + - stage: pcre2 # runtime-dependency of systemd-hwdb +steps: + - sources: + - url: https://github.com/systemd/systemd/archive/refs/tags/v{{ .systemd_version }}.tar.gz + destination: systemd.tar.gz + sha256: "{{ .systemd_sha256 }}" + sha512: "{{ .systemd_sha512 }}" + env: + SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }} + prepare: + - | + tar -xzf systemd.tar.gz --strip-components=1 + ln -s /toolchain/bin/echo /toolchain/bin/getent + mkdir -p /usr/bin + ln -sf /toolchain/bin/env /usr/bin/env + ln -sf /toolchain/bin/python3 /toolchain/bin/python + + pip3 install jinja2 ninja + + # Patches for musl from openembedded-core, MIT licensed + # Also replicated by Chimera Linux: https://github.com/chimera-linux/cports/tree/001642bd7691349e95574d93e325bb05d5dcb2c1/main/udev/patches + patch -p1 < /pkg/patches/0004-missing_type.h-add-comparison_fn_t.patch + patch -p1 < /pkg/patches/0005-add-fallback-parse_printf_format-implementation.patch + patch -p1 < /pkg/patches/0006-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch + patch -p1 < /pkg/patches/0008-Use-uintmax_t-for-handling-rlim_t.patch + patch -p1 < /pkg/patches/0009-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch + patch -p1 < /pkg/patches/0010-Define-glibc-compatible-basename-for-non-glibc-syste.patch + patch -p1 < /pkg/patches/0011-Do-not-disable-buffering-when-writing-to-oom_score_a.patch + patch -p1 < /pkg/patches/0012-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch + patch -p1 < /pkg/patches/0013-avoid-redefinition-of-prctl_mm_map-structure.patch + patch -p1 < /pkg/patches/0014-do-not-disable-buffer-in-writing-files.patch + patch -p1 < /pkg/patches/0016-Handle-missing-gshadow.patch + patch -p1 < /pkg/patches/0017-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch + patch -p1 < /pkg/patches/0019-Adjust-for-musl-headers.patch + patch -p1 < /pkg/patches/0022-sd-event-Make-malloc_trim-conditional-on-glibc.patch + patch -p1 < /pkg/patches/0023-shared-Do-not-use-malloc_info-on-musl.patch + patch -p1 < /pkg/patches/0024-avoid-missing-LOCK_EX-declaration.patch + patch -p1 < /pkg/patches/0025-include-signal.h-to-avoid-the-undeclared-error.patch + patch -p1 < /pkg/patches/0026-undef-stdin-for-references-using-stdin-as-a-struct-m.patch + patch -p1 < /pkg/patches/0027-adjust-header-inclusion-order-to-avoid-redeclaration.patch + patch -p1 < /pkg/patches/0028-build-path.c-avoid-boot-time-segfault-for-musl.patch + + # Own patches + patch -p1 < /pkg/patches/0001-chore-musl-headers-compatibility-for-udev.patch + + meson setup build \ + --buildtype=release \ + -Dmode=release \ + -Dlibdir=/usr/lib \ + -Dversion-tag="{{ .systemd_version }}-talos" \ + -Dselinux=enabled \ + -Dblkid=enabled \ + -Dkmod=enabled \ + -Dopenssl=disabled \ + -Dgshadow=false \ + -Dutmp=false \ + -Duserdb=false \ + -Ddbus=disabled \ + -Dglib=disabled \ + -Dnss-mymachines=disabled \ + -Dnss-myhostname=false \ + -Dnss-resolve=disabled \ + -Dnss-systemd=false \ + -Dbacklight=false \ + -Dbinfmt=false \ + -Dbpf-framework=disabled \ + -Dcoredump=false \ + -Denvironment-d=false \ + -Dfirstboot=false \ + -Dhibernate=false \ + -Dhostnamed=false \ + -Dlink-udev-shared=false \ + -Dlogind=false \ + -Dmachined=false \ + -Dnetworkd=false \ + -Doomd=false \ + -Dportabled=false \ + -Dsysext=false \ + -Danalyze=false \ + -Dtimedated=false \ + -Dtimesyncd=false \ + -Dtmpfiles=false \ + -Dpolkit=disabled \ + -Dstatic-libudev=true \ + -Dman=disabled \ + -Dtests=false \ + -Dwerror=false + build: + - | + meson compile -C build + install: + - | + meson install -C build --destdir /installroot + + mkdir -p /rootfs/usr/bin + cp /installroot/usr/bin/udevadm /rootfs/usr/bin/ + + mkdir -p /rootfs/sbin + ln -s /usr/bin/udevadm /rootfs/sbin/udevadm + ln -s /usr/bin/udevadm /rootfs/sbin/systemd-udevd + + mkdir -p /rootfs/usr/lib/pkgconfig/ + mkdir -p /rootfs/usr/share/pkgconfig/ + cp /installroot/usr/lib/pkgconfig/libudev.pc /rootfs/usr/lib/pkgconfig/ + cp /installroot/usr/share/pkgconfig/udev.pc /rootfs/usr/share/pkgconfig/ + + mkdir -p /rootfs/usr/etc/ + cp -r /installroot/etc/udev /rootfs/usr/etc/ + cp -r /installroot/usr/include /rootfs/usr/ + + # Build hwdb.bin + /installroot/usr/bin/systemd-hwdb update --root=/installroot --usr --strict + + mkdir -p /rootfs/usr/lib/ + cp -r /installroot/usr/lib/udev /rootfs/usr/lib/ + cp --preserve=links /installroot/usr/lib/libudev.* /rootfs/usr/lib/ + # Already built this + rm -rf /rootfs/usr/lib/udev/hwdb.d + rm -f /rootfs/usr/lib/udev/rules.d/{README,60-cdrom_id.rules,60-persistent-alsa.rules,60-persistent-v4l.rules,64-btrfs.rules,70-joystick.rules,70-mouse.rules,70-touchpad.rules,78-sound-card.rules,80-net-name-slot.rules,90-vconsole.rules,99-systemd.rules} + # Azure csi support + cp /pkg/files/66-azure.rules /rootfs/usr/lib/udev/rules.d/66-azure.rules +finalize: + - from: /rootfs + to: /