Commit Graph

8565 Commits

Author SHA1 Message Date
Kamil Szczęk
70246e37bc libfido2-util: fix a regression in the pre-flight mechanism
The recently merged PR #32295 introduced support for the credProtect
extension, but in doing so, it broke the discoverability of credentials
by setting the policy to FIDO_CRED_PROT_UV_REQUIRED for UV-less,
PIN-protected credentials. This policy would require us to pass the PIN
to the token in the pre-flight request to be able to discover it,
which defeats the purpose of pre-flight requests as they're supposed
to be non-interactive.

This commit restricts the usage of credProtect to UV credentials only.
2024-05-02 16:30:05 +02:00
Yu Watanabe
affde1d7e7 logs-show: adjust source timestamp with header timestamp
Previously, _SOURCE_REALTIME_TIMESTAMP was only used for realtime
timestamp, and _SOURCE_MONOTONIC_TIMESTAMP was for monotonic.

This make these journal field used more aggressively. If we need
realtime timestamp, but an entry has only _SOURCE_MONOTONIC_TIMESTAMP,
then now realtime timestamp is calculated based on
_SOURCE_MONOTONIC_TIMESTAMP and the header dual timestamp.
Similary, monotonic timestamp is obtained from
_SOURCE_REALTIME_TIMESTAMP and the header dual timestamp.

This should change shown timestamps not so much in most cases, but may
be improve the situation such as #32492.
2024-05-02 06:34:01 +09:00
Yu Watanabe
6ed286d2cf logs-show: make output_timestamp_realtime() only take realtime timestamp
No functional change, just refactoring and preparation for later
commits.
2024-05-02 06:34:01 +09:00
Daan De Meyer
b7ad477879 reboot-util: Add some basic validation on reboot arguments
Let's only accept valid ASCII and put a size limit on reboot arguments.
2024-05-02 00:52:06 +09:00
Mike Yuan
80a3600210 shared/install: use FOREACH_ARRAY for install_changes_have_modification 2024-05-01 18:04:55 +08:00
Mike Yuan
a4d733db9f shared/install: reduce variable scope 2024-05-01 17:35:20 +08:00
Yu Watanabe
4e494e6aac tree-wise: several cleanups for logging
- drop unnecessary SYNTHETIC_ERRNO() when the logger does not propagate
  error code,
- drop unnecessary '%m' in error message when the error code is
  specified with SYNTHETIC_ERRNO(),
- add missing full stop at the end of log message,
- use RET_GATHER(),
- add missing ", ignoring.",
- upeercase the first letter, etc., etc...
2024-05-01 04:41:06 +09:00
Christian Göttsche
b9a05e860c shared: create inaccessible files with correct security label 2024-04-29 18:17:46 +02:00
Christian Göttsche
22b768d127 basic: add mknodat_label()
Add helper for mknodat(2) which creates the destination with the correct
security label.
2024-04-29 18:14:41 +02:00
Daan De Meyer
ba4c69a0c6 core: Pass NULL error in dump_impl()
If mac_selinux_access_check() or bus_verify_bypass_dump_ratelimit_async()
fail, we goto "ratelimited" where we set a custom D-BUS error. In
"ratelimited", we call sd_bus_error_setf() which eventually hits an
assert_return(!bus_error_is_dirty()). Avoid hitting this assertion by
passing NULL as the error to mac_selinux_access_check() and
bus_verify_bypass_dump_ratelimit_async() since we will override the error
immediately anyway if either fails.

