Commit Graph
70410 Commits
Author SHA1 Message Date
Yu Watanabe 3f53332d4e namespace-util: introduce netns_acquire()
Similar to userns_acquire(), but for network namespace.
2024-01-19 15:06:08 +09:00
Yu Watanabe 387f39ea30 process-util: introduce FORK_NEW_NETNS for safe_fork()
Similar to FORK_NEW_MOUNTNS or FORK_NEW_USERNS.
2024-01-19 15:06:08 +09:00
Yu Watanabe cb566b5d13 namespace-util: downgrade log level in userns_acquire()
On failure, the caller logs the error in LOG_ERR.
2024-01-19 15:06:08 +09:00
Yu Watanabe d2881ef96e tree-wide: add short comments for namespace_open() and namespace_enter()
Also use -EBADF when unspecified.
2024-01-19 15:06:08 +09:00
Yu Watanabe 5178d4a77e namespace-util: rename arguments to prefix 'ret_'
Also reorder opening namespace fd to make it match with the order of the
arguments.
2024-01-19 15:06:08 +09:00
Antonio Alvarez Feijoo f14686c1d2 Revert "man: add missing <cmdsynopsis> wrapper"
This reverts commit 35fc10756b.

Although DocBook 4.5 states that `cmdsynopsis` can be used within `term` [1],
and `term` within `varlistentry`, `man` does not display the list of commands
after this change. FWIW, `cmdsynopsis` is used tree-wide within `refsynopsisdiv`
only.

[1] https://tdg.docbook.org/tdg/4.5/term
2024-01-19 15:03:34 +09:00
Yu Watanabe 6504d41c63 network: use strdup_or_null() where appropriate 2024-01-19 14:53:51 +09:00
Black-Hole1 5a02a9adb2 virt: support detection of Apple Virtualization guests with cpuid
This is a supplement to #24419. On macOS Intel machines, detection needs to be done through cpuid.
In macOS, `dmi_vendors` detection is only applicable to M series.

Signed-off-by: Black-Hole1 <bh@bugs.cc>
2024-01-19 14:47:24 +09:00
Yu Watanabe 4abb8d7b0b Merge pull request #30975 from yuwata/network-route-several-helper-functions
network/route: introduce several helper functions
2024-01-19 14:42:40 +09:00
Yu Watanabe 3babbdf632 network/route: introduce route_get_request()
No functional change, just refactoring and preparation for later
commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe 2f542fc3d4 network: adjust nexthops of dynamic routes before requesting
No effective functionality is changed. Preparation for later commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe acc3fc9e5f network/route-nexthop: introduce route_adjust_nexthops() and route_nexthops_needs_adjust()
These are not used in this commit, but will be used later.
Preparation for later commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe 413ea20ab3 network/route-nexthop: introduce route_nexthops_copy()
This also introduce an extra argument for route_dup(), but it is
currently unused, will be used later.

No functional change, just preparation for later commits.
2024-01-19 10:21:55 +09:00
Yu Watanabe 406fde1a4d network/route-nexthop: use RTA_MULTIPATH when weight is not zero
As we have no way to specify the weight of gateway without using
RTA_MULTIPATH.
2024-01-19 10:13:44 +09:00
Alberto Planas 4054e8128e Measure empty PK and KEK EFI vars
The OVMF UEFI firmware is measuring PK and KEK when secure boot is
disabled, and those variables are absent.  This can be checked via the
event log to see that there are extensions for PCR 7 associated with PK
and KEK events of type EV_EFI_VARIABLE_DRIVER_CONFIG.

When running the "lock-secureboot-policy" verb, pcrlock complains that
those variables are not found and refuse to generate the
240-secureboot-policy.pcrlock.d/generated.pcrlock file.

The "TCG PC Client Platform Firmware Profile Specification Version 1.05
Revision 23"[1] from May 7, 2021, in section "3.3.4.8 PCR[7] - Secure
Boot Policy Measurements", point 10.b:

If reading a UEFI variable returns UEFI_NOT_FOUND, platform firmware
SHALL measure the absence of the variable. The
UEFI_VARIABLE_DATA.VariableDataLength field MUST be set to zero and
UEFI_VARIABLE_DATA.VariableData field will have a size of zero.

