Commit graph

70485 commits

Author SHA1 Message Date
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 61e44e0132
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
Lennart Poettering 69f3c61990 tree-wide: port over various pieces of code to strv_extend_many() 2024-01-17 11:32:11 +01:00
Lennart Poettering 80f1e209a5 strv: add strv_extend_many() helper
This is supposed to be a nicer, faster replacement for the often seen
pattern strv_extend_strv(l, STRV_MAKE(…), false)
2024-01-17 11:32:11 +01:00
Lennart Poettering b9d37112f2 strv: remove strv_extend_front()
It's entirely identical to strv_push_prepend() hence drop the duplicate
definition.
2024-01-17 11:32:11 +01:00
Lennart Poettering a43431067e strv: modernize strv_insert()
Let's use memmove() to move the string contents, rather than manual
loops.

Fix the overflow extension.

Prefer reallocarray() over malloc()
2024-01-17 11:32:11 +01:00
Frantisek Sumsal fdd84270df Reorder arguments for calloc()-like functions, part #2
To appease gcc-14's -Wcalloc-transposed-args check.

Follow-up for 2a9ab0974b.
2024-01-17 11:09:09 +01:00
hfavisado 02b346d64f hwdb: Correct display rotation on Chuwi Ubook X N4100 (#24248) 2024-01-17 09:31:05 +01:00
Lennart Poettering cd3745713b
Merge pull request #30958 from YHNdnzj/loginctl-list-session-more-info
loginctl: show more info in list-sessions (ListSessionsEx())
2024-01-17 09:21:46 +01:00
Mike Yuan a37928d34c
TEST-35-LOGIN: test changes to list-sessions 2024-01-17 11:30:05 +08:00
Mike Yuan ea54517476
loginctl: add --json= and -j, decouple list-* from --output=
--output= is documented to only affect journal output in *-status.
Let's use --json= and -j standard options for list-* instead.
2024-01-17 11:30:04 +08:00
Mike Yuan 4a3e43ddc5
loginctl: show more info in list-sessions (ListSessionsEx())
At the same time, 8b6c039a1a is reverted, i.e.
session state is removed from the output. It was added to workaround #26744,
and doesn't really make too much sense after the issue is properly fixed.
2024-01-17 11:25:49 +08:00
Mike Yuan b3cb952c03
logind-dbus: introduce ListSessionsEx() call
As per https://github.com/systemd/systemd/pull/30884#discussion_r1448938737
2024-01-17 11:25:48 +08:00
Mike Yuan 7fbdd8c323
man: don't use versioned standard-options
no-pager-255 was added in #29184, which I reviewed and agreed.
However, as #30887 came up, I reconsidered it a bit, and now
I actually think that this should be removed.

We add new tools that refer to these standard options. During
the process, some options are also promoted to be standard ones.
I think a more sane practice is to generally keep old tools in
the loop, rather than overloading the standard-options with versions.
2024-01-17 11:25:45 +08:00
Yu Watanabe 443afd6c19
Merge pull request #30967 from yuwata/network-can-required-operstate-for-online
network: several cleanups for required operstate for online, and change the default for CAN devices
2024-01-17 07:01:24 +09:00
Luca Boccassi db75b2aba7
Merge pull request #30962 from poettering/varlink-json-sensitive-rework
varlink/json: rework "sensitive" logic
2024-01-16 21:23:54 +00:00
Luca Boccassi aa3ee22592
Merge pull request #30955 from yuwata/network-queue-request_detach
network/queue: cleanups for detaching request
2024-01-16 21:17:32 +00:00
Luca Boccassi eda07d7fcf
Merge pull request #30949 from yuwata/network-route-cosmetic-cleanups
network/route: several cosmetic cleanups
2024-01-16 21:16:09 +00:00
Dan Streetman fda3e84465 tpm2: If unsealing results in policy hash mismatch when using RSA pubkey, possibly retry
The commit e3acb4d24c changed how we format a
TPM2B_PUBLIC object from an openssl PEM RSA key if it used the TPM-defined
"default" RSA exponent, to instead set the TPM2B_PUBLIC RSA exponent to the
special-case value of 0. This broke backwards compatibility with
previously-sealed data. The previous commit fixed our code to no longer use the
"special case" exponent value of 0, while this commit adds a fallback check for
any sealed data that used the exponent value of 0. Now unsealing should work
for sealed data that used either method (either 0 or the actual value).
2024-01-16 15:57:08 -05:00
Frantisek Sumsal a165918491 ukify: use datetime.timezone.utc instead of datetime.UTC
For compat with older Python versions, since datetime.UTC is an alias
introduced in Python 3.11.
2024-01-16 21:48:44 +01:00
Frantisek Sumsal ee23a85561 ci: install python3-pytest for ukify tests 2024-01-16 21:36:05 +01:00
Dan Streetman e2e8d8f2a2 test: check TPM2B_PUBLIC "name" during PEM->TPM2B_PUBLIC conversion tests
Check the calculated TPM2B_PUBLIC key "name" to verify our PEM->TPM2B_PUBLIC
function remains consistent with previous code. This is important as the
TPM2B_PUBLIC "name" is used in the Authorize policy and so any change to a key
"name" would break unsealing for previously-sealed objects (see bug #30546).

Note that the tpm2_tpm2b_public_from_openssl_pkey() function results in a
TPM2B_PUBLIC with the same "name" as using the tpm2-tools program
tpm2_loadexternal, at least as of tpm2-tools version 5.6.18, with the test keys
from TEST(tpm2b_public_from_openssl_pkey) in src/test/test-tpm2.
2024-01-16 14:27:52 -05:00
Dan Streetman 910caa2443 test: verify PEM->TPM2B_PUBLIC conversion for RSA key with non-default exponent
The tpm2 test currently verifies PEM->TPM2B_PUBLIC conversion for an RSA key
with the default exponent (0x10001); this adds verification for an RSA key with
a non-default exponent.
2024-01-16 14:11:31 -05:00
Dan Streetman 1242b9ab2b tpm2: Do not use RSA exponent special-case default value in PEM->TPM2B_PUBLIC conversion
The openssl default value for an RSA key exponent value is 0x10001, and the TPM
specification defines a exponent value of 0 as representing this value. The
systemd code that converted an RSA PEM public key to a TPM2B_PUBLIC object
previously used the exponent value directly, but commit
e3acb4d24c changed the conversion to use the
special case exponent value of 0 for any RSA key with an exponent value of
0x10001.

Because the entire TPM2B_PUBLIC object is used to calculate its "name", this
difference in exponent value (0x10001 vs 0) introduced a change in the key
"name". Since the Authorize policy uses the key "name" directly in its policy
session hash value, this change resulted in new systemd code being unable to
properly unseal any data (e.g. a LUKS volume) that was previously sealed.

This reverts the code to no longer override an RSA exponent value of 0x10001
with the special case value of 0.

Fixes a bug introduced by commit e3acb4d24c.

Fixes: #30546
2024-01-16 14:09:51 -05:00
Yu Watanabe 7155ad9532 test-network: test the default required operational state for CAN devices 2024-01-17 04:05:43 +09:00
Yu Watanabe 3255bda698 network: make 'carrier' as the default required operational state for CAN device
As CAN devices do not support IP address, hence the state never goes to
higher than 'carrier'.

Prompted by https://github.com/linux-can/can-utils/issues/68#issuecomment-1327987724.
2024-01-17 04:05:43 +09:00
Yu Watanabe 2e59ba4e24 wait-online: several cleanups for LinkOperationalState
- fix memleak in parser,
- fix missing return in parser on failure,
- drop unnecessary temporary argument in command line argument parser,
- use recently introduced macros and helper functions.
2024-01-17 04:05:43 +09:00
Yu Watanabe 2278d9f66e network: several cleanups for LinkOperationalState
- introduce link_required_operstate_for_online() helper function,
- use recently introduced macros and helper functions,
- unconditionally serialize the minimum and maximum of required
  operational state.
2024-01-17 04:05:43 +09:00
Yu Watanabe ba04f957fe network: drop unnecessary temporary variables 2024-01-17 04:05:43 +09:00