Commit Graph
49229 Commits
Author SHA1 Message Date
Yu Watanabe 61628287bd journal: explicitly sync namespaced journals before stopping socket units
Otherwise, if a service unit that requests LogNamespace= stopped before
systemd-journald@.service is started, logs generated by the service will be
lost, as systemd-journald@.socket is stopped and
systemd-journald@.service will never started.

To prevent the issue, let's introduce another implicit dependency to
a oneshot service that explicitly synchronizes a namespaced journal file
when the log namespace is not needed anymore.

Fixes #32604.
2024-05-02 19:41:01 +02:00
Lennart Poettering 61ab5ddcdc tree-wide: fix type confusion around parsing JSON booleans
Sometimes we store them in a tristate, sometimes in C stdbool booleans.
Sometimes we fucked up picking the right parsing function however. Fix
that.
2024-05-02 19:31:08 +02:00
Sam Leonard 03e3b2672b cryptenroll: disable loading public key if --tpm2-public-key= is empty 2024-05-02 16:34:09 +02:00
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
Antonio Alvarez Feijoo fb17510ede importctl: fix flag checking against wrong variable
Fixes 67c7ee11af
2024-05-02 13:58:20 +02:00
Luca Boccassi afb1c42f5a Merge pull request #32592 from yuwata/journal-timestamp
journal: several timestamp cleanups and improvements
2024-05-02 13:57:40 +02:00
Mike Yuan 89ad0a7117 Merge pull request #32617 from yuwata/journal-sync
journald: wait for journal files fsync()ed on Synchronize() varlink method
2024-05-02 13:39:16 +08:00
Mike Yuan 8bd2f9415c core/selinux-access: use empty_to_na where appropriate 2024-05-02 13:36:52 +08: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
Yu Watanabe c9df471428 sd-journal: verify monotonic timestamp before assigning result
Previously, ret_boot_id was assigned even when the function failed due
to an invalid monotonic timestamp stored for a journal entry.
2024-05-02 06:34:01 +09:00
Yu Watanabe fbecb1fd8d journal: use STRLEN() and xsprintf()
No functional change, just refactoring.
2024-05-02 06:34:01 +09:00
Yu Watanabe 3cd7783e56 journald-audit: set _SOURCE_REALTIME_TIMESTAMP= field in server_dispatch_message()
No functional change, just refactoring.
2024-05-02 06:34:01 +09:00
Yu Watanabe 12d63b2ea0 journald: wait for journal files fsync()ed on Synchronize() varlink method
Otherwise, we may not be able to read newer journal entries even after
'journalctl --sync' is called.

Closing #32539.
2024-05-02 04:15:21 +09:00
Yu Watanabe 73cd8a94e8 journald: make several functions static 2024-05-02 04:15:21 +09:00
Ronan Pigott 414a9b8e5e resolved: validate authentic insecure delegation to CNAME
If the parent zone uses a non-opt-out method that provides authenticated
negative DS replies, we still can't expect signatures from the child
zone. sd-resolved was using the authenticated status of the DS reply to
require signatures for CNAMEs, even though it had already proved that no
signature exists.

Fixes: 47690634f1 ("resolved: don't request the SOA for every dns label")
2024-05-01 20:34:08 +02:00
Ronan Pigott 5237ffdf2b resolved: probe for dnssec support in allow-downgrade mode
Previously, sd-resolved unnecessarily requested SOA records for each dns
label in the query, even though they are not needed for the chain of
trust. Since 47690634f1, only the necessary records are queried when
validating.

This is actually a problem in allow-downgrade mode, since we will no
longer attempt a query for a record that we know is signed a priori, and
will therefore never update our belief about the state of dnssec support
in the recursive resolver.

Rectify this by reintroducing a query for the root zone SOA in the
allow-downgrade case, specifically to test that the resolver attaches
the RRSIGs which we know must exist.

Fixes: 47690634f1 ("resolved: don't request the SOA for every dns label")
2024-05-01 20:32:30 +02: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
Yu Watanabe 8bf27cd010 Merge pull request #32611 from DaanDeMeyer/qdisc
network/tc: Avoid concurrent set modification in tclass_drop()/qdisc_drop()
2024-05-02 00:51:31 +09:00
Daan De Meyer ee8f605ded network/tc: Avoid concurrent set modification in tclass_drop()/qdisc_drop()
With the current algorithm, we can end up removing entries from the
qdisc/tclass sets while having multiple open iterators over the sets at
various positions which leads to assertion failures in the hashmap logic
as it's only safe to remove the "current" entry.

To avoid the problem, let's split up marking and dropping of tclasses
and qdiscs. First, we recursively iterate tclasses/qdiscs and mark all
that need to be removed. Next, we iterate once over tclasses and qdiscs
and remove all marked entries.

