Complete Yocto mirror with license table for TQMa6UL (2038-compliance)

- 264 license table entries with exact download URLs (224/264 resolved)
- Complete sources/ directory with all BitBake recipes
- Build configuration: tqma6ul-multi-mba6ulx, spaetzle (musl)
- Full traceability for Softwarefreigabeantrag
- GCC 13.4.0, Linux 6.6.102, U-Boot 2023.04, musl 1.2.4
- License distribution: GPL-2.0 (24), MIT (23), GPL-2.0+ (18), BSD-3 (16)
This commit is contained in:
Siggi (OpenClaw Agent)
2026-03-01 20:58:18 +00:00
commit 16accb6b24
15086 changed files with 1292356 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
require systemd.inc
inherit native
deltask do_configure
deltask do_compile
do_install () {
install -Dm 0755 ${S}/src/ukify/ukify.py ${D}${bindir}/ukify
}
addtask install after do_unpack
PACKAGES = "${PN}"
FILES:${PN} = "${bindir}/ukify"

View File

@@ -0,0 +1,67 @@
require systemd.inc
FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:"
require conf/image-uefi.conf
DEPENDS = "libcap util-linux gperf-native python3-jinja2-native python3-pyelftools-native"
inherit meson pkgconfig gettext
inherit deploy
LDFLAGS:prepend = "${@ " ".join(d.getVar('LD').split()[1:])} "
EFI_LD = "bfd"
LDFLAGS:append = " -fuse-ld=${EFI_LD}"
do_write_config[vardeps] += "EFI_LD"
do_write_config:append() {
cat >${WORKDIR}/meson-${PN}.cross <<EOF
[binaries]
c_ld = ${@meson_array('EFI_LD', d)}
EOF
}
MESON_CROSS_FILE:append = " --cross-file ${WORKDIR}/meson-${PN}.cross"
MESON_TARGET = "systemd-boot"
EXTRA_OEMESON += "-Defi=true \
-Dbootloader=true \
-Dman=false \
"
# install to the image as boot*.efi if its the EFI_PROVIDER,
# otherwise install as the full name.
# This allows multiple bootloaders to coexist in a single image.
python __anonymous () {
import re
target = d.getVar('TARGET_ARCH')
prefix = "" if d.getVar('EFI_PROVIDER') == "systemd-boot" else "systemd-"
systemdimage = prefix + d.getVar("EFI_BOOT_IMAGE")
d.setVar("SYSTEMD_BOOT_IMAGE", systemdimage)
prefix = "systemd-" if prefix == "" else ""
d.setVar("SYSTEMD_BOOT_IMAGE_PREFIX", prefix)
}
FILES:${PN} = "${EFI_FILES_PATH}/${SYSTEMD_BOOT_IMAGE}"
RDEPENDS:${PN} += "virtual-systemd-bootconf"
CFLAGS:append:libc-musl = " -D__DEFINED_wchar_t"
COMPATIBLE_HOST = "(aarch64.*|arm.*|x86_64.*|i.86.*)-linux"
COMPATIBLE_HOST:x86-x32 = "null"
do_install() {
install -d ${D}${EFI_FILES_PATH}
install ${B}/src/boot/efi/systemd-boot*.efi ${D}${EFI_FILES_PATH}/${SYSTEMD_BOOT_IMAGE}
}
do_deploy () {
install ${B}/src/boot/efi/systemd-boot*.efi ${DEPLOYDIR}
install ${B}/src/boot/efi/linux*.efi.stub ${DEPLOYDIR}
install ${B}/src/boot/efi/addon*.efi.stub ${DEPLOYDIR}
}
addtask deploy before do_build after do_compile

View File

@@ -0,0 +1,32 @@
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
SUMMARY = "Basic systemd-boot configuration files"
RPROVIDES:${PN} += "virtual-systemd-bootconf"
PACKAGE_ARCH = "${MACHINE_ARCH}"
inherit systemd-boot-cfg
S = "${WORKDIR}"
LABELS = "boot"
ROOT ?= "root=/dev/sda2"
APPEND:append = " ${ROOT}"
python do_configure() {
bb.build.exec_func('build_efi_cfg', d)
}
do_configure[vardeps] += "APPEND"
do_install() {
install -d ${D}/boot
install -d ${D}/boot/loader
install -d ${D}/boot/loader/entries
install loader.conf ${D}/boot/loader/
rm loader.conf
install *.conf ${D}/boot/loader/entries/
}
FILES:${PN} = "/boot/loader/* /boot/loader/entries/*"

View File

@@ -0,0 +1,50 @@
SUMMARY = "Enhances systemd compatilibity with existing SysVinit scripts"
HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd"
LICENSE = "MIT"
PACKAGE_WRITE_DEPS += "systemd-systemctl-native"
S = "${WORKDIR}"
inherit features_check
INHIBIT_DEFAULT_DEPS = "1"
ALLOW_EMPTY:${PN} = "1"
REQUIRED_DISTRO_FEATURES += "systemd"
REQUIRED_DISTRO_FEATURES += "usrmerge"
SYSTEMD_DISABLED_SYSV_SERVICES = " \
busybox-udhcpc \
hwclock \
networking \
nfsserver \
nfscommon \
syslog.busybox \
"
pkg_postinst:${PN} () {
test -d $D${sysconfdir}/init.d || exit 0
cd $D${sysconfdir}/init.d
echo "Disabling the following sysv scripts: "
if [ -n "$D" ]; then
OPTS="--root=$D"
else
OPTS=""
fi
for i in ${SYSTEMD_DISABLED_SYSV_SERVICES} ; do
if [ -e $i -o -e $i.sh ] && ! [ -e $D${sysconfdir}/systemd/system/$i.service -o -e $D${systemd_system_unitdir}/$i.service ] ; then
echo -n "$i: "
systemctl $OPTS mask $i.service
fi
done
echo
}
RDEPENDS:${PN} = "systemd"

View File

@@ -0,0 +1,3 @@
[Journal]
ForwardToSyslog=yes
RuntimeMaxUse=64M

View File

@@ -0,0 +1,2 @@
[Login]
KillUserProcesses=yes

View File

@@ -0,0 +1,2 @@
[Manager]
DefaultMemoryAccounting=yes

View File

@@ -0,0 +1,3 @@
[Manager]
# Change DefaultTimeoutStartSec from 90s to 240s
DefaultTimeoutStartSec = 240s

View File

@@ -0,0 +1,13 @@
[Match]
Type=ether
Name=!veth*
KernelCommandLine=!nfsroot
KernelCommandLine=!ip
[Network]
DHCP=yes
[DHCP]
UseMTU=yes
RouteMetric=10
ClientIdentifier=mac

View File

@@ -0,0 +1,46 @@
SUMMARY = "Systemd system configuration"
DESCRIPTION = "Systemd may require slightly different configuration for \
different machines. For example, qemu machines require a longer \
DefaultTimeoutStartSec setting."
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
inherit features_check
REQUIRED_DISTRO_FEATURES += "usrmerge"
PE = "1"
PACKAGECONFIG ??= "dhcp-ethernet"
PACKAGECONFIG[dhcp-ethernet] = ""
SRC_URI = "\
file://journald.conf \
file://logind.conf \
file://system.conf \
file://system.conf-qemuall \
file://wired.network \
"
do_install() {
install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf
install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf
install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf
if ${@bb.utils.contains('PACKAGECONFIG', 'dhcp-ethernet', 'true', 'false', d)}; then
install -D -m0644 ${WORKDIR}/wired.network ${D}${systemd_unitdir}/network/80-wired.network
fi
}
# Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
do_install:append:qemuall() {
install -D -m0644 ${WORKDIR}/system.conf-qemuall ${D}${systemd_unitdir}/system.conf.d/01-${PN}.conf
}
PACKAGE_ARCH = "${MACHINE_ARCH}"
FILES:${PN} = "\
${systemd_unitdir}/journald.conf.d/ \
${systemd_unitdir}/logind.conf.d/ \
${systemd_unitdir}/system.conf.d/ \
${systemd_unitdir}/network/ \
"

View File

@@ -0,0 +1,13 @@
SUMMARY = "Machine specific systemd units"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PACKAGE_ARCH = "${MACHINE_ARCH}"
inherit systemd features_check
REQUIRED_DISTRO_FEATURES += "usrmerge"
SYSTEMD_SERVICE:${PN} = ""
ALLOW_EMPTY:${PN} = "1"

View File

@@ -0,0 +1,52 @@
SUMMARY = "Serial terminal support for systemd"
HOMEPAGE = "https://www.freedesktop.org/wiki/Software/systemd/"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
SERIAL_CONSOLES ?= "115200;ttyS0"
SERIAL_TERM ?= "linux"
SRC_URI = "file://serial-getty@.service"
S = "${WORKDIR}"
# As this package is tied to systemd, only build it when we're also building systemd.
inherit features_check
REQUIRED_DISTRO_FEATURES += "systemd"
REQUIRED_DISTRO_FEATURES += "usrmerge"
do_install() {
if [ ! -z "${SERIAL_CONSOLES}" ] ; then
default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
install -d ${D}${systemd_system_unitdir}/
install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_system_unitdir}/
sed -i -e "s/\@BAUDRATE\@/$default_baudrate/g" ${D}${systemd_system_unitdir}/serial-getty@.service
sed -i -e "s/\@TERM\@/${SERIAL_TERM}/g" ${D}${systemd_system_unitdir}/serial-getty@.service
tmp="${SERIAL_CONSOLES}"
for entry in $tmp ; do
baudrate=`echo $entry | sed 's/\;.*//'`
ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
if [ "$baudrate" = "$default_baudrate" ] ; then
# enable the service
ln -sf ${systemd_system_unitdir}/serial-getty@.service \
${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
else
# install custom service file for the non-default baudrate
install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
sed -i -e "s/\@BAUDRATE\@/$baudrate/g" ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
# enable the service
ln -sf ${systemd_system_unitdir}/serial-getty$baudrate@.service \
${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service
fi
done
fi
}
# This is a machine specific file
FILES:${PN} = "${systemd_system_unitdir}/*.service ${sysconfdir}"
PACKAGE_ARCH = "${MACHINE_ARCH}"
ALLOW_EMPTY:${PN} = "1"

View File

@@ -0,0 +1,45 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
PartOf=dev-%i.device
ConditionPathExists=/dev/%i
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service
[Service]
Environment="TERM=@TERM@"
ExecStart=-/sbin/agetty -8 -L %I @BAUDRATE@ $TERM
Type=idle
Restart=always
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
[Install]
WantedBy=getty.target

View File

@@ -0,0 +1,16 @@
SUMMARY = "Wrapper for enabling systemd services"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
inherit native
SRC_URI = "file://systemctl"
S = "${WORKDIR}"
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/systemctl ${D}${bindir}
}

View File

@@ -0,0 +1,362 @@
#!/usr/bin/env python3
"""systemctl: subset of systemctl used for image construction
Mask/preset systemd units
"""
import argparse
import fnmatch
import os
import re
import sys
from collections import namedtuple
from itertools import chain
from pathlib import Path
version = 1.0
ROOT = Path("/")
SYSCONFDIR = Path("etc")
BASE_LIBDIR = Path("lib")
LIBDIR = Path("usr", "lib")
locations = list()
class SystemdFile():
"""Class representing a single systemd configuration file"""
_clearable_keys = ['WantedBy']
def __init__(self, root, path, instance_unit_name):
self.sections = dict()
self._parse(root, path)
dirname = os.path.basename(path.name) + ".d"
for location in locations:
files = (root / location / "system" / dirname).glob("*.conf")
if instance_unit_name:
inst_dirname = instance_unit_name + ".d"
files = chain(files, (root / location / "system" / inst_dirname).glob("*.conf"))
for path2 in sorted(files):
self._parse(root, path2)
def _parse(self, root, path):
"""Parse a systemd syntax configuration file
Args:
path: A pathlib.Path object pointing to the file
"""
skip_re = re.compile(r"^\s*([#;]|$)")
section_re = re.compile(r"^\s*\[(?P<section>.*)\]")
kv_re = re.compile(r"^\s*(?P<key>[^\s]+)\s*=\s*(?P<value>.*)")
section = None
if path.is_symlink():
try:
path.resolve()
except FileNotFoundError:
# broken symlink, try relative to root
path = root / Path(os.readlink(str(path))).relative_to(ROOT)
with path.open() as f:
for line in f:
if skip_re.match(line):
continue
line = line.strip()
m = section_re.match(line)
if m:
if m.group('section') not in self.sections:
section = dict()
self.sections[m.group('section')] = section
else:
section = self.sections[m.group('section')]
continue
while line.endswith("\\"):
line += f.readline().rstrip("\n")
m = kv_re.match(line)
k = m.group('key')
v = m.group('value')
if k not in section:
section[k] = list()
# If we come across a "key=" line for a "clearable key", then
# forget all preceding assignments. This works because we are
# processing files in correct parse order.
if k in self._clearable_keys and not v:
del section[k]
continue
section[k].extend(v.split())
def get(self, section, prop):
"""Get a property from section
Args:
section: Section to retrieve property from
prop: Property to retrieve
Returns:
List representing all properties of type prop in section.
Raises:
KeyError: if ``section`` or ``prop`` not found
"""
return self.sections[section][prop]
class Presets():
"""Class representing all systemd presets"""
def __init__(self, scope, root):
self.directives = list()
self._collect_presets(scope, root)
def _parse_presets(self, presets):
"""Parse presets out of a set of preset files"""
skip_re = re.compile(r"^\s*([#;]|$)")
directive_re = re.compile(r"^\s*(?P<action>enable|disable)\s+(?P<unit_name>(.+))")
Directive = namedtuple("Directive", "action unit_name")
for preset in presets:
with preset.open() as f:
for line in f:
m = directive_re.match(line)
if m:
directive = Directive(action=m.group('action'),
unit_name=m.group('unit_name'))
self.directives.append(directive)
elif skip_re.match(line):
pass
else:
sys.exit("Unparsed preset line in {}".format(preset))
def _collect_presets(self, scope, root):
"""Collect list of preset files"""
presets = dict()
for location in locations:
paths = (root / location / scope).glob("*.preset")
for path in paths:
# earlier names override later ones
if path.name not in presets:
presets[path.name] = path
self._parse_presets([v for k, v in sorted(presets.items())])
def state(self, unit_name):
"""Return state of preset for unit_name
Args:
presets: set of presets
unit_name: name of the unit
Returns:
None: no matching preset
`enable`: unit_name is enabled
`disable`: unit_name is disabled
"""
for directive in self.directives:
if fnmatch.fnmatch(unit_name, directive.unit_name):
return directive.action
return None
def add_link(path, target):
try:
path.parent.mkdir(parents=True)
except FileExistsError:
pass
if not path.is_symlink():
print("ln -s {} {}".format(target, path))
path.symlink_to(target)
class SystemdUnitNotFoundError(Exception):
def __init__(self, path, unit):
self.path = path
self.unit = unit
class SystemdUnit():
def __init__(self, root, unit):
self.root = root
self.unit = unit
self.config = None
def _path_for_unit(self, unit):
for location in locations:
path = self.root / location / "system" / unit
if path.exists() or path.is_symlink():
return path
raise SystemdUnitNotFoundError(self.root, unit)
def _process_deps(self, config, service, location, prop, dirstem, instance):
systemdir = self.root / SYSCONFDIR / "systemd" / "system"
target = ROOT / location.relative_to(self.root)
try:
for dependent in config.get('Install', prop):
# expand any %i to instance (ignoring escape sequence %%)
dependent = re.sub("([^%](%%)*)%i", "\\g<1>{}".format(instance), dependent)
wants = systemdir / "{}.{}".format(dependent, dirstem) / service
add_link(wants, target)
except KeyError:
pass
def enable(self, units_enabled=[]):
# if we're enabling an instance, first extract the actual instance
# then figure out what the template unit is
template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit)
instance_unit_name = None
if template:
instance = template.group('instance')
if instance != "":
instance_unit_name = self.unit
unit = re.sub(r"@[^\.]*\.", "@.", self.unit, 1)
else:
instance = None
unit = self.unit
path = self._path_for_unit(unit)
if path.is_symlink():
# ignore aliases
return
config = SystemdFile(self.root, path, instance_unit_name)
if instance == "":
try:
default_instance = config.get('Install', 'DefaultInstance')[0]
except KeyError:
# no default instance, so nothing to enable
return
service = self.unit.replace("@.",
"@{}.".format(default_instance))
else:
service = self.unit
self._process_deps(config, service, path, 'WantedBy', 'wants', instance)
self._process_deps(config, service, path, 'RequiredBy', 'requires', instance)
try:
for also in config.get('Install', 'Also'):
try:
units_enabled.append(unit)
if also not in units_enabled:
SystemdUnit(self.root, also).enable(units_enabled)
except SystemdUnitNotFoundError as e:
sys.exit("Error: Systemctl also enable issue with %s (%s)" % (service, e.unit))
except KeyError:
pass
systemdir = self.root / SYSCONFDIR / "systemd" / "system"
target = ROOT / path.relative_to(self.root)
try:
for dest in config.get('Install', 'Alias'):
alias = systemdir / dest
add_link(alias, target)
except KeyError:
pass
def mask(self):
systemdir = self.root / SYSCONFDIR / "systemd" / "system"
add_link(systemdir / self.unit, "/dev/null")
def collect_services(root):
"""Collect list of service files"""
services = set()
for location in locations:
paths = (root / location / "system").glob("*")
for path in paths:
if path.is_dir():
continue
services.add(path.name)
return services
def preset_all(root):
presets = Presets('system-preset', root)
services = collect_services(root)
for service in services:
state = presets.state(service)
if state == "enable" or state is None:
try:
SystemdUnit(root, service).enable()
except SystemdUnitNotFoundError:
sys.exit("Error: Systemctl preset_all issue in %s" % service)
# If we populate the systemd links we also create /etc/machine-id, which
# allows systemd to boot with the filesystem read-only before generating
# a real value and then committing it back.
#
# For the stateless configuration, where /etc is generated at runtime
# (for example on a tmpfs), this script shouldn't run at all and we
# allow systemd to completely populate /etc.
(root / SYSCONFDIR / "machine-id").touch()
def main():
if sys.version_info < (3, 4, 0):
sys.exit("Python 3.4 or greater is required")
parser = argparse.ArgumentParser()
parser.add_argument('command', nargs='?', choices=['enable', 'mask',
'preset-all'])
parser.add_argument('service', nargs=argparse.REMAINDER)
parser.add_argument('--root')
parser.add_argument('--preset-mode',
choices=['full', 'enable-only', 'disable-only'],
default='full')
args = parser.parse_args()
root = Path(args.root) if args.root else ROOT
locations.append(SYSCONFDIR / "systemd")
# Handle the usrmerge case by ignoring /lib when it's a symlink
if not (root / BASE_LIBDIR).is_symlink():
locations.append(BASE_LIBDIR / "systemd")
locations.append(LIBDIR / "systemd")
command = args.command
if not command:
parser.print_help()
return 0
if command == "mask":
for service in args.service:
try:
SystemdUnit(root, service).mask()
except SystemdUnitNotFoundError as e:
sys.exit("Error: Systemctl main mask issue in %s (%s)" % (service, e.unit))
elif command == "enable":
for service in args.service:
try:
SystemdUnit(root, service).enable()
except SystemdUnitNotFoundError as e:
sys.exit("Error: Systemctl main enable issue in %s (%s)" % (service, e.unit))
elif command == "preset-all":
if len(args.service) != 0:
sys.exit("Too many arguments.")
if args.preset_mode != "enable-only":
sys.exit("Only enable-only is supported as preset-mode.")
preset_all(root)
else:
raise RuntimeError()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,22 @@
SUMMARY = "A System and service manager"
HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd"
DESCRIPTION = "systemd is a system and service manager for Linux, compatible with \
SysV and LSB init scripts. systemd provides aggressive parallelization \
capabilities, uses socket and D-Bus activation for starting services, \
offers on-demand starting of daemons, keeps track of processes using \
Linux cgroups, supports snapshotting and restoring of the system \
state, maintains mount and automount points and implements an \
elaborate transactional dependency-based service control logic. It can \
work as a drop-in replacement for sysvinit."
LICENSE = "GPL-2.0-only & LGPL-2.1-or-later"
LICENSE:libsystemd = "LGPL-2.1-or-later"
LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=751419260aa954499f7abaabaa882bbe \
file://LICENSE.LGPL2.1;md5=4fbd65380cdd255951079008b364516c"
SRCREV = "70500d37992a01d3275b1c414c3ed161d6f91f9e"
SRCBRANCH = "v255-stable"
SRC_URI = "git://github.com/systemd/systemd-stable.git;protocol=https;branch=${SRCBRANCH}"
S = "${WORKDIR}/git"