This patch mark those variables to be marked as "synthesize empty",
generating the correct hash for those variables.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2024-01-19 00:18:20 +00:00
Nick Cao 4be1fc8443 network: Add L3MasterDevice= into routing policy 2024-01-19 00:17:50 +00:00
Luca Boccassi 12af3f1834 Merge pull request #30988 from bluca/dbus_docs
A couple of clarification for D-Bus methods
2024-01-18 22:45:24 +00:00
Luca Boccassi 803bcc434f man: explicitly say that portable1's Attach/Detach are synchronous 2024-01-18 17:22:12 +00:00
Luca Boccassi d156e66f82 man: add more suggestions on how to use StartUnit and JobRemoved
This is not immediately clear for users, so spell out the preferred pattern
clearly in the D-Bus documentation.
2024-01-18 17:22:12 +00:00
Nandakumar Raghavan ee8f3e489e networkd: Adding DHCPv4 private options to D-BUS
Currently DHCPv4 private options are not exposed in D-BUS.
This change is to include those private options into D-BUS
2024-01-18 09:41:23 +01:00
Lennart Poettering e7f2eef411 Merge pull request #30973 from mrc0mmand/gcc14
Reorder arguments for calloc()-like functions, part #2
2024-01-18 09:16:40 +01:00
Lennart Poettering 2d1e7d1937 dissect-image: introduce new get_common_dissect_directory() helper
So far, if some component mounts a DDI in some local mount namespace we
created a temporary mountpoint in /tmp/ for that. Let's instead use the
same directory inode in /run/ instead. This is safe, since if everything
runs in a local mount namespace (with propagation on /run/ off) then
they shouldn't fight for the inode. And it relieves us from having to
clean up the directory after use. Morever, it allows us to run without
/tmp/ mounted.

This only moves dissect-image.c and the dissec tool over. More stuff is
moved over later.
2024-01-18 01:30:10 +00:00
Luca Boccassi 73a994cff0 Merge pull request #30990 from poettering/more-mime
register mime types for some of our data files according to the shared mime spec
2024-01-18 00:01:09 +00:00
Lennart Poettering 75f8b0fe70 man: don't suggest using pam_unix.so's use_authtok switch
Our dumbed down example PAM stacks do not contain cracklib/pwq modules,
hence using use_authtok on the pam_unix.so password change stack won't
work, because it has the effect that pam_unix.so never asks for a
password on its own, expecting the cracklib/pwq modules to have
queried/validated them beforehand.

I noticed this issue because of #30969: Debian's PAM setup suffers by
the same issue – even though they don't actually use our suggested PAM
fragments at all.

See: #30969
2024-01-17 23:59:05 +00:00
Lennart Poettering 16d4aed919 mime: also add magic-based mime type rules for our other binary files
No immediate usecase, it's just nice that if you browser these files
with a graphical file manager you see them recognized as what they are.
2024-01-17 22:52:19 +01:00
Lennart Poettering 2dda9c779e mime: expose a mime type for encrypted credentials
Let's make things nice for desktops, and provide a mime type for
credential files.

This uses the 128bit header identifier that our credential files start
with. However, the files are always base64 encoded, hence we have to
match the base64 string, hence add a small test case that generates them
properly for us, and truncates them at the right place (since 128 is not
evently divisable by 6).
2024-01-17 22:51:44 +01:00
Lennart Poettering b9e2d83b75 vmspawn: include qemu cmdline in debug output
It's just so useful for debugging to know what is going to be executed.
2024-01-17 19:08:32 +01:00
Lennart Poettering ad9e1246b5 Merge pull request #30980 from poettering/varlink-call-full
varlink: some tweaks and fixes
2024-01-17 19:08:12 +01:00
Luca Boccassi 0a9735eac2 Merge pull request #30661 from rpigott/resolved-https-record
resolved: support RFC 9460 SVCB and HTTPS records
2024-01-17 16:20:35 +00:00
Andres Beltran 6ff84614f5 Restart the DHCPv4 client when max REQUEST attempts is reached 2024-01-17 16:15:47 +00:00
Luca Boccassi ed62937f78 user-util: remove dead code
The branch explicitly checks that all of these ret_ variables are NULL,
so they will never be used.

Follow-up for 83e9b584db