We modify both functions as well to allow passing a NULL error and fix
the argument name as well while we're at it.
2024-04-29 14:14:40 +02:00
Daan De Meyer
4eae58b3d3 pam: Setup logging to syslog
We already log to syslog using pam_syslog() for logs generated directly
within our pam plugins. However, any logs generated by our generic logging
macros that are invoked within a pam plugin will log to the console. Let's
make sure our generic logging macros are set up to log to syslog as well.
2024-04-29 12:17:18 +02:00
Mike Yuan
39a8ef05cd various: drop unnecessary DISABLE_WARNING_FORMAT_NONLITERAL
We use _printf_ for these functions, so there shouldn't
be a warning in the first place.
2024-04-28 13:33:17 +02:00
Dmitry V. Levin
c309b9e9c3 treewide: fix a few typos in NEWS, docs, comments, and log messages 2024-04-27 12:11:13 +02:00
Mike Yuan
a0a09da45e mount-setup: fix typo 2024-04-26 10:24:38 +08:00
Lennart Poettering
b24c384b5d varlink: make errors returned by verify_unix_socket() systematic
Previously, if we encountered a non-socket fd we'd return ENOTSOCK the
first time, but the subsequent times we'd return ENOMEDIUM, due to
caching. Let's make sure we return the same errors all the the time.
2024-04-25 22:17:30 +02:00
Daan De Meyer
2541f28e4b Merge pull request #32477 from DaanDeMeyer/fixes
Various fixes
2024-04-25 18:24:09 +02:00
Daan De Meyer
aa976d8788 tree-wide: Use log_setup() everywhere
Otherwise the default log target is the console and we won't use
the journal socket even if it is available.
2024-04-25 17:06:43 +02:00
Lennart Poettering
78ef66354c varlink: fix varlink_get_peer_pidref() fallback
let's properly handle old kernels that have no pidfd, and use regular
pids in that case, as intended originally.
2024-04-25 12:44:00 +02:00
Yu Watanabe
90db1582a9 run/run: fix invocation ID handling
Fixes a regression introduced by 8157cc0e3e.
2024-04-25 10:58:56 +02:00
Mike Yuan
21f8e749a1 mount-setup: use mount_verbose_full where appropriate 2024-04-24 08:39:26 +08:00
Daan De Meyer
e660fee2d0 Merge pull request #32392 from DaanDeMeyer/executor-log-level
core: Set a sensible systemd-executor log level in test runs
2024-04-22 19:26:52 +02:00
Daan De Meyer
827004df94 mount-util: Silence noisy trace log message 2024-04-22 18:01:06 +02:00
Mike Yuan
adaf1f7ea3 shared/verbs: show list of verbs when missing
Replaces #32062

As discussed in #32062, making 'help' the default verb
is not very appealing for two reasons:

1) If the verb is missing, showing a help which is pages long
   isn't really helpful to locate the problem.
   (https://github.com/systemd/systemd/pull/32062#issuecomment-2064997158)

2) We want to reserve the right to set default verbs to be
   more useful ones, instead of help. E.g. 'busctl' lists all
   bus peers by default.

So, when there are more than 2 verbs, let's instead add
the list of available verbs to the "Command verb required"
message, that serves as a hint. That way we try to be friendlier
to users, but still make the problem obvious.
2024-04-22 20:42:35 +08:00
Mike Yuan
48fb49f1bd shared/verbs: minor modernization 2024-04-22 20:35:51 +08:00
Lennart Poettering
21a3bc6b9f tpm2-util: add generic wrapper tpm2_context_new_or_warn() that wrpas tpm2_context_new and logs about errors
We so far just print a short log message that is not very useful, let's
add some recognizable error codes, and output better log messages if we
can't get TPM stuff to work.

Fixes: #31925
2024-04-22 12:40:09 +02:00
Daan De Meyer
7a7d7a2e22 test: Don't allocate scope if already running in unit with delegated cgroup
If we're already running in a unit with delegation turned on, let's
skip allocation of a scope unit and cgroup subroot. This allows journald
to correctly attribute the logs of all subprocesses spawned by tests such
as test-execute to the test-execute service when the test is running in a service.
2024-04-22 09:42:29 +02:00
Daan De Meyer
b8c6c35804 test: Use log_setup()
Specifically, this will make tests log to the journal if stderr is
connected to the journal. This means we get proper log priorities
and such compared to if we just logged to stderr.
2024-04-22 09:42:29 +02:00
Daan De Meyer
dd8e82f0d6 test: Add ASSERT_ERROR() and ASSERT_ERROR_ERRNO()
For when we expect something to fail with a specific error.
2024-04-22 09:42:29 +02:00
Mike Yuan
f8598699e7 Merge pull request #32370 from YHNdnzj/vpick-check-early
shared/vpick: some minor cleanups
2024-04-20 21:02:37 +08:00
Lennart Poettering
5c81de98fc timedate: handle gracefully if RTC lost time because of power loss
Apparently some RTC drivers return EINVAL in that case when we try to
read it. Handle that reasonably gracefully.