View File

@@ -0,0 +1,9 @@
#This goes hand-in-hand with the base-files of OE-Core. The file must
# be sorted before 'systemd.conf' becuase this attempts to create a file
# inside /var/log.
d /run/lock 1777 - - -
d /var/volatile/log - - - -
d /var/volatile/tmp 1777 - -
L /var/tmp - - - - /var/volatile/tmp

View File

@@ -0,0 +1,6 @@
[Service]
# By running with these options instead of root, networkd is allowed to request
# a hostname change via DBUS when policykit is not present
User=systemd-network
Group=systemd-hostname
AmbientCapabilities=CAP_SYS_ADMIN

View File

@@ -0,0 +1,58 @@
From b270af4c086d254758fdcd1d294b15a555a4b3ea Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 13:55:12 +0800
Subject: [PATCH] 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 <alex.kiernan@gmail.com>
[Rebased for v244]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[Rebased for v242]
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
[Rebased for v250, Drop __compare_fn_t]
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
---
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 f6233090a9..6c0456349d 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 <stdlib.h>
#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 ae91534198..7f67eea38b 100644
--- a/src/libsystemd/sd-journal/catalog.c
+++ b/src/libsystemd/sd-journal/catalog.c
@@ -28,6 +28,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/",

View File

@@ -0,0 +1,431 @@
From 0660aea3d7c8058d73c9f7b2971f4daf35dd7a32 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Sat, 22 May 2021 20:26:24 +0200
Subject: [PATCH] add fallback parse_printf_format implementation
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Emil Renner Berthing <systemd@esmil.dk>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
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 8c16c1c5c0..408d2ab80a 100644
--- a/meson.build
+++ b/meson.build
@@ -732,6 +732,7 @@ endif
foreach header : ['crypt.h',
'linux/memfd.h',
'linux/vm_sockets.h',
+ 'printf.h',
'sys/auxv.h',
'threads.h',
'valgrind/memcheck.h',
diff --git a/src/basic/meson.build b/src/basic/meson.build
index 111253e3a5..bdaa2fc5e4 100644
--- a/src/basic/meson.build
+++ b/src/basic/meson.build
@@ -183,6 +183,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 <systemd@esmil.dk>
+
+ 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 <http://www.gnu.org/licenses/>.
+***/
+
+#include <stddef.h>
+#include <string.h>
+
+#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 <systemd@esmil.dk>
+
+ 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 <http://www.gnu.org/licenses/>.
+***/
+
+#pragma once
+
+#include "config.h"
+
+#if HAVE_PRINTF_H
+#include <printf.h>
+#else
+
+#include <stddef.h>
+
+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 4e93ac90c9..f9deb6f662 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 <printf.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#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 be23b2fe75..69a2eb6404 100644
--- a/src/libsystemd/sd-journal/journal-send.c
+++ b/src/libsystemd/sd-journal/journal-send.c
@@ -2,7 +2,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <printf.h>
#include <stddef.h>
#include <sys/un.h>
#include <unistd.h>
@@ -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)

View File