CID#1533239
CID#1533240
CID#1533241
2024-01-17 16:11:15 +00:00
Mike Yuan e7cbb4a137 run: strjoina is used, not sprintf
Follow-up for 43ead5e3d6
2024-01-17 16:10:37 +00:00
Mike Yuan 46ce85bf7f hibernate-util: log that we actually read /sys/power/resume* rather than cmdline
/sys/power/resume is always populated by the initrd, while
/sys/power/resume_offset might have been populated by
the kernel itself. Therefore, if the user is using an initrd
that doesn't include resume hook, the hibernation would fail,
which is expected. However, it was hard to track down the real
problem, since the previous log message suggested that resume=
is not set through kernel cmdline.
2024-01-17 16:10:14 +00:00
Lennart Poettering 71d0ecc5b9 varlink: introduce varlink_call_and_log() which calls and then logs an error
As it turns out we do this in a similar way at various times (and
sometimes incorrectly), hence add a common implementation to share the
code and fix the incorrect behaviour.
2024-01-17 16:20:54 +01:00
Lennart Poettering 0444391d1e varlink: drop "ret_flags" parameter from varlink_call()
The parameter returns the flags field of the reply message. This is only
relevant in very few cases, hence drop it from the call, but keep it in
a more generic varlink_call_full() call for those who need it.

Do something similar for varlink_callb().
2024-01-17 16:14:10 +01:00
Lennart Poettering 19ea126e0a varlink: if varlink_call() is called with ret_error_id=NULL propagate error via return value
It's OK if callers don't want to know the varlink error string. But in
that case return the fact the call failed via the return value, as a
negative errno as usual, to make sure it's not accidentally ignored.

Similar for varlink_observe()
2024-01-17 16:14:10 +01:00
Lennart Poettering c171b67a10 varlink: in varlink_observe() correctly collect error parameters
In varlink errors can have parameters (and they regularly do, for
example the io.systemd.System error we generate carries the errno in its
parameter), hence it's essential that varlink_oberserve collects that
properly and returns it too.
2024-01-17 16:14:10 +01:00
Lennart Poettering a4562f945d varlink: add helper that turns varlink errors back to errnos, client-side 2024-01-17 16:14:10 +01:00
Mike Yuan d9975dbb3c logind-action: also check .target unit state when selecting sleep action 2024-01-17 13:28:19 +00:00
Lennart Poettering 66ea62b71e Merge pull request #30971 from ddstreet/tpm2_key_conversion
Fix tpm unsealing when using RSA public key signatures
2024-01-17 13:36:47 +01:00
Frantisek Sumsal dc571cccd7 macro: terminate the temporary VA_ARGS_FOREACH() array with a sentinel
So gcc-14 doesn't complain we're out of bounds on the last iteration:

[2092/2414] Compiling C object test-macro.p/src_test_test-macro.c.o
In file included from ../src/basic/list.h:209,
                 from ../src/basic/log.h:10,
                 from ../src/test/test-macro.c:5:
../src/test/test-macro.c: In function ‘test_FOREACH_VA_ARGS’:
../src/basic/macro.h:395:90: warning: array subscript 1 is outside array bounds of ‘uint8_t[1]’ {aka ‘unsigned char[1]’} [-Warray-bounds=]
  395 |              ((long)(_current_ - _entries_) < (long)ELEMENTSOF(_entries_)) && ({ entry = *_current_; true; }); \
