Commit Graph
60350 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 1d3fae91f7 Merge pull request #24867 from yuwata/sd-dhcp6-client-large-packet
sd-dhcp6-client: allow to build large packet
2022-10-12 09:18:07 +02:00
Luca Boccassi dd4212105e Merge pull request #24957 from yuwata/network-ignore-failure-in-sending-solicitation
network: ignore failure in sending solicitation
2022-10-11 21:58:26 +02:00
Luca Boccassi da60182759 Merge pull request #24933 from keszybz/erradicate-strerror
Erradicate strerror
2022-10-11 21:47:38 +02:00
Luca Boccassi 2c03055e99 Merge pull request #24968 from poettering/logs-show-timestamp-fix
logs-show timestamp fix
2022-10-11 21:45:46 +02:00
Zbigniew Jędrzejewski-Szmek ef3458cd5d logind: do not emit beep in wall messages
Those may go via the PC speaker, which is annoying and unexpected.
Most people have it off, so this doesn't work reliably anyway, so we can
disable it without much loss.

Fixes #23520.
2022-10-11 21:43:31 +02:00
Zbigniew Jędrzejewski-Szmek 0b6a47957b tree-wide: drop () around the first argument of a ternary op
https://github.com/systemd/systemd/pull/24933#discussion_r991242789
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek b413d4fd3e man: use man7.org for strerror_r 2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek 2fd922afed man: recommend strerror_r() over strerror()
Let's nudge people towards the use of an anonymous buffer like we
do internally.

"errno" → "errnum", to match the man page for strerror, and also to avoid
confusion with the global variable. In general, I think that errno is a
terrible interface and we shouldn't encourage people to use it. Those functions
use errno-style error numbers, which are a different thing.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek b4096cecff man: recommend %m over strerror()
The need to set errno is very very ugly, but at least it is thread-safe and
works correctly. Using strerror() is likely to be wrong, so let's not recommend
that. People who do a lot of logging would provide use some wrapper that sets
errno like we do, so nudge people towards %m.

I tested that all the separate .c files compile cleanly.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek 29c45dc434 man: use external .c files for three examples
This way it's much easier to test that the code compiles without issues.
It's also easier to edit the code.

Indentation in one of the examples is reduced to two spaces. This is what we
use in man pages to make them fit on screen better.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek 0cf1a4b3a7 Get rid of strerror_safe() 2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek eaaf7465ee sd-bus: make bus_error_message() a thread-safe macro
strerror_r() is used instead of strerror(). The usual trick is employed: we
allocate a buffer that lives until the end of the surrounding block to provide
the scratch space. This change is particularly important forn sd-bus and the
pam modules, which may be called from threaded code.

I checked the codebase, and we only use bus_error_message() in log statements,
so the returned pointer is not used beyond its valid lifetime.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek a390b03089 core: adjust log message
"umount startup job" is rather confusing. Let's say "unmount job", which should
be more meaningful for a user.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek 5475e963c5 analyze: add forgotten return statement
We would fail with an assert in sd_bus_message_enter_container() afterwards.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek f37508d506 tree-wide: get rid of lgtm annotations
We now use CodeQL, and LGTM itself is gone. Those old annotations are not
useful for anythign now.
2022-10-11 16:59:00 +02:00
Zbigniew Jędrzejewski-Szmek f69ae8585f tree-wide: define and use STRERROR_OR_EOF() 2022-10-11 16:58:21 +02:00
Lennart Poettering 4ba5536f71 logs-show: be more careful when initializing get_dual_timestamp() return parameters
make sure we always have something to return in all return parameters,
including in the boot id return parameter, in all code paths.

Follow-up for: #24965
2022-10-11 16:40:53 +02:00
Zbigniew Jędrzejewski-Szmek a6e016af01 tree-wide: use STRERROR() 2022-10-11 16:39:09 +02:00
Lennart Poettering 868503917d sd-journal: exit loop once we got all fields we are interested in 2022-10-11 16:39:06 +02:00
Zbigniew Jędrzejewski-Szmek 2c5d05b3cd basic: add STRERROR() wrapper for strerror_r() 2022-10-11 16:10:21 +02:00
Zbigniew Jędrzejewski-Szmek 0cbefc7d4f shared/journal-importer: use %m instead of strerror()
Here SYNTHETIC_ERRNO() was used based on the general rule that logging
functions should do that when the error value is generated at the call
site. But here we're really propagating a memory allocation error, which
wasn't reported using errno, but the meaning is the same. And it's better
to bend the rule a bit like this than to use strerror().
2022-10-11 16:10:21 +02:00
Zbigniew Jędrzejewski-Szmek 3855303428 core,logind,systemctl,journald: replace calls to strerror() with setting errno + %m
strerror() is not thread safe and calling it just isn't worth the effort
required to justify why it would be safe in those cases. It's easier to just
use %m which is thread-safe out of the box. I don't think that any of the
changes in the patch cause any functional difference. This is just about
getting rid of calls to strerror() in general.

