Commit Graph
8191 Commits
Author SHA1 Message Date
Adrian Vovk f0409e7b42 user-record: Add method to match whole perMachine entry
We already had methods to check just the machine-id or just the
hostname, so this method pretty trivially checks both
2024-01-18 17:54:46 -05: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
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
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
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
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 69f3c61990 tree-wide: port over various pieces of code to strv_extend_many() 2024-01-17 11:32:11 +01: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
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
Ronan Pigott 9c331dc3c8 resolvectl: add SVCB and HTTPS json format 2024-01-16 11:26:37 -07:00
Lennart Poettering 85978d296c varlink: restore debug output on incoming messages
Now that we can selectively suppress only sensitive fields in JSON
objects we can reenable debug logging for incoming messages, which was
removed in 2e3414660c.

This makes Varlink fully debuggable again: we'll see both incoming and
outgoing messages, only the sensitive fields are suppressed.

See: #30578
2024-01-16 17:17:19 +01:00
Lennart Poettering 9912897170 json: replace JSON_FORMAT_REFUSE_SENSITIVE with JSON_FORMAT_CENSOR_SENSITIVE
Previously, the flag would completely refuse formatting a JSON object if
any field of it was marked sensitive. With this change we'll simply
replace the subobject with the string "<sensitive data>", and show
everything else.

This is tremendously useful when debugging, since it means that we can
again trace varlink calls through the stack: we can show all the message
metadata and just suppress the actually sensitive parameters.

The ability to debug this matters, and we should not hide more
information that we can get away with, to keep things debuggable and
maintainable.
2024-01-16 17:17:19 +01:00
Lennart Poettering c609338b1d json: export json_variant_is_sensitive_recursive()
Let's export this function, so that we can use it elsewhere. Also, while
at it, let's cache the result in a flag. This is only safe if the result
is positive, since we allow the flag to be enabled at any time down thre
tree somewhere, which we need to look at. (We never allow it to be
turned off however)
2024-01-16 17:16:18 +01:00
Lennart Poettering a570877c12 varlink: optionally, mark all incoming message's "parameters" field as sensitive
So far the varlink logic honoured the "sensitive" flag of output
messages. Let's add something similar for input messages. Since we don't
really know incoming messages, the flag simply controls whether the
"parmaeters" field of all incoming messages should be marked as
sensitive.

Then, turn this on in the credentials logic and in homed, since both
deal with credentials.
2024-01-16 17:14:20 +01:00
Luca Boccassi 97cc54bffd Merge pull request #30963 from poettering/creds-tweaks
two minor creds-util.c simplifications
2024-01-16 15:25:08 +00:00
Luca Boccassi 50f89c7d6d Merge pull request #30961 from poettering/varlink-bus-polkit-fixes
varlink polkit client fixes
2024-01-16 15:24:22 +00:00
Lennart Poettering a9e4057f1f creds-util: drop unnecessary include
Follow-up for: e653a194e4
2024-01-16 14:16:42 +01:00
Lennart Poettering cdbcb1fe6e creds-util: simplify offset calculation a bit
Don't recalculate the overall offset entirely each time we process
another header. Instead, if we already validated an earlier offset, just
reuse the result, it's readily available in 'p'.

No change in behaviour, just a bit of code simplification.
2024-01-16 14:16:18 +01:00
Lennart Poettering e96202fa5d bus-polkit: don't return positive in varlink_verify_polkit_async() just because we already sent an error reply
A positive return value means "access granted", hence if we already
reply to the method call don't accidentally return positive.

Follow-up for: d04c1a1c8e
2024-01-16 13:59:49 +01:00
Lennart Poettering 0ca9a44799 bus-polkit: explicitly cast away return value we ignore 2024-01-16 13:59:49 +01:00
Lennart Poettering 956d8aee01 bus-polkit: treat various well-known PK errors as denied
Various recognizable errors from

https://www.freedesktop.org/software/polkit/docs/latest/eggdbus-interface-org.freedesktop.PolicyKit1.Authority.html#eggdbus-errordomain-org.freedesktop.PolicyKit1.Error.

should be considered access failures, hence treat them like that.
2024-01-16 13:59:49 +01:00
Lennart Poettering 4a6fe5f05e varlink: also honour new env var $SYSTEMD_VARLINK_LISTEN in varlink_server_listen_auto()
varlink_server_listen_auto() is supposed to be the one-stop solution for
turning simple command line tools into IPC services. They aren't easy to
test/debug however, since you have to invoke them through a service
manager.