Fixes: #31854
2024-04-20 09:15:07 +09:00
Mike Yuan
b6d31deca4 shared/vpick: check deterministic suffix earlier
Follow-up for 421a4ba7e4
2024-04-20 07:17:04 +08:00
Mike Yuan
fde8fb7466 shared/vpick: flatten errno check 2024-04-20 07:16:24 +08:00
Mike Yuan
164f3d8f3d shared/vpick: use strdup_to where appropriate 2024-04-20 07:16:00 +08:00
Luca Boccassi
565f6130b2 Merge pull request #32142 from bluca/portable_vpick
portable: support vpick
2024-04-19 20:34:16 +02:00
Luca Boccassi
421a4ba7e4 vpick: add pick_filter_image_any filter that matches both dirs and images 2024-04-19 13:25:32 +01:00
Luca Boccassi
5dcd6b1d55 Merge pull request #31978 from nolange/fix_openssl_deprecations
Fix openssl deprecations
2024-04-19 11:20:44 +02:00
Yu Watanabe
ff5b9aeeda Merge pull request #32340 from YHNdnzj/wait-for-unit-cleanup
bus-wait-for-units: some cleanup
2024-04-19 12:36:48 +09:00
Mike Yuan
61cd6c4db7 bus-wait-for-units: simplify property_map_job_id 2024-04-19 10:08:37 +08:00
Mike Yuan
ac21fafbea bus-wait-for-units: drop 'current' field
This is not used anywhere.
2024-04-19 10:08:37 +08:00
Mike Yuan
cc6978d6ae bus-wait-for-units: check for existing unit first, use hashmap_ensure_put 2024-04-19 10:08:36 +08:00
Mike Yuan
df0183d8f1 bus-wait-for-units: make callback type end with "_t" 2024-04-19 10:08:36 +08:00
Mike Yuan
4b8fdb4681 bus-wait-for-units: drop ready_callback
This is never used, and given that bus_wait_for_units_run
returns BusWaitForUnits.state it's not really useful.
2024-04-19 10:08:36 +08:00
Yu Watanabe
f72e851fd3 conf-parser: move config_parse_timezone() to conf-parser.[ch]
Even though it is currently only used by networkd, the parser itself
is quite generic. Let's move it to the shared library.
2024-04-19 10:23:01 +09:00
Nick Rosbrook
c0bc1e8971 copy: ignore -EOPNOTSUPP from copy_file_range()
According to copy_file_range (2), errno will be set to EOPNOTSUPP when
the file system does not support copy_file_range(). Since there is
already fallback logic in place here for other kinds of errors, add
-EOPNOTSUPP to the list of ignored errors.
2024-04-19 09:57:25 +09:00
Lennart Poettering
dd37963aff Merge pull request #31790 from poettering/pcrlock-policy-fix
Replace PolicyAuthValue by PolicySigned as access policy for pcrlock policy nvindex
2024-04-18 21:11:27 +02:00
Lennart Poettering
d10d4a3701 tpm2-util: now that we don't use PolicyAuthValue anymore, let's not set an authValue anymore for the policy nvindex
We have now switched from PolicyAuthValue to PolicySigned to control
access to the policy nvindex to. This means there's no point in setting
an authValue on the nvindex anymore, hence drop this.
2024-04-18 18:12:23 +02:00
Lennart Poettering
cb835a2ed1 pcrlock: switch access policy for nvindex to store policy in from PolicyAuthValue to PolicySigned (with an HMAC-SHA256 key)
So far the nvindex to store the pcrlock policy in was protected via a
PolicyAuthValue policy (i.e. with a simple PIN set on the nvindex).
That's a bad idea however, as it means an attacker can simply remove and
re-create the nvindex and the "name" of the nvindex does not change,
thus defeating the logic. (This is because the authValue is *not* part
of the "name" of an nvindex!).

Fix this by switching from PolicyAuthValue to PolicySigned with an
HMAC-SHA256 key. Behaviour is very similar: however, the PIN is now part
of of the access policy hash, which *is* part of the "name" of an
nvindex. Thus, if an attacker removes and recreates the nvindex it has
to provide the same PIN again or the "name" of the nvindex will change.
Mission accomplished.

I'd like to thank Chris Coulson for finding this issue (and helping me
address it). Thank you!
2024-04-18 18:12:23 +02:00
Lennart Poettering
19d82e1bee tpm2-util: add comment explaining what tpm2_define_policy_nv_index() actually does 2024-04-18 18:12:23 +02:00
Lennart Poettering
371b594414 tpm2-util: load external key into NULL hierarchy if private key is provided
If we load an external key into the TPM we must do so in the NULL
hierarchy. An external key after all is one that is not wrapped by any
hierarchy's seed.

See TPM2 spec, Part 3, Section 12.3.1
2024-04-18 18:12:23 +02:00
Lennart Poettering
d0f8da9815 tpm2-util: rename tpm2_get_pin_auth() → tpm2_auth_value_from_pin()
Just some renaming. I found the old name a bit confusing since it sounds
as if this would get the pin from somewhere, but it really doesn't. It
just converts a PIN into an auth_value, and I think saying so explicitly
makes things easier to grok.
2024-04-18 18:12:23 +02:00