When we print an error message and fail to format the string, using something
like "(null)" is good enough. This is very very unlikely to happen anyway.
2022-10-11 16:10:21 +02:00
Zbigniew Jędrzejewski-Szmek 892dc96787 basic/stdio-util: allow xsprintf() to be used without any arguments
xsprintf(buf, "…: %m") would fail, now it works.
2022-10-11 16:10:21 +02:00
Zbigniew Jędrzejewski-Szmek 8ad572e60d analyze: use the same error variable name as everywhere else 2022-10-11 16:10:21 +02:00
Zbigniew Jędrzejewski-Szmek f48e93764f pam_systemd: use pam_syslog_pam_error()
Error handling in acquire_user_record() was checking the wrong
condition (PAM errors are always >= 0, so r < 0 cannot match).

Apart from the fix for error handling, no change in behaviour is intended.
I did some minor adjustements to formatting and added _cleanup_ in one more
place.
2022-10-11 16:10:20 +02:00
Zbigniew Jędrzejewski-Szmek e91b05f418 pam_systemd_home: use pam_syslog_pam_error()
The message in acquire_home() was looking at the wrong variable
('r' instead of 'acquired_fd').

Apart from that, no change in behaviour is intended.
2022-10-11 16:10:08 +02:00
Zbigniew Jędrzejewski-Szmek 4ac6ac9f09 shared/pam-util: add pam_syslog_pam_error() wrapper
This is a primitive helper that wraps calls to pam_syslog() replacing
@PAMERR@ with pam_strerror() output in the format string. This allows for
a bunch of boilerplate to be removed.

@PAMERR@ is only supported at the end of the string. Similarly to %m,
realistically that's the only place where it is useful.

Note that unlike in logging functions in log.[ch], here the error value is
only used for the message and is not saved anywhere, so we don't need to
care about SYNTHETIC_ERRNO.
2022-10-11 16:10:08 +02:00
Zbigniew Jędrzejewski-Szmek 7e7b53b4a7 pam_systemd: use pam_syslog_errno()
The debug message for "nice" is tweaked to show the level that was set.

Like in the two previous commits, the return code on error might be changed.
2022-10-11 16:10:08 +02:00
Zbigniew Jędrzejewski-Szmek 544ec3c0ab pam_systemd_home: use pam_syslog_errno()
Like in the previous commit, the return code on error might be changed.
2022-10-11 16:10:01 +02:00
Daan De Meyer 3388a4b582 test-journal-flush: Don't fail on EADDRNOTAVAIL
File corruption can cause EADDRNOTAVAIL errors. Let's not make these
fatal for the flush test.
2022-10-11 23:03:06 +09:00
Daan De Meyer 9377e53f4f meson: Fix pcrphase unit conditions 2022-10-11 15:29:08 +02:00
Daan De Meyer 88ee6a9e4b logs-show: Always retrieve the boot ID from the entry
If _SOURCE_MONOTONIC_TIMESTAMP was set in the entry, we wouldn't
query the boot ID, leading to every kernel entry in the export mode
to have BOOT_ID=000000000000000. Let's fix this by always querying
the boot ID.
2022-10-11 15:25:12 +02:00
Lennart Poettering a5a0da085a update TODO 2022-10-11 15:07:32 +02:00
Daan De Meyer beead603c5 Merge pull request #24629 from DaanDeMeyer/mkosi-kernel
mkosi: Optionally build a kernel image from mkosi.kernel/
2022-10-11 14:37:19 +02:00
Frantisek Sumsal 6788418af1 test: add coverage for the nvme-subsystem
Specifically for:
  - https://github.com/systemd/systemd/pull/24748
  - https://github.com/systemd/systemd/pull/24766
  - https://github.com/systemd/systemd/pull/24946