Let's make this easier: if the SYSTEMD_VARLINK_LISTEN env var is set,
let's listen on the socket specified therein. This makes things easier
to gdb: just run the service from the cmdline.
2024-01-16 13:45:35 +01:00
Lennart Poettering 1752a8ee33 varlink-idl: prefix all varlink IDL debug lines wit "Varlink-IDL:"
Let's improve debuggability of varlink IPC transactions, and separate
out log messages triggered by the IPC info from others, by prefixing
them with a specific prefix.
2024-01-16 13:44:21 +01:00
Daan De Meyer 16e4efa7d3 tree-wide: Load entry-token and layout.conf from /usr/lib/kernel/ as well 2024-01-16 14:54:04 +09:00
Mike Yuan ad0b7e03db battery-util: raise log level for battery_is_discharging_and_low 2024-01-15 02:57:44 +08:00
Yu Watanabe b24db7052e varlink/network: OnlineState may not be set
Follow-up for c5c74d85d3.

Fixes #30918.
2024-01-14 04:57:41 +09:00
Luca Boccassi c9eb59e710 Merge pull request #30896 from yuwata/network-route-conf-parser
network: minor cleanups for conf parsers
2024-01-12 23:27:39 +00:00
Lennart Poettering 91b34c7641 networkd: expose the nsid in the GetNamespaceId() varlink call
Let's return both ids in the GetNamespaceID(), since they are pretty
much the same concept.
2024-01-12 21:43:34 +01:00
Lennart Poettering fa2bc6f1d7 socket-util: add netns_get_nsid() helper to show nsid of netns 2024-01-12 21:43:34 +01:00
Luca Boccassi ffcb8647ca Merge pull request #30904 from YHNdnzj/no-selinux-reload
core/execute: don't reload selinux before spawning executor
2024-01-12 15:51:54 +00:00
Lennart Poettering f4220d8c05 json: downgrade extension log message to LOG_DEBUG
This is not supposed to be something we should complain about loudly
after all.

Follow-up for: a617fd9047
2024-01-12 14:37:17 +00:00
Mike Yuan a399804225 selinux-util: reorder functions 2024-01-12 17:17:37 +08:00
Yu Watanabe 4207f6c05d network/route-nexthop: make GatewayOnLink= support an empty string
And invalidate the route section if an invalid string is specified.
2024-01-12 09:44:03 +09:00
Yu Watanabe 967cd1712c Merge pull request #30867 from dtardon/udev-conf-dropins
Allow dropins for udev.conf
2024-01-12 06:37:23 +09:00
Yu Watanabe fa552ea1b1 Merge pull request #30893 from yuwata/add-trailing-NUL
json,netlink: add trailing NUL byte when we read binary data
2024-01-12 06:36:46 +09:00
David Tardon 09dd8e77fc udev: factor out config parser call into function
... which is then called from both places. This makes sure that the
configuration is parsed by udevd and other tools in exactly the same
way.
2024-01-12 05:12:42 +09:00
David Tardon a1c7dc7d16 udev-util: drop unused function 2024-01-12 05:11:18 +09:00
David Tardon 07f5e35fe7 udev-util: use config. parser to parse udev.conf 2024-01-12 05:11:14 +09:00
Yu Watanabe 70c24d0d9f sd-netlink: add trailing NUL byte for safety in sd_netlink_message_read_data()
Then, drop sd_netlink_message_read_data_suffix0().
2024-01-12 04:48:26 +09:00
Yu Watanabe 1f179b37f2 json: add trailing NUL byte in json_dispatch_byte_array_iovec()
For safety.

Addresses https://github.com/systemd/systemd/pull/30879#discussion_r1448518226.
2024-01-12 04:44:51 +09:00
Lennart Poettering e09c255d2e install: optionally return discovered unit file path in unit_file_exists() 2024-01-11 16:05:20 +01:00
Lennart Poettering 3392079e4b generator: teach generator_add_symlink_full() to optionally make alias symlinks rather than just .wants/ style symlinks 2024-01-11 16:05:20 +01:00
Lennart Poettering 7ceb76b63c generator: optionally return resulting unit file path in generator_open_unit_file_full()
This is useful if we want to make symlinks to it later.
2024-01-11 16:05:20 +01:00
Yu Watanabe 72278e62d9 json: introduce json_dispatch_byte_array_iovec() and json_dispatch_in_addr() 2024-01-11 17:03:25 +09:00