Fixes 632d321050
2024-05-01 16:15:20 +02:00
Mike Yuan d69cba3bff core/dbus-manager: mark unit file state as outdated only if
some changes succeeded

Follow-up for a82b8b3dc8

We don't need to invalidate the unit file state
if all operations failed.

Also, emit UnitFilesChanged signal as long as
some operations succeeded.
2024-05-01 18:22:02 +08: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 1cca93f7f3 systemctl: fix log message when glob patterns passed to disable command and friends
Fixes #32599.
2024-05-01 17:13:10 +09:00
Daan De Meyer 6be4dab095 systemctl: Implement --wait for kill command
TEST-26-SYSTEMCTL is racy as we call systemctl is-active immediately
after systemctl kill. Let's implement --wait for systemctl kill and
use it in TEST-26-SYSTEMCTL to avoid the race.
2024-05-01 09:40:32 +02:00
Yu Watanabe 9d3d6c1e07 core/exec-credential: update comment 2024-05-01 15:58:20 +09:00
Daan De Meyer 5bcf0881a3 core: Fix file descriptor leak 2024-05-01 11:52:13 +09: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
Luca Boccassi ba2caa8a38 build-path: fix SIGSEGV on RISC-V and MIPS
On RISC-V and MIPS DT_STRTAB is an offset, not a full address.

Follow-up for 91d149cfb4
2024-04-30 18:11:10 +02:00
Antonio Alvarez Feijoo 1434754430 network-generator: add missing return on error after the logging refactor
Fixes 3cb618084a
2024-04-30 18:09:37 +02:00
Luca Boccassi da77ea5c63 Merge pull request #32523 from cgzones/inaccessible_label
shared: create inaccessible files with correct security label
2024-04-30 16:20:49 +02:00
Daan De Meyer 123450e58e journal: Add journal.storage credential
In mkosi CI, we want persistent journals when running interactively
and runtime journals when running in CI, so let's add a credential
that allows us to configure which one to use.
2024-04-30 14:19:55 +02:00
Yu Watanabe 8719a65003 test-journal-flush: use archived journal if possible
Workaround for #32436.

The test may fail if the journal is vacuumed or rotated during the test is running.
Let's use the newest archive file for safety.
2024-04-30 10:50:43 +02:00
Daan De Meyer 132f6cfcfe machine: Add PIDFDs= fallback
In some environments, systemd-machined might not be restarted on
downgrade. For safety, let's add the usual PIDFDs= fallback here
as well.
2024-04-29 22:56:49 +02:00
Ronan Pigott d840783db5 resolved: always progress DS queries
If we request a DS and the resolver offers an unsigned SOA, a new
auxiliary transaction for the DS will be rejected as a loop, and we
might not make any progress toward finding the DS we need. Let's ensure
that we at least always check the parent in this case.

Fixes: 47690634f1 ("resolved: don't request the SOA for every dns label")
2024-04-29 19:04:11 +02:00
Christian Göttsche b9a05e860c shared: create inaccessible files with correct security label 2024-04-29 18:17:46 +02:00
Christian Göttsche 4be62f821c basic: add open_mkdir_at_full()
Add helper for open_mkdir_at() which accepts xopen flags, e.g. to pass
XO_LABEL to create the target with the correct security context.
2024-04-29 18:16:58 +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
Mike Yuan f193fcbce9 Merge pull request #32547 from YHNdnzj/minor-cleanup
Some cleanups prompted during review
2024-04-29 21:08:06 +08:00
Antonio Alvarez Feijoo c355b6af19 boot: fix argument name mismatch in two functions 2024-04-29 14:34:37 +02:00
Daan De Meyer 7a66f21556 core: Add systemd.crash_action= kernel command line argument
Required for integration tests to power off on PID 1 crashes. We
deprecate systemd.crash_reboot and related options by removing them
from the documentation but still parsing them.
2024-04-29 14:34:22 +02:00
Mike Yuan 821bf13b6e journalctl: also check arg_file_stdin with other journal location
options

Prompted by #32491
2024-04-29 14:18:38 +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 f0fb294369 fs-util: modernize touch_file a bit 2024-04-29 16:33:17 +08:00
Mike Yuan 973464ad0e fs-util: try AT_EMPTY_PATH first for futimens_opath 2024-04-29 16:33:17 +08:00
Mike Yuan cce82462a1 efivars: drop unneeded UTIME_NOW
futimens(2) defaults to current time if 'times' is NULL.
2024-04-29 16:33:17 +08:00
Mike Yuan 767d817895 pam_systemd_loadkey: add missing PAM_EXTERN 2024-04-29 16:33:17 +08: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
Sebastian Pucilowski e6c4b5dc52 network: DHCP version logging typos
Some DHCP client log messages report "DHCP4" or "DHCP6" instead of
"DHCPv4" or "DHCPv6" as used within the rest of the codebase. Typos
fixed.
2024-04-28 11:47:55 +09:00