2022-10-11 13:38:30 +02:00
Yu Watanabe abb977a61a sd-radv: mention that failures in sending RA are ignored 2022-10-11 16:22:35 +09:00
Yu Watanabe 852bf93826 sd-ndisc: ignore failure in sending solicitation
Even if a bonding master interface has carrier, the underlying slave
interfaces may not. In such a case, sending solicitation fails with
-ENOBUS. Here, let's unconditionally ignore errors, as anyway we will
send a solicitation later.

Fixes #24717.
2022-10-11 16:19:16 +09:00
Yu Watanabe f4a4493eb5 udev: add one more assertion
Follow-up for 6209bbbd4b.
2022-10-11 00:17:20 +02:00
Richard Phibel a5b4550213 coredumpctl: Add support for the --root option (after merge fixes) 2022-10-10 21:21:52 +02:00
Lennart Poettering 00675c363f tree-wide: add ERRNO_IS_XATTR_ABSENT() helper
We check the same list of error codes on various xattr operations, and
we should on some more. Add a common helper for this purpose.
2022-10-10 16:00:15 +02:00
Luca Boccassi dcf1bf3b6d mkosi: update to latest commit
Require dto fix Debian testing/unstable builds, as the initrd is
versioned
2022-10-10 13:19:41 +02:00
Lennart Poettering 4db5c45df8 NEWS: make clear we talk about *system* credentials here
The new conditoins are placed inside of services, but they cannot be
used to test service creds, but only system creds. This deserves
explicit mention, since it might be confusing otherwise.

Reverts a small part of 02380e1946
2022-10-10 20:00:43 +09:00
Yu Watanabe 2164ccdaa2 Merge pull request #24654 from fbuihuu/mount_followup_for_pr_19983
Mount followup for pr 23367
2022-10-10 19:13:22 +09:00
Daan De Meyer 32b61b0559 Merge pull request #24595 from rphibel/support-image-option-in-systemctl-and-coredumpctl
systemctl/coredumpctl: add support for --root and --image options
2022-10-10 11:35:20 +02:00
Yu Watanabe 6209bbbd4b udev: drop assertion which is always false
Fixes a bug introduced by 67c3e1f63a.

Fixes #24945.
2022-10-10 10:26:38 +02:00
Zbigniew Jędrzejewski-Szmek b1eff892bb shared/pam-util: add pam_syslog_errno() wrapper that sets errno
So far our pam code was using strerror_safe(). But that's not a good approach,
because strerror_safe() is not thread-safe, and the pam code is "library code"
that should be thread-safe. In fact, the whole effort to use strerror() is
unnecessary, because pam_syslog() is documented to support %m. The
implementation in linux-pam simply uses vasprintf(). If we use %m too, we get
rid of the issue. The wrapper sets errno temporarily from the argument.

Apparently some PAM consumers run multiple PAM stacks in threads, so we should
avoid non-thread-safe code.

The new helper returns PAM_BUF_ERR for ENOMEM, and PAM_SERVICE_ERR in other
cases. This may change the returned code in some cases, but I think a) it
doesn't matter much, b) it's probably for the better. E.g. we might now return
PAM_SERVICE_ERR if the dbus message is borked, and PAM_SERVICE_ERR seems
appropriate.
2022-10-10 09:55:21 +02:00
Zbigniew Jędrzejewski-Szmek 50c5b991df basic/errno-util: add helper to protect and set errno in one step
This pattern is used in a few places. Those are changed in this patch.
Subsequent patches will add more.
2022-10-10 09:12:21 +02:00
Jan Janssen 7aa4762ce2 meson: Fix build with --optimization=plain
Note that -O0 is deliberately filtered out as we have to compile with at
least -O1 due to #24202.

Fixes: #24323
2022-10-09 22:15:11 +02:00
Zbigniew Jędrzejewski-Szmek 02380e1946 NEWS: fix typos and reword things
In particular, 'system/service credentials' are now described as simply
'credentials'. The selling point of credentials is that they are transparently
propagated from the system to services, so distinguishing between system and
service credentials is not important.

The description of ordering against initrd-switch-root.target is completely
rewritten. The old description was confused.

I think the description of systemd-measure should be reworked to clearly
describe what new functionality is provided and what policy changes are
built on top. But I don't qrok the details, so I left this part unchanged.
2022-10-09 17:28:53 +02:00
Zbigniew Jędrzejewski-Szmek 01f516314f man: use a list for description of ConditionFirmware=
Also reduce confusion of <replaceable> and <literal> and reword things for
legibility a bit.
2022-10-09 17:28:53 +02:00