Compare commits

...

43 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 80b9e60022
Merge 8da8996181 into 0e44a351ea 2024-11-25 00:14:26 +00:00
Daan De Meyer 0e44a351ea mkosi: Make sure mkosi.clangd always runs on the host
If the editor that invokes mkosi.clangd is a flatpak, let's make sure
that mkosi is run on the host and not in the flatpak sandbox since it
won't be installed there.
2024-11-25 00:21:10 +01:00
Luca Boccassi 94eacb9329
Various mkosi and integration test fixes (#35336) 2024-11-24 18:10:03 +00:00
Daan De Meyer f458a60391 test: Lint integration-test-wrapper.py 2024-11-24 16:47:20 +01:00
Daan De Meyer ceca7c5005 test: Fix typing errors in integration-test-wrapper.py 2024-11-24 16:47:20 +01:00
Daan De Meyer 4f969b20b0 test: Format integration-test-wrapper.py 2024-11-24 16:47:20 +01:00
Daan De Meyer d6047d9fb5 ukify: Fix typing error 2024-11-24 16:47:20 +01:00
Daan De Meyer a2aacbfad5 Move mypy.ini and ruff.toml to top level
This allows reusing them for integration-test-wrapper.py as well.
2024-11-24 16:47:20 +01:00
Daan De Meyer 6d2fd490cf integration-test-wrapper: Remove unneeded format strings 2024-11-24 16:47:20 +01:00
Daan De Meyer c859b310ed mkosi: Add github CLI to tools 2024-11-24 16:47:20 +01:00
Daan De Meyer 51cd3dec2a mkosi: Add dnf and dnf5 to sanitizer workaround list 2024-11-24 16:47:20 +01:00
Daan De Meyer fdc4706850 mkosi: Install clangd everywhere 2024-11-24 16:47:20 +01:00
Daan De Meyer 506403f561 mkosi: Use bash to execute command -v
command is only an executable on Fedora due to a downstream patch,
on Arch for example it's only a builtin so we have to use bash to
execute command -v to get proper results on Arch.
2024-11-24 16:47:18 +01:00
Daan De Meyer 6fd5df6005 mkosi: Add shellcheck to tools 2024-11-24 16:47:04 +01:00
Daan De Meyer a197604af4 mkosi: update to latest 2024-11-24 16:47:04 +01:00
Vito Caputo 4f3df8c1bb NEWS: add blurb thanking Nick Owens
Nick's largely responsible for nerd-sniping me into fixing #34516
and did most of the testing.
2024-11-24 16:31:27 +09:00
白一百 8c18851e7e
hwdb: add entry for Chuwi Hi10 X1 (#35331)
https://www.chuwi.com/product/items/chuwi-hi10-x1.html
Rotated -90 degrees in the Z axis.
2024-11-24 16:30:33 +09:00
Yu Watanabe 5b2926d941 curl-util: do not configure new io event source when the event loop is already dead
Similar to c5ecf09494, but for io event source.

Fixes #35322.
2024-11-23 22:49:57 +01:00
Ani Sinha 4b356c90dc measure: add 'dtbauto' option in help message
'dtbauto' command line was missing from the help string. Add it.
2024-11-23 12:43:34 +00:00
Léane GRASSER f28e16d14e po: Translated using Weblate (French)
Currently translated at 100.0% (257 of 257 strings)

Co-authored-by: Léane GRASSER <leane.grasser@proton.me>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/fr/
Translation: systemd/main
2024-11-23 20:49:18 +09:00
Yu Watanabe 9e05e33871 networkd-test.py: fix interface state checker
After 259125d53d, network interfaces
declared by .netdev files are created after systemd-networkd sends READY
notification. So, even when networkd is started, the netdevs may not
be created yet, and 'ip' command may fail. Let's also check the return
code of the command.

This also
- drops never worked stdout checks,
- makes the test fail if the interface is not created within the timeout.
2024-11-23 17:33:43 +09:00
Lennart Poettering 95116bdfd5 nspawn: improve log message on bad incoming sd_notify() message
It's the PID that is wrong, not the UID/GID, be precise.
2024-11-23 17:33:17 +09:00
Lennart Poettering 2bd290ca02 nspawn: fix userns_mkdir() invocation
The wrong error code was logged.

But actually given that userns_mkdir() is fine with existing dirs, let's
drop the redundant conditionalization.

Follow-up for: a1fcaa1549
2024-11-23 17:33:06 +09:00
Yu Watanabe 1e9fb1d456 shutdown: propagate one more error from sync_making_progress()
No functional change, just refactoring, as anyway all errors will be
ignored by the caller.
2024-11-23 17:32:51 +09:00
Yu Watanabe 56c761f8c6
namespace-util: handle -ENOSPC by userns_acquire() gracefully in is_idmapping_supported() (#35313)
Follow-up for edae62120f.
Fixes #35311.
2024-11-23 17:32:23 +09:00
Yu Watanabe b76730f3fe shutdown: close DM block device before issuing DM_DEV_REMOVE ioctl
Otherwise, the ioctl() may fail with EBUSY.

Follow-up for b4b66b2662.
Hopefully fixes #35243.
2024-11-23 17:31:36 +09:00
Yu Watanabe 3dda236c5c basic/linux: update kernel headers from v6.12 2024-11-23 17:31:12 +09:00
Zbigniew Jędrzejewski-Szmek 5598454a3f Undeprecate commandline params forcequotacheck, fastboot, and forcefsck
Those are historical names, but there is nothing wrong with them. The files on
/ (/fastboot, /forcefsck, and /forcequotacheck) are problematic because they
require a modification of the root file system. But the commandline params work
fine. They have the obvious advantage compared to our "modern" option that they
are much easier to type without looking up the spelling in the docs. Undeprecate
them to avoid unnecessary churn.
2024-11-23 17:30:56 +09:00
Yu Watanabe 2994ca354b namespace-util: update log messages 2024-11-23 06:52:48 +09:00
Yu Watanabe eb14b993bb namespace-util: handle -ENOSPC by userns_acquire() gracefully in is_idmapping_supported()
Follow-up for edae62120f.
Fixes #35311.
2024-11-23 06:52:38 +09:00
Christian Hesse c946b13575 link README.logs from tmpfiles.d/legacy.conf only if available
The file README.logs is installed only if SysVInit support is enabled.
Thus the link should depend on it as well.
2024-11-22 18:33:20 +00:00
Lennart Poettering e39cbb1442 varlink: apparently on old kernels SO_PEERPIDFD returns EINVAL 2024-11-23 03:09:49 +09:00
Marco Tomaschett bc4a027f9c
hwdb: add support for PineTab2 to 60-sensor.hwdb (#35304)
Add accelerometer support for PineTab2
2024-11-23 03:08:06 +09:00
Zbigniew Jędrzejewski-Szmek 8da8996181 gpt-auto-generator: improve log message
We said "exiting", but then the program continues to do other operations
and log additional messages.
2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek fb1ad8c2df shared/exec-util: fix logging of the args of an executed program
The debug logs has lots of "About to execute /some/path (null)". This
occurs when the args array is empty. Instead, only print "(null)" if
we failed with oom.

Having strv_skip() return NULL makes this pleasant to write without repeating
strv_isempty() a few times.
2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek 7a5997bad1 test-execve: minor simplification 2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek 64e225d4c3 various: handle the positive condition after strv_skip() first 2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek d9cb7338f9 busctl: use RET_GATHER 2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek 654fa34796 busctl: use STRV_FOREACH in the usual fashion
Also put positive branch first, do not use 'i' as a char** variable name.
2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek 0638a45ec9 analyze: use STRV_FOREACH in consistent fashion
Also put positive condition first.
2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek e97f1ad4c9 basic/strv: return NULL from strv_skip
strv_skip was written to carefully return the original array, but this turns
out to be an unnecessary complication. After the previous patch, no caller
cares about the distinction between NULL and { NULL }, but various callers need
to wrap the process the returned value with strv_isempty(), sometimes more than
once. Let's always return NULL for an empty result to allow callers to be
simplified.
2024-11-20 15:05:16 +01:00
Zbigniew Jędrzejewski-Szmek 48e5aec4a3 homectl: split out inspect_home() and authenticate_home()
mangle_user_list() was doing a microoptimization of avoiding of copying of a
single string by constructing the strv object manually. This seems like more
trouble than it's worth, considering that this is called once in the program's
life.

Rework the code to have inspect_home() and authenticate_home() that handle a
single home name and call them in a loop from the outer function.
2024-11-20 14:58:56 +01:00
Zbigniew Jędrzejewski-Szmek 907a3b128c vconsole-setup: reword error messages
I was looking at some logs, and — without context —
"Setting source virtual console failed" doesn't make sense. It's a source
internally in vconsole-setup because we configure it and then use it to copy
the settings to other consoles. But at the point this message is emitted it's
not yet a source of anything. Also, "setting" sounds like we'd like to assign
it somewhere, which is even more confusing. Reword the messages to be more
down-to-earth and meaningful without looking at the code.
2024-11-19 17:18:14 +01:00
59 changed files with 519 additions and 495 deletions

View File

@ -37,7 +37,7 @@ jobs:
VALIDATE_GITHUB_ACTIONS: true VALIDATE_GITHUB_ACTIONS: true
- name: Check that tabs are not used in Python code - name: Check that tabs are not used in Python code
run: sh -c '! git grep -P "\\t" -- src/ukify/ukify.py' run: sh -c '! git grep -P "\\t" -- src/ukify/ukify.py test/integration-test-wrapper.py'
- name: Install ruff and mypy - name: Install ruff and mypy
run: | run: |
@ -47,14 +47,14 @@ jobs:
- name: Run mypy - name: Run mypy
run: | run: |
python3 -m mypy --version python3 -m mypy --version
python3 -m mypy src/ukify/ukify.py python3 -m mypy src/ukify/ukify.py test/integration-test-wrapper.py
- name: Run ruff check - name: Run ruff check
run: | run: |
ruff --version ruff --version
ruff check src/ukify/ukify.py ruff check src/ukify/ukify.py test/integration-test-wrapper.py
- name: Run ruff format - name: Run ruff format
run: | run: |
ruff --version ruff --version
ruff format --check src/ukify/ukify.py ruff format --check src/ukify/ukify.py test/integration-test-wrapper.py

View File

@ -105,7 +105,7 @@ jobs:
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: systemd/mkosi@8976a0abb19221e65300222f2d33067970cca0f1 - uses: systemd/mkosi@0825cca8084674ec8fa27502134b1bc601f79e0c
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space # Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
# immediately, we remove the files in the background. However, we first move them to a different location # immediately, we remove the files in the background. However, we first move them to a different location

3
NEWS
View File

@ -764,6 +764,9 @@ CHANGES WITH 257 in spe:
other cases EnterNamespace= might be an suitable approach to acquire other cases EnterNamespace= might be an suitable approach to acquire
symbolized backtraces.) symbolized backtraces.)
Special thanks to Nick Owens for bringing attention to and testing
fixes for issue #34516.
Contributions from: 12paper, A. Wilcox, Abderrahim Kitouni, Contributions from: 12paper, A. Wilcox, Abderrahim Kitouni,
Adrian Vovk, Alain Greppin, Allison Karlitskaya, Alyssa Ross, Adrian Vovk, Alain Greppin, Allison Karlitskaya, Alyssa Ross,
Anders Jonsson, Andika Triwidada, Andres Beltran, Anouk Ceyssens, Anders Jonsson, Andika Triwidada, Andres Beltran, Anouk Ceyssens,

View File

@ -295,6 +295,10 @@ sensor:modalias:acpi:MXC6655*:dmi:*:svnCHUWIInnovationAndTechnology*:pnHi10X:*
sensor:modalias:acpi:KIOX000A*:dmi:*:svnCHUWIInnovationAndTechnology*:pnHi10X:* sensor:modalias:acpi:KIOX000A*:dmi:*:svnCHUWIInnovationAndTechnology*:pnHi10X:*
ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1
# Chuwi Hi10 X1
sensor:modalias:acpi:NSA2513*:dmi:*:svnCHUWIInnovationAndTechnology*:pnHi10X1:*
ACCEL_MOUNT_MATRIX=0, 1, 0; -1, 0, 0; 0, 0, 1
# Chuwi Hi10 Go # Chuwi Hi10 Go
sensor:modalias:acpi:MXC6655*:dmi:*:svnCHUWIINNOVATIONLIMITED:pnHi10Go:* sensor:modalias:acpi:MXC6655*:dmi:*:svnCHUWIINNOVATIONLIMITED:pnHi10Go:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0,-1, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=-1, 0, 0; 0,-1, 0; 0, 0, 1
@ -953,6 +957,15 @@ sensor:modalias:acpi:MXC6655*:dmi:*:svnDefaultstring*:pnP612F:*
sensor:modalias:acpi:SMO8500*:dmi:*:svnPEAQ:pnPEAQPMMC1010MD99187:* sensor:modalias:acpi:SMO8500*:dmi:*:svnPEAQ:pnPEAQPMMC1010MD99187:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
#########################################
# Pine64
#########################################
# PineTab2
sensor:modalias:of:NaccelerometerT_null_Csilan,sc7a20:*
ACCEL_MOUNT_MATRIX=0, 0, -1; 1, 0, 0; 0, -1, 0
######################################### #########################################
# Pipo # Pipo
######################################### #########################################

View File

@ -1,12 +1,18 @@
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
MKOSI_CONFIG="$(mkosi --json summary | jq -r .Images[-1])" if command -v flatpak-spawn >/dev/null; then
SPAWN=(flatpak-spawn --host)
else
SPAWN=()
fi
MKOSI_CONFIG="$("${SPAWN[@]}" --host mkosi --json summary | jq -r .Images[-1])"
DISTRIBUTION="$(jq -r .Distribution <<< "$MKOSI_CONFIG")" DISTRIBUTION="$(jq -r .Distribution <<< "$MKOSI_CONFIG")"
RELEASE="$(jq -r .Release <<< "$MKOSI_CONFIG")" RELEASE="$(jq -r .Release <<< "$MKOSI_CONFIG")"
ARCH="$(jq -r .Architecture <<< "$MKOSI_CONFIG")" ARCH="$(jq -r .Architecture <<< "$MKOSI_CONFIG")"
exec mkosi \ exec "${SPAWN[@]}" mkosi \
--incremental=strict \ --incremental=strict \
--build-sources-ephemeral=no \ --build-sources-ephemeral=no \
--format=none \ --format=none \

View File

@ -6,10 +6,12 @@ ToolsTreeDistribution=arch
[Build] [Build]
ToolsTreePackages= ToolsTreePackages=
cryptsetup cryptsetup
github-cli
libcap libcap
libmicrohttpd libmicrohttpd
python-jinja python-jinja
python-pytest python-pytest
ruff ruff
shellcheck
tpm2-tss tpm2-tss
util-linux-libs util-linux-libs

View File

@ -16,3 +16,4 @@ ToolsTreePackages=
tpm2-tss-devel tpm2-tss-devel
python3-jinja2 python3-jinja2
python3-pytest python3-pytest
shellcheck

View File

@ -6,6 +6,7 @@ ToolsTreeDistribution=|ubuntu
[Build] [Build]
ToolsTreePackages= ToolsTreePackages=
gh
libblkid-dev libblkid-dev
libcap-dev libcap-dev
libcryptsetup-dev libcryptsetup-dev
@ -16,3 +17,4 @@ ToolsTreePackages=
libtss2-dev libtss2-dev
python3-jinja2 python3-jinja2
python3-pytest python3-pytest
shellcheck

View File

@ -5,4 +5,5 @@ ToolsTreeDistribution=fedora
[Build] [Build]
ToolsTreePackages= ToolsTreePackages=
gh
ruff ruff

View File

@ -5,6 +5,7 @@ ToolsTreeDistribution=opensuse
[Build] [Build]
ToolsTreePackages= ToolsTreePackages=
gh
pkgconfig(blkid) pkgconfig(blkid)
pkgconfig(libcap) pkgconfig(libcap)
pkgconfig(libcryptsetup) pkgconfig(libcryptsetup)
@ -16,3 +17,4 @@ ToolsTreePackages=
tss2-devel tss2-devel
python3-jinja2 python3-jinja2
python3-pytest python3-pytest
ShellCheck

View File

@ -13,6 +13,7 @@ Environment=
[Content] [Content]
Packages= Packages=
clang-devel
compiler-rt compiler-rt
gdb gdb
git-core git-core

View File

@ -15,6 +15,7 @@ Environment=
[Content] [Content]
Packages= Packages=
apt apt
clangd
erofs-utils erofs-utils
git-core git-core
libclang-rt-dev libclang-rt-dev

View File

@ -12,6 +12,7 @@ Environment=
[Content] [Content]
Packages= Packages=
clang
diffutils diffutils
erofs-utils erofs-utils
gcc-c++ gcc-c++

View File

@ -57,6 +57,8 @@ wrap=(
delv delv
dhcpd dhcpd
dig dig
dnf
dnf5
dmsetup dmsetup
dnsmasq dnsmasq
findmnt findmnt
@ -93,7 +95,7 @@ wrap=(
) )
for bin in "${wrap[@]}"; do for bin in "${wrap[@]}"; do
if ! mkosi-chroot command -v "$bin" >/dev/null; then if ! mkosi-chroot bash -c "command -v $bin" >/dev/null; then
continue continue
fi fi
@ -103,7 +105,7 @@ for bin in "${wrap[@]}"; do
enable_lsan=0 enable_lsan=0
fi fi
target="$(mkosi-chroot command -v "$bin")" target="$(mkosi-chroot bash -c "command -v $bin")"
mv "$BUILDROOT/$target" "$BUILDROOT/$target.orig" mv "$BUILDROOT/$target" "$BUILDROOT/$target.orig"

View File

@ -12,7 +12,7 @@ msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-06 14:42+0000\n" "POT-Creation-Date: 2024-11-06 14:42+0000\n"
"PO-Revision-Date: 2024-11-20 19:13+0000\n" "PO-Revision-Date: 2024-11-23 10:38+0000\n"
"Last-Translator: Léane GRASSER <leane.grasser@proton.me>\n" "Last-Translator: Léane GRASSER <leane.grasser@proton.me>\n"
"Language-Team: French <https://translate.fedoraproject.org/projects/systemd/" "Language-Team: French <https://translate.fedoraproject.org/projects/systemd/"
"main/fr/>\n" "main/fr/>\n"
@ -1258,7 +1258,7 @@ msgstr ""
#: src/sysupdate/org.freedesktop.sysupdate1.policy:75 #: src/sysupdate/org.freedesktop.sysupdate1.policy:75
msgid "Manage optional features" msgid "Manage optional features"
msgstr "Gérer les fonctionnalités en option" msgstr "Gérer les fonctionnalités facultatives"
#: src/sysupdate/org.freedesktop.sysupdate1.policy:76 #: src/sysupdate/org.freedesktop.sysupdate1.policy:76
msgid "Authentication is required to manage optional features" msgid "Authentication is required to manage optional features"

View File

@ -47,30 +47,25 @@ int verb_architectures(int argc, char *argv[], void *userdata) {
(void) table_hide_column_from_display(table, (size_t) 0); (void) table_hide_column_from_display(table, (size_t) 0);
if (strv_isempty(strv_skip(argv, 1))) char **args = strv_skip(argv, 1);
for (Architecture a = 0; a < _ARCHITECTURE_MAX; a++) { if (args) {
r = add_arch(table, a); STRV_FOREACH(arg, args) {
if (r < 0)
return r;
}
else {
STRV_FOREACH(as, strv_skip(argv, 1)) {
Architecture a; Architecture a;
if (streq(*as, "native")) if (streq(*arg, "native"))
a = native_architecture(); a = native_architecture();
else if (streq(*as, "uname")) else if (streq(*arg, "uname"))
a = uname_architecture(); a = uname_architecture();
else if (streq(*as, "secondary")) { else if (streq(*arg, "secondary")) {
#ifdef ARCHITECTURE_SECONDARY #ifdef ARCHITECTURE_SECONDARY
a = ARCHITECTURE_SECONDARY; a = ARCHITECTURE_SECONDARY;
#else #else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No secondary architecture."); return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No secondary architecture.");
#endif #endif
} else } else
a = architecture_from_string(*as); a = architecture_from_string(*arg);
if (a < 0) if (a < 0)
return log_error_errno(a, "Architecture \"%s\" not known.", *as); return log_error_errno(a, "Architecture \"%s\" not known.", *arg);
r = add_arch(table, a); r = add_arch(table, a);
if (r < 0) if (r < 0)
@ -78,7 +73,12 @@ int verb_architectures(int argc, char *argv[], void *userdata) {
} }
(void) table_set_sort(table, (size_t) 0); (void) table_set_sort(table, (size_t) 0);
} } else
for (Architecture a = 0; a < _ARCHITECTURE_MAX; a++) {
r = add_arch(table, a);
if (r < 0)
return r;
}
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0) if (r < 0)

View File

@ -9,12 +9,11 @@
#include "strv.h" #include "strv.h"
int verb_cat_config(int argc, char *argv[], void *userdata) { int verb_cat_config(int argc, char *argv[], void *userdata) {
char **list;
int r; int r;
pager_open(arg_pager_flags); pager_open(arg_pager_flags);
list = strv_skip(argv, 1); char **list = strv_skip(argv, 1);
STRV_FOREACH(arg, list) { STRV_FOREACH(arg, list) {
const char *t = NULL; const char *t = NULL;

View File

@ -17,7 +17,24 @@ int verb_exit_status(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to right-align status: %m"); return log_error_errno(r, "Failed to right-align status: %m");
if (strv_isempty(strv_skip(argv, 1))) char **args = strv_skip(argv, 1);
if (args)
STRV_FOREACH(arg, args) {
int status;
status = exit_status_from_string(*arg);
if (status < 0)
return log_error_errno(status, "Invalid exit status \"%s\".", *arg);
assert(status >= 0 && (size_t) status < ELEMENTSOF(exit_status_mappings));
r = table_add_many(table,
TABLE_STRING, exit_status_mappings[status].name ?: "-",
TABLE_INT, status,
TABLE_STRING, exit_status_class(status) ?: "-");
if (r < 0)
return table_log_add_error(r);
}
else
for (size_t i = 0; i < ELEMENTSOF(exit_status_mappings); i++) { for (size_t i = 0; i < ELEMENTSOF(exit_status_mappings); i++) {
if (!exit_status_mappings[i].name) if (!exit_status_mappings[i].name)
continue; continue;
@ -29,22 +46,6 @@ int verb_exit_status(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
} }
else
for (int i = 1; i < argc; i++) {
int status;
status = exit_status_from_string(argv[i]);
if (status < 0)
return log_error_errno(status, "Invalid exit status \"%s\".", argv[i]);
assert(status >= 0 && (size_t) status < ELEMENTSOF(exit_status_mappings));
r = table_add_many(table,
TABLE_STRING, exit_status_mappings[status].name ?: "-",
TABLE_INT, status,
TABLE_STRING, exit_status_class(status) ?: "-");
if (r < 0)
return table_log_add_error(r);
}
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0) if (r < 0)

View File

@ -106,15 +106,30 @@ static void dump_filesystem_set(const FilesystemSet *set) {
} }
int verb_filesystems(int argc, char *argv[], void *userdata) { int verb_filesystems(int argc, char *argv[], void *userdata) {
bool first = true;
#if ! HAVE_LIBBPF #if ! HAVE_LIBBPF
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Not compiled with libbpf support, sorry."); return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Not compiled with libbpf support, sorry.");
#endif #endif
pager_open(arg_pager_flags); pager_open(arg_pager_flags);
if (strv_isempty(strv_skip(argv, 1))) { char **args = strv_skip(argv, 1);
if (args)
STRV_FOREACH(name, args) {
if (name != args)
puts("");
const FilesystemSet *set = filesystem_set_find(*name);
if (!set) {
/* make sure the error appears below normal output */
fflush(stdout);
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
"Filesystem set \"%s\" not found.", *name);
}
dump_filesystem_set(set);
}
else {
_cleanup_set_free_ Set *kernel = NULL, *known = NULL; _cleanup_set_free_ Set *kernel = NULL, *known = NULL;
int k; int k;
@ -126,27 +141,24 @@ int verb_filesystems(int argc, char *argv[], void *userdata) {
for (FilesystemGroups i = 0; i < _FILESYSTEM_SET_MAX; i++) { for (FilesystemGroups i = 0; i < _FILESYSTEM_SET_MAX; i++) {
const FilesystemSet *set = filesystem_sets + i; const FilesystemSet *set = filesystem_sets + i;
if (!first) if (i > 0)
puts(""); puts("");
dump_filesystem_set(set); dump_filesystem_set(set);
filesystem_set_remove(kernel, set); filesystem_set_remove(kernel, set);
if (i != FILESYSTEM_SET_KNOWN) if (i != FILESYSTEM_SET_KNOWN)
filesystem_set_remove(known, set); filesystem_set_remove(known, set);
first = false;
} }
if (arg_quiet) /* Let's not show the extra stuff in quiet mode */ if (arg_quiet) /* Let's not show the extra stuff in quiet mode */
return 0; return 0;
if (!set_isempty(known)) { if (!set_isempty(known)) {
_cleanup_free_ char **l = NULL;
printf("\n" printf("\n"
"# %sUngrouped filesystems%s (known but not included in any of the groups except @known):\n", "# %sUngrouped filesystems%s (known but not included in any of the groups except @known):\n",
ansi_highlight(), ansi_normal()); ansi_highlight(), ansi_normal());
l = set_get_strv(known); _cleanup_free_ char **l = set_get_strv(known);
if (!l) if (!l)
return log_oom(); return log_oom();
@ -197,25 +209,7 @@ int verb_filesystems(int argc, char *argv[], void *userdata) {
STRV_FOREACH(filesystem, l) STRV_FOREACH(filesystem, l)
printf("# %s\n", *filesystem); printf("# %s\n", *filesystem);
} }
} else }
STRV_FOREACH(name, strv_skip(argv, 1)) {
const FilesystemSet *set;
if (!first)
puts("");
set = filesystem_set_find(*name);
if (!set) {
/* make sure the error appears below normal output */
fflush(stdout);
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
"Filesystem set \"%s\" not found.", *name);
}
dump_filesystem_set(set);
first = false;
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -35,11 +35,12 @@ int verb_malloc(int argc, char *argv[], void *userdata) {
char **services = STRV_MAKE("org.freedesktop.systemd1"); char **services = STRV_MAKE("org.freedesktop.systemd1");
int r; int r;
if (!strv_isempty(strv_skip(argv, 1))) { char **args = strv_skip(argv, 1);
services = strv_skip(argv, 1); if (args) {
STRV_FOREACH(service, services) STRV_FOREACH(service, args)
if (!service_name_is_valid(*service)) if (!service_name_is_valid(*service))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "D-Bus service name '%s' is not valid.", *service); return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "D-Bus service name '%s' is not valid.", *service);
services = args;
} }
r = acquire_bus(&bus, NULL); r = acquire_bus(&bus, NULL);

View File

@ -114,19 +114,14 @@ int verb_pcrs(int argc, char *argv[], void *userdata) {
if (!alg) /* hide hash column if we couldn't acquire it */ if (!alg) /* hide hash column if we couldn't acquire it */
(void) table_set_display(table, 0, 1); (void) table_set_display(table, 0, 1);
if (strv_isempty(strv_skip(argv, 1))) char **args = strv_skip(argv, 1);
for (uint32_t pi = 0; pi < _TPM2_PCR_INDEX_MAX_DEFINED; pi++) { if (args) {
r = add_pcr_to_table(table, alg, pi); STRV_FOREACH(arg, args) {
if (r < 0)
return r;
}
else {
for (int i = 1; i < argc; i++) {
int pi; int pi;
pi = tpm2_pcr_index_from_string(argv[i]); pi = tpm2_pcr_index_from_string(*arg);
if (pi < 0) if (pi < 0)
return log_error_errno(pi, "PCR index \"%s\" not known.", argv[i]); return log_error_errno(pi, "PCR index \"%s\" not known.", *arg);
r = add_pcr_to_table(table, alg, pi); r = add_pcr_to_table(table, alg, pi);
if (r < 0) if (r < 0)
@ -134,7 +129,12 @@ int verb_pcrs(int argc, char *argv[], void *userdata) {
} }
(void) table_set_sort(table, (size_t) 0); (void) table_set_sort(table, (size_t) 0);
} } else
for (uint32_t pi = 0; pi < _TPM2_PCR_INDEX_MAX_DEFINED; pi++) {
r = add_pcr_to_table(table, alg, pi);
if (r < 0)
return r;
}
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, /* show_header= */true); r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, /* show_header= */true);
if (r < 0) if (r < 0)

View File

@ -103,12 +103,30 @@ static void dump_syscall_filter(const SyscallFilterSet *set) {
} }
int verb_syscall_filters(int argc, char *argv[], void *userdata) { int verb_syscall_filters(int argc, char *argv[], void *userdata) {
bool first = true;
int r; int r;
pager_open(arg_pager_flags); pager_open(arg_pager_flags);
if (strv_isempty(strv_skip(argv, 1))) { char **args = strv_skip(argv, 1);
if (args)
STRV_FOREACH(name, args) {
const SyscallFilterSet *set;
if (name != args)
puts("");
set = syscall_filter_set_find(*name);
if (!set) {
/* make sure the error appears below normal output */
fflush(stdout);
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
"Filter set \"%s\" not found.", *name);
}
dump_syscall_filter(set);
}
else {
_cleanup_set_free_ Set *kernel = NULL, *known = NULL; _cleanup_set_free_ Set *kernel = NULL, *known = NULL;
int k = 0; /* explicit initialization to appease gcc */ int k = 0; /* explicit initialization to appease gcc */
@ -121,27 +139,24 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
for (int i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) { for (int i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) {
const SyscallFilterSet *set = syscall_filter_sets + i; const SyscallFilterSet *set = syscall_filter_sets + i;
if (!first) if (i > 0)
puts(""); puts("");
dump_syscall_filter(set); dump_syscall_filter(set);
syscall_set_remove(kernel, set); syscall_set_remove(kernel, set);
if (i != SYSCALL_FILTER_SET_KNOWN) if (i != SYSCALL_FILTER_SET_KNOWN)
syscall_set_remove(known, set); syscall_set_remove(known, set);
first = false;
} }
if (arg_quiet) /* Let's not show the extra stuff in quiet mode */ if (arg_quiet) /* Let's not show the extra stuff in quiet mode */
return 0; return 0;
if (!set_isempty(known)) { if (!set_isempty(known)) {
_cleanup_free_ char **l = NULL;
printf("\n" printf("\n"
"# %sUngrouped System Calls%s (known but not included in any of the groups except @known):\n", "# %sUngrouped System Calls%s (known but not included in any of the groups except @known):\n",
ansi_highlight(), ansi_normal()); ansi_highlight(), ansi_normal());
l = set_get_strv(known); _cleanup_free_ char **l = set_get_strv(known);
if (!l) if (!l)
return log_oom(); return log_oom();
@ -157,13 +172,11 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
if (!arg_quiet) if (!arg_quiet)
log_notice_errno(k, "# Not showing unlisted system calls, couldn't retrieve kernel system call list: %m"); log_notice_errno(k, "# Not showing unlisted system calls, couldn't retrieve kernel system call list: %m");
} else if (!set_isempty(kernel)) { } else if (!set_isempty(kernel)) {
_cleanup_free_ char **l = NULL;
printf("\n" printf("\n"
"# %sUnlisted System Calls%s (supported by the local kernel, but not included in any of the groups listed above):\n", "# %sUnlisted System Calls%s (supported by the local kernel, but not included in any of the groups listed above):\n",
ansi_highlight(), ansi_normal()); ansi_highlight(), ansi_normal());
l = set_get_strv(kernel); _cleanup_free_ char **l = set_get_strv(kernel);
if (!l) if (!l)
return log_oom(); return log_oom();
@ -172,25 +185,7 @@ int verb_syscall_filters(int argc, char *argv[], void *userdata) {
STRV_FOREACH(syscall, l) STRV_FOREACH(syscall, l)
printf("# %s\n", *syscall); printf("# %s\n", *syscall);
} }
} else }
STRV_FOREACH(name, strv_skip(argv, 1)) {
const SyscallFilterSet *set;
if (!first)
puts("");
set = syscall_filter_set_find(*name);
if (!set) {
/* make sure the error appears below normal output */
fflush(stdout);
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
"Filter set \"%s\" not found.", *name);
}
dump_syscall_filter(set);
first = false;
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -75,11 +75,12 @@ static int test_timestamp_one(const char *p) {
int verb_timestamp(int argc, char *argv[], void *userdata) { int verb_timestamp(int argc, char *argv[], void *userdata) {
int r = 0; int r = 0;
STRV_FOREACH(p, strv_skip(argv, 1)) { char **args = strv_skip(argv, 1);
RET_GATHER(r, test_timestamp_one(*p)); STRV_FOREACH(arg, args) {
if (arg != args)
puts("");
if (p[1]) RET_GATHER(r, test_timestamp_one(*arg));
putchar('\n');
} }
return r; return r;

View File

@ -21,7 +21,7 @@
#define AUTOFS_MIN_PROTO_VERSION 3 #define AUTOFS_MIN_PROTO_VERSION 3
#define AUTOFS_MAX_PROTO_VERSION 5 #define AUTOFS_MAX_PROTO_VERSION 5
#define AUTOFS_PROTO_SUBVERSION 5 #define AUTOFS_PROTO_SUBVERSION 6
/* /*
* The wait_queue_token (autofs_wqt_t) is part of a structure which is passed * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed

View File

@ -1121,6 +1121,9 @@ enum bpf_attach_type {
#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
/* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[]
* in sync with the definitions below.
*/
enum bpf_link_type { enum bpf_link_type {
BPF_LINK_TYPE_UNSPEC = 0, BPF_LINK_TYPE_UNSPEC = 0,
BPF_LINK_TYPE_RAW_TRACEPOINT = 1, BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
@ -2851,7 +2854,7 @@ union bpf_attr {
* **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**, * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**,
* **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**, * **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**,
* **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**, * **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**,
* **TCP_BPF_RTO_MIN**. * **TCP_BPF_RTO_MIN**, **TCP_BPF_SOCK_OPS_CB_FLAGS**.
* * **IPPROTO_IP**, which supports *optname* **IP_TOS**. * * **IPPROTO_IP**, which supports *optname* **IP_TOS**.
* * **IPPROTO_IPV6**, which supports the following *optname*\ s: * * **IPPROTO_IPV6**, which supports the following *optname*\ s:
* **IPV6_TCLASS**, **IPV6_AUTOFLOWLABEL**. * **IPV6_TCLASS**, **IPV6_AUTOFLOWLABEL**.
@ -5519,11 +5522,12 @@ union bpf_attr {
* **-EOPNOTSUPP** if the hash calculation failed or **-EINVAL** if * **-EOPNOTSUPP** if the hash calculation failed or **-EINVAL** if
* invalid arguments are passed. * invalid arguments are passed.
* *
* void *bpf_kptr_xchg(void *map_value, void *ptr) * void *bpf_kptr_xchg(void *dst, void *ptr)
* Description * Description
* Exchange kptr at pointer *map_value* with *ptr*, and return the * Exchange kptr at pointer *dst* with *ptr*, and return the old value.
* old value. *ptr* can be NULL, otherwise it must be a referenced * *dst* can be map value or local kptr. *ptr* can be NULL, otherwise
* pointer which will be released when this helper is called. * it must be a referenced pointer which will be released when this helper
* is called.
* Return * Return
* The old value of kptr (which can be NULL). The returned pointer * The old value of kptr (which can be NULL). The returned pointer
* if not NULL, is a reference which must be released using its * if not NULL, is a reference which must be released using its
@ -6046,11 +6050,6 @@ enum {
BPF_F_MARK_ENFORCE = (1ULL << 6), BPF_F_MARK_ENFORCE = (1ULL << 6),
}; };
/* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */
enum {
BPF_F_INGRESS = (1ULL << 0),
};
/* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */
enum { enum {
BPF_F_TUNINFO_IPV6 = (1ULL << 0), BPF_F_TUNINFO_IPV6 = (1ULL << 0),
@ -6197,10 +6196,12 @@ enum {
BPF_F_BPRM_SECUREEXEC = (1ULL << 0), BPF_F_BPRM_SECUREEXEC = (1ULL << 0),
}; };
/* Flags for bpf_redirect_map helper */ /* Flags for bpf_redirect and bpf_redirect_map helpers */
enum { enum {
BPF_F_BROADCAST = (1ULL << 3), BPF_F_INGRESS = (1ULL << 0), /* used for skb path */
BPF_F_EXCLUDE_INGRESS = (1ULL << 4), BPF_F_BROADCAST = (1ULL << 3), /* used for XDP path */
BPF_F_EXCLUDE_INGRESS = (1ULL << 4), /* used for XDP path */
#define BPF_F_REDIRECT_FLAGS (BPF_F_INGRESS | BPF_F_BROADCAST | BPF_F_EXCLUDE_INGRESS)
}; };
#define __bpf_md_ptr(type, name) \ #define __bpf_md_ptr(type, name) \
@ -7080,6 +7081,7 @@ enum {
TCP_BPF_SYN = 1005, /* Copy the TCP header */ TCP_BPF_SYN = 1005, /* Copy the TCP header */
TCP_BPF_SYN_IP = 1006, /* Copy the IP[46] and TCP header */ TCP_BPF_SYN_IP = 1006, /* Copy the IP[46] and TCP header */
TCP_BPF_SYN_MAC = 1007, /* Copy the MAC, IP[46], and TCP header */ TCP_BPF_SYN_MAC = 1007, /* Copy the MAC, IP[46], and TCP header */
TCP_BPF_SOCK_OPS_CB_FLAGS = 1008, /* Get or Set TCP sock ops flags */
}; };
enum { enum {
@ -7512,4 +7514,13 @@ struct bpf_iter_num {
__u64 __opaque[1]; __u64 __opaque[1];
} __attribute__((aligned(8))); } __attribute__((aligned(8)));
/*
* Flags to control BPF kfunc behaviour.
* - BPF_F_PAD_ZEROS: Pad destination buffer with zeros. (See the respective
* helper documentation for details.)
*/
enum bpf_kfunc_flags {
BPF_F_PAD_ZEROS = (1ULL << 0),
};
#endif /* __LINUX_BPF_H__ */ #endif /* __LINUX_BPF_H__ */

View File

@ -28,6 +28,23 @@
#define _BITUL(x) (_UL(1) << (x)) #define _BITUL(x) (_UL(1) << (x))
#define _BITULL(x) (_ULL(1) << (x)) #define _BITULL(x) (_ULL(1) << (x))
#if !defined(__ASSEMBLY__)
/*
* Missing __asm__ support
*
* __BIT128() would not work in the __asm__ code, as it shifts an
* 'unsigned __init128' data type as direct representation of
* 128 bit constants is not supported in the gcc compiler, as
* they get silently truncated.
*
* TODO: Please revisit this implementation when gcc compiler
* starts representing 128 bit constants directly like long
* and unsigned long etc. Subsequently drop the comment for
* GENMASK_U128() which would then start supporting __asm__ code.
*/
#define _BIT128(x) ((unsigned __int128)(1) << (x))
#endif
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1) #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))

View File

@ -2531,4 +2531,20 @@ struct ethtool_link_settings {
* __u32 map_lp_advertising[link_mode_masks_nwords]; * __u32 map_lp_advertising[link_mode_masks_nwords];
*/ */
}; };
/**
* enum phy_upstream - Represents the upstream component a given PHY device
* is connected to, as in what is on the other end of the MII bus. Most PHYs
* will be attached to an Ethernet MAC controller, but in some cases, there's
* an intermediate PHY used as a media-converter, which will driver another
* MII interface as its output.
* @PHY_UPSTREAM_MAC: Upstream component is a MAC (a switch port,
* or ethernet controller)
* @PHY_UPSTREAM_PHY: Upstream component is a PHY (likely a media converter)
*/
enum phy_upstream {
PHY_UPSTREAM_MAC,
PHY_UPSTREAM_PHY,
};
#endif /* _LINUX_ETHTOOL_H */ #endif /* _LINUX_ETHTOOL_H */

View File

@ -67,6 +67,7 @@ enum {
FRA_IP_PROTO, /* ip proto */ FRA_IP_PROTO, /* ip proto */
FRA_SPORT_RANGE, /* sport */ FRA_SPORT_RANGE, /* sport */
FRA_DPORT_RANGE, /* dport */ FRA_DPORT_RANGE, /* dport */
FRA_DSCP, /* dscp */
__FRA_MAX __FRA_MAX
}; };

View File

@ -230,8 +230,8 @@ struct tpacket_hdr_v1 {
* ts_first_pkt: * ts_first_pkt:
* Is always the time-stamp when the block was opened. * Is always the time-stamp when the block was opened.
* Case a) ZERO packets * Case a) ZERO packets
* No packets to deal with but atleast you know the * No packets to deal with but at least you know
* time-interval of this block. * the time-interval of this block.
* Case b) Non-zero packets * Case b) Non-zero packets
* Use the ts of the first packet in the block. * Use the ts of the first packet in the block.
* *
@ -265,7 +265,8 @@ enum tpacket_versions {
- struct tpacket_hdr - struct tpacket_hdr
- pad to TPACKET_ALIGNMENT=16 - pad to TPACKET_ALIGNMENT=16
- struct sockaddr_ll - struct sockaddr_ll
- Gap, chosen so that packet data (Start+tp_net) alignes to TPACKET_ALIGNMENT=16 - Gap, chosen so that packet data (Start+tp_net) aligns to
TPACKET_ALIGNMENT=16
- Start+tp_mac: [ Optional MAC header ] - Start+tp_mac: [ Optional MAC header ]
- Start+tp_net: Packet data, aligned to TPACKET_ALIGNMENT=16. - Start+tp_net: Packet data, aligned to TPACKET_ALIGNMENT=16.
- Pad to align to TPACKET_ALIGNMENT=16 - Pad to align to TPACKET_ALIGNMENT=16

View File

@ -141,7 +141,7 @@ struct in_addr {
*/ */
#define IP_PMTUDISC_INTERFACE 4 #define IP_PMTUDISC_INTERFACE 4
/* weaker version of IP_PMTUDISC_INTERFACE, which allows packets to get /* weaker version of IP_PMTUDISC_INTERFACE, which allows packets to get
* fragmented if they exeed the interface mtu * fragmented if they exceed the interface mtu
*/ */
#define IP_PMTUDISC_OMIT 5 #define IP_PMTUDISC_OMIT 5

View File

@ -140,25 +140,6 @@
#endif /* _NETINET_IN_H */ #endif /* _NETINET_IN_H */
/* Coordinate with glibc netipx/ipx.h header. */
#if defined(__NETIPX_IPX_H)
#define __UAPI_DEF_SOCKADDR_IPX 0
#define __UAPI_DEF_IPX_ROUTE_DEFINITION 0
#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 0
#define __UAPI_DEF_IPX_CONFIG_DATA 0
#define __UAPI_DEF_IPX_ROUTE_DEF 0
#else /* defined(__NETIPX_IPX_H) */
#define __UAPI_DEF_SOCKADDR_IPX 1
#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
#define __UAPI_DEF_IPX_CONFIG_DATA 1
#define __UAPI_DEF_IPX_ROUTE_DEF 1
#endif /* defined(__NETIPX_IPX_H) */
/* Definitions for xattr.h */ /* Definitions for xattr.h */
#if defined(_SYS_XATTR_H) #if defined(_SYS_XATTR_H)
#define __UAPI_DEF_XATTR 0 #define __UAPI_DEF_XATTR 0
@ -240,23 +221,6 @@
#define __UAPI_DEF_IP6_MTUINFO 1 #define __UAPI_DEF_IP6_MTUINFO 1
#endif #endif
/* Definitions for ipx.h */
#ifndef __UAPI_DEF_SOCKADDR_IPX
#define __UAPI_DEF_SOCKADDR_IPX 1
#endif
#ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION
#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
#endif
#ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION
#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
#endif
#ifndef __UAPI_DEF_IPX_CONFIG_DATA
#define __UAPI_DEF_IPX_CONFIG_DATA 1
#endif
#ifndef __UAPI_DEF_IPX_ROUTE_DEF
#define __UAPI_DEF_IPX_ROUTE_DEF 1
#endif
/* Definitions for xattr.h */ /* Definitions for xattr.h */
#ifndef __UAPI_DEF_XATTR #ifndef __UAPI_DEF_XATTR
#define __UAPI_DEF_XATTR 1 #define __UAPI_DEF_XATTR 1

View File

@ -436,7 +436,7 @@ enum nft_set_elem_flags {
* @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data) * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)
* @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes) * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)
* @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32) * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)
* @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64) * @NFTA_SET_ELEM_TIMEOUT: timeout value, zero means never times out (NLA_U64)
* @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64) * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)
* @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY) * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)
* @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes) * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)
@ -1694,7 +1694,7 @@ enum nft_flowtable_flags {
* *
* @NFTA_FLOWTABLE_TABLE: name of the table containing the expression (NLA_STRING) * @NFTA_FLOWTABLE_TABLE: name of the table containing the expression (NLA_STRING)
* @NFTA_FLOWTABLE_NAME: name of this flow table (NLA_STRING) * @NFTA_FLOWTABLE_NAME: name of this flow table (NLA_STRING)
* @NFTA_FLOWTABLE_HOOK: netfilter hook configuration(NLA_U32) * @NFTA_FLOWTABLE_HOOK: netfilter hook configuration (NLA_NESTED)
* @NFTA_FLOWTABLE_USE: number of references to this flow table (NLA_U32) * @NFTA_FLOWTABLE_USE: number of references to this flow table (NLA_U32)
* @NFTA_FLOWTABLE_HANDLE: object handle (NLA_U64) * @NFTA_FLOWTABLE_HANDLE: object handle (NLA_U64)
* @NFTA_FLOWTABLE_FLAGS: flags (NLA_U32) * @NFTA_FLOWTABLE_FLAGS: flags (NLA_U32)

View File

@ -16,10 +16,15 @@ struct nhmsg {
struct nexthop_grp { struct nexthop_grp {
__u32 id; /* nexthop id - must exist */ __u32 id; /* nexthop id - must exist */
__u8 weight; /* weight of this nexthop */ __u8 weight; /* weight of this nexthop */
__u8 resvd1; __u8 weight_high; /* high order bits of weight */
__u16 resvd2; __u16 resvd2;
}; };
static __inline__ __u16 nexthop_grp_weight(const struct nexthop_grp *entry)
{
return ((entry->weight_high << 8) | entry->weight) + 1;
}
enum { enum {
NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group
* default type if not specified * default type if not specified
@ -33,6 +38,9 @@ enum {
#define NHA_OP_FLAG_DUMP_STATS BIT(0) #define NHA_OP_FLAG_DUMP_STATS BIT(0)
#define NHA_OP_FLAG_DUMP_HW_STATS BIT(1) #define NHA_OP_FLAG_DUMP_HW_STATS BIT(1)
/* Response OP_FLAGS. */
#define NHA_OP_FLAG_RESP_GRP_RESVD_0 BIT(31) /* Dump clears resvd fields. */
enum { enum {
NHA_UNSPEC, NHA_UNSPEC,
NHA_ID, /* u32; id for nexthop. id == 0 means auto-assign */ NHA_ID, /* u32; id for nexthop. id == 0 means auto-assign */

View File

@ -531,20 +531,24 @@ int is_idmapping_supported(const char *path) {
userns_fd = userns_acquire(uid_map, gid_map); userns_fd = userns_acquire(uid_map, gid_map);
if (ERRNO_IS_NEG_NOT_SUPPORTED(userns_fd) || ERRNO_IS_NEG_PRIVILEGE(userns_fd)) if (ERRNO_IS_NEG_NOT_SUPPORTED(userns_fd) || ERRNO_IS_NEG_PRIVILEGE(userns_fd))
return false; return false;
if (userns_fd == -ENOSPC) {
log_debug_errno(userns_fd, "Failed to acquire new user namespace, user.max_user_namespaces seems to be exhausted or maybe even zero, assuming ID-mapping is not supported: %m");
return false;
}
if (userns_fd < 0) if (userns_fd < 0)
return log_debug_errno(userns_fd, "ID-mapping supported namespace acquire failed for '%s' : %m", path); return log_debug_errno(userns_fd, "Failed to acquire new user namespace for checking if '%s' supports ID-mapping: %m", path);
dir_fd = RET_NERRNO(open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW)); dir_fd = RET_NERRNO(open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW));
if (ERRNO_IS_NEG_NOT_SUPPORTED(dir_fd)) if (ERRNO_IS_NEG_NOT_SUPPORTED(dir_fd))
return false; return false;
if (dir_fd < 0) if (dir_fd < 0)
return log_debug_errno(dir_fd, "ID-mapping supported open failed for '%s' : %m", path); return log_debug_errno(dir_fd, "Failed to open '%s', cannot determine if ID-mapping is supported: %m", path);
mount_fd = RET_NERRNO(open_tree(dir_fd, "", AT_EMPTY_PATH | OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC)); mount_fd = RET_NERRNO(open_tree(dir_fd, "", AT_EMPTY_PATH | OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC));
if (ERRNO_IS_NEG_NOT_SUPPORTED(mount_fd) || ERRNO_IS_NEG_PRIVILEGE(mount_fd) || mount_fd == -EINVAL) if (ERRNO_IS_NEG_NOT_SUPPORTED(mount_fd) || ERRNO_IS_NEG_PRIVILEGE(mount_fd) || mount_fd == -EINVAL)
return false; return false;
if (mount_fd < 0) if (mount_fd < 0)
return log_debug_errno(mount_fd, "ID-mapping supported open_tree failed for '%s' : %m", path); return log_debug_errno(mount_fd, "Failed to open mount tree '%s', cannot determine if ID-mapping is supported: %m", path);
r = RET_NERRNO(mount_setattr(mount_fd, "", AT_EMPTY_PATH, r = RET_NERRNO(mount_setattr(mount_fd, "", AT_EMPTY_PATH,
&(struct mount_attr) { &(struct mount_attr) {
@ -554,7 +558,7 @@ int is_idmapping_supported(const char *path) {
if (ERRNO_IS_NEG_NOT_SUPPORTED(r) || ERRNO_IS_NEG_PRIVILEGE(r) || r == -EINVAL) if (ERRNO_IS_NEG_NOT_SUPPORTED(r) || ERRNO_IS_NEG_PRIVILEGE(r) || r == -EINVAL)
return false; return false;
if (r < 0) if (r < 0)
return log_debug_errno(r, "ID-mapping supported setattr failed for '%s' : %m", path); return log_debug_errno(r, "Failed to set mount attribute to '%s', cannot determine if ID-mapping is supported: %m", path);
return true; return true;
} }

View File

@ -956,14 +956,16 @@ bool strv_fnmatch_full(
} }
char** strv_skip(char **l, size_t n) { char** strv_skip(char **l, size_t n) {
while (n > 0) { while (n > 0) {
if (strv_isempty(l)) if (strv_isempty(l))
return l; return NULL;
l++, n--; l++, n--;
} }
/* To simplify callers, always return NULL instead of a zero-item array. */
if (strv_isempty(l))
return NULL;
return l; return l;
} }

View File

@ -547,9 +547,21 @@ static int tree(int argc, char **argv, void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
if (argc <= 1) { char **args = strv_skip(argv, 1);
if (args)
STRV_FOREACH(arg, args) {
if (arg != args)
puts("");
if (args[1]) {
pager_open(arg_pager_flags);
printf("Service %s%s%s:\n", ansi_highlight(), *arg, ansi_normal());
}
RET_GATHER(r, tree_one(bus, *arg));
}
else {
_cleanup_strv_free_ char **names = NULL; _cleanup_strv_free_ char **names = NULL;
bool not_first = false;
r = sd_bus_list_names(bus, &names, NULL); r = sd_bus_list_names(bus, &names, NULL);
if (r < 0) if (r < 0)
@ -557,42 +569,21 @@ static int tree(int argc, char **argv, void *userdata) {
pager_open(arg_pager_flags); pager_open(arg_pager_flags);
STRV_FOREACH(i, names) { STRV_FOREACH(name, names) {
int q; if (!arg_unique && (*name)[0] == ':')
if (!arg_unique && (*i)[0] == ':')
continue; continue;
if (!arg_acquired && (*i)[0] == ':') if (!arg_acquired && (*name)[0] == ':')
continue; continue;
if (not_first) if (name != names)
printf("\n"); puts("");
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal()); printf("Service %s%s%s:\n", ansi_highlight(), *name, ansi_normal());
q = tree_one(bus, *i); RET_GATHER(r, tree_one(bus, *name));
if (q < 0 && r >= 0)
r = q;
not_first = true;
}
} else
STRV_FOREACH(i, strv_skip(argv, 1)) {
int q;
if (i > argv+1)
printf("\n");
if (argv[2]) {
pager_open(arg_pager_flags);
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
}
q = tree_one(bus, *i);
if (q < 0 && r >= 0)
r = q;
} }
}
return r; return r;
} }

View File

@ -98,16 +98,11 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
} }
} }
#if HAVE_SYSV_COMPAT else if (streq(key, "fastboot") && !value)
else if (streq(key, "fastboot") && !value) {
log_warning("Please pass 'fsck.mode=skip' rather than 'fastboot' on the kernel command line.");
arg_skip = true; arg_skip = true;
} else if (streq(key, "forcefsck") && !value) { else if (streq(key, "forcefsck") && !value)
log_warning("Please pass 'fsck.mode=force' rather than 'forcefsck' on the kernel command line.");
arg_force = true; arg_force = true;
}
#endif
return 0; return 0;
} }

View File

@ -663,8 +663,9 @@ static int add_root_mount(void) {
r = efi_loader_get_device_part_uuid(NULL); r = efi_loader_get_device_part_uuid(NULL);
if (r == -ENOENT) { if (r == -ENOENT) {
log_notice("EFI loader partition unknown, exiting.\n" log_notice("EFI loader partition unknown, not processing %s.\n"
"(The boot loader did not set EFI variable LoaderDevicePartUUID.)"); "(The boot loader did not set EFI variable LoaderDevicePartUUID.)",
in_initrd() ? "/sysroot" : "/");
return 0; return 0;
} else if (r < 0) } else if (r < 0)
return log_error_errno(r, "Failed to read loader partition UUID: %m"); return log_error_errno(r, "Failed to read loader partition UUID: %m");

View File

@ -691,122 +691,110 @@ static void dump_home_record(UserRecord *hr) {
} }
} }
static char **mangle_user_list(char **list, char ***ret_allocated) { static int inspect_home(sd_bus *bus, const char *name) {
_cleanup_free_ char *myself = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
char **l; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
const char *json;
int incomplete;
uid_t uid;
int r;
if (!strv_isempty(list)) { r = parse_uid(name, &uid);
*ret_allocated = NULL; if (r < 0) {
return list; if (!valid_user_group_name(name, 0))
} return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid user name '%s'.", name);
myself = getusername_malloc(); r = bus_call_method(bus, bus_mgr, "GetUserRecordByName", &error, &reply, "s", name);
if (!myself) } else
return NULL; r = bus_call_method(bus, bus_mgr, "GetUserRecordByUID", &error, &reply, "u", (uint32_t) uid);
if (r < 0)
return log_error_errno(r, "Failed to inspect home: %s", bus_error_message(&error, r));
l = new(char*, 2); r = sd_bus_message_read(reply, "sbo", &json, &incomplete, NULL);
if (!l) if (r < 0)
return NULL; return bus_log_parse_error(r);
l[0] = TAKE_PTR(myself); r = sd_json_parse(json, SD_JSON_PARSE_SENSITIVE, &v, NULL, NULL);
l[1] = NULL; if (r < 0)
return log_error_errno(r, "Failed to parse JSON identity: %m");
*ret_allocated = l; hr = user_record_new();
return l; if (!hr)
return log_oom();
r = user_record_load(hr, v, USER_RECORD_LOAD_REFUSE_SECRET|USER_RECORD_LOG|USER_RECORD_PERMISSIVE);
if (r < 0)
return r;
hr->incomplete = incomplete;
dump_home_record(hr);
return 0;
} }
static int inspect_home(int argc, char *argv[], void *userdata) { static int inspect_homes(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_strv_free_ char **mangled_list = NULL; int r;
int r, ret = 0;
char **items;
pager_open(arg_pager_flags);
r = acquire_bus(&bus); r = acquire_bus(&bus);
if (r < 0) if (r < 0)
return r; return r;
items = mangle_user_list(strv_skip(argv, 1), &mangled_list); pager_open(arg_pager_flags);
if (!items)
return log_oom();
STRV_FOREACH(i, items) { char **args = strv_skip(argv, 1);
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; if (args) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_free_ char *myself = getusername_malloc();
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL; if (!myself)
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
const char *json;
int incomplete;
uid_t uid;
r = parse_uid(*i, &uid);
if (r < 0) {
if (!valid_user_group_name(*i, 0)) {
log_error("Invalid user name '%s'.", *i);
if (ret == 0)
ret = -EINVAL;
continue;
}
r = bus_call_method(bus, bus_mgr, "GetUserRecordByName", &error, &reply, "s", *i);
} else
r = bus_call_method(bus, bus_mgr, "GetUserRecordByUID", &error, &reply, "u", (uint32_t) uid);
if (r < 0) {
log_error_errno(r, "Failed to inspect home: %s", bus_error_message(&error, r));
if (ret == 0)
ret = r;
continue;
}
r = sd_bus_message_read(reply, "sbo", &json, &incomplete, NULL);
if (r < 0) {
bus_log_parse_error(r);
if (ret == 0)
ret = r;
continue;
}
r = sd_json_parse(json, SD_JSON_PARSE_SENSITIVE, &v, NULL, NULL);
if (r < 0) {
log_error_errno(r, "Failed to parse JSON identity: %m");
if (ret == 0)
ret = r;
continue;
}
hr = user_record_new();
if (!hr)
return log_oom(); return log_oom();
r = user_record_load(hr, v, USER_RECORD_LOAD_REFUSE_SECRET|USER_RECORD_LOG|USER_RECORD_PERMISSIVE); return inspect_home(bus, myself);
if (r < 0) { } else {
if (ret == 0) STRV_FOREACH(arg, args)
ret = r; RET_GATHER(r, inspect_home(bus, *arg));
continue; return r;
}
hr->incomplete = incomplete;
dump_home_record(hr);
} }
return ret;
} }
static int authenticate_home(int argc, char *argv[], void *userdata) { static int authenticate_home(sd_bus *bus, const char *name) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_(user_record_unrefp) UserRecord *secret = NULL;
_cleanup_strv_free_ char **mangled_list = NULL; int r;
int r, ret = 0;
char **items;
items = mangle_user_list(strv_skip(argv, 1), &mangled_list); r = acquire_passed_secrets(name, &secret);
if (!items) if (r < 0)
return log_oom(); return r;
for (;;) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_mgr, "AuthenticateHome");
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_message_append(m, "s", name);
if (r < 0)
return bus_log_create_error(r);
r = bus_message_append_secret(m, secret);
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_call(bus, m, HOME_SLOW_BUS_CALL_TIMEOUT_USEC, &error, NULL);
if (r < 0) {
r = handle_generic_user_record_error(name, secret, &error, r, false);
if (r >= 0)
continue;
}
return r;
}
}
static int authenticate_homes(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
r = acquire_bus(&bus); r = acquire_bus(&bus);
if (r < 0) if (r < 0)
@ -814,44 +802,19 @@ static int authenticate_home(int argc, char *argv[], void *userdata) {
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password); (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
STRV_FOREACH(i, items) { char **args = strv_skip(argv, 1);
_cleanup_(user_record_unrefp) UserRecord *secret = NULL; if (args) {
_cleanup_free_ char *myself = getusername_malloc();
if (!myself)
return log_oom();
r = acquire_passed_secrets(*i, &secret); return authenticate_home(bus, myself);
if (r < 0) } else {
return r; STRV_FOREACH(arg, args)
RET_GATHER(r, authenticate_home(bus, *arg));
for (;;) { return r;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_mgr, "AuthenticateHome");
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_message_append(m, "s", *i);
if (r < 0)
return bus_log_create_error(r);
r = bus_message_append_secret(m, secret);
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_call(bus, m, HOME_SLOW_BUS_CALL_TIMEOUT_USEC, &error, NULL);
if (r < 0) {
r = handle_generic_user_record_error(*i, secret, &error, r, false);
if (r < 0) {
if (ret == 0)
ret = r;
break;
}
} else
break;
}
} }
return ret;
} }
static int update_last_change(sd_json_variant **v, bool with_password, bool override) { static int update_last_change(sd_json_variant **v, bool with_password, bool override) {
@ -4727,8 +4690,8 @@ static int run(int argc, char *argv[]) {
{ "list", VERB_ANY, 1, VERB_DEFAULT, list_homes }, { "list", VERB_ANY, 1, VERB_DEFAULT, list_homes },
{ "activate", 2, VERB_ANY, 0, activate_home }, { "activate", 2, VERB_ANY, 0, activate_home },
{ "deactivate", 2, VERB_ANY, 0, deactivate_home }, { "deactivate", 2, VERB_ANY, 0, deactivate_home },
{ "inspect", VERB_ANY, VERB_ANY, 0, inspect_home }, { "inspect", VERB_ANY, VERB_ANY, 0, inspect_homes },
{ "authenticate", VERB_ANY, VERB_ANY, 0, authenticate_home }, { "authenticate", VERB_ANY, VERB_ANY, 0, authenticate_homes },
{ "create", VERB_ANY, 2, 0, create_home }, { "create", VERB_ANY, 2, 0, create_home },
{ "remove", 2, VERB_ANY, 0, remove_home }, { "remove", 2, VERB_ANY, 0, remove_home },
{ "update", VERB_ANY, 2, 0, update_home }, { "update", VERB_ANY, 2, 0, update_home },

View File

@ -133,17 +133,7 @@ static int verb_show(int argc, char **argv, void *userdata) {
int r; int r;
argv = strv_skip(argv, 1); argv = strv_skip(argv, 1);
if (strv_isempty(argv)) { if (argv)
if (!sd_id128_is_null(arg_app))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"'show --app-specific=' can only be used with explicit UUID input.");
for (const GptPartitionType *e = gpt_partition_type_table; e->name; e++) {
r = show_one(&table, e->name, e->uuid, e == gpt_partition_type_table);
if (r < 0)
return r;
}
} else
STRV_FOREACH(p, argv) { STRV_FOREACH(p, argv) {
sd_id128_t uuid; sd_id128_t uuid;
const char *id = NULL; const char *id = NULL;
@ -171,6 +161,17 @@ static int verb_show(int argc, char **argv, void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
} }
else {
if (!sd_id128_is_null(arg_app))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"'show --app-specific=' can only be used with explicit UUID input.");
for (const GptPartitionType *e = gpt_partition_type_table; e->name; e++) {
r = show_one(&table, e->name, e->uuid, e == gpt_partition_type_table);
if (r < 0)
return r;
}
}
if (table) { if (table) {
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);

View File

@ -75,6 +75,10 @@ static int curl_glue_socket_callback(CURL *curl, curl_socket_t s, int action, vo
return 0; return 0;
} }
/* Don't configure io event source anymore when the event loop is dead already. */
if (g->event && sd_event_get_state(g->event) == SD_EVENT_FINISHED)
return 0;
r = hashmap_ensure_allocated(&g->ios, &trivial_hash_ops); r = hashmap_ensure_allocated(&g->ios, &trivial_hash_ops);
if (r < 0) { if (r < 0) {
log_oom(); log_oom();

View File

@ -16,7 +16,7 @@ int varlink_get_peer_pidref(sd_varlink *v, PidRef *ret) {
int pidfd = sd_varlink_get_peer_pidfd(v); int pidfd = sd_varlink_get_peer_pidfd(v);
if (pidfd < 0) { if (pidfd < 0) {
if (!ERRNO_IS_NEG_NOT_SUPPORTED(pidfd)) if (!ERRNO_IS_NEG_NOT_SUPPORTED(pidfd) && pidfd != -EINVAL)
return pidfd; return pidfd;
pid_t pid; pid_t pid;

View File

@ -101,18 +101,19 @@ static int help(int argc, char *argv[], void *userdata) {
" -j Same as --json=pretty on tty, --json=short otherwise\n" " -j Same as --json=pretty on tty, --json=short otherwise\n"
" --append=PATH Load specified JSON signature, and append new signature to it\n" " --append=PATH Load specified JSON signature, and append new signature to it\n"
"\n%3$sUKI PE Section Options:%4$s %3$sUKI PE Section%4$s\n" "\n%3$sUKI PE Section Options:%4$s %3$sUKI PE Section%4$s\n"
" --linux=PATH Path to Linux kernel image file %7$s .linux\n" " --linux=PATH Path to Linux kernel image file %7$s .linux\n"
" --osrel=PATH Path to os-release file %7$s .osrel\n" " --osrel=PATH Path to os-release file %7$s .osrel\n"
" --cmdline=PATH Path to file with kernel command line %7$s .cmdline\n" " --cmdline=PATH Path to file with kernel command line %7$s .cmdline\n"
" --initrd=PATH Path to initrd image file %7$s .initrd\n" " --initrd=PATH Path to initrd image file %7$s .initrd\n"
" --ucode=PATH Path to microcode image file %7$s .ucode\n" " --ucode=PATH Path to microcode image file %7$s .ucode\n"
" --splash=PATH Path to splash bitmap file %7$s .splash\n" " --splash=PATH Path to splash bitmap file %7$s .splash\n"
" --dtb=PATH Path to DeviceTree file %7$s .dtb\n" " --dtb=PATH Path to DeviceTree file %7$s .dtb\n"
" --uname=PATH Path to 'uname -r' file %7$s .uname\n" " --dtbauto=PATH Path to DeviceTree file for auto selection %7$s .dtbauto\n"
" --sbat=PATH Path to SBAT file %7$s .sbat\n" " --uname=PATH Path to 'uname -r' file %7$s .uname\n"
" --pcrpkey=PATH Path to public key for PCR signatures %7$s .pcrpkey\n" " --sbat=PATH Path to SBAT file %7$s .sbat\n"
" --profile=PATH Path to profile file %7$s .profile\n" " --pcrpkey=PATH Path to public key for PCR signatures %7$s .pcrpkey\n"
" --hwids=PATH Path to HWIDs file %7$s .hwids\n" " --profile=PATH Path to profile file %7$s .profile\n"
" --hwids=PATH Path to HWIDs file %7$s .hwids\n"
"\nSee the %2$s for details.\n", "\nSee the %2$s for details.\n",
program_invocation_short_name, program_invocation_short_name,
link, link,

View File

@ -2280,10 +2280,9 @@ static int copy_devnode_one(const char *dest, const char *node, bool ignore_mkno
r = path_extract_directory(from, &parent); r = path_extract_directory(from, &parent);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to extract directory from %s: %m", from); return log_error_errno(r, "Failed to extract directory from %s: %m", from);
if (!path_equal(parent, "/dev/")) { r = userns_mkdir(dest, parent, 0755, 0, 0);
if (userns_mkdir(dest, parent, 0755, 0, 0) < 0) if (r < 0)
return log_error_errno(r, "Failed to create directory %s: %m", parent); return log_error_errno(r, "Failed to create directory %s: %m", parent);
}
if (mknod(to, st.st_mode, st.st_rdev) < 0) { if (mknod(to, st.st_mode, st.st_rdev) < 0) {
r = -errno; /* Save the original error code. */ r = -errno; /* Save the original error code. */
@ -4654,7 +4653,7 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
ucred = CMSG_FIND_DATA(&msghdr, SOL_SOCKET, SCM_CREDENTIALS, struct ucred); ucred = CMSG_FIND_DATA(&msghdr, SOL_SOCKET, SCM_CREDENTIALS, struct ucred);
if (!ucred || ucred->pid != inner_child_pid) { if (!ucred || ucred->pid != inner_child_pid) {
log_debug("Received notify message without valid credentials. Ignoring."); log_debug("Received notify message from process that is not the payload's PID 1. Ignoring.");
return 0; return 0;
} }

View File

@ -36,14 +36,9 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
arg_skip = true; arg_skip = true;
else else
log_warning("Invalid quotacheck.mode= value, ignoring: %s", value); log_warning("Invalid quotacheck.mode= value, ignoring: %s", value);
}
#if HAVE_SYSV_COMPAT } else if (streq(key, "forcequotacheck") && !value)
else if (streq(key, "forcequotacheck") && !value) {
log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line. Proceeding anyway.");
arg_force = true; arg_force = true;
}
#endif
return 0; return 0;
} }

View File

@ -152,11 +152,13 @@ static int do_execute(
} }
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *args = NULL; _cleanup_free_ char *s = NULL;
if (argv)
args = quote_command_line(strv_skip(argv, 1), SHELL_ESCAPE_EMPTY);
log_debug("About to execute %s%s%s", t, argv ? " " : "", argv ? strnull(args) : ""); char **args = strv_skip(argv, 1);
if (args)
s = quote_command_line(args, SHELL_ESCAPE_EMPTY);
log_debug("About to execute %s%s%s", t, args ? " " : "", args ? strnull(s) : "");
} }
if (FLAGS_SET(flags, EXEC_DIR_WARN_WORLD_WRITABLE)) { if (FLAGS_SET(flags, EXEC_DIR_WARN_WORLD_WRITABLE)) {

View File

@ -98,15 +98,17 @@ static int delete_dm(DeviceMapper *m) {
assert(major(m->devnum) != 0); assert(major(m->devnum) != 0);
assert(m->path); assert(m->path);
fd = open(m->path, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0)
log_debug_errno(errno, "Failed to open DM block device %s for syncing, ignoring: %m", m->path);
else {
(void) sync_with_progress(fd);
fd = safe_close(fd);
}
fd = open("/dev/mapper/control", O_RDWR|O_CLOEXEC); fd = open("/dev/mapper/control", O_RDWR|O_CLOEXEC);
if (fd < 0) if (fd < 0)
return -errno; return log_debug_errno(errno, "Failed to open /dev/mapper/control: %m");
_cleanup_close_ int block_fd = open(m->path, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
if (block_fd < 0)
log_debug_errno(errno, "Failed to open DM block device %s for syncing, ignoring: %m", m->path);
else
(void) sync_with_progress(block_fd);
return RET_NERRNO(ioctl(fd, DM_DEV_REMOVE, &(struct dm_ioctl) { return RET_NERRNO(ioctl(fd, DM_DEV_REMOVE, &(struct dm_ioctl) {
.version = { .version = {

View File

@ -211,10 +211,8 @@ static int sync_making_progress(unsigned long long *prev_dirty) {
continue; continue;
errno = 0; errno = 0;
if (sscanf(line, "%*s %llu %*s", &ull) != 1) { if (sscanf(line, "%*s %llu %*s", &ull) != 1)
log_warning_errno(errno_or_else(EIO), "Failed to parse /proc/meminfo field, ignoring: %m"); return log_warning_errno(errno_or_else(EIO), "Failed to parse /proc/meminfo field: %m");
return false;
}
val += ull; val += ull;
} }

View File

@ -172,14 +172,14 @@ int verb_list_dependencies(int argc, char *argv[], void *userdata) {
return r; return r;
patterns = strv_skip(argv, 1); patterns = strv_skip(argv, 1);
if (strv_isempty(patterns)) { if (patterns) {
units = strv_new(SPECIAL_DEFAULT_TARGET);
if (!units)
return log_oom();
} else {
r = expand_unit_names(bus, patterns, NULL, &units, NULL); r = expand_unit_names(bus, patterns, NULL, &units, NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to expand names: %m"); return log_error_errno(r, "Failed to expand names: %m");
} else {
units = strv_new(SPECIAL_DEFAULT_TARGET);
if (!units)
return log_oom();
} }
pager_open(arg_pager_flags); pager_open(arg_pager_flags);

View File

@ -20,15 +20,13 @@
*/ */
static int run(int argc, char **argv) { static int run(int argc, char **argv) {
_cleanup_close_ int fd = -EBADF;
char **args = strv_skip(argv, 1);
int r; int r;
test_setup_logging(LOG_DEBUG); test_setup_logging(LOG_DEBUG);
args = !strv_isempty(args) ? args : STRV_MAKE("/bin/true"); char **args = strv_skip(argv, 1) ?: STRV_MAKE("/bin/true");
fd = open(args[0], O_RDONLY | O_CLOEXEC); _cleanup_close_ int fd = open(args[0], O_RDONLY | O_CLOEXEC);
if (fd < 0) if (fd < 0)
return log_error_errno(errno, "open(%s) failed: %m", args[0]); return log_error_errno(errno, "open(%s) failed: %m", args[0]);

View File

@ -1004,17 +1004,21 @@ TEST(strv_skip) {
test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 0, STRV_MAKE("foo", "bar", "baz")); test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 0, STRV_MAKE("foo", "bar", "baz"));
test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 1, STRV_MAKE("bar", "baz")); test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 1, STRV_MAKE("bar", "baz"));
test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 2, STRV_MAKE("baz")); test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 2, STRV_MAKE("baz"));
test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 3, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 3, NULL);
test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 4, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 4, NULL);
test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 55, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 55, NULL);
test_strv_skip_one(STRV_MAKE("quux"), 0, STRV_MAKE("quux")); test_strv_skip_one(STRV_MAKE("quux"), 0, STRV_MAKE("quux"));
test_strv_skip_one(STRV_MAKE("quux"), 1, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE("quux"), 1, NULL);
test_strv_skip_one(STRV_MAKE("quux"), 55, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE("quux"), 55, NULL);
test_strv_skip_one(STRV_MAKE(NULL), 0, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE(NULL), 0, NULL);
test_strv_skip_one(STRV_MAKE(NULL), 1, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE(NULL), 1, NULL);
test_strv_skip_one(STRV_MAKE(NULL), 55, STRV_MAKE(NULL)); test_strv_skip_one(STRV_MAKE(NULL), 55, NULL);
test_strv_skip_one(NULL, 0, NULL);
test_strv_skip_one(NULL, 1, NULL);
test_strv_skip_one(NULL, 55, NULL);
} }
TEST(strv_extend_n) { TEST(strv_extend_n) {

View File

@ -35,7 +35,10 @@ static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) {
"%s: expected: load [module…]", argv[0]); "%s: expected: load [module…]", argv[0]);
char **modules = strv_skip(argv, 2); char **modules = strv_skip(argv, 2);
if (strv_isempty(modules)) { if (modules)
STRV_FOREACH(module, modules)
(void) module_load_and_warn(ctx, *module, /* verbose = */ false);
else {
const char *modalias; const char *modalias;
r = sd_device_get_property_value(dev, "MODALIAS", &modalias); r = sd_device_get_property_value(dev, "MODALIAS", &modalias);
@ -43,9 +46,7 @@ static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) {
return log_device_warning_errno(dev, r, "Failed to read property \"MODALIAS\": %m"); return log_device_warning_errno(dev, r, "Failed to read property \"MODALIAS\": %m");
(void) module_load_and_warn(ctx, modalias, /* verbose = */ false); (void) module_load_and_warn(ctx, modalias, /* verbose = */ false);
} else }
STRV_FOREACH(module, modules)
(void) module_load_and_warn(ctx, *module, /* verbose = */ false);
return 0; return 0;
} }

View File

@ -467,7 +467,7 @@ class SignTool:
raise NotImplementedError() raise NotImplementedError()
@staticmethod @staticmethod
def from_string(name) -> type['SignTool']: def from_string(name: str) -> type['SignTool']:
if name == 'pesign': if name == 'pesign':
return PeSign return PeSign
elif name == 'sbsign': elif name == 'sbsign':

View File

@ -630,7 +630,7 @@ static int run(int argc, char **argv) {
} else { } else {
fd = find_source_vc(&vc, &idx); fd = find_source_vc(&vc, &idx);
if (fd < 0 && fd != -EBUSY) if (fd < 0 && fd != -EBUSY)
return log_error_errno(fd, "No usable source console found: %m"); return log_error_errno(fd, "No virtual console that can be configured found: %m");
} }
utf8 = is_locale_utf8(); utf8 = is_locale_utf8();
@ -640,7 +640,7 @@ static int run(int argc, char **argv) {
/* We found only busy VCs, which might happen during the boot process when the boot splash is /* We found only busy VCs, which might happen during the boot process when the boot splash is
* displayed on the only allocated VC. In this case we don't interfere and avoid initializing * displayed on the only allocated VC. In this case we don't interfere and avoid initializing
* the VC partially as some operations are likely to fail. */ * the VC partially as some operations are likely to fail. */
log_notice("All allocated VCs are currently busy, skipping initialization of font and keyboard settings."); log_notice("All allocated virtual consoles are busy, will not configure key mapping and font.");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -664,7 +664,7 @@ static int run(int argc, char **argv) {
setup_remaining_vcs(fd, idx, utf8); setup_remaining_vcs(fd, idx, utf8);
else else
log_full(r == EX_OSERR ? LOG_NOTICE : LOG_WARNING, log_full(r == EX_OSERR ? LOG_NOTICE : LOG_WARNING,
"Setting source virtual console failed, ignoring remaining ones."); "Configuration of first virtual console failed, ignoring remaining ones.");
} }
return IN_SET(r, 0, EX_OSERR) && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE; return IN_SET(r, 0, EX_OSERR) && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;

View File

@ -1,8 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
'''Test wrapper command for driving integration tests. """Test wrapper command for driving integration tests."""
'''
import argparse import argparse
import json import json
@ -13,7 +12,6 @@ import sys
import textwrap import textwrap
from pathlib import Path from pathlib import Path
EMERGENCY_EXIT_DROPIN = """\ EMERGENCY_EXIT_DROPIN = """\
[Unit] [Unit]
Wants=emergency-exit.service Wants=emergency-exit.service
@ -34,7 +32,7 @@ ExecStart=false
""" """
def main(): def main() -> None:
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--mkosi', required=True) parser.add_argument('--mkosi', required=True)
parser.add_argument('--meson-source-dir', required=True, type=Path) parser.add_argument('--meson-source-dir', required=True, type=Path)
@ -46,34 +44,43 @@ def main():
parser.add_argument('--slow', action=argparse.BooleanOptionalAction) parser.add_argument('--slow', action=argparse.BooleanOptionalAction)
parser.add_argument('--vm', action=argparse.BooleanOptionalAction) parser.add_argument('--vm', action=argparse.BooleanOptionalAction)
parser.add_argument('--exit-code', required=True, type=int) parser.add_argument('--exit-code', required=True, type=int)
parser.add_argument('mkosi_args', nargs="*") parser.add_argument('mkosi_args', nargs='*')
args = parser.parse_args() args = parser.parse_args()
if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))): if not bool(int(os.getenv('SYSTEMD_INTEGRATION_TESTS', '0'))):
print(f"SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping {args.name}", file=sys.stderr) print(
f'SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping {args.name}',
file=sys.stderr,
)
exit(77) exit(77)
if args.slow and not bool(int(os.getenv("SYSTEMD_SLOW_TESTS", "0"))): if args.slow and not bool(int(os.getenv('SYSTEMD_SLOW_TESTS', '0'))):
print(f"SYSTEMD_SLOW_TESTS=1 not found in environment, skipping {args.name}", file=sys.stderr) print(
f'SYSTEMD_SLOW_TESTS=1 not found in environment, skipping {args.name}',
file=sys.stderr,
)
exit(77) exit(77)
if args.vm and bool(int(os.getenv("TEST_NO_QEMU", "0"))): if args.vm and bool(int(os.getenv('TEST_NO_QEMU', '0'))):
print(f"TEST_NO_QEMU=1, skipping {args.name}", file=sys.stderr) print(f'TEST_NO_QEMU=1, skipping {args.name}', file=sys.stderr)
exit(77) exit(77)
for s in os.getenv("TEST_SKIP", "").split(): for s in os.getenv('TEST_SKIP', '').split():
if s in args.name: if s in args.name:
print(f"Skipping {args.name} due to TEST_SKIP", file=sys.stderr) print(f'Skipping {args.name} due to TEST_SKIP', file=sys.stderr)
exit(77) exit(77)
keep_journal = os.getenv("TEST_SAVE_JOURNAL", "fail") keep_journal = os.getenv('TEST_SAVE_JOURNAL', 'fail')
shell = bool(int(os.getenv("TEST_SHELL", "0"))) shell = bool(int(os.getenv('TEST_SHELL', '0')))
if shell and not sys.stderr.isatty(): if shell and not sys.stderr.isatty():
print(f"--interactive must be passed to meson test to use TEST_SHELL=1", file=sys.stderr) print(
'--interactive must be passed to meson test to use TEST_SHELL=1',
file=sys.stderr,
)
exit(1) exit(1)
name = args.name + (f"-{i}" if (i := os.getenv("MESON_TEST_ITERATION")) else "") name = args.name + (f'-{i}' if (i := os.getenv('MESON_TEST_ITERATION')) else '')
dropin = textwrap.dedent( dropin = textwrap.dedent(
"""\ """\
@ -84,14 +91,14 @@ def main():
if not shell: if not shell:
dropin += textwrap.dedent( dropin += textwrap.dedent(
f""" """
[Unit] [Unit]
SuccessAction=exit SuccessAction=exit
SuccessActionExitStatus=123 SuccessActionExitStatus=123
""" """
) )
if os.getenv("TEST_MATCH_SUBTEST"): if os.getenv('TEST_MATCH_SUBTEST'):
dropin += textwrap.dedent( dropin += textwrap.dedent(
f""" f"""
[Service] [Service]
@ -99,7 +106,7 @@ def main():
""" """
) )
if os.getenv("TEST_MATCH_TESTCASE"): if os.getenv('TEST_MATCH_TESTCASE'):
dropin += textwrap.dedent( dropin += textwrap.dedent(
f""" f"""
[Service] [Service]
@ -116,7 +123,7 @@ def main():
""" """
) )
journal_file = (args.meson_build_dir / (f"test/journal/{name}.journal")).absolute() journal_file = (args.meson_build_dir / (f'test/journal/{name}.journal')).absolute()
journal_file.unlink(missing_ok=True) journal_file.unlink(missing_ok=True)
elif not shell: elif not shell:
dropin += textwrap.dedent( dropin += textwrap.dedent(
@ -136,54 +143,60 @@ def main():
*(['--forward-journal', journal_file] if journal_file else []), *(['--forward-journal', journal_file] if journal_file else []),
*( *(
[ [
'--credential', '--credential', f'systemd.extra-unit.emergency-exit.service={shlex.quote(EMERGENCY_EXIT_SERVICE)}', # noqa: E501
f"systemd.extra-unit.emergency-exit.service={shlex.quote(EMERGENCY_EXIT_SERVICE)}", '--credential', f'systemd.unit-dropin.emergency.target={shlex.quote(EMERGENCY_EXIT_DROPIN)}',
'--credential',
f"systemd.unit-dropin.emergency.target={shlex.quote(EMERGENCY_EXIT_DROPIN)}",
] ]
if not sys.stderr.isatty() if not sys.stderr.isatty()
else [] else []
), ),
'--credential', '--credential', f'systemd.unit-dropin.{args.unit}={shlex.quote(dropin)}',
f"systemd.unit-dropin.{args.unit}={shlex.quote(dropin)}",
'--runtime-network=none', '--runtime-network=none',
'--runtime-scratch=no', '--runtime-scratch=no',
*args.mkosi_args, *args.mkosi_args,
'--qemu-firmware', args.firmware, '--qemu-firmware',
*(['--qemu-kvm', 'no'] if int(os.getenv("TEST_NO_KVM", "0")) else []), args.firmware,
*(['--qemu-kvm', 'no'] if int(os.getenv('TEST_NO_KVM', '0')) else []),
'--kernel-command-line-extra', '--kernel-command-line-extra',
' '.join([ ' '.join(
'systemd.hostname=H', [
f"SYSTEMD_UNIT_PATH=/usr/lib/systemd/tests/testdata/{args.name}.units:/usr/lib/systemd/tests/testdata/units:", 'systemd.hostname=H',
*([f"systemd.unit={args.unit}"] if not shell else []), f'SYSTEMD_UNIT_PATH=/usr/lib/systemd/tests/testdata/{args.name}.units:/usr/lib/systemd/tests/testdata/units:',
'systemd.mask=systemd-networkd-wait-online.service', *([f'systemd.unit={args.unit}'] if not shell else []),
*( 'systemd.mask=systemd-networkd-wait-online.service',
[ *(
"systemd.mask=serial-getty@.service", [
"systemd.show_status=error", 'systemd.mask=serial-getty@.service',
"systemd.crash_shell=0", 'systemd.show_status=error',
"systemd.crash_action=poweroff", 'systemd.crash_shell=0',
] 'systemd.crash_action=poweroff',
if not sys.stderr.isatty() ]
else [] if not sys.stderr.isatty()
), else []
]), ),
]
),
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}", '--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}",
*(['--runtime-build-sources=no'] if not sys.stderr.isatty() else []), *(['--runtime-build-sources=no'] if not sys.stderr.isatty() else []),
'qemu' if args.vm or os.getuid() != 0 else 'boot', 'qemu' if args.vm or os.getuid() != 0 else 'boot',
] ] # fmt: skip
result = subprocess.run(cmd) result = subprocess.run(cmd)
# On Debian/Ubuntu we get a lot of random QEMU crashes. Retry once, and then skip if it fails again. # On Debian/Ubuntu we get a lot of random QEMU crashes. Retry once, and then skip if it fails again.
if args.vm and result.returncode == 247 and args.exit_code != 247: if args.vm and result.returncode == 247 and args.exit_code != 247:
journal_file.unlink(missing_ok=True) if journal_file:
journal_file.unlink(missing_ok=True)
result = subprocess.run(cmd) result = subprocess.run(cmd)
if args.vm and result.returncode == 247 and args.exit_code != 247: if args.vm and result.returncode == 247 and args.exit_code != 247:
print(f"Test {args.name} failed due to QEMU crash (error 247), ignoring", file=sys.stderr) print(
f'Test {args.name} failed due to QEMU crash (error 247), ignoring',
file=sys.stderr,
)
exit(77) exit(77)
if journal_file and (keep_journal == "0" or (result.returncode in (args.exit_code, 77) and keep_journal == "fail")): if journal_file and (
keep_journal == '0' or (result.returncode in (args.exit_code, 77) and keep_journal == 'fail')
):
journal_file.unlink(missing_ok=True) journal_file.unlink(missing_ok=True)
if shell or result.returncode in (args.exit_code, 77): if shell or result.returncode in (args.exit_code, 77):
@ -192,31 +205,33 @@ def main():
if journal_file: if journal_file:
ops = [] ops = []
if os.getenv("GITHUB_ACTIONS"): if os.getenv('GITHUB_ACTIONS'):
id = os.environ["GITHUB_RUN_ID"] id = os.environ['GITHUB_RUN_ID']
iteration = os.environ["GITHUB_RUN_ATTEMPT"] iteration = os.environ['GITHUB_RUN_ATTEMPT']
j = json.loads( j = json.loads(
subprocess.run( subprocess.run(
[ [
args.mkosi, args.mkosi,
"--directory", os.fspath(args.meson_source_dir), '--directory', os.fspath(args.meson_source_dir),
"--json", '--json',
"summary", 'summary',
], ],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
text=True, text=True,
).stdout ).stdout
) ) # fmt: skip
distribution = j["Images"][-1]["Distribution"] distribution = j['Images'][-1]['Distribution']
release = j["Images"][-1]["Release"] release = j['Images'][-1]['Release']
artifact = f"ci-mkosi-{id}-{iteration}-{distribution}-{release}-failed-test-journals" artifact = f'ci-mkosi-{id}-{iteration}-{distribution}-{release}-failed-test-journals'
ops += [f"gh run download {id} --name {artifact} -D ci/{artifact}"] ops += [f'gh run download {id} --name {artifact} -D ci/{artifact}']
journal_file = Path(f"ci/{artifact}/test/journal/{name}.journal") journal_file = Path(f'ci/{artifact}/test/journal/{name}.journal')
ops += [f"journalctl --file {journal_file} --no-hostname -o short-monotonic -u {args.unit} -p info"] ops += [f'journalctl --file {journal_file} --no-hostname -o short-monotonic -u {args.unit} -p info']
print("Test failed, relevant logs can be viewed with: \n\n" print(
f"{(' && '.join(ops))}\n", file=sys.stderr) "Test failed, relevant logs can be viewed with: \n\n" f"{(' && '.join(ops))}\n",
file=sys.stderr,
)
# 0 also means we failed so translate that to a non-zero exit code to mark the test as failed. # 0 also means we failed so translate that to a non-zero exit code to mark the test as failed.
exit(result.returncode or 1) exit(result.returncode or 1)

View File

@ -960,10 +960,13 @@ exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ {{ s/^.*=/
# wait until devices got created # wait until devices got created
for _ in range(50): for _ in range(50):
out = subprocess.check_output(['ip', 'a', 'show', 'dev', self.if_router]) if subprocess.run(['ip', 'link', 'show', 'dev', self.if_router],
if b'state UP' in out and b'scope global' in out: stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0:
break break
time.sleep(0.1) time.sleep(0.1)
else:
subprocess.call(['ip', 'link', 'show', 'dev', self.if_router])
self.fail('Timed out waiting for {ifr} created.'.format(ifr=self.if_router))
def shutdown_iface(self): def shutdown_iface(self):
'''Remove test interface and stop DHCP server''' '''Remove test interface and stop DHCP server'''

View File

@ -13,11 +13,12 @@
d /run/lock 0755 root root - d /run/lock 0755 root root -
L /var/lock - - - - ../run/lock L /var/lock - - - - ../run/lock
{% if HAVE_SYSV_COMPAT %}
{% if CREATE_LOG_DIRS %} {% if CREATE_LOG_DIRS %}
L$ /var/log/README - - - - ../..{{DOC_DIR}}/README.logs L$ /var/log/README - - - - ../..{{DOC_DIR}}/README.logs
{% endif %} {% endif %}
{% if HAVE_SYSV_COMPAT %}
# /run/lock/subsys is used for serializing SysV service execution, and # /run/lock/subsys is used for serializing SysV service execution, and
# hence without use on SysV-less systems. # hence without use on SysV-less systems.
d /run/lock/subsys 0755 root root - d /run/lock/subsys 0755 root root -