@@ -0,0 +1,76 @@
From edc39fe19419120f70341cd50d4d097a514ac9cb Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Thu, 21 Feb 2019 16:23:24 +0800
Subject: [PATCH] binfmt: Don't install dependency links at install time for
the binfmt services
use [Install] blocks so that they get created when the service is enabled
like a traditional service.
The [Install] blocks were rejected upstream as they don't have a way to
"enable" it on install without static symlinks which can't be disabled,
only masked. We however can do that in a postinst.
Upstream-Status: Denied
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
units/meson.build | 2 --
units/proc-sys-fs-binfmt_misc.automount | 3 +++
units/systemd-binfmt.service.in | 4 ++++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/units/meson.build b/units/meson.build
index e7bfb7f838..1d5ec4b178 100644
--- a/units/meson.build
+++ b/units/meson.build
@@ -154,7 +154,6 @@ units = [
{
'file' : 'proc-sys-fs-binfmt_misc.automount',
'conditions' : ['ENABLE_BINFMT'],
- 'symlinks' : ['sysinit.target.wants/'],
},
{
'file' : 'proc-sys-fs-binfmt_misc.mount',
@@ -251,7 +250,6 @@ units = [
{
'file' : 'systemd-binfmt.service.in',
'conditions' : ['ENABLE_BINFMT'],
- 'symlinks' : ['sysinit.target.wants/'],
},
{
'file' : 'systemd-bless-boot.service.in',
diff --git a/units/proc-sys-fs-binfmt_misc.automount b/units/proc-sys-fs-binfmt_misc.automount
index 5d212015a5..6c2900ca77 100644
--- a/units/proc-sys-fs-binfmt_misc.automount
+++ b/units/proc-sys-fs-binfmt_misc.automount
@@ -22,3 +22,6 @@ Before=shutdown.target
[Automount]
Where=/proc/sys/fs/binfmt_misc
+
+[Install]
+WantedBy=sysinit.target
diff --git a/units/systemd-binfmt.service.in b/units/systemd-binfmt.service.in
index 6861c76674..531e9fbd90 100644
--- a/units/systemd-binfmt.service.in
+++ b/units/systemd-binfmt.service.in
@@ -14,6 +14,7 @@ Documentation=https://docs.kernel.org/admin-guide/binfmt-misc.html
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
DefaultDependencies=no
Conflicts=shutdown.target
+Wants=proc-sys-fs-binfmt_misc.automount
After=proc-sys-fs-binfmt_misc.automount
After=proc-sys-fs-binfmt_misc.mount
After=local-fs.target
@@ -31,3 +32,6 @@ RemainAfterExit=yes
ExecStart={{LIBEXECDIR}}/systemd-binfmt
ExecStop={{LIBEXECDIR}}/systemd-binfmt --unregister
TimeoutSec=90s
+
+[Install]
+WantedBy=sysinit.target

View File

@@ -0,0 +1,701 @@
From c728a728cd54c372162f5447aa94921efb0c35f0 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 14:18:21 +0800
Subject: [PATCH] src/basic/missing.h: check for missing strndupa
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
include missing.h for definition of strndupa
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[Rebased for v242]
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
[rebased for systemd 244]
[Rebased for v247]
Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
[Rebased for v254]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[Rebased for v255.1]
Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
[Rebased for v255.14]
---
meson.build | 1 +
src/backlight/backlight.c | 1 +
src/basic/cgroup-util.c | 1 +
src/basic/env-util.c | 1 +
src/basic/log.c | 1 +
src/basic/missing_stdlib.h | 12 ++++++++++++
src/basic/mkdir.c | 1 +
src/basic/mountpoint-util.c | 1 +
src/basic/parse-util.c | 1 +
src/basic/path-lookup.c | 1 +
src/basic/percent-util.c | 1 +
src/basic/proc-cmdline.c | 1 +
src/basic/procfs-util.c | 1 +
src/basic/time-util.c | 1 +
src/boot/bless-boot.c | 1 +
src/core/dbus-cgroup.c | 1 +
src/core/dbus-execute.c | 1 +
src/core/dbus-util.c | 1 +
src/core/execute.c | 1 +
src/core/kmod-setup.c | 1 +
src/core/service.c | 1 +
src/coredump/coredump-vacuum.c | 1 +
src/fstab-generator/fstab-generator.c | 1 +
src/journal-remote/journal-remote-main.c | 1 +
src/journal/journalctl.c | 1 +
src/libsystemd/sd-bus/bus-message.c | 1 +
src/libsystemd/sd-bus/bus-objects.c | 1 +
src/libsystemd/sd-bus/bus-socket.c | 1 +
src/libsystemd/sd-bus/sd-bus.c | 1 +
src/libsystemd/sd-bus/test-bus-benchmark.c | 1 +
src/libsystemd/sd-journal/sd-journal.c | 1 +
src/login/pam_systemd.c | 1 +
src/network/generator/network-generator.c | 1 +
src/nspawn/nspawn-settings.c | 1 +
src/nss-mymachines/nss-mymachines.c | 1 +
src/portable/portable.c | 1 +
src/resolve/resolvectl.c | 1 +
src/shared/bus-get-properties.c | 1 +
src/shared/bus-unit-procs.c | 1 +
src/shared/bus-unit-util.c | 1 +
src/shared/bus-util.c | 1 +
src/shared/dns-domain.c | 1 +
src/shared/journal-importer.c | 1 +
src/shared/logs-show.c | 1 +
src/shared/pager.c | 1 +
src/socket-proxy/socket-proxyd.c | 1 +
src/test/test-hexdecoct.c | 1 +
src/udev/udev-builtin-net_id.c | 1 +
src/udev/udev-builtin-path_id.c | 1 +
src/udev/udev-event.c | 1 +
src/udev/udev-rules.c | 1 +
51 files changed, 62 insertions(+)
diff --git a/meson.build b/meson.build
index 408d2ab80a..2c00b7047f 100644
--- a/meson.build
+++ b/meson.build
@@ -572,6 +572,7 @@ foreach ident : ['secure_getenv', '__secure_getenv']
endforeach
foreach ident : [
+ ['strndupa' , '''#include <string.h>'''],
['memfd_create', '''#include <sys/mman.h>'''],
['gettid', '''#include <sys/types.h>
#include <unistd.h>'''],
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index b2032adaa5..ee9201826d 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -20,6 +20,7 @@
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
+#include "missing_stdlib.h"
#define PCI_CLASS_GRAPHICS_CARD 0x30000
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index e978bd3eff..d08c903c3b 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -38,6 +38,7 @@
#include "unit-name.h"
#include "user-util.h"
#include "xattr-util.h"
+#include "missing_stdlib.h"
static int cg_enumerate_items(const char *controller, const char *path, FILE **ret, const char *item) {
_cleanup_free_ char *fs = NULL;
diff --git a/src/basic/env-util.c b/src/basic/env-util.c
index a97651d7af..09fa601250 100644
--- a/src/basic/env-util.c
+++ b/src/basic/env-util.c
@@ -19,6 +19,7 @@
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
+#include "missing_stdlib.h"
/* We follow bash for the character set. Different shells have different rules. */
#define VALID_BASH_ENV_NAME_CHARS \
diff --git a/src/basic/log.c b/src/basic/log.c
index ade6c8b089..0ba68b2119 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -40,6 +40,7 @@
#include "terminal-util.h"
#include "time-util.h"
#include "utf8.h"
+#include "missing_stdlib.h"
#define SNDBUF_SIZE (8*1024*1024)
#define IOVEC_MAX 256U
diff --git a/src/basic/missing_stdlib.h b/src/basic/missing_stdlib.h
index 8c76f93eb2..9068bfb4f0 100644
--- a/src/basic/missing_stdlib.h
+++ b/src/basic/missing_stdlib.h
@@ -11,3 +11,15 @@
# error "neither secure_getenv nor __secure_getenv are available"
# endif
#endif
+
+/* string.h */
+#if ! HAVE_STRNDUPA
+#define strndupa(s, n) \
+ ({ \
+ const char *__old = (s); \
+ size_t __len = strnlen(__old, (n)); \
+ char *__new = (char *)alloca(__len + 1); \
+ __new[__len] = '\0'; \
+ (char *)memcpy(__new, __old, __len); \
+ })
+#endif
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
index c770e5ed32..1fd8816cd0 100644
--- a/src/basic/mkdir.c
+++ b/src/basic/mkdir.c
@@ -16,6 +16,7 @@
#include "stat-util.h"
#include "stdio-util.h"
#include "user-util.h"
+#include "missing_stdlib.h"
int mkdirat_safe_internal(
int dir_fd,
diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c
index 51fbe4ed84..26626c1499 100644
--- a/src/basic/mountpoint-util.c
+++ b/src/basic/mountpoint-util.c
@@ -18,6 +18,7 @@
#include "missing_stat.h"
#include "missing_syscall.h"
#include "mkdir.h"
+#include "missing_stdlib.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
index 0430e33e40..f3728de026 100644
--- a/src/basic/parse-util.c
+++ b/src/basic/parse-util.c
@@ -18,6 +18,7 @@
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
+#include "missing_stdlib.h"
int parse_boolean(const char *v) {
if (!v)
diff --git a/src/basic/path-lookup.c b/src/basic/path-lookup.c
index d76705bd4b..149fb249d0 100644
--- a/src/basic/path-lookup.c
+++ b/src/basic/path-lookup.c
@@ -16,6 +16,7 @@
#include "strv.h"
#include "tmpfile-util.h"
#include "user-util.h"
+#include "missing_stdlib.h"
int xdg_user_runtime_dir(char **ret, const char *suffix) {
const char *e;
diff --git a/src/basic/percent-util.c b/src/basic/percent-util.c
index cab9d0eaea..5f6ca258e9 100644
--- a/src/basic/percent-util.c
+++ b/src/basic/percent-util.c
@@ -3,6 +3,7 @@
#include "percent-util.h"
#include "string-util.h"
#include "parse-util.h"
+#include "missing_stdlib.h"
static int parse_parts_value_whole(const char *p, const char *symbol) {
const char *pc, *n;
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c
index 522d8de1f4..7c129dc0fc 100644
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -16,6 +16,7 @@
#include "string-util.h"
#include "strv.h"
#include "virt.h"
+#include "missing_stdlib.h"
int proc_cmdline_filter_pid1_args(char **argv, char ***ret) {
enum {
diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c
index d7cfcd9105..6cb0ddf575 100644
--- a/src/basic/procfs-util.c
+++ b/src/basic/procfs-util.c
@@ -12,6 +12,7 @@
#include "procfs-util.h"
#include "stdio-util.h"
#include "string-util.h"
+#include "missing_stdlib.h"
int procfs_get_pid_max(uint64_t *ret) {
_cleanup_free_ char *value = NULL;
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 0c2d739977..5c150806a0 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -27,6 +27,7 @@
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
+#include "missing_stdlib.h"
static clockid_t map_clock_id(clockid_t c) {
diff --git a/src/boot/bless-boot.c b/src/boot/bless-boot.c
index 12dfdf76fa..e66332519a 100644
--- a/src/boot/bless-boot.c
+++ b/src/boot/bless-boot.c
@@ -22,6 +22,7 @@
#include "terminal-util.h"
#include "verbs.h"
#include "virt.h"
+#include "missing_stdlib.h"
static char **arg_path = NULL;
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index b3baf03afc..7404784a01 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -25,6 +25,7 @@
#include "parse-util.h"
#include "path-util.h"
#include "percent-util.h"
+#include "missing_stdlib.h"
#include "socket-util.h"
BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", CGroupTasksMax, cgroup_tasks_max_resolve);
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 71b07a6ec1..174a94e8a0 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -42,6 +42,7 @@
#include "unit-printf.h"
#include "user-util.h"
#include "utf8.h"
+#include "missing_stdlib.h"
BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output, exec_output, ExecOutput);
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_input, exec_input, ExecInput);
diff --git a/src/core/dbus-util.c b/src/core/dbus-util.c
index 7bb026af48..a86128e40c 100644
--- a/src/core/dbus-util.c
+++ b/src/core/dbus-util.c
@@ -10,6 +10,7 @@
#include "unit-printf.h"
#include "user-util.h"
#include "unit.h"
+#include "missing_stdlib.h"
int bus_property_get_triggered_unit(
sd_bus *bus,
diff --git a/src/core/execute.c b/src/core/execute.c
index aa179fd57e..1ee9f4526b 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -72,6 +72,7 @@
#include "unit-serialize.h"
#include "user-util.h"
#include "utmp-wtmp.h"
+#include "missing_stdlib.h"
static bool is_terminal_input(ExecInput i) {
return IN_SET(i,
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index b8e3f7aadd..8ce8ca68d8 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -13,6 +13,7 @@
#include "string-util.h"
#include "strv.h"
#include "virt.h"
+#include "missing_stdlib.h"
#if HAVE_KMOD
#include "module-util.h"
diff --git a/src/core/service.c b/src/core/service.c
index d0353ae461..7f98f5ee45 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -45,6 +45,7 @@
#include "unit-name.h"
#include "unit.h"
#include "utf8.h"
+#include "missing_stdlib.h"
#define service_spawn(...) service_spawn_internal(__func__, __VA_ARGS__)
diff --git a/src/coredump/coredump-vacuum.c b/src/coredump/coredump-vacuum.c
index 7e0c98cb7d..978a7f5874 100644
--- a/src/coredump/coredump-vacuum.c
+++ b/src/coredump/coredump-vacuum.c
@@ -17,6 +17,7 @@
#include "string-util.h"
#include "time-util.h"
#include "user-util.h"
+#include "missing_stdlib.h"
#define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */
#define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index e7caf510ba..79b252cad7 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -37,6 +37,7 @@
#include "unit-name.h"
#include "virt.h"
#include "volatile-util.h"
+#include "missing_stdlib.h"
typedef enum MountPointFlags {
MOUNT_NOAUTO = 1 << 0,
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 2d380bc7a7..d3f5612728 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -27,6 +27,7 @@
#include "stat-util.h"
#include "string-table.h"
#include "strv.h"
+#include "missing_stdlib.h"
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-remote.pem"
#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-remote.pem"
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index f52ed03dd0..3fa708a906 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -77,6 +77,7 @@
#include "unit-name.h"
#include "user-util.h"
#include "varlink.h"
+#include "missing_stdlib.h"
#define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE)
#define PROCESS_INOTIFY_INTERVAL 1024 /* Every 1,024 messages processed */
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index ab8b06896d..43f9131205 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -19,6 +19,7 @@
#include "strv.h"
#include "time-util.h"
#include "utf8.h"
+#include "missing_stdlib.h"
static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored);
static int message_parse_fields(sd_bus_message *m);
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index c25c40ff37..57a5da704f 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -11,6 +11,7 @@
#include "missing_capability.h"
#include "string-util.h"
#include "strv.h"
+#include "missing_stdlib.h"
static int node_vtable_get_userdata(
sd_bus *bus,
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index 5ade8e99aa..7553cf319d 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -29,6 +29,7 @@
#include "string-util.h"
#include "user-util.h"
#include "utf8.h"
+#include "missing_stdlib.h"
#define SNDBUF_SIZE (8*1024*1024)
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index b32cd6c6a0..cc484454e0 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -46,6 +46,7 @@
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
+#include "missing_stdlib.h"
#define log_debug_bus_message(m) \
do { \
diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c
index d988588de0..458df8df9a 100644
--- a/src/libsystemd/sd-bus/test-bus-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-benchmark.c
@@ -14,6 +14,7 @@
#include "string-util.h"
#include "tests.h"
#include "time-util.h"
+#include "missing_stdlib.h"
#define MAX_SIZE (2*1024*1024)
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index acabec699f..8115d3784a 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -44,6 +44,7 @@
#include "strv.h"
#include "syslog-util.h"
#include "uid-alloc-range.h"
+#include "missing_stdlib.h"
#define JOURNAL_FILES_RECHECK_USEC (2 * USEC_PER_SEC)
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index bf45974ca5..2cb7e930c0 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -35,6 +35,7 @@
#include "login-util.h"
#include "macro.h"
#include "missing_syscall.h"
+#include "missing_stdlib.h"
#include "pam-util.h"
#include "parse-util.h"
#include "path-util.h"
diff --git a/src/network/generator/network-generator.c b/src/network/generator/network-generator.c
index e5f78a3b99..4833de2009 100644
--- a/src/network/generator/network-generator.c
+++ b/src/network/generator/network-generator.c
@@ -15,6 +15,7 @@
#include "string-util.h"
#include "strv.h"
#include "vlan-util.h"
+#include "missing_stdlib.h"
/*
# .network
diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c
index 2bb034eb22..c9837b8d79 100644
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -16,6 +16,7 @@
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
+#include "missing_stdlib.h"
Settings *settings_new(void) {
Settings *s;
diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c
index c64e79bdff..eda26b0b9a 100644
--- a/src/nss-mymachines/nss-mymachines.c
+++ b/src/nss-mymachines/nss-mymachines.c
@@ -21,6 +21,7 @@
#include "nss-util.h"
#include "signal-util.h"
#include "string-util.h"
+#include "missing_stdlib.h"
static void setup_logging_once(void) {
static pthread_once_t once = PTHREAD_ONCE_INIT;
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 4aced8c391..6f426e0e51 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -42,6 +42,7 @@
#include "strv.h"
#include "tmpfile-util.h"
#include "user-util.h"
+#include "missing_stdlib.h"
/* Markers used in the first line of our 20-portable.conf unit file drop-in to determine, that a) the unit file was
* dropped there by the portable service logic and b) for which image it was dropped there. */
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
index 64b829e5e6..3a06758848 100644
--- a/src/resolve/resolvectl.c
+++ b/src/resolve/resolvectl.c
@@ -48,6 +48,7 @@
#include "varlink.h"
#include "verb-log-control.h"
#include "verbs.h"
+#include "missing_stdlib.h"
static int arg_family = AF_UNSPEC;
static int arg_ifindex = 0;
diff --git a/src/shared/bus-get-properties.c b/src/shared/bus-get-properties.c
index 53e5d6b99f..851ecd5644 100644
--- a/src/shared/bus-get-properties.c
+++ b/src/shared/bus-get-properties.c
@@ -4,6 +4,7 @@
#include "rlimit-util.h"
#include "stdio-util.h"
#include "string-util.h"
+#include "missing_stdlib.h"
int bus_property_get_bool(
sd_bus *bus,
diff --git a/src/shared/bus-unit-procs.c b/src/shared/bus-unit-procs.c
index 8b462b5627..183ce1c18e 100644
--- a/src/shared/bus-unit-procs.c
+++ b/src/shared/bus-unit-procs.c
@@ -11,6 +11,7 @@
#include "sort-util.h"
#include "string-util.h"
#include "terminal-util.h"
+#include "missing_stdlib.h"
struct CGroupInfo {
char *cgroup_path;
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 50de98941f..d47beccb0b 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -50,6 +50,7 @@
#include "unit-def.h"
#include "user-util.h"
#include "utf8.h"
+#include "missing_stdlib.h"
int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
assert(message);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 4123152d93..74f148c8b4 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -24,6 +24,7 @@
#include "path-util.h"
#include "socket-util.h"
#include "stdio-util.h"
+#include "missing_stdlib.h"
static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
sd_event *e = ASSERT_PTR(userdata);
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index b41c9b06ca..e69050a507 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -18,6 +18,7 @@
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
+#include "missing_stdlib.h"
int dns_label_unescape(const char **name, char *dest, size_t sz, DNSLabelFlags flags) {
const char *n;
diff --git a/src/shared/journal-importer.c b/src/shared/journal-importer.c
index bb0536e48a..11cc1315d8 100644
--- a/src/shared/journal-importer.c
+++ b/src/shared/journal-importer.c
@@ -16,6 +16,7 @@
#include "string-util.h"
#include "strv.h"
#include "unaligned.h"
+#include "missing_stdlib.h"
enum {
IMPORTER_STATE_LINE = 0, /* waiting to read, or reading line */
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 0a31be382f..92d629e7e0 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -41,6 +41,7 @@
#include "time-util.h"
#include "utf8.h"
#include "web-util.h"
+#include "missing_stdlib.h"
/* up to three lines (each up to 100 characters) or 300 characters, whichever is less */
#define PRINT_LINE_THRESHOLD 3
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 41dd7bffdc..9ca45d8b91 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -25,6 +25,7 @@
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
+#include "missing_stdlib.h"
static pid_t pager_pid = 0;
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 287fd6c181..8f8d5493da 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -27,6 +27,7 @@
#include "set.h"
#include "socket-util.h"
#include "string-util.h"
+#include "missing_stdlib.h"
#define BUFFER_SIZE (256 * 1024)
diff --git a/src/test/test-hexdecoct.c b/src/test/test-hexdecoct.c
index f884008660..987e180697 100644
--- a/src/test/test-hexdecoct.c
+++ b/src/test/test-hexdecoct.c
@@ -7,6 +7,7 @@
#include "macro.h"
#include "random-util.h"
#include "string-util.h"
+#include "missing_stdlib.h"
#include "tests.h"
TEST(hexchar) {
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index 91b40088f4..f528a46b8e 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -39,6 +39,7 @@
#include "strv.h"
#include "strxcpyx.h"
#include "udev-builtin.h"
+#include "missing_stdlib.h"
#define ONBOARD_14BIT_INDEX_MAX ((1U << 14) - 1)
#define ONBOARD_16BIT_INDEX_MAX ((1U << 16) - 1)
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
index 467c9a6ad3..f74dae60af 100644
--- a/src/udev/udev-builtin-path_id.c
+++ b/src/udev/udev-builtin-path_id.c
@@ -24,6 +24,7 @@
#include "sysexits.h"
#include "udev-builtin.h"
#include "udev-util.h"
+#include "missing_stdlib.h"
_printf_(2,3)
static void path_prepend(char **path, const char *fmt, ...) {
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index ed22c8b679..19ebe20237 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -16,6 +16,7 @@
#include "udev-util.h"
#include "udev-watch.h"
#include "user-util.h"
+#include "missing_stdlib.h"
UdevEvent *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl, int log_level) {
UdevEvent *event;
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index c242549654..e5b8df5c2d 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -41,6 +41,7 @@
#include "udev-util.h"
#include "user-util.h"
#include "virt.h"
+#include "missing_stdlib.h"
#define RULES_DIRS ((const char* const*) CONF_PATHS_STRV("udev/rules.d"))

View File

@@ -0,0 +1,97 @@
From 3a51e31be9f626cf772733cb289ed64739fab0e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Tue, 20 Feb 2024 19:26:16 +0100
Subject: [PATCH] timedated: Respond on org.freedesktop.timedate1.SetNTP only
when really finished
The method returns prematurely (before jobs it triggers terminate). This
is externally visible because other methods may fail if jobs did not
finish.
Postpone the DBus method response until we collect all signals for
finished jobs.
systemd-timedated keeps track of in-flight DBus requests and answers
them all in unspecified order when jobs finish. The capacity of requests
in systemd-timedated is limited.
Fixes: #17739
Upstream-Status: Backport [https://github.com/systemd/systemd/commit/3a51e31be9f626cf772733cb289ed64739fab0e4]
Signed-off-by: Michal Seben <michal.seben@siemens.com>
---
src/timedate/timedated.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
Index: git/src/timedate/timedated.c
===================================================================
--- git.orig/src/timedate/timedated.c
+++ git/src/timedate/timedated.c
@@ -45,6 +45,7 @@
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
#define UNIT_LIST_DIRS (const char* const*) CONF_PATHS_STRV("systemd/ntp-units.d")
+#define SET_NTP_IN_FLIGHT_MAX 16
typedef struct UnitStatusInfo {
char *name;
@@ -61,6 +62,7 @@ typedef struct Context {
bool local_rtc;
Hashmap *polkit_registry;
sd_bus_message *cache;
+ Set *set_ntp_calls;
sd_bus_slot *slot_job_removed;
@@ -121,6 +123,7 @@ static void context_clear(Context *c) {
free(c->zone);
bus_verify_polkit_async_registry_free(c->polkit_registry);
sd_bus_message_unref(c->cache);
+ set_free(c->set_ntp_calls);
sd_bus_slot_unref(c->slot_job_removed);
@@ -461,11 +464,19 @@ static int match_job_removed(sd_bus_mess
n += !!u->path;
if (n == 0) {
+ sd_bus_message *cm;
+
c->slot_job_removed = sd_bus_slot_unref(c->slot_job_removed);
(void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m),
"/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP",
NULL);
+ while ((cm = set_steal_first(c->set_ntp_calls))) {
+ r = sd_bus_reply_method_return(cm, NULL);
+ if (r < 0)
+ log_debug_errno(r, "Failed to reply to SetNTP method call, ignoring: %m");
+ sd_bus_message_unref(cm);
+ }
}
return 0;
@@ -944,6 +955,9 @@ static int method_set_ntp(sd_bus_message
LIST_FOREACH(units, u, c->units)
u->path = mfree(u->path);
+ if (set_size(c->set_ntp_calls) >= SET_NTP_IN_FLIGHT_MAX)
+ return sd_bus_error_set_errnof(error, EAGAIN, "Too many calls in flight.");
+
if (!c->slot_job_removed) {
r = bus_match_signal_async(
bus,
@@ -998,11 +1012,12 @@ static int method_set_ntp(sd_bus_message
c->slot_job_removed = TAKE_PTR(slot);
if (selected)
- log_info("Set NTP to enabled (%s).", selected->name);
+ log_info("Set NTP to be enabled (%s).", selected->name);
else
- log_info("Set NTP to disabled.");
+ log_info("Set NTP to be disabled.");
- return sd_bus_reply_method_return(m, NULL);
+ /* Asynchrounous reply to m in match_job_removed() */
+ return set_ensure_consume(&c->set_ntp_calls, &bus_message_hash_ops, sd_bus_message_ref(m));
}
static int method_list_timezones(sd_bus_message *m, void *userdata, sd_bus_error *error) {

View File

@@ -0,0 +1,152 @@
From 674232187bf337c31a6528b4d241eafeb27ac85e Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 14:56:21 +0800
Subject: [PATCH] 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 <raj.khem@gmail.com>
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
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 9b3e73cce0..3790ba3be5 100644
--- a/src/test/test-glob-util.c
+++ b/src/test/test-glob-util.c
@@ -34,6 +34,12 @@ TEST(glob_first) {
assert_se(first == NULL);
}
+/* 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 d22fa3b3c7..3471f98add 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
@@ -2426,7 +2432,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 = 0, k;
@@ -2453,7 +2461,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 = 0, k;

View File

@@ -0,0 +1,41 @@
From cdaafa37983753d309d2b37f8262e71f95798e52 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 15:00:06 +0800
Subject: [PATCH] add missing FTW_ macros for musl
This is to avoid build failures like below for musl.
locale-util.c:296:24: error: 'FTW_STOP' undeclared
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
src/basic/missing_type.h | 4 ++++
src/test/test-recurse-dir.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/src/basic/missing_type.h b/src/basic/missing_type.h
index 6c0456349d..73a5b90e3c 100644
--- a/src/basic/missing_type.h
+++ b/src/basic/missing_type.h
@@ -14,3 +14,7 @@
#ifndef __GLIBC__
typedef int (*comparison_fn_t)(const void *, const void *);
#endif
+
+#ifndef FTW_CONTINUE
+#define FTW_CONTINUE 0
+#endif
diff --git a/src/test/test-recurse-dir.c b/src/test/test-recurse-dir.c
index 8684d064ec..70fc2b5376 100644
--- a/src/test/test-recurse-dir.c
+++ b/src/test/test-recurse-dir.c
@@ -8,6 +8,7 @@
#include "recurse-dir.h"
#include "strv.h"
#include "tests.h"
+#include "missing_type.h"
static char **list_nftw = NULL;

View File

@@ -0,0 +1,103 @@
From 8c33fe6338c448dca8533b9d3f9933e2794bda61 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 15:12:41 +0800
Subject: [PATCH] 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 <raj.khem@gmail.com>
[Rebased for v241]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
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 8719df3e29..9becc96066 100644
--- a/src/basic/format-util.h
+++ b/src/basic/format-util.h
@@ -34,13 +34,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 c1f0b2b974..61c5412582 100644
--- a/src/basic/rlimit-util.c
+++ b/src/basic/rlimit-util.c
@@ -44,7 +44,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));
}
@@ -307,13 +307,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;
@@ -422,7 +422,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 1ee9f4526b..cb29799afb 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1043,9 +1043,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) {

View File

@@ -0,0 +1,96 @@
From 68ab3364c0fe1073bba3adf02add7108de80a17c Mon Sep 17 00:00:00 2001
From: Andre McCurdy <armccurdy@gmail.com>
Date: Tue, 10 Oct 2017 14:33:30 -0700
Subject: [PATCH] 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 <armccurdy@gmail.com>
---
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 6a1e2e76d1..c3f7235e09 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 0d5075e1e6..dc59a9582c 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -137,7 +137,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? */
@@ -145,7 +145,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 */
@@ -156,7 +156,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;
}

View File

@@ -0,0 +1,30 @@
From 6dd1aa50da27c07530a434218b5a7a384d0c6747 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 27 May 2018 08:36:44 -0700
Subject: [PATCH] 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 <raj.khem@gmail.com>
---
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 b6d8be3083..0a29036c4c 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;

View File

@@ -0,0 +1,40 @@
From 8da2b10dcbf423f791db79b7dfcc6cfaf8e26f8b Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 5 Sep 2015 06:31:47 +0000
Subject: [PATCH] implment systemd-sysv-install for OE
Use update-rc.d for enabling/disabling and status command
to check the status of the sysv service
Upstream-Status: Inappropriate [OE-Specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/systemctl/systemd-sysv-install.SKELETON | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/systemctl/systemd-sysv-install.SKELETON b/src/systemctl/systemd-sysv-install.SKELETON
index cb58d8243b..000bdf6165 100755
--- a/src/systemctl/systemd-sysv-install.SKELETON
+++ b/src/systemctl/systemd-sysv-install.SKELETON
@@ -34,17 +34,17 @@ case "$1" in
enable)
# call the command to enable SysV init script $NAME here
# (consider optional $ROOT)
- echo "IMPLEMENT ME: enabling SysV init.d script $NAME"
+ update-rc.d -f $NAME defaults
;;
disable)
# call the command to disable SysV init script $NAME here
# (consider optional $ROOT)
- echo "IMPLEMENT ME: disabling SysV init.d script $NAME"
+ update-rc.d -f $NAME remove
;;
is-enabled)
# exit with 0 if $NAME is enabled, non-zero if it is disabled
# (consider optional $ROOT)
- echo "IMPLEMENT ME: checking SysV init.d script $NAME"
+ /etc/init.d/$NAME status
;;
*)
usage ;;

View File

@@ -0,0 +1,38 @@
From ed33f139195794477ac854214022034db306f42d Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Wed, 4 Jul 2018 15:00:44 +0800
Subject: [PATCH] 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 <Qi.Chen@windriver.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
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 bbce0ea985..d2f7c27cea 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -1716,7 +1716,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) {

View File

@@ -0,0 +1,73 @@
From ef261a0122ff5a4340897c9afe1fae04d14eb0dd Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Tue, 10 Jul 2018 15:40:17 +0800
Subject: [PATCH] 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 <Qi.Chen@windriver.com>
---
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 69a2eb6404..1561859650 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];

View File

@@ -0,0 +1,29 @@
From 8b76e1f027d73e26cfc8e13bd49f43197dbb9004 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 15:44:54 +0800
Subject: [PATCH] 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 <Qi.Chen@windriver.com>
---
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 7d9e395c92..88c2d7dfac 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 <linux/prctl.h>
+#endif
/* 58319057b7847667f0c9585b9de0e8932b0fdb08 (4.3) */
#ifndef PR_CAP_AMBIENT

View File

@@ -0,0 +1,559 @@
From 9686b8c52bd9e532ebe687dd31352d884873e0a4 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Fri, 1 Mar 2019 15:22:15 +0800
Subject: [PATCH] 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 <Qi.Chen@windriver.com>
[Rebased for v242]
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
[rebased for systemd 243]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
[rebased for systemd 254]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[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 | 4 ++--
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, 50 insertions(+), 51 deletions(-)
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index d08c903c3b..77ebe85dfd 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -443,7 +443,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 r;
@@ -873,7 +873,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))
@@ -891,7 +891,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;
@@ -918,7 +918,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;
@@ -928,7 +928,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;
@@ -1844,7 +1844,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 2101f617ad..63817bae17 100644
--- a/src/basic/namespace-util.c
+++ b/src/basic/namespace-util.c
@@ -227,12 +227,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_error_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_error_errno(r, "Failed to write GID map: %m");
diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c
index 6cb0ddf575..247cf9e1d1 100644
--- a/src/basic/procfs-util.c
+++ b/src/basic/procfs-util.c
@@ -64,13 +64,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 b66a6622ae..8d1c93008a 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 d398655b0a..9558f38a72 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -4589,7 +4589,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
u->freezer_state = FREEZER_THAWING;
}
- r = write_string_file(path, one_zero(action == FREEZER_FREEZE), WRITE_STRING_FILE_DISABLE_BUFFER);
+ r = write_string_file(path, one_zero(action == FREEZER_FREEZE), 0);
if (r < 0)
return r;
diff --git a/src/core/main.c b/src/core/main.c
index 364dc895d1..d28ec42030 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1683,7 +1683,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 500c310cfc..f9845ff9e7 100644
--- a/src/home/homework.c
+++ b/src/home/homework.c
@@ -278,7 +278,7 @@ static void drop_caches_now(void) {
* for details. We write "2" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but
* not more. */
- r = write_string_file("/proc/sys/vm/drop_caches", "2\n", WRITE_STRING_FILE_DISABLE_BUFFER);
+ r = write_string_file("/proc/sys/vm/drop_caches", "2\n", 0);
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 5f7491e8e2..b4a0af4073 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -2516,7 +2516,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 a5002437c6..b12e6cd9c9 100644
--- a/src/nspawn/nspawn-cgroup.c
+++ b/src/nspawn/nspawn-cgroup.c
@@ -124,7 +124,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 005a3d2be1..526d3c4311 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -2707,7 +2707,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"
@@ -4160,7 +4160,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");
@@ -4170,7 +4170,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 1b8a86dc54..5ca14433c8 100644
--- a/src/shared/cgroup-setup.c
+++ b/src/shared/cgroup-setup.c
@@ -351,7 +351,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;
@@ -969,7 +969,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 67862dcc61..9e9265c214 100644
--- a/src/shared/hibernate-util.c
+++ b/src/shared/hibernate-util.c
@@ -504,7 +504,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),
@@ -520,7 +520,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 99ccefb227..e4975018ab 100644
--- a/src/shared/watchdog.c
+++ b/src/shared/watchdog.c
@@ -93,7 +93,7 @@ static int 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 21062b24e0..262dd71d72 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -137,7 +137,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;
@@ -155,7 +155,7 @@ static int write_mode(char * const *modes) {
STRV_FOREACH(mode, modes) {
int k;
- k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER);
+ k = write_string_file("/sys/power/disk", *mode, 0);
if (k >= 0) {
log_debug("Using sleep disk mode '%s'.", *mode);
return 0;
diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c
index 16d4fb07d4..aca7506463 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 e5b8df5c2d..63ca15628c 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2711,7 +2711,6 @@ static int udev_rule_apply_token_to_event(
log_event_debug(dev, token, "ATTR '%s' writing '%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 4d82c65f0a..3a3d861b83 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -261,7 +261,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));

View File

@@ -0,0 +1,57 @@
From 385fbcc3cec50b995299e25f913d9683ddf51174 Mon Sep 17 00:00:00 2001
From: Scott Murray <scott.murray@konsulko.com>
Date: Fri, 13 Sep 2019 19:26:27 -0400
Subject: [PATCH] Handle __cpu_mask usage
Fixes errors:
src/test/test-cpu-set-util.c:18:54: error: '__cpu_mask' undeclared (first use in this function)
src/test/test-sizeof.c:73:14: error: '__cpu_mask' undeclared (first use in this function)
__cpu_mask is an internal type of glibc's cpu_set implementation, not
part of the POSIX definition, which is problematic when building with
musl, which does not define a matching type. From inspection of musl's
sched.h, however, it is clear that the corresponding type would be
unsigned long, which does match glibc's actual __CPU_MASK_TYPE. So,
add a typedef to cpu-set-util.h defining __cpu_mask appropriately.
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
src/shared/cpu-set-util.h | 2 ++
src/test/test-sizeof.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/shared/cpu-set-util.h b/src/shared/cpu-set-util.h
index 3c63a58826..4c2d4347fc 100644
--- a/src/shared/cpu-set-util.h
+++ b/src/shared/cpu-set-util.h
@@ -6,6 +6,8 @@
#include "macro.h"
#include "missing_syscall.h"
+typedef unsigned long __cpu_mask;
+
/* This wraps the libc interface with a variable to keep the allocated size. */
typedef struct CPUSet {
cpu_set_t *set;
diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c
index ea0c58770e..b65c0bd370 100644
--- a/src/test/test-sizeof.c
+++ b/src/test/test-sizeof.c
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <sched.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
@@ -12,6 +11,7 @@
#include <float.h>
#include "time-util.h"
+#include "cpu-set-util.h"
/* Print information about various types. Useful when diagnosing
* gcc diagnostics on an unfamiliar architecture. */

View File

@@ -0,0 +1,170 @@
From bc62e5e507cc3f10fde7d35d16059a06a78757b6 Mon Sep 17 00:00:00 2001
From: Alex Kiernan <alex.kiernan@gmail.com>
Date: Tue, 10 Mar 2020 11:05:20 +0000
Subject: [PATCH] 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 <alex.kiernan@gmail.com>
[Rebased for v247]
Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
---
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 414a49331b..1a4e1b628c 100644
--- a/src/shared/user-record-nss.c
+++ b/src/shared/user-record-nss.c
@@ -329,8 +329,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)
@@ -346,6 +348,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);
@@ -361,6 +364,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)),
@@ -387,6 +391,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;
@@ -415,6 +420,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(
@@ -426,7 +434,9 @@ int nss_group_record_by_name(
struct group grp, *result;
bool incomplete = false;
size_t buflen = 4096;
+#if ENABLE_GSHADOW
struct sgrp sgrp, *sresult = NULL;
+#endif
int r;
assert(name);
@@ -455,6 +465,7 @@ int nss_group_record_by_name(
buf = mfree(buf);
}
+#if ENABLE_GSHADOW
if (with_shadow) {
r = nss_sgrp_for_group(result, &sgrp, &sbuf);
if (r < 0) {
@@ -466,6 +477,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;
@@ -483,7 +497,9 @@ int nss_group_record_by_gid(
struct group grp, *result;
bool incomplete = false;
size_t buflen = 4096;
+#if ENABLE_GSHADOW
struct sgrp sgrp, *sresult = NULL;
+#endif
int r;
for (;;) {
@@ -509,6 +525,7 @@ int nss_group_record_by_gid(
buf = mfree(buf);
}
+#if ENABLE_GSHADOW
if (with_shadow) {
r = nss_sgrp_for_group(result, &sgrp, &sbuf);
if (r < 0) {
@@ -520,6 +537,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 <grp.h>
+#if ENABLE_GSHADOW
#include <gshadow.h>
+#else
+struct sgrp;
+#endif
#include <pwd.h>
#include <shadow.h>
diff --git a/src/shared/userdb.c b/src/shared/userdb.c
index 7469768233..556e6b84e6 100644
--- a/src/shared/userdb.c
+++ b/src/shared/userdb.c
@@ -1039,13 +1039,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) {
@@ -1058,6 +1060,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;

View File

@@ -0,0 +1,46 @@
From 79f2f3e90229f4812d93c6965cb67385642dfcc4 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 12 Apr 2021 23:44:53 -0700
Subject: [PATCH] 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 <raj.khem@gmail.com>
---
src/basic/missing_syscall.h | 6 ++++++
src/shared/base-filesystem.c | 1 +
2 files changed, 7 insertions(+)
diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h
index e2cd8b4e35..f2fe489de7 100644
--- a/src/basic/missing_syscall.h
+++ b/src/basic/missing_syscall.h
@@ -20,6 +20,12 @@
#include <asm/sgidefs.h>
#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"
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index dc59a9582c..9e802ef5a5 100644
--- 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 */

View File

@@ -0,0 +1,34 @@
From a8e07d87adfeb1c72c6eaf5402db465a78e08ee6 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 21 Jan 2022 15:15:11 -0800
Subject: [PATCH] pass correct parameters to getdents64
Fixes
../git/src/basic/recurse-dir.c:57:40: error: incompatible pointer types passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types]
n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../git/src/basic/stat-util.c:102:28: error: incompatible pointer types passing 'union (unnamed union at ../git/src/basic/stat-util.c:78:9) *' to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types]
n = getdents64(fd, &buffer, sizeof(buffer));
^~~~~~~
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
---
src/basic/recurse-dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/basic/recurse-dir.c b/src/basic/recurse-dir.c
index d648862dbc..a1fea243e8 100644
--- a/src/basic/recurse-dir.c
+++ b/src/basic/recurse-dir.c
@@ -55,7 +55,7 @@ int readdir_all(int dir_fd,
bs = MIN(MALLOC_SIZEOF_SAFE(de) - offsetof(DirectoryEntries, buffer), (size_t) SSIZE_MAX);
assert(bs > de->buffer_size);
- n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
+ n = getdents64(dir_fd, (struct dirent*)((uint8_t*) de->buffer + de->buffer_size), bs - de->buffer_size);
if (n < 0)
return -errno;
if (n == 0)

View File

@@ -0,0 +1,569 @@
From 5da745dc6f60f6fac65371a60eee7cecaf575eae Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 21 Jan 2022 22:19:37 -0800
Subject: [PATCH] Adjust for musl headers
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
[Rebased for v255.1]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
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 | 2 +-
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-bridge-mdb.c | 4 ++--
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-route.c | 8 ++++----
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 +-
38 files changed, 45 insertions(+), 42 deletions(-)
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index c20367dfc9..b8d4cd8c2a 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -5,7 +5,7 @@
#include <errno.h>
#include <sys/ioctl.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_infiniband.h>
#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 <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#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 <inttypes.h>
#include <netinet/in.h>
#include <linux/genetlink.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "batadv.h"
#include "fileio.h"
diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c
index 4d75a0d6bf..985b3197e0 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 <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "alloc-util.h"
#include "bond.h"
diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c
index 3e394edadf..f12f667687 100644
--- a/src/network/netdev/bridge.c
+++ b/src/network/netdev/bridge.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_bridge.h>
#include "bridge.h"
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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "dummy.h"
diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c
index bc655ec7ff..a77e8e17e4 100644
--- a/src/network/netdev/geneve.c
+++ b/src/network/netdev/geneve.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "alloc-util.h"
#include "conf-parser.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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_link.h>
#include "ipoib.h"
diff --git a/src/network/netdev/ipvlan.c b/src/network/netdev/ipvlan.c
index 05d5d010f6..d440f49537 100644
--- a/src/network/netdev/ipvlan.c
+++ b/src/network/netdev/ipvlan.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "conf-parser.h"
#include "ipvlan.h"
diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c
index 17d6acefb6..679d0984f9 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 <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_macsec.h>
#include <linux/genetlink.h>
diff --git a/src/network/netdev/macvlan.c b/src/network/netdev/macvlan.c
index 203807e3a5..8ab09a387e 100644
--- a/src/network/netdev/macvlan.c
+++ b/src/network/netdev/macvlan.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "conf-parser.h"
#include "macvlan.h"
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
index 57127a861a..7f787d0b9f 100644
--- a/src/network/netdev/netdev.c
+++ b/src/network/netdev/netdev.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <unistd.h>
#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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "nlmon.h"
diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c
index ab3b8fbb51..68f88b3ca3 100644
--- a/src/network/netdev/tunnel.c
+++ b/src/network/netdev/tunnel.c
@@ -2,7 +2,7 @@
#include <netinet/in.h>
#include <linux/fou.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_tunnel.h>
#include <linux/ip.h>
#include <linux/ip6_tunnel.h>
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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "vcan.h"
diff --git a/src/network/netdev/veth.c b/src/network/netdev/veth.c
index e0f5b4ebb1..8a424ed03d 100644
--- a/src/network/netdev/veth.c
+++ b/src/network/netdev/veth.c
@@ -3,7 +3,7 @@
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/veth.h>
#include "netlink-util.h"
diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c
index 2390206993..efec630e30 100644
--- a/src/network/netdev/vlan.c
+++ b/src/network/netdev/vlan.c
@@ -2,7 +2,7 @@
#include <errno.h>
#include <net/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_vlan.h>
#include "parse-util.h"
diff --git a/src/network/netdev/vrf.c b/src/network/netdev/vrf.c
index b75ec2bcc6..6aeeea640b 100644
--- a/src/network/netdev/vrf.c
+++ b/src/network/netdev/vrf.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#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 <linux/can/vxcan.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "vxcan.h"
diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c
index b11fdbbd0d..a971a917f0 100644
--- a/src/network/netdev/vxlan.c
+++ b/src/network/netdev/vxlan.c
@@ -2,7 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "conf-parser.h"
#include "alloc-util.h"
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index 52fed20b57..e66bc34993 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -6,7 +6,7 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/ipv6_route.h>
#include "sd-resolve.h"
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 <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "missing_network.h"
#include "xfrm.h"
diff --git a/src/network/networkd-bridge-mdb.c b/src/network/networkd-bridge-mdb.c
index bd1a9745dc..949d3da029 100644
--- a/src/network/networkd-bridge-mdb.c
+++ b/src/network/networkd-bridge-mdb.c
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <net/if.h>
-#include <linux/if_bridge.h>
#include "netlink-util.h"
#include "networkd-bridge-mdb.h"
@@ -11,6 +9,8 @@
#include "networkd-queue.h"
#include "string-util.h"
#include "vlan-util.h"
+#include <net/if.h>
+#include <linux/if_bridge.h>
#define STATIC_BRIDGE_MDB_ENTRIES_PER_NETWORK_MAX 1024U
diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c
index 080b15387c..efe8283957 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 <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
+#include <net/if.h>
#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 af2fe9efcd..511565700f 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 <linux/ipv6_route.h>
#include "dhcp6-lease-internal.h"
#include "hashmap.h"
@@ -20,6 +19,8 @@
#include "strv.h"
#include "tunnel.h"
+#include <linux/ipv6_route.h>
+
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 607fe0053c..9ce4005874 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 <netinet/in.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if.h>
#include "sd-dhcp-server.h"
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 8945827862..7571429523 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -3,7 +3,7 @@
#include <netinet/in.h>
#include <netinet/ip.h>
#include <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#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 <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "in-addr-util.h"
#include "networkd-address.h"
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index a4fa321264..0fd81a53d1 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -3,7 +3,7 @@
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_link.h>
#include <linux/netdevice.h>
#include <sys/socket.h>
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 840ccb158d..9f2e85e32f 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -6,7 +6,7 @@
#include <arpa/inet.h>
#include <netinet/icmp6.h>
#include <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "sd-ndisc.h"
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index eb502ae2cf..5b25ee4523 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -1,9 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <linux/icmpv6.h>
-#include <linux/ipv6_route.h>
-#include <linux/nexthop.h>
-
#include "alloc-util.h"
#include "event-util.h"
#include "netlink-util.h"
@@ -21,6 +17,10 @@
#include "vrf.h"
#include "wireguard.h"
+#include <linux/icmpv6.h>
+#include <linux/ipv6_route.h>
+#include <linux/nexthop.h>
+
int route_new(Route **ret) {
_cleanup_(route_freep) Route *route = NULL;
diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c
index 011ea1fe6e..59dfe733eb 100644
--- a/src/network/networkd-setlink.c
+++ b/src/network/networkd-setlink.c
@@ -2,7 +2,7 @@
#include <netinet/in.h>
#include <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/if_bridge.h>
#include "missing_network.h"
diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c
index 2b226b2e2a..f12a474e2f 100644
--- a/src/network/networkd-sysctl.c
+++ b/src/network/networkd-sysctl.c
@@ -2,7 +2,7 @@
#include <netinet/in.h>
#include <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include "missing_network.h"
#include "networkd-link.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 <linux/const.h>
#include <linux/types.h>
-#include <linux/if_ether.h>
+#include <netinet/if_ether.h>
+//#include <linux/if_ether.h>
#include <limits.h> /* for INT_MAX */
diff --git a/src/shared/netif-util.c b/src/shared/netif-util.c
index f56c5646c1..5af28ff119 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 <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#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 f528a46b8e..830318cda5 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -18,7 +18,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <linux/if.h>
-#include <linux/if_arp.h>
+//#include <linux/if_arp.h>
#include <linux/netdevice.h>
#include <linux/pci_regs.h>

View File

@@ -0,0 +1,49 @@
From 1c5c9714a2a9bc651687bf2c583019c52ed93ac4 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 8 Nov 2022 13:31:34 -0800
Subject: [PATCH] test-bus-error: strerror() is assumed to be GNU specific
version mark it so
Upstream-Status: Inappropriate [Upstream systemd only supports glibc]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/libsystemd/sd-bus/test-bus-error.c | 2 ++
src/test/test-errno-util.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/libsystemd/sd-bus/test-bus-error.c b/src/libsystemd/sd-bus/test-bus-error.c
index a55f3f9856..4123bf3da0 100644
--- a/src/libsystemd/sd-bus/test-bus-error.c
+++ b/src/libsystemd/sd-bus/test-bus-error.c
@@ -99,7 +99,9 @@ TEST(error) {
assert_se(!sd_bus_error_is_set(&error));
assert_se(sd_bus_error_set_errno(&error, EBUSY) == -EBUSY);
assert_se(streq(error.name, "System.Error.EBUSY"));
+#ifdef __GLIBC__
assert_se(streq(error.message, STRERROR(EBUSY)));
+#endif
assert_se(sd_bus_error_has_name(&error, "System.Error.EBUSY"));
assert_se(sd_bus_error_get_errno(&error) == EBUSY);
assert_se(sd_bus_error_is_set(&error));
diff --git a/src/test/test-errno-util.c b/src/test/test-errno-util.c
index 376d532281..967cfd4d67 100644
--- a/src/test/test-errno-util.c
+++ b/src/test/test-errno-util.c
@@ -4,7 +4,7 @@
#include "stdio-util.h"
#include "string-util.h"
#include "tests.h"
-
+#ifdef __GLIBC__
TEST(strerror_not_threadsafe) {
/* Just check that strerror really is not thread-safe. */
log_info("strerror(%d) → %s", 200, strerror(200));
@@ -46,6 +46,7 @@ TEST(STRERROR_OR_ELSE) {
log_info("STRERROR_OR_ELSE(EPERM, \"EOF\") → %s", STRERROR_OR_EOF(EPERM));
log_info("STRERROR_OR_ELSE(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM));
}
+#endif /* __GLIBC__ */
TEST(PROTECT_ERRNO) {
errno = 12;

View File

@@ -0,0 +1,39 @@
From 43f56ac05ff4b9c7774b6f580612f2a7896a4885 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 23 Jan 2023 23:39:46 -0800
Subject: [PATCH] errno-util: Make STRERROR portable for musl
Sadly, systemd has decided to use yet another GNU extention in a macro
lets make this such that we can use XSI compliant strerror_r() for
non-glibc hosts
Upstream-Status: Inappropriate [musl specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/basic/errno-util.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h
index 27804e6382..274c1c6ef1 100644
--- a/src/basic/errno-util.h
+++ b/src/basic/errno-util.h
@@ -15,8 +15,16 @@
* https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks
*
* Note that we use the GNU variant of strerror_r() here. */
-#define STRERROR(errnum) strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
-
+static inline const char * STRERROR(int errnum);
+
+static inline const char * STRERROR(int errnum) {
+#ifdef __GLIBC__
+ return strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN);
+#else
+ static __thread char buf[ERRNO_BUF_LEN];
+ return strerror_r(abs(errnum), buf, ERRNO_BUF_LEN) ? "unknown error" : buf;
+#endif
+}
/* A helper to print an error message or message for functions that return 0 on EOF.
* Note that we can't use ({ … }) to define a temporary variable, so errnum is
* evaluated twice. */

View File

@@ -0,0 +1,36 @@
From cda1cc94bd81c8ff9135255895a414fb938e2c79 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 2 Aug 2023 12:06:27 -0700
Subject: [PATCH] sd-event: Make malloc_trim() conditional on glibc
musl does not have this API
Upstream-Status: Inappropriate [musl-specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
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 b3541a1429..ba87265d9f 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1874,7 +1874,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
@@ -1888,7 +1888,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)

View File

@@ -0,0 +1,54 @@
From 2913e608d6e91c8037d698534f72970b4c365d8f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 2 Aug 2023 12:20:40 -0700
Subject: [PATCH] shared: Do not use malloc_info on musl
Upstream-Status: Inappropriate [musl-specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
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 74f148c8b4..2d862a123d 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -611,15 +611,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;
}

View File

@@ -0,0 +1,40 @@
From 9d151b5bb3105fb21d55a301def3d97b5a314580 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Tue, 2 Jan 2024 11:03:27 +0800
Subject: [PATCH] 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 <Qi.Chen@windriver.com>
---
src/core/exec-invoke.c | 1 +
src/shared/dev-setup.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c
index 9d27280ed0..569311422d 100644
--- a/src/core/exec-invoke.c
+++ b/src/core/exec-invoke.c
@@ -5,6 +5,7 @@
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/prctl.h>
+#include <sys/file.h>
#if HAVE_PAM
#include <security/pam_appl.h>
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 <sys/types.h>
+#include <sys/file.h>
int lock_dev_console(void);

View File

@@ -0,0 +1 @@
disable *

View File

@@ -0,0 +1,104 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: udev
# Required-Start: mountvirtfs
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Start udevd, populate /dev and load drivers.
### END INIT INFO
. /etc/init.d/functions
export TZ=/etc/localtime
[ -d /sys/class ] || exit 1
[ -r /proc/mounts ] || exit 1
[ -x @UDEVD@ ] || exit 1
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
readfile () {
filename=$1
READDATA=""
if [ -r $filename ]; then
while read line; do
READDATA="$READDATA$line"
done < $filename
fi
}
case "$1" in
start)
export ACTION=add
# propagate /dev from /sys
echo "Starting udev"
# mount the devtmpfs on /dev, if not already done
LANG=C awk '$2 == "/dev" && ($3 == "devtmpfs") { exit 1 }' /proc/mounts && {
mount -n -o mode=0755 -t devtmpfs none "/dev"
}
[ -e /dev/pts ] || mkdir -m 0755 /dev/pts
[ -e /dev/shm ] || mkdir -m 1777 /dev/shm
mount -a -t tmpfs 2>/dev/null
# cache handling
if [ "$DEVCACHE" != "" ]; then
readfile /proc/version
VERSION="$READDATA"
readfile /proc/cmdline
CMDLINE="$READDATA"
readfile /proc/devices
DEVICES="$READDATA"
readfile /proc/atags
ATAGS="$READDATA"
if [ -e $DEVCACHE ]; then
readfile /etc/udev/cache.data
if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then
(cd /; tar xf $DEVCACHE > /dev/null 2>&1)
not_first_boot=1
[ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
[ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache
else
echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache
fi
else
echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache
fi
fi
# make_extra_nodes
killproc systemd-udevd > "/dev/null" 2>&1
# trigger the sorted events
echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
@UDEVD@ -d
udevadm control --env=STARTUP=1
if [ "$not_first_boot" != "" ];then
udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform
(udevadm settle --timeout=3; udevadm control --env=STARTUP=)&
else
udevadm trigger --action=add
udevadm settle
fi
;;
stop)
echo "Stopping udevd"
start-stop-daemon --stop --name systemd-udevd --quiet
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
status systemd-udevd
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0

View File

@@ -0,0 +1,11 @@
<?xml version="1.0"?> <!--*-nxml-*-->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy group="systemd-hostname">
<allow own="org.freedesktop.hostname1"/>
<allow send_destination="org.freedesktop.hostname1"/>
<allow receive_sender="org.freedesktop.hostname1"/>
</policy>
</busconfig>

View File

@@ -0,0 +1,7 @@
# Systemd expect a color capable pager, however the less provided
# by busybox is not. This make many interaction with systemd pretty
# annoying. As a workaround we disable the systemd pager if less
# is not the GNU version.
if ! less -V > /dev/null 2>&1 ; then
export SYSTEMD_PAGER=
fi

View File

@@ -0,0 +1,18 @@
# There are a number of modifiers that are allowed to be used in some
# of the different fields. They provide the following subsitutions:
#
# %n the "kernel number" of the device.
# For example, 'sda3' has a "kernel number" of '3'
# %e the smallest number for that name which does not matches an existing node
# %k the kernel name for the device
# %M the kernel major number for the device
# %m the kernel minor number for the device
# %b the bus id for the device
# %c the string returned by the PROGRAM
# %s{filename} the content of a sysfs attribute
# %% the '%' char itself
#
# Create a symlink to any touchscreen input device
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{modalias}=="input:*-e0*,3,*a0,1,*18,*", SYMLINK+="input/touchscreen0"
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{modalias}=="ads7846", SYMLINK+="input/touchscreen0"

View File

@@ -0,0 +1,896 @@
require systemd.inc
PROVIDES = "udev"
PE = "1"
DEPENDS = "gperf-native libcap util-linux python3-jinja2-native"
SECTION = "base/shell"
inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives qemu systemd gettext bash-completion manpages features_check
# unmerged-usr support is deprecated upstream, taints the system and will be
# removed in the near future. Fail the build if it is not enabled.
REQUIRED_DISTRO_FEATURES += "usrmerge"
# As this recipe builds udev, respect systemd being in DISTRO_FEATURES so
# that we don't build both udev and systemd in world builds.
REQUIRED_DISTRO_FEATURES += "systemd"
SRC_URI += " \
file://touchscreen.rules \
file://00-create-volatile.conf \
${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', 'file://org.freedesktop.hostname1_no_polkit.conf', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', 'file://00-hostnamed-network-user.conf', '', d)} \
file://init \
file://99-default.preset \
file://systemd-pager.sh \
file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
file://0003-timedated-Respond-on-org.freedesktop.timedate1.SetNT.patch \
file://0008-implment-systemd-sysv-install-for-OE.patch \
"
# patches needed by musl
SRC_URI:append:libc-musl = " ${SRC_URI_MUSL}"
SRC_URI_MUSL = "\
file://0001-missing_type.h-add-comparison_fn_t.patch \
file://0002-add-fallback-parse_printf_format-implementation.patch \
file://0003-src-basic-missing.h-check-for-missing-strndupa.patch \
file://0004-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch \
file://0005-add-missing-FTW_-macros-for-musl.patch \
file://0006-Use-uintmax_t-for-handling-rlim_t.patch \
file://0007-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch \
file://0008-Define-glibc-compatible-basename-for-non-glibc-syste.patch \
file://0009-Do-not-disable-buffering-when-writing-to-oom_score_a.patch \
file://0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch \
file://0011-avoid-redefinition-of-prctl_mm_map-structure.patch \
file://0012-do-not-disable-buffer-in-writing-files.patch \
file://0013-Handle-__cpu_mask-usage.patch \
file://0014-Handle-missing-gshadow.patch \
file://0015-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch \
file://0016-pass-correct-parameters-to-getdents64.patch \
file://0017-Adjust-for-musl-headers.patch \
file://0018-test-bus-error-strerror-is-assumed-to-be-GNU-specifi.patch \
file://0019-errno-util-Make-STRERROR-portable-for-musl.patch \
file://0020-sd-event-Make-malloc_trim-conditional-on-glibc.patch \
file://0021-shared-Do-not-use-malloc_info-on-musl.patch \
file://0022-avoid-missing-LOCK_EX-declaration.patch \
"
PAM_PLUGINS = " \
pam-plugin-unix \
pam-plugin-loginuid \
pam-plugin-keyinit \
pam-plugin-namespace \
"
PACKAGECONFIG ??= " \
${@bb.utils.filter('DISTRO_FEATURES', 'acl audit efi ldconfig pam pni-names selinux smack usrmerge polkit seccomp', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'minidebuginfo', 'coredump elfutils', '', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'wifi', 'rfkill', '', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xkbcommon', '', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', 'link-udev-shared', d)} \
backlight \
binfmt \
cgroupv2 \
gshadow \
hibernate \
hostnamed \
idn \
ima \
kmod \
localed \
logind \
machined \
myhostname \
networkd \
nss \
nss-mymachines \
nss-resolve \
quotacheck \
randomseed \
resolved \
set-time-epoch \
sysusers \
sysvinit \
timedated \
timesyncd \
userdb \
utmp \
vconsole \
wheel-group \
zstd \
"
PACKAGECONFIG:remove:libc-musl = " \
gshadow \
idn \
localed \
myhostname \
nss \
nss-mymachines \
nss-resolve \
sysusers \
userdb \
utmp \
"
# https://github.com/seccomp/libseccomp/issues/347
PACKAGECONFIG:remove:mipsarch = "seccomp"
TARGET_CC_ARCH:append:libc-musl = " -D__UAPI_DEF_ETHHDR=0 -D_LARGEFILE64_SOURCE"
# Some of the dependencies are weak-style recommends - if not available at runtime,
# systemd won't fail but the library-related feature will be skipped with a warning.
# Use the upstream systemd serial-getty@.service and rely on
# systemd-getty-generator instead of using the OE-core specific
# systemd-serialgetty.bb - not enabled by default.
PACKAGECONFIG[serial-getty-generator] = ""
PACKAGECONFIG[acl] = "-Dacl=true,-Dacl=false,acl"
PACKAGECONFIG[audit] = "-Daudit=true,-Daudit=false,audit"
PACKAGECONFIG[backlight] = "-Dbacklight=true,-Dbacklight=false"
PACKAGECONFIG[binfmt] = "-Dbinfmt=true,-Dbinfmt=false"
PACKAGECONFIG[bzip2] = "-Dbzip2=true,-Dbzip2=false,bzip2"
PACKAGECONFIG[cgroupv2] = "-Ddefault-hierarchy=unified,-Ddefault-hierarchy=hybrid"
PACKAGECONFIG[coredump] = "-Dcoredump=true,-Dcoredump=false"
PACKAGECONFIG[cryptsetup] = "-Dlibcryptsetup=true,-Dlibcryptsetup=false,cryptsetup,,cryptsetup"
PACKAGECONFIG[cryptsetup-plugins] = "-Dlibcryptsetup-plugins=true,-Dlibcryptsetup-plugins=false,cryptsetup,,cryptsetup"
PACKAGECONFIG[tpm2] = "-Dtpm2=true,-Dtpm2=false,tpm2-tss,tpm2-tss libtss2 libtss2-tcti-device"
# If multiple compression libraries are enabled, the format to use for compression is chosen implicitly,
# so if you want to compress with e.g. lz4 you cannot enable zstd, so you cannot read zstd-compressed journal files.
# This option allows to enable all compression formats for reading, but choosing a specific one for writing.
PACKAGECONFIG[default-compression-lz4] = "-Dlz4=true -Ddefault-compression=lz4,,lz4"
PACKAGECONFIG[default-compression-xz] = "-Dxz=true -Ddefault-compression=xz,,xz"
PACKAGECONFIG[default-compression-zstd] = "-Dzstd=true -Ddefault-compression=zstd,,zstd"
PACKAGECONFIG[dbus] = "-Ddbus=true,-Ddbus=false,dbus"
PACKAGECONFIG[efi] = "-Defi=true -Dbootloader=true,-Defi=false -Dbootloader=false,python3-pyelftools-native"
PACKAGECONFIG[elfutils] = "-Delfutils=true,-Delfutils=false,elfutils,,libelf libdw"
PACKAGECONFIG[firstboot] = "-Dfirstboot=true,-Dfirstboot=false"
PACKAGECONFIG[repart] = "-Drepart=true,-Drepart=false"
PACKAGECONFIG[homed] = "-Dhomed=true,-Dhomed=false"
# Sign the journal for anti-tampering
PACKAGECONFIG[gcrypt] = "-Dgcrypt=true,-Dgcrypt=false,libgcrypt"
PACKAGECONFIG[gnutls] = "-Dgnutls=true,-Dgnutls=false,gnutls"
PACKAGECONFIG[gshadow] = "-Dgshadow=true,-Dgshadow=false"
PACKAGECONFIG[hibernate] = "-Dhibernate=true,-Dhibernate=false"
PACKAGECONFIG[hostnamed] = "-Dhostnamed=true,-Dhostnamed=false"
PACKAGECONFIG[idn] = "-Didn=true,-Didn=false"
PACKAGECONFIG[ima] = "-Dima=true,-Dima=false"
# importd requires journal-upload/xz/zlib/bzip2/gcrypt
PACKAGECONFIG[importd] = "-Dimportd=true,-Dimportd=false,glib-2.0"
# Update NAT firewall rules
PACKAGECONFIG[iptc] = "-Dlibiptc=true,-Dlibiptc=false,iptables"
PACKAGECONFIG[journal-color] = ",,,less"
PACKAGECONFIG[journal-upload] = "-Dlibcurl=true,-Dlibcurl=false,curl"
PACKAGECONFIG[kmod] = "-Dkmod=true,-Dkmod=false,kmod"
PACKAGECONFIG[ldconfig] = "-Dldconfig=true,-Dldconfig=false,,ldconfig"
PACKAGECONFIG[libidn] = "-Dlibidn=true,-Dlibidn=false,libidn,,libidn"
PACKAGECONFIG[libidn2] = "-Dlibidn2=true,-Dlibidn2=false,libidn2,,libidn2"
# Link udev shared with systemd helper library.
# If enabled the udev package depends on the systemd package (which has the needed shared library).
PACKAGECONFIG[link-udev-shared] = "-Dlink-udev-shared=true,-Dlink-udev-shared=false"
PACKAGECONFIG[localed] = "-Dlocaled=true,-Dlocaled=false"
PACKAGECONFIG[logind] = "-Dlogind=true,-Dlogind=false"
PACKAGECONFIG[lz4] = "-Dlz4=true,-Dlz4=false,lz4"
PACKAGECONFIG[machined] = "-Dmachined=true,-Dmachined=false"
PACKAGECONFIG[manpages] = "-Dman=true,-Dman=false,libxslt-native xmlto-native docbook-xml-dtd4-native docbook-xsl-stylesheets-native"
PACKAGECONFIG[microhttpd] = "-Dmicrohttpd=true,-Dmicrohttpd=false,libmicrohttpd"
PACKAGECONFIG[myhostname] = "-Dnss-myhostname=true,-Dnss-myhostname=false,,libnss-myhostname"
PACKAGECONFIG[networkd] = "-Dnetworkd=true,-Dnetworkd=false"
PACKAGECONFIG[no-dns-fallback] = "-Ddns-servers="
PACKAGECONFIG[no-ntp-fallback] = "-Dntp-servers="
PACKAGECONFIG[nss] = "-Dnss-systemd=true,-Dnss-systemd=false,,libnss-systemd"
PACKAGECONFIG[nss-mymachines] = "-Dnss-mymachines=true,-Dnss-mymachines=false"
PACKAGECONFIG[nss-resolve] = "-Dnss-resolve=true,-Dnss-resolve=false"
PACKAGECONFIG[oomd] = "-Doomd=true,-Doomd=false"
PACKAGECONFIG[openssl] = "-Dopenssl=true,-Dopenssl=false,openssl"
PACKAGECONFIG[p11kit] = "-Dp11kit=true,-Dp11kit=false,p11-kit"
PACKAGECONFIG[pam] = "-Dpam=true,-Dpam=false,libpam,${PAM_PLUGINS}"
PACKAGECONFIG[pcre2] = "-Dpcre2=true,-Dpcre2=false,libpcre2,,libpcre2"
PACKAGECONFIG[polkit] = "-Dpolkit=true,-Dpolkit=false"
# If polkit is disabled and networkd+hostnamed are in use, enabling this option and
# using dbus-broker will allow networkd to be authorized to change the
# hostname without acquiring additional privileges
PACKAGECONFIG[polkit_hostnamed_fallback] = ",,,,dbus-broker,polkit"
PACKAGECONFIG[portabled] = "-Dportabled=true,-Dportabled=false"
PACKAGECONFIG[pstore] = "-Dpstore=true,-Dpstore=false"
PACKAGECONFIG[pni-names] = ",,,"
PACKAGECONFIG[qrencode] = "-Dqrencode=true,-Dqrencode=false,qrencode,,qrencode"
PACKAGECONFIG[quotacheck] = "-Dquotacheck=true,-Dquotacheck=false"
PACKAGECONFIG[randomseed] = "-Drandomseed=true,-Drandomseed=false"
PACKAGECONFIG[resolved] = "-Dresolve=true,-Dresolve=false"
PACKAGECONFIG[rfkill] = "-Drfkill=true,-Drfkill=false"
PACKAGECONFIG[seccomp] = "-Dseccomp=true,-Dseccomp=false,libseccomp"
PACKAGECONFIG[selinux] = "-Dselinux=true,-Dselinux=false,libselinux,initscripts-sushell"
PACKAGECONFIG[smack] = "-Dsmack=true,-Dsmack=false"
PACKAGECONFIG[sysext] = "-Dsysext=true, -Dsysext=false"
PACKAGECONFIG[sysusers] = "-Dsysusers=true,-Dsysusers=false"
PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,systemd-compat-units update-rc.d"
# When enabled use reproducible build timestamp if set as time epoch,
# or build time if not. When disabled, time epoch is unset.
def build_epoch(d):
epoch = d.getVar('SOURCE_DATE_EPOCH') or "-1"
return '-Dtime-epoch=%d' % int(epoch)
PACKAGECONFIG[set-time-epoch] = "${@build_epoch(d)},-Dtime-epoch=0"
PACKAGECONFIG[timedated] = "-Dtimedated=true,-Dtimedated=false"
PACKAGECONFIG[timesyncd] = "-Dtimesyncd=true,-Dtimesyncd=false"
PACKAGECONFIG[usrmerge] = "-Dsplit-usr=false,-Dsplit-usr=true"
PACKAGECONFIG[sbinmerge] = "-Dsplit-bin=false,-Dsplit-bin=true"
PACKAGECONFIG[userdb] = "-Duserdb=true,-Duserdb=false"
PACKAGECONFIG[utmp] = "-Dutmp=true,-Dutmp=false"
PACKAGECONFIG[valgrind] = "-DVALGRIND=1,,valgrind"
PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${PN}-vconsole-setup"
PACKAGECONFIG[wheel-group] = "-Dwheel-group=true, -Dwheel-group=false"
PACKAGECONFIG[xdg-autostart] = "-Dxdg-autostart=true,-Dxdg-autostart=false"
# Verify keymaps on locale change
PACKAGECONFIG[xkbcommon] = "-Dxkbcommon=true,-Dxkbcommon=false,libxkbcommon"
PACKAGECONFIG[xz] = "-Dxz=true,-Dxz=false,xz"
PACKAGECONFIG[zlib] = "-Dzlib=true,-Dzlib=false,zlib"
PACKAGECONFIG[zstd] = "-Dzstd=true,-Dzstd=false,zstd"
RESOLV_CONF ??= ""
# Helper variables to clarify locations. This mirrors the logic in systemd's
# build system.
rootprefix ?= "${root_prefix}"
rootlibdir ?= "${base_libdir}"
rootlibexecdir = "${rootprefix}/lib"
EXTRA_OEMESON += "-Dnobody-user=nobody \
-Dnobody-group=nogroup \
-Drootlibdir=${rootlibdir} \
-Drootprefix=${rootprefix} \
-Ddefault-locale=C \
-Dmode=release \
-Dsystem-alloc-uid-min=101 \
-Dsystem-uid-max=999 \
-Dsystem-alloc-gid-min=101 \
-Dsystem-gid-max=999 \
${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', '-Ddefault-mdns=no -Ddefault-llmnr=no', '', d)} \
"
# Hardcode target binary paths to avoid using paths from sysroot or worse
# it pokes for these binaries on build host and encodes that distro assumption
# into target
EXTRA_OEMESON += "-Dkexec-path=${sbindir}/kexec \
-Dkmod-path=${base_bindir}/kmod \
-Dmount-path=${base_bindir}/mount \
-Dquotacheck-path=${sbindir}/quotacheck \
-Dquotaon-path=${sbindir}/quotaon \
-Dsulogin-path=${base_sbindir}/sulogin \
-Dnologin-path=${base_sbindir}/nologin \
-Dumount-path=${base_bindir}/umount \
-Dloadkeys-path=${bindir}/loadkeys \
-Dsetfont-path=${bindir}/setfont"
# The 60 seconds is watchdog's default vaule.
WATCHDOG_TIMEOUT ??= "60"
do_install() {
meson_do_install
if ${@bb.utils.contains('PACKAGECONFIG', 'sysusers', 'true', 'false', d)}; then
# Change the root user's home directory in /lib/sysusers.d/basic.conf.
# This is done merely for backward compatibility with previous systemd recipes.
# systemd hardcodes root user's HOME to be "/root". Changing to use other values
# may have unexpected runtime behaviors.
if [ "${ROOT_HOME}" != "/root" ]; then
bbwarn "Using ${ROOT_HOME} as root user's home directory is not fully supported by systemd"
sed -i -e 's#/root#${ROOT_HOME}#g' ${D}${exec_prefix}/lib/sysusers.d/basic.conf
fi
fi
install -d ${D}/${base_sbindir}
if ${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', 'false', 'true', d)}; then
# Provided by a separate recipe
rm ${D}${systemd_system_unitdir}/serial-getty* -f
fi
# Provide support for initramfs
[ ! -e ${D}/init ] && ln -s ${rootlibexecdir}/systemd/systemd ${D}/init
[ ! -e ${D}/${base_sbindir}/udevd ] && ln -s ${rootlibexecdir}/systemd/systemd-udevd ${D}/${base_sbindir}/udevd
install -d ${D}${sysconfdir}/udev/rules.d/
install -d ${D}${nonarch_libdir}/tmpfiles.d
for rule in $(find ${WORKDIR} -maxdepth 1 -type f -name "*.rules"); do
install -m 0644 $rule ${D}${sysconfdir}/udev/rules.d/
done
install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${nonarch_libdir}/tmpfiles.d/
if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/systemd-udevd
sed -i s%@UDEVD@%${rootlibexecdir}/systemd/systemd-udevd% ${D}${sysconfdir}/init.d/systemd-udevd
install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_unitdir}/systemd-sysv-install
fi
if "${@'true' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'false'}"; then
# base-files recipe provides /var/log which is a symlink to /var/volatile/log
rm -rf ${D}${localstatedir}/log
printf 'L\t\t%s/log\t\t-\t-\t-\t-\t%s/volatile/log\n' "${localstatedir}" \
"${localstatedir}" >>${D}${nonarch_libdir}/tmpfiles.d/00-create-volatile.conf
elif [ -e ${D}${localstatedir}/log/journal ]; then
chown root:systemd-journal ${D}${localstatedir}/log/journal
# journal-remote creates this at start
rm -rf ${D}${localstatedir}/log/journal/remote
fi
# if the user requests /tmp be on persistent storage (i.e. not volatile)
# then don't use a tmpfs for /tmp
if [ "${VOLATILE_TMP_DIR}" != "yes" ]; then
rm -f ${D}${rootlibdir}/systemd/system/tmp.mount
rm -f ${D}${rootlibdir}/systemd/system/local-fs.target.wants/tmp.mount
fi
install -d ${D}${systemd_system_unitdir}/graphical.target.wants
install -d ${D}${systemd_system_unitdir}/multi-user.target.wants
install -d ${D}${systemd_system_unitdir}/poweroff.target.wants
install -d ${D}${systemd_system_unitdir}/reboot.target.wants
install -d ${D}${systemd_system_unitdir}/rescue.target.wants
# Create symlinks for systemd-update-utmp-runlevel.service
if ${@bb.utils.contains('PACKAGECONFIG', 'utmp', 'true', 'false', d)}; then
ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/graphical.target.wants/systemd-update-utmp-runlevel.service
ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/multi-user.target.wants/systemd-update-utmp-runlevel.service
ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/poweroff.target.wants/systemd-update-utmp-runlevel.service
ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/reboot.target.wants/systemd-update-utmp-runlevel.service
ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_system_unitdir}/rescue.target.wants/systemd-update-utmp-runlevel.service
fi
# this file is needed to exist if networkd is disabled but timesyncd is still in use since timesyncd checks it
# for existence else it fails
if [ -s ${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf ] &&
! ${@bb.utils.contains('PACKAGECONFIG', 'networkd', 'true', 'false', d)}; then
echo 'd /run/systemd/netif/links 0755 root root -' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
fi
if ! ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'true', 'false', d)}; then
echo 'L! ${sysconfdir}/resolv.conf - - - - ../run/systemd/resolve/resolv.conf' >>${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
echo 'd /run/systemd/resolve 0755 root root -' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
echo 'f /run/systemd/resolve/resolv.conf 0644 root root' >>${D}${exec_prefix}/lib/tmpfiles.d/systemd.conf
ln -s ../run/systemd/resolve/resolv.conf ${D}${sysconfdir}/resolv-conf.systemd
else
resolv_conf="${@bb.utils.contains('RESOLV_CONF', 'stub-resolv', 'run/systemd/resolve/stub-resolv.conf', 'run/systemd/resolve/resolv.conf', d)}"
sed -i -e "s%^L! /etc/resolv.conf.*$%L! /etc/resolv.conf - - - - ../${resolv_conf}%g" ${D}${exec_prefix}/lib/tmpfiles.d/etc.conf
ln -s ../${resolv_conf} ${D}${sysconfdir}/resolv-conf.systemd
fi
if ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'false', 'true', d)}; then
rm ${D}${exec_prefix}/lib/tmpfiles.d/x11.conf
rm -r ${D}${sysconfdir}/X11
fi
# If polkit is setup fixup permissions and ownership
if ${@bb.utils.contains('PACKAGECONFIG', 'polkit', 'true', 'false', d)}; then
if [ -d ${D}${datadir}/polkit-1/rules.d ]; then
chmod 700 ${D}${datadir}/polkit-1/rules.d
chown polkitd:root ${D}${datadir}/polkit-1/rules.d
fi
fi
# If polkit is not available and a fallback was requested, install a drop-in that allows networkd to
# request hostname changes via DBUS without elevating its privileges
if ${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', 'true', 'false', d)}; then
install -d ${D}${systemd_system_unitdir}/systemd-hostnamed.service.d/
install -m 0644 ${WORKDIR}/00-hostnamed-network-user.conf ${D}${systemd_system_unitdir}/systemd-hostnamed.service.d/
install -d ${D}${datadir}/dbus-1/system.d/
install -m 0644 ${WORKDIR}/org.freedesktop.hostname1_no_polkit.conf ${D}${datadir}/dbus-1/system.d/
fi
# create link for existing udev rules
ln -s ${base_bindir}/udevadm ${D}${base_sbindir}/udevadm
# install default policy for presets
# https://www.freedesktop.org/wiki/Software/systemd/Preset/#howto
install -Dm 0644 ${WORKDIR}/99-default.preset ${D}${systemd_unitdir}/system-preset/99-default.preset
# add a profile fragment to disable systemd pager with busybox less
install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh
if [ -n "${WATCHDOG_TIMEOUT}" ]; then
sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
${D}/${sysconfdir}/systemd/system.conf
fi
if ${@bb.utils.contains('PACKAGECONFIG', 'pni-names', 'true', 'false', d)}; then
if ! grep -q '^NamePolicy=.*mac' ${D}${rootlibexecdir}/systemd/network/99-default.link; then
sed -i '/^NamePolicy=/s/$/ mac/' ${D}${rootlibexecdir}/systemd/network/99-default.link
fi
if ! grep -q 'AlternativeNamesPolicy=.*mac' ${D}${rootlibexecdir}/systemd/network/99-default.link; then
sed -i '/AlternativeNamesPolicy=/s/$/ mac/' ${D}${rootlibexecdir}/systemd/network/99-default.link
fi
fi
if [ -e ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf ];then
sed -i -e '/^L \/var\/log\/README/d' ${D}${nonarch_libdir}/tmpfiles.d/legacy.conf
fi
}
python populate_packages:prepend (){
systemdlibdir = d.getVar("rootlibdir")
do_split_packages(d, systemdlibdir, r'^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True)
}
PACKAGES_DYNAMIC += "^lib(udev|systemd|nss).*"
PACKAGE_BEFORE_PN = "\
${PN}-analyze \
${PN}-binfmt \
${PN}-container \
${PN}-crypt \
${PN}-extra-utils \
${PN}-gui \
${PN}-initramfs \
${PN}-journal-gatewayd \
${PN}-journal-upload \
${PN}-journal-remote \
${PN}-kernel-install \
${PN}-rpm-macros \
${PN}-udev-rules \
${PN}-vconsole-setup \
${PN}-zsh-completion \
libsystemd-shared \
udev \
udev-bash-completion \
udev-hwdb \
"
SUMMARY:${PN}-container = "Tools for containers and VMs"
DESCRIPTION:${PN}-container = "Systemd tools to spawn and manage containers and virtual machines."
SUMMARY:${PN}-journal-gatewayd = "HTTP server for journal events"
DESCRIPTION:${PN}-journal-gatewayd = "systemd-journal-gatewayd serves journal events over the network. Clients must connect using HTTP. The server listens on port 19531 by default."
SUMMARY:${PN}-journal-upload = "Send journal messages over the network"
DESCRIPTION:${PN}-journal-upload = "systemd-journal-upload uploads journal entries to a specified URL."
SUMMARY:${PN}-journal-remote = "Receive journal messages over the network"
DESCRIPTION:${PN}-journal-remote = "systemd-journal-remote is a command to receive serialized journal events and store them to journal files."
SUMMARY:libsystemd-shared = "Systemd shared library"
SYSTEMD_PACKAGES = "${@bb.utils.contains('PACKAGECONFIG', 'binfmt', '${PN}-binfmt', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '${PN}-journal-gatewayd', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '${PN}-journal-remote', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'journal-upload', '${PN}-journal-upload', '', d)} \
"
SYSTEMD_SERVICE:${PN}-binfmt = "systemd-binfmt.service"
USERADD_PACKAGES = "${PN} \
udev \
${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '${PN}-journal-gatewayd', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'microhttpd', '${PN}-journal-remote', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'journal-upload', '${PN}-journal-upload', '', d)} \
"
GROUPADD_PARAM:${PN} = "-r systemd-journal;"
GROUPADD_PARAM:udev = "-r render"
GROUPADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', '-r systemd-hostname;', '', d)}"
USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'coredump', '--system -d / -M --shell /sbin/nologin systemd-coredump;', '', d)}"
USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'networkd', '--system -d / -M --shell /sbin/nologin systemd-network;', '', d)}"
USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'polkit', '--system --no-create-home --user-group --home-dir ${sysconfdir}/polkit-1 polkitd;', '', d)}"
USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'resolved', '--system -d / -M --shell /sbin/nologin systemd-resolve;', '', d)}"
USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'timesyncd', '--system -d / -M --shell /sbin/nologin systemd-timesync;', '', d)}"
USERADD_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'oomd', '--system -d / -M --shell /sbin/nologin systemd-oom;', '', d)}"
USERADD_PARAM:${PN}-journal-gatewayd = "--system -d / -M --shell /sbin/nologin systemd-journal-gateway"
USERADD_PARAM:${PN}-journal-remote = "--system -d / -M --shell /sbin/nologin systemd-journal-remote"
USERADD_PARAM:${PN}-journal-upload = "--system -d / -M --shell /sbin/nologin systemd-journal-upload"
FILES:${PN}-analyze = "${bindir}/systemd-analyze"
FILES:${PN}-crypt = "${bindir}/systemd-cryptenroll \
${libdir}/cryptsetup \
"
RRECOMMENDS:${PN} += "${PN}-crypt"
FILES:${PN}-initramfs = "/init"
RDEPENDS:${PN}-initramfs = "${PN}"
FILES:${PN}-gui = "${bindir}/systemadm"
FILES:${PN}-vconsole-setup = "${rootlibexecdir}/systemd/systemd-vconsole-setup \
${systemd_system_unitdir}/systemd-vconsole-setup.service \
${systemd_system_unitdir}/sysinit.target.wants/systemd-vconsole-setup.service"
RDEPENDS:${PN}-kernel-install += "bash"
FILES:${PN}-kernel-install = "${bindir}/kernel-install \
${sysconfdir}/kernel/ \
${exec_prefix}/lib/kernel \
"
FILES:${PN}-rpm-macros = "${exec_prefix}/lib/rpm \
"
FILES:${PN}-zsh-completion = "${datadir}/zsh/site-functions"
FILES:${PN}-binfmt = "${sysconfdir}/binfmt.d/ \
${exec_prefix}/lib/binfmt.d \
${rootlibexecdir}/systemd/systemd-binfmt \
${systemd_system_unitdir}/proc-sys-fs-binfmt_misc.* \
${systemd_system_unitdir}/systemd-binfmt.service"
RRECOMMENDS:${PN}-binfmt = "${@bb.utils.contains('PACKAGECONFIG', 'binfmt', 'kernel-module-binfmt-misc', '', d)}"
RDEPENDS:${PN}-vconsole-setup = "${@bb.utils.contains('PACKAGECONFIG', 'vconsole', 'kbd kbd-consolefonts kbd-keymaps', '', d)}"
FILES:${PN}-journal-gatewayd = "${rootlibexecdir}/systemd/systemd-journal-gatewayd \
${systemd_system_unitdir}/systemd-journal-gatewayd.service \
${systemd_system_unitdir}/systemd-journal-gatewayd.socket \
${systemd_system_unitdir}/sockets.target.wants/systemd-journal-gatewayd.socket \
${datadir}/systemd/gatewayd/browse.html \
"
SYSTEMD_SERVICE:${PN}-journal-gatewayd = "systemd-journal-gatewayd.socket"
FILES:${PN}-journal-upload = "${rootlibexecdir}/systemd/systemd-journal-upload \
${systemd_system_unitdir}/systemd-journal-upload.service \
${sysconfdir}/systemd/journal-upload.conf \
"
SYSTEMD_SERVICE:${PN}-journal-upload = "systemd-journal-upload.service"
FILES:${PN}-journal-remote = "${rootlibexecdir}/systemd/systemd-journal-remote \
${sysconfdir}/systemd/journal-remote.conf \
${systemd_system_unitdir}/systemd-journal-remote.service \
${systemd_system_unitdir}/systemd-journal-remote.socket \
"
SYSTEMD_SERVICE:${PN}-journal-remote = "systemd-journal-remote.socket"
FILES:${PN}-container = "${sysconfdir}/dbus-1/system.d/org.freedesktop.import1.conf \
${sysconfdir}/dbus-1/system.d/org.freedesktop.machine1.conf \
${sysconfdir}/systemd/system/multi-user.target.wants/machines.target \
${base_bindir}/machinectl \
${bindir}/systemd-nspawn \
${nonarch_libdir}/systemd/import-pubring.gpg \
${systemd_system_unitdir}/busnames.target.wants/org.freedesktop.import1.busname \
${systemd_system_unitdir}/busnames.target.wants/org.freedesktop.machine1.busname \
${systemd_system_unitdir}/local-fs.target.wants/var-lib-machines.mount \
${systemd_system_unitdir}/machines.target.wants/var-lib-machines.mount \
${systemd_system_unitdir}/remote-fs.target.wants/var-lib-machines.mount \
${systemd_system_unitdir}/machine.slice \
${systemd_system_unitdir}/machines.target \
${systemd_system_unitdir}/org.freedesktop.import1.busname \
${systemd_system_unitdir}/org.freedesktop.machine1.busname \
${systemd_system_unitdir}/systemd-importd.service \
${systemd_system_unitdir}/systemd-machined.service \
${systemd_system_unitdir}/dbus-org.freedesktop.machine1.service \
${systemd_system_unitdir}/var-lib-machines.mount \
${rootlibexecdir}/systemd/systemd-import \
${rootlibexecdir}/systemd/systemd-importd \
${rootlibexecdir}/systemd/systemd-machined \
${rootlibexecdir}/systemd/systemd-pull \
${exec_prefix}/lib/tmpfiles.d/systemd-nspawn.conf \
${exec_prefix}/lib/tmpfiles.d/README \
${systemd_system_unitdir}/systemd-nspawn@.service \
${datadir}/dbus-1/system-services/org.freedesktop.import1.service \
${datadir}/dbus-1/system-services/org.freedesktop.machine1.service \
${datadir}/dbus-1/system.d/org.freedesktop.import1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.machine1.conf \
${datadir}/polkit-1/actions/org.freedesktop.import1.policy \
${datadir}/polkit-1/actions/org.freedesktop.machine1.policy \
"
RDEPENDS:${PN}-container = "${@bb.utils.contains('PACKAGECONFIG', 'nss-mymachines', 'libnss-mymachines', '', d)}"
# "machinectl import-tar" uses "tar --numeric-owner", not supported by busybox.
RRECOMMENDS:${PN}-container += "\
${PN}-journal-gatewayd \
${PN}-journal-remote \
${PN}-journal-upload \
kernel-module-dm-mod \
kernel-module-loop \
kernel-module-tun \
tar \
"
FILES:${PN}-extra-utils = "\
${base_bindir}/systemd-escape \
${base_bindir}/systemd-inhibit \
${bindir}/systemd-detect-virt \
${bindir}/systemd-dissect \
${bindir}/systemd-path \
${bindir}/systemd-run \
${bindir}/systemd-cat \
${bindir}/systemd-creds \
${bindir}/systemd-delta \
${bindir}/systemd-cgls \
${bindir}/systemd-cgtop \
${bindir}/systemd-stdio-bridge \
${base_sbindir}/mount.ddi \
${systemd_system_unitdir}/initrd.target.wants/systemd-pcrphase-initrd.path \
${systemd_system_unitdir}/sysinit.target.wants/systemd-pcrphase.path \
${systemd_system_unitdir}/sysinit.target.wants/systemd-pcrphase-sysinit.path \
${rootlibexecdir}/systemd/systemd-resolve-host \
${rootlibexecdir}/systemd/systemd-ac-power \
${rootlibexecdir}/systemd/systemd-activate \
${rootlibexecdir}/systemd/systemd-measure \
${rootlibexecdir}/systemd/systemd-pcrphase \
${rootlibexecdir}/systemd/systemd-socket-proxyd \
${rootlibexecdir}/systemd/systemd-sleep \
${rootlibexecdir}/systemd/system-sleep \
${systemd_system_unitdir}/systemd-hibernate.service \
${systemd_system_unitdir}/systemd-hybrid-sleep.service \
${systemd_system_unitdir}/systemd-pcrphase-initrd.service \
${systemd_system_unitdir}/systemd-pcrphase.service \
${systemd_system_unitdir}/systemd-pcrphase-sysinit.service \
${systemd_system_unitdir}/systemd-suspend.service \
${systemd_system_unitdir}/sleep.target \
${rootlibexecdir}/systemd/systemd-initctl \
${systemd_system_unitdir}/systemd-initctl.service \
${systemd_system_unitdir}/systemd-initctl.socket \
${systemd_system_unitdir}/sockets.target.wants/systemd-initctl.socket \
${rootlibexecdir}/systemd/system-generators/systemd-gpt-auto-generator \
${rootlibexecdir}/systemd/systemd-cgroups-agent \
"
FILES:${PN}-udev-rules = "\
${rootlibexecdir}/udev/rules.d/70-uaccess.rules \
${rootlibexecdir}/udev/rules.d/71-seat.rules \
${rootlibexecdir}/udev/rules.d/73-seat-late.rules \
${rootlibexecdir}/udev/rules.d/99-systemd.rules \
"
CONFFILES:${PN} = "${sysconfdir}/systemd/coredump.conf \
${sysconfdir}/systemd/journald.conf \
${sysconfdir}/systemd/logind.conf \
${sysconfdir}/systemd/networkd.conf \
${sysconfdir}/systemd/pstore.conf \
${sysconfdir}/systemd/resolved.conf \
${sysconfdir}/systemd/sleep.conf \
${sysconfdir}/systemd/system.conf \
${sysconfdir}/systemd/timesyncd.conf \
${sysconfdir}/systemd/user.conf \
"
FILES:${PN} = " ${base_bindir}/* \
${base_sbindir}/shutdown \
${base_sbindir}/halt \
${base_sbindir}/poweroff \
${base_sbindir}/runlevel \
${base_sbindir}/telinit \
${base_sbindir}/resolvconf \
${base_sbindir}/reboot \
${base_sbindir}/init \
${datadir}/dbus-1/services \
${datadir}/dbus-1/system-services \
${datadir}/polkit-1 \
${datadir}/${BPN} \
${datadir}/factory \
${sysconfdir}/credstore/ \
${sysconfdir}/credstore.encrypted/ \
${sysconfdir}/dbus-1/ \
${sysconfdir}/modules-load.d/ \
${sysconfdir}/pam.d/ \
${sysconfdir}/profile.d/ \
${sysconfdir}/sysctl.d/ \
${sysconfdir}/systemd/ \
${sysconfdir}/tmpfiles.d/ \
${sysconfdir}/xdg/ \
${sysconfdir}/init.d/README \
${sysconfdir}/resolv-conf.systemd \
${sysconfdir}/X11/xinit/xinitrc.d/* \
${rootlibexecdir}/systemd/* \
${rootlibdir}/systemd/libsystemd-core* \
${libdir}/pam.d \
${nonarch_libdir}/pam.d \
${systemd_unitdir}/* \
${base_libdir}/security/*.so \
/cgroup \
${bindir}/systemd* \
${bindir}/busctl \
${bindir}/coredumpctl \
${bindir}/localectl \
${bindir}/hostnamectl \
${bindir}/resolvectl \
${bindir}/timedatectl \
${bindir}/bootctl \
${bindir}/oomctl \
${bindir}/userdbctl \
${exec_prefix}/lib/credstore \
${exec_prefix}/lib/tmpfiles.d/*.conf \
${exec_prefix}/lib/systemd \
${exec_prefix}/lib/modules-load.d \
${exec_prefix}/lib/sysctl.d \
${exec_prefix}/lib/sysusers.d \
${exec_prefix}/lib/environment.d \
${exec_prefix}/lib/pcrlock.d \
${localstatedir} \
${rootlibexecdir}/modprobe.d/systemd.conf \
${rootlibexecdir}/modprobe.d/README \
${datadir}/dbus-1/system.d/org.freedesktop.timedate1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.locale1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.network1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.resolve1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.systemd1.conf \
${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', '${datadir}/dbus-1/system.d/org.freedesktop.hostname1_no_polkit.conf', '', d)} \
${datadir}/dbus-1/system.d/org.freedesktop.hostname1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.login1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.timesync1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.portable1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.oom1.conf \
${datadir}/dbus-1/system.d/org.freedesktop.home1.conf \
"
FILES:${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd"
RDEPENDS:${PN} += "kmod dbus util-linux-mount util-linux-umount udev (= ${EXTENDPKGV}) systemd-udev-rules util-linux-agetty util-linux-fsck util-linux-swaponoff"
RDEPENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
RDEPENDS:${PN} += "volatile-binds"
RRECOMMENDS:${PN} += "systemd-extra-utils \
udev-hwdb \
e2fsprogs-e2fsck \
kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 kernel-module-sch-fq-codel \
os-release \
systemd-conf \
${@bb.utils.contains('PACKAGECONFIG', 'logind', 'pam-plugin-umask', '', d)} \
"
INSANE_SKIP:${PN} += "dev-so libdir"
INSANE_SKIP:${PN}-dbg += "libdir"
INSANE_SKIP:${PN}-doc += " libdir"
INSANE_SKIP:libsystemd-shared += "libdir"
FILES:libsystemd-shared = "${rootlibdir}/systemd/libsystemd-shared*.so"
RPROVIDES:udev = "hotplug"
RDEPENDS:udev-bash-completion += "bash-completion"
RDEPENDS:udev-hwdb += "udev"
FILES:udev += "${base_sbindir}/udevd \
${rootlibexecdir}/systemd/network/99-default.link \
${rootlibexecdir}/systemd/systemd-udevd \
${rootlibexecdir}/udev/accelerometer \
${rootlibexecdir}/udev/ata_id \
${rootlibexecdir}/udev/cdrom_id \
${rootlibexecdir}/udev/collect \
${rootlibexecdir}/udev/dmi_memory_id \
${rootlibexecdir}/udev/fido_id \
${rootlibexecdir}/udev/findkeyboards \
${rootlibexecdir}/udev/iocost \
${rootlibexecdir}/udev/keyboard-force-release.sh \
${rootlibexecdir}/udev/keymap \
${rootlibexecdir}/udev/mtd_probe \
${rootlibexecdir}/udev/scsi_id \
${rootlibexecdir}/udev/v4l_id \
${rootlibexecdir}/udev/keymaps \
${rootlibexecdir}/udev/rules.d/50-udev-default.rules \
${rootlibexecdir}/udev/rules.d/60-autosuspend.rules \
${rootlibexecdir}/udev/rules.d/60-autosuspend-chromiumos.rules \
${rootlibexecdir}/udev/rules.d/60-block.rules \
${rootlibexecdir}/udev/rules.d/60-cdrom_id.rules \
${rootlibexecdir}/udev/rules.d/60-dmi-id.rules \
${rootlibexecdir}/udev/rules.d/60-drm.rules \
${rootlibexecdir}/udev/rules.d/60-evdev.rules \
${rootlibexecdir}/udev/rules.d/60-fido-id.rules \
${rootlibexecdir}/udev/rules.d/60-infiniband.rules \
${rootlibexecdir}/udev/rules.d/60-input-id.rules \
${rootlibexecdir}/udev/rules.d/60-persistent-alsa.rules \
${rootlibexecdir}/udev/rules.d/60-persistent-input.rules \
${rootlibexecdir}/udev/rules.d/60-persistent-storage.rules \
${rootlibexecdir}/udev/rules.d/60-persistent-storage-mtd.rules \
${rootlibexecdir}/udev/rules.d/60-persistent-storage-tape.rules \
${rootlibexecdir}/udev/rules.d/60-persistent-v4l.rules \
${rootlibexecdir}/udev/rules.d/60-sensor.rules \
${rootlibexecdir}/udev/rules.d/60-serial.rules \
${rootlibexecdir}/udev/rules.d/61-autosuspend-manual.rules \
${rootlibexecdir}/udev/rules.d/64-btrfs.rules \
${rootlibexecdir}/udev/rules.d/70-camera.rules \
${rootlibexecdir}/udev/rules.d/70-joystick.rules \
${rootlibexecdir}/udev/rules.d/70-memory.rules \
${rootlibexecdir}/udev/rules.d/70-mouse.rules \
${rootlibexecdir}/udev/rules.d/70-power-switch.rules \
${rootlibexecdir}/udev/rules.d/70-touchpad.rules \
${rootlibexecdir}/udev/rules.d/75-net-description.rules \
${rootlibexecdir}/udev/rules.d/75-probe_mtd.rules \
${rootlibexecdir}/udev/rules.d/78-sound-card.rules \
${rootlibexecdir}/udev/rules.d/80-drivers.rules \
${rootlibexecdir}/udev/rules.d/80-net-setup-link.rules \
${rootlibexecdir}/udev/rules.d/81-net-dhcp.rules \
${rootlibexecdir}/udev/rules.d/90-vconsole.rules \
${rootlibexecdir}/udev/rules.d/90-iocost.rules \
${rootlibexecdir}/udev/rules.d/README \
${sysconfdir}/udev \
${sysconfdir}/init.d/systemd-udevd \
${systemd_system_unitdir}/*udev* \
${systemd_system_unitdir}/*.wants/*udev* \
${base_bindir}/systemd-hwdb \
${base_bindir}/udevadm \
${base_sbindir}/udevadm \
${systemd_system_unitdir}/systemd-hwdb-update.service \
"
FILES:udev-bash-completion = "${datadir}/bash-completion/completions/udevadm"
FILES:udev-hwdb = "${rootlibexecdir}/udev/hwdb.d \
"
RCONFLICTS:${PN} = "tiny-init ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolvconf', '', d)}"
INITSCRIPT_PACKAGES = "udev"
INITSCRIPT_NAME:udev = "systemd-udevd"
INITSCRIPT_PARAMS:udev = "start 03 S ."
python __anonymous() {
if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
if bb.utils.contains('DISTRO_FEATURES', 'systemd-resolved', True, False, d) and not bb.utils.contains('PACKAGECONFIG', 'nss-resolve resolved', True, False, d):
bb.error("DISTRO_FEATURES[systemd-resolved] requires PACKAGECONFIG[nss-resolve, resolved]")
if bb.utils.contains('PACKAGECONFIG', 'repart', True, False, d) and not bb.utils.contains('PACKAGECONFIG', 'openssl', True, False, d):
bb.error("PACKAGECONFIG[repart] requires PACKAGECONFIG[openssl]")
if bb.utils.contains('PACKAGECONFIG', 'homed', True, False, d) and not bb.utils.contains('PACKAGECONFIG', 'userdb openssl cryptsetup', True, False, d):
bb.error("PACKAGECONFIG[homed] requires PACKAGECONFIG[userdb], PACKAGECONFIG[openssl] and PACKAGECONFIG[cryptsetup]")
}
python do_warn_musl() {
if d.getVar('TCLIBC') == "musl":
bb.warn("Using systemd with musl is not recommended since it is not supported upstream and some patches are known to be problematic.")
}
addtask warn_musl before do_configure
ALTERNATIVE:${PN} = "halt reboot shutdown poweroff runlevel ${@bb.utils.contains('PACKAGECONFIG', 'resolved', 'resolv-conf', '', d)}"
ALTERNATIVE_TARGET[resolv-conf] = "${sysconfdir}/resolv-conf.systemd"
ALTERNATIVE_LINK_NAME[resolv-conf] = "${sysconfdir}/resolv.conf"
ALTERNATIVE_PRIORITY[resolv-conf] ?= "50"
ALTERNATIVE_TARGET[halt] = "${base_bindir}/systemctl"
ALTERNATIVE_LINK_NAME[halt] = "${base_sbindir}/halt"
ALTERNATIVE_PRIORITY[halt] ?= "300"
ALTERNATIVE_TARGET[reboot] = "${base_bindir}/systemctl"
ALTERNATIVE_LINK_NAME[reboot] = "${base_sbindir}/reboot"
ALTERNATIVE_PRIORITY[reboot] ?= "300"
ALTERNATIVE_TARGET[shutdown] = "${base_bindir}/systemctl"
ALTERNATIVE_LINK_NAME[shutdown] = "${base_sbindir}/shutdown"
ALTERNATIVE_PRIORITY[shutdown] ?= "300"
ALTERNATIVE_TARGET[poweroff] = "${base_bindir}/systemctl"
ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff"
ALTERNATIVE_PRIORITY[poweroff] ?= "300"
ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
ALTERNATIVE_PRIORITY[runlevel] ?= "300"
pkg_postinst:${PN}:libc-glibc () {
if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then
sed -e '/^hosts:/s/\s*\<myhostname\>//' \
-e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 myhostname \3\4\5/' \
-i $D${sysconfdir}/nsswitch.conf
fi
if ${@bb.utils.contains('PACKAGECONFIG', 'nss', 'true', 'false', d)}; then
sed -e 's#\(^passwd:.*\)#\1 systemd#' \
-e 's#\(^group:.*\)#\1 systemd#' \
-e 's#\(^shadow:.*\)#\1 systemd#' \
-i $D${sysconfdir}/nsswitch.conf
fi
}
pkg_prerm:${PN}:libc-glibc () {
if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then
sed -e '/^hosts:/s/\s*\<myhostname\>//' \
-e '/^hosts:/s/\s*myhostname//' \
-i $D${sysconfdir}/nsswitch.conf
fi
if ${@bb.utils.contains('PACKAGECONFIG', 'nss', 'true', 'false', d)}; then
sed -e '/^passwd:/s#\s*systemd##' \
-e '/^group:/s#\s*systemd##' \
-e '/^shadow:/s#\s*systemd##' \
-i $D${sysconfdir}/nsswitch.conf
fi
}
PACKAGE_WRITE_DEPS += "qemu-native"
pkg_postinst:udev-hwdb () {
if test -n "$D"; then
$INTERCEPT_DIR/postinst_intercept update_udev_hwdb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} rootlibexecdir="${rootlibexecdir}" PREFERRED_PROVIDER_udev="${PREFERRED_PROVIDER_udev}" base_bindir="${base_bindir}"
else
udevadm hwdb --update
fi
}
pkg_prerm:udev-hwdb () {
rm -f $D${sysconfdir}/udev/hwdb.bin
}