../src/basic/macro.h:392:9: note: in expansion of macro ‘_VA_ARGS_FOREACH’
  392 |         _VA_ARGS_FOREACH(entry, UNIQ_T(_entries_, UNIQ), UNIQ_T(_current_, UNIQ), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~~
../src/test/test-macro.c:322:9: note: in expansion of macro ‘VA_ARGS_FOREACH’
  322 |         VA_ARGS_FOREACH(u8, 0) {
      |         ^~~~~~~~~~~~~~~
../src/fundamental/macro-fundamental.h:163:37: note: at offset 1 into object ‘__unique_prefix__entries_181’ of size 1
  163 | #define UNIQ_T(x, uniq) CONCATENATE(__unique_prefix_, CONCATENATE(x, uniq))
      |                                     ^~~~~~~~~~~~~~~~
../src/basic/macro.h:394:28: note: in definition of macro ‘_VA_ARGS_FOREACH’
  394 |         for (typeof(entry) _entries_[] = { __VA_ARGS__ }, *_current_ = _entries_; \
      |                            ^~~~~~~~~
../src/fundamental/macro-fundamental.h:109:27: note: in expansion of macro ‘XCONCATENATE’
  109 | #define CONCATENATE(x, y) XCONCATENATE(x, y)
      |                           ^~~~~~~~~~~~
../src/fundamental/macro-fundamental.h:163:25: note: in expansion of macro ‘CONCATENATE’
  163 | #define UNIQ_T(x, uniq) CONCATENATE(__unique_prefix_, CONCATENATE(x, uniq))
      |                         ^~~~~~~~~~~
../src/basic/macro.h:392:33: note: in expansion of macro ‘UNIQ_T’
  392 |         _VA_ARGS_FOREACH(entry, UNIQ_T(_entries_, UNIQ), UNIQ_T(_current_, UNIQ), ##__VA_ARGS__)
      |                                 ^~~~~~
../src/test/test-macro.c:322:9: note: in expansion of macro ‘VA_ARGS_FOREACH’
  322 |         VA_ARGS_FOREACH(u8, 0) {
      |         ^~~~~~~~~~~~~~~
2024-01-17 13:20:37 +01:00
Lennart Poettering 5a702b6c81 Merge pull request #30974 from poettering/strv-extend-many
strv: add new strv_extend_many() helper
2024-01-17 13:13:30 +01:00
Lennart Poettering 631cdd59e1 ssh-generator: correct log level of one function
add_export_unix_socket() generally logs about errors, but we forgot one
case.
2024-01-17 13:13:13 +01:00
Mike Yuan 18cf8411b7 core/unit: check for correct function in vtable
Prompted by https://github.com/systemd/systemd/pull/30974/commits/61e44e01325eca50e88fc9cd400ee340081e9134
2024-01-17 11:54:06 +00:00
Luca Boccassi ddf934cf04 Merge pull request #30972 from mrc0mmand/ci-unit-tests-ukify
ci: install python3-pytest for ukify tests
2024-01-17 11:46:45 +00:00
Frantisek Sumsal b59bce308d meson: disable -Wnonnull-compare
This gets enabled by default in gcc-14 and complains everywhere where we
use assert() on an expression that is always true (i.e. using
`int x[static 2]` in function declaration, etc.):

[153/2414] Compiling C object src/basic/libbasic.a.p/fs-util.c.o
In file included from ../src/basic/macro.h:13,
                 from ../src/basic/alloc-util.h:10,
                 from ../src/basic/fs-util.c:11:
../src/basic/fd-util.h: In function ‘format_proc_fd_path’:
../src/fundamental/macro-fundamental.h:74:41: warning: ‘nonnull’ argument ‘buf’ compared to NULL [-Wnonnull-compare]
   74 | #define _unlikely_(x) (__builtin_expect(!!(x), 0))
      |                                         ^~~~~
../src/basic/macro.h:150:21: note: in expansion of macro ‘_unlikely_’
  150 |                 if (_unlikely_(!(expr)))                                \
      |                     ^~~~~~~~~~
../src/basic/macro.h:167:22: note: in expansion of macro ‘assert_message_se’
  167 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/basic/fd-util.h:129:9: note: in expansion of macro ‘assert’
  129 |         assert(buf);
      |         ^~~~~~

Disabling this selectively only for asserts is a bit painful, since the
option is not available in all compilers, and it'd need to be handled in
the EFI stuff as well.
2024-01-17 12:45:39 +01:00
Yu Watanabe 1cdd8b1b66 sd-netlink: fix rtnl_resolve_link_alternative_name()
Fixes a bug introduced by afdf6c3b60.
2024-01-17 18:53:45 +08:00
Lennart Poettering 41c41313b2 exec-credential: strv_extend() handles NULL strings gracefully 2024-01-17 11:32:11 +01:00
Lennart Poettering 010cd1dc58 tree-wide: propagate the error we got from strv_extend_xyz() to the caller
It's a bit sloppy to return -ENOMEM rather than the actual error we
already returned in the first place (even though it's always going to be
ENOMEM)
2024-01-17 11:32:11 +01:00
Lennart Poettering 4212636763 dbus-unit: don't eat up error codes needlessly 2024-01-17 11:32:11 +01:00