]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agotree-wide: drop () around the first argument of a ternary op 24933/head
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2022 12:50:35 +0000 (14:50 +0200)] 
tree-wide: drop () around the first argument of a ternary op

https://github.com/systemd/systemd/pull/24933#discussion_r991242789

3 years agoman: use man7.org for strerror_r
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2022 09:00:57 +0000 (11:00 +0200)] 
man: use man7.org for strerror_r

3 years agoman: recommend strerror_r() over strerror()
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 14:24:01 +0000 (16:24 +0200)] 
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.

3 years agoman: recommend %m over strerror()
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 14:19:21 +0000 (16:19 +0200)] 
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.

3 years agoman: use external .c files for three examples
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2022 07:18:26 +0000 (09:18 +0200)] 
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.

3 years agoGet rid of strerror_safe()
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 13:59:34 +0000 (15:59 +0200)] 
Get rid of strerror_safe()

3 years agosd-bus: make bus_error_message() a thread-safe macro
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 13:56:25 +0000 (15:56 +0200)] 
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.

3 years agocore: adjust log message
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 13:53:10 +0000 (15:53 +0200)] 
core: adjust log message

"umount startup job" is rather confusing. Let's say "unmount job", which should
be more meaningful for a user.

3 years agoanalyze: add forgotten return statement
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 13:52:33 +0000 (15:52 +0200)] 
analyze: add forgotten return statement

We would fail with an assert in sd_bus_message_enter_container() afterwards.

3 years agotree-wide: get rid of lgtm annotations
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2022 07:31:58 +0000 (09:31 +0200)] 
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.

3 years agotree-wide: define and use STRERROR_OR_EOF()
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2022 19:19:43 +0000 (21:19 +0200)] 
tree-wide: define and use STRERROR_OR_EOF()

3 years agotree-wide: use STRERROR()
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 13:28:05 +0000 (15:28 +0200)] 
tree-wide: use STRERROR()

3 years agobasic: add STRERROR() wrapper for strerror_r()
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 10:28:31 +0000 (12:28 +0200)] 
basic: add STRERROR() wrapper for strerror_r()

3 years agoshared/journal-importer: use %m instead of strerror()
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 07:18:26 +0000 (09:18 +0200)] 
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().

3 years agocore,logind,systemctl,journald: replace calls to strerror() with setting errno + %m
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 07:15:44 +0000 (09:15 +0200)] 
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.

3 years agobasic/stdio-util: allow xsprintf() to be used without any arguments
Zbigniew Jędrzejewski-Szmek [Fri, 7 Oct 2022 13:26:36 +0000 (15:26 +0200)] 
basic/stdio-util: allow xsprintf() to be used without any arguments

xsprintf(buf, "…: %m") would fail, now it works.

3 years agoanalyze: use the same error variable name as everywhere else
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 14:37:57 +0000 (16:37 +0200)] 
analyze: use the same error variable name as everywhere else

3 years agopam_systemd: use pam_syslog_pam_error()
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2022 12:59:50 +0000 (14:59 +0200)] 
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.

3 years agopam_systemd_home: use pam_syslog_pam_error()
Zbigniew Jędrzejewski-Szmek [Tue, 11 Oct 2022 12:51:47 +0000 (14:51 +0200)] 
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.

3 years agoshared/pam-util: add pam_syslog_pam_error() wrapper
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 13:47:12 +0000 (15:47 +0200)] 
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.

3 years agopam_systemd: use pam_syslog_errno()
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 12:29:53 +0000 (14:29 +0200)] 
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.

3 years agopam_systemd_home: use pam_syslog_errno()
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 12:25:02 +0000 (14:25 +0200)] 
pam_systemd_home: use pam_syslog_errno()

Like in the previous commit, the return code on error might be changed.

3 years agoshared/pam-util: add pam_syslog_errno() wrapper that sets errno
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 12:19:12 +0000 (14:19 +0200)] 
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.

3 years agobasic/errno-util: add helper to protect and set errno in one step
Zbigniew Jędrzejewski-Szmek [Thu, 6 Oct 2022 12:41:50 +0000 (14:41 +0200)] 
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.

3 years agobasic/log: include the log syntax callback in the errno protection block
Zbigniew Jędrzejewski-Szmek [Thu, 6 Oct 2022 11:07:49 +0000 (13:07 +0200)] 
basic/log: include the log syntax callback in the errno protection block

In general, log_syntax_internal() must keep errno unchanged. But the
call to log_syntax_callback() was added outside of the block protected
by PROTECT_ERRNO.

3 years agopam_systemd_home: inline loop variable declaration
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 12:14:13 +0000 (14:14 +0200)] 
pam_systemd_home: inline loop variable declaration

3 years agosd-bus: decrease indentation
Zbigniew Jędrzejewski-Szmek [Tue, 4 Oct 2022 10:37:49 +0000 (12:37 +0200)] 
sd-bus: decrease indentation

3 years agonetwork: fix use-after-free
Yu Watanabe [Mon, 3 Oct 2022 03:35:29 +0000 (12:35 +0900)] 
network: fix use-after-free

If the lifetime of the route is already expired, do not try to
configure it.

Fixes a use-after-free, as the Request object is already freed, thus, we
cannot use Route or Link stored in Request object.

3 years agoresolve: drop remaining references for Monitor=
Yu Watanabe [Mon, 3 Oct 2022 00:29:45 +0000 (09:29 +0900)] 
resolve: drop remaining references for Monitor=

Follow-up for b25d819aee10b79a1c972d25be81a238448134dd.

3 years agonetwork: don't forget old RAs when a new one arrives
Thomas Hebb [Thu, 29 Sep 2022 06:40:35 +0000 (23:40 -0700)] 
network: don't forget old RAs when a new one arrives

IPv6 Neighbor Discovery lets us autoconfigure a link's IPv6 addresses,
routes, DNS servers, and DNS search domains by listening for Router
Advertisement (RA) packets broadcast by one or more routers on the link.
Each RA can contain zero or more "options," each describing one piece of
configuration (e.g. a single route).

Currently, when we receive an RA from a router, we delete any addresses,
routes, etc. that originated from that router's previous RAs unless
they're also present as options in the new RA.

That behavior is a violation of RFC 4861[1]. In Section 9, the RFC
states that

    Senders MAY send a subset of options in different packets. ... Thus,
    a receiver MUST NOT associate any action with the absence of an
    option in a particular packet. This protocol specifies that
    receivers should only act on the expiration of timers and on the
    information that is received in the packets.

Several other passages in the RFC reiterate this. Section 6.2.3:

    A router MAY choose not to include some or all options when sending
    unsolicited Router Advertisements.

Section 6.3.4:

    Hosts accept the union of all received information; the receipt of a
    Router Advertisement MUST NOT invalidate all information received in
    a previous advertisement or from another source.

At least one consumer router in production today, the Google Nest Wifi,
often sends RAs that omit its global IPv6 prefix. When current versions
of systemd-networkd receive those RAs, they immediately delete the
interface's global IPv6 address, which breaks IPv6 connectivity.

Fix the issue by removing the invalidation logic entirely. It's not
needed at all, since we already invalidate addresses, routes, and DNS
configuration when the interface goes down or their lifetimes expire.

This fix does have the side effect of preventing changes to the .network
file (e.g. denylisted prefixes, whether to add routes from RAs) from
taking effect as soon as a new RA arrives. Instead, a full interface
reconfiguration is needed. But triggering those changes on RA receipt
was already rather arbitrary and out of the administrator's control, so
I think this change is fine.

commit 69203fba700e ("network: ndisc: remove old addresses and routes
after at least one SLAAC address becomes ready") introduced this
behavior. commit 50550722e3ba fixed it partially, by preventing one
router's RAs from invalidating another router's configuration.

[1] https://www.rfc-editor.org/rfc/rfc4861

Fixes: 69203fba700e ("network: ndisc: remove old addresses and routes after at least one SLAAC address becomes ready")
3 years agoresolve: fix typo
Yu Watanabe [Mon, 3 Oct 2022 00:23:37 +0000 (09:23 +0900)] 
resolve: fix typo

3 years agorepart: Take --root into account in read only filesystems shortcut
Daan De Meyer [Sun, 2 Oct 2022 19:37:31 +0000 (21:37 +0200)] 
repart: Take --root into account in read only filesystems shortcut

3 years agoMerge pull request #24897 from mrc0mmand/TEST-64-sanitiers-open-scsi
Yu Watanabe [Sun, 2 Oct 2022 22:51:50 +0000 (07:51 +0900)] 
Merge pull request #24897 from mrc0mmand/TEST-64-sanitiers-open-scsi

test: pre-load ASan's DSO for iscsi-init.service

3 years agotest: pre-load ASan's DSO for iscsi-init.service 24897/head
Frantisek Sumsal [Sun, 2 Oct 2022 20:51:56 +0000 (22:51 +0200)] 
test: pre-load ASan's DSO for iscsi-init.service

The iscsi-init.service calls `sh` which might, in certain circumstances,
pull in instrumented systemd NSS modules causing `sh` to fail. Let's mitigate
this by pulling in an env file crafted by `create_asan_wrapper()` that
(among others) pre-loads ASan's DSO.

3 years agotest: introduce a simple environment file for test service
Frantisek Sumsal [Fri, 23 Sep 2022 22:00:36 +0000 (07:00 +0900)] 
test: introduce a simple environment file for test service

3 years agorepart: Don't fail on missing verity sig partition
Daan De Meyer [Sun, 2 Oct 2022 08:51:53 +0000 (10:51 +0200)] 
repart: Don't fail on missing verity sig partition

Also, provide a proper error message when we fail to find a verity
sibling partition.

3 years agotest: expand the expression in `cleanup_initdir()`
Frantisek Sumsal [Sat, 1 Oct 2022 19:56:08 +0000 (21:56 +0200)] 
test: expand the expression in `cleanup_initdir()`

Otherwise we might unexpectedly return 1 if the `get_bool` call fails.

If the `get_bool` part in `get_bool "$TEST_SETUP_CLEANUP_ROOTDIR" &&  _umount_dir "${initdir:?}"`
fails, the whole expression will short-circuit evaluate to 1, and since it's
the last expression in the function it's also it's return value, which doesn't
reflect the original intent of the expression:

```
# BUILD_DIR=$PWD/build make -C test/TEST-64-UDEV-STORAGE/ setup run TESTCASES=testcase_always_skip
make: Entering directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE'
TEST-64-UDEV-STORAGE SETUP: systemd-udev storage tests
Reusing existing image /var/tmp/systemd-test.uPbJZ9/default.img → /var/tmp/systemd-test.uPbJZ9/default.img
TEST-64-UDEV-STORAGE RUN: systemd-udev storage tests
------ testcase_always_skip: BEGIN ------
Skipping...
------ testcase_always_skip: END (SKIP) ------
Passed tests: 0
    *
Skipped tests: 1
    * testcase_always_skip
Failed tests: 0
    *
TEST-64-UDEV-STORAGE RUN: systemd-udev storage tests [OK]
make: Leaving directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE'

# BUILD_DIR=$PWD/build make -C test/TEST-64-UDEV-STORAGE/ setup run TESTCASES=testcase_always_skip
make: Entering directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE'
TEST-64-UDEV-STORAGE SETUP: systemd-udev storage tests
Reusing existing image /var/tmp/systemd-test.uPbJZ9/default.img → /var/tmp/systemd-test.uPbJZ9/default.img
make: *** [Makefile:4: setup] Error 1
make: Leaving directory '/home/fsumsal/repos/@systemd/systemd/test/TEST-64-UDEV-STORAGE'
```

3 years agotest: drop the explicit bus assignment for the pci-bridge
Frantisek Sumsal [Sat, 1 Oct 2022 18:56:01 +0000 (20:56 +0200)] 
test: drop the explicit bus assignment for the pci-bridge

as it doesn't work with the Q35 chipset due to a different topology.
Auto-assignment seems to work with both Q35 and i440FX chipsets.

3 years agoMerge pull request #24878 from keszybz/condition-first-boot
Luca Boccassi [Sat, 1 Oct 2022 18:30:21 +0000 (19:30 +0100)] 
Merge pull request #24878 from keszybz/condition-first-boot

Tweak condition first boot to use the same logic in pid1 and units

3 years agohwdb: Add Fn+F12 on HP Dragonfly G2 and mute extra rfkill keys
Maxim Mikityanskiy [Sat, 1 Oct 2022 11:28:44 +0000 (14:28 +0300)] 
hwdb: Add Fn+F12 on HP Dragonfly G2 and mute extra rfkill keys

Add new key mappings for the HP Elite Dragonfly G2 laptop:

1. Map Fn+F12 (HP Programmable Key) to prog1.

2. Unmap Fn+F11 (Airplane mode) from atkbd and Intel HID events, as this
   key is also reported by HP Wireless hotkeys.

3 years agoman: Update systemd.killMode docs
Clyde Byrd III [Tue, 8 Mar 2022 23:26:33 +0000 (15:26 -0800)] 
man: Update systemd.killMode docs

3 years agobuild(deps): bump ninja from 1.10.2.3 to 1.10.2.4 in /.github/workflows
dependabot[bot] [Sat, 1 Oct 2022 11:01:11 +0000 (11:01 +0000)] 
build(deps): bump ninja from 1.10.2.3 to 1.10.2.4 in /.github/workflows

Bumps [ninja](https://github.com/ninja-build/ninja) from 1.10.2.3 to 1.10.2.4.
- [Release notes](https://github.com/ninja-build/ninja/releases)
- [Commits](https://github.com/ninja-build/ninja/commits)

---
updated-dependencies:
- dependency-name: ninja
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agoci: pin stefanbuck/github-issue-parser to a tagged release
Frantisek Sumsal [Sat, 1 Oct 2022 11:09:28 +0000 (13:09 +0200)] 
ci: pin stefanbuck/github-issue-parser to a tagged release

Since [0] got resolved ([1]) we can finally pin the action to a tagged
release (v2.0.4 ATTOW) and let Dependabot to do its job by updating it
to the latest tagged release when it becomes available.

Replaces: #24886

[0] https://github.com/stefanbuck/github-issue-parser/issues/23
[1] https://github.com/stefanbuck/github-issue-parser/pull/39

3 years agobuild(deps): bump actions/labeler from 4.0.0 to 4.0.1
dependabot[bot] [Sat, 1 Oct 2022 09:02:58 +0000 (09:02 +0000)] 
build(deps): bump actions/labeler from 4.0.0 to 4.0.1

Bumps [actions/labeler](https://github.com/actions/labeler) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/9fd24f1f9d6ceb64ba34d181b329ee72f99978a0...e54e5b338fbd6e6cdb5d60f51c22335fc57c401e)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agobuild(deps): bump redhat-plumbers-in-action/differential-shellcheck
dependabot[bot] [Sat, 1 Oct 2022 09:03:02 +0000 (09:03 +0000)] 
build(deps): bump redhat-plumbers-in-action/differential-shellcheck

Bumps [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) from 3.0.1 to 3.1.1.
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/CHANGELOG.md)
- [Commits](https://github.com/redhat-plumbers-in-action/differential-shellcheck/compare/a14889568f6210b361eb29e16f3b07f512fca846...1b1b75e42f0694c1012228513b21617a748c866e)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agobuild(deps): bump meson from 0.63.1 to 0.63.2 in /.github/workflows
dependabot[bot] [Sat, 1 Oct 2022 09:03:12 +0000 (09:03 +0000)] 
build(deps): bump meson from 0.63.1 to 0.63.2 in /.github/workflows

Bumps [meson](https://github.com/mesonbuild/meson) from 0.63.1 to 0.63.2.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/0.63.1...0.63.2)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agoman: add cross-links about preset operations 24878/head
Zbigniew Jędrzejewski-Szmek [Fri, 30 Sep 2022 13:31:40 +0000 (15:31 +0200)] 
man: add cross-links about preset operations

3 years agomanager: fix/change evaluation of ConditionFirstBoot
Zbigniew Jędrzejewski-Szmek [Fri, 30 Sep 2022 10:50:40 +0000 (12:50 +0200)] 
manager: fix/change evaluation of ConditionFirstBoot

The code to evaluate the kernel command line option was busted because it
was doing 'return b == !!r' at a point where 'r > 0'. Thus we'd return "true"
in both cases:

$ SYSTEMD_PROC_CMDLINE=systemd.condition-first-boot build/systemd-analyze condition 'ConditionFirstBoot=true'
test.service: ConditionFirstBoot=true succeeded.
Conditions succeeded.
$ SYSTEMD_PROC_CMDLINE=systemd.condition-first-boot build/systemd-analyze condition 'ConditionFirstBoot=false'
test.service: ConditionFirstBoot=false succeeded.
Conditions succeeded.

We only use 'ConditionFirstBoot=true' in units, so this wasn't noticed.

But I think the logic is broken in general: the condition should evaluate as
true only during initial boot. If we rerun the units at later points, we should
not consider ConditionFirstBoot to be true.

Also, the first boot logic is also used in pid1 itself. AFAICT, for two
things: in first boot machine-id is initialized transiently (this allows
first-boot operations to be restarted if boot fails), and preset-all is
executed. But this logic was different and separate from the logic to
evaluate ConditionFirstBoot. The distinction is abolished, and the operations
in pid1 now use the same logic as ConditionFirstBoot, which means that the
kernel command line option is checked, and condition_test_first_boot()
just tests whether pid1 thinks we're in first boot.

This makes things easier to grok for the user: there's just one condition for
"first boot" and it applies to both pid1 and units.

3 years agodocs/CONTRIBUTING: strenghten language about ABI stability, fix links, other tweaks
Zbigniew Jędrzejewski-Szmek [Fri, 30 Sep 2022 15:26:34 +0000 (17:26 +0200)] 
docs/CONTRIBUTING: strenghten language about ABI stability, fix links, other tweaks

The text made it sound like breaking ABI in libsystemd is allowed with good reasons.
In fact, we plan never to do this, so make the language stronger.

Also remind people about distro forums for reporting bugs. Those are probably a
better place than systemd-devel for new users.

Also, add some missing articles and apostrophes, fix URLs, remove repeated phrases,
etc.

3 years agoRevert "bpf: fix is_allow_list section"
James Hilliard [Fri, 30 Sep 2022 21:42:22 +0000 (15:42 -0600)] 
Revert "bpf: fix is_allow_list section"

GCC was modified to use the same default section as LLVM, as such
this is no longer required.

Details:
https://github.com/gcc-mirror/gcc/commit/a0aafbc324aa90421f0ce99c6f5bbf64ed163da6

This reverts commit e8b1e9cf1095f9d6d0f1e2dce2503e25fec2e6c5.

3 years agomeson: set minimum libbpf/bpftool versions for bpf-gcc
James Hilliard [Sat, 1 Oct 2022 00:09:53 +0000 (00:09 +0000)] 
meson: set minimum libbpf/bpftool versions for bpf-gcc

We need the following libbpf commits for bpf-gcc compatibility:
 - https://github.com/libbpf/libbpf/commit/3d484ca47339b23afb2ec7c508ed9a3a5cf1d287
 - https://github.com/libbpf/libbpf/commit/b31ca3fa0e62fde6aa66f855136e29e088ad9dde

These are first present in libbpf 1.0.0 and bpftool 7.0.0.

3 years agoMerge pull request #24829 from yuwata/blockdev-new-from-fd
Luca Boccassi [Fri, 30 Sep 2022 19:07:49 +0000 (20:07 +0100)] 
Merge pull request #24829 from yuwata/blockdev-new-from-fd

blockdev-util: introduce block_device_new_from_fd() and _path()

3 years agoMerge pull request #24749 from yuwata/dissect-image-file
Luca Boccassi [Fri, 30 Sep 2022 19:02:19 +0000 (20:02 +0100)] 
Merge pull request #24749 from yuwata/dissect-image-file

dissect-image: introduce dissect_image_file() which works for regular file instead of block device

3 years agoresolve: unsupported DNSSEC algorithms are considered INSECURE; not BOGUS
Jacek Migacz [Wed, 21 Sep 2022 06:23:22 +0000 (08:23 +0200)] 
resolve: unsupported DNSSEC algorithms are considered INSECURE; not BOGUS

Resolves: #19824

3 years agoMerge pull request #24639 from yuwata/test-mountpoint-util
Zbigniew Jędrzejewski-Szmek [Fri, 30 Sep 2022 15:34:21 +0000 (17:34 +0200)] 
Merge pull request #24639 from yuwata/test-mountpoint-util

test-mountpoint-util: support running on a mount namespace with another mount on /proc

3 years agoMerge pull request #24853 from poettering/resolved-monitor-fixes
Luca Boccassi [Fri, 30 Sep 2022 14:46:13 +0000 (15:46 +0100)] 
Merge pull request #24853 from poettering/resolved-monitor-fixes

resolved: various monitor fixes

3 years agoMerge pull request #24739 from keszybz/coredump-formatting
Luca Boccassi [Fri, 30 Sep 2022 14:42:15 +0000 (15:42 +0100)] 
Merge pull request #24739 from keszybz/coredump-formatting

Improve formatting of package metadata in coredumps

3 years agofirstboot: add debug logging
Zbigniew Jędrzejewski-Szmek [Fri, 30 Sep 2022 09:48:12 +0000 (11:48 +0200)] 
firstboot: add debug logging

$ SYSTEMD_LOG_LEVEL=debug build/systemd-firstboot --prompt-root-password
Found container virtualization systemd-nspawn.
Found /etc/locale.conf, assuming locale information has been configured.
Failed to read credential firstboot.keymap, ignoring: No such device or address
Prompting for keymap was not requested.
Found /etc/localtime, assuming timezone has been configured.
Prompting for hostname was not requested.
Found /etc/machine-id, assuming machine-id has been configured.
Found /etc/passwd and /etc/shadow, assuming root account has been initialized.
Creation of /etc/kernel/cmdline was not requested, skipping.

3 years agosystemctl: color ignored exit status in yellow, not red
Christian Hesse [Fri, 30 Sep 2022 08:26:43 +0000 (10:26 +0200)] 
systemctl: color ignored exit status in yellow, not red

If the executable path is prefixed with "-", an exit code of the command
normally considered a failure (i.e. non-zero exit status or abnormal exit
due to signal) is recorded, but has no further effect and is considered
equivalent to success.

Let's honor this with `systemctl status`, and color ignored exit status
in yellow, not red.

3 years agogenerator: skip fsck if fsck command is missing
Jonas Kümmerlin [Thu, 29 Sep 2022 16:51:03 +0000 (18:51 +0200)] 
generator: skip fsck if fsck command is missing

This is useful for systems which don't have any fsck.

We already skip emitting the fsck dependency when the fsck.$fstype helper
is missing, but fstab-generator doesn't necessarily know the fstype when
handling the root= parameter.

Previously, systemd-fsck was started for these mounts and then exited
immediately because it couldn't find the fsck.$fstype helper.

3 years agoportablectl: add --force attach/detach
Luca Boccassi [Thu, 29 Sep 2022 21:41:55 +0000 (22:41 +0100)] 
portablectl: add --force attach/detach

Allows to skip check that ensures units must not be running.

I have a use case that would use reattach, except the orchestrator
is using a non-standard versioning scheme, so image matching cannot
work. As a workaround, need to be able to detach and then attach
manually, without stopping the units to avoid extended downtimes
and loss of FD store.

3 years agoupdate TODO 24853/head
Lennart Poettering [Fri, 30 Sep 2022 12:14:33 +0000 (14:14 +0200)] 
update TODO

3 years agotest: rework resolved monitoring test
Lennart Poettering [Fri, 30 Sep 2022 08:04:37 +0000 (10:04 +0200)] 
test: rework resolved monitoring test

Let's remove some sleep loops, and instead:

1. Use Type=notify to wait until "resolvectl monitor" successfully
   installed its monitor, so that we know that queries enqueued later
   will definitely be seen.

2. Use "grep -m1" to watch "journalctl -f" output to wait precisely for
   the RR data we want to see, and immediately exit.

This shortens code quite a bit, and should make it more robust.

3 years agoresolvectl: add new "monitor" verb
Lennart Poettering [Wed, 28 Sep 2022 10:46:21 +0000 (12:46 +0200)] 
resolvectl: add new "monitor" verb

3 years agoMerge pull request #24831 from poettering/dbus-dump-doc
Franck Bui [Fri, 30 Sep 2022 12:23:59 +0000 (14:23 +0200)] 
Merge pull request #24831 from poettering/dbus-dump-doc

man: clarify that D-Bus Dump() call is a debugging interface with no guarantees

3 years agoresolved: beef up monitor protocol, include full query info
Lennart Poettering [Wed, 28 Sep 2022 10:46:09 +0000 (12:46 +0200)] 
resolved: beef up monitor protocol, include full query info

3 years agoresolved: add dns_question_merge() helper
Lennart Poettering [Thu, 29 Sep 2022 16:26:44 +0000 (18:26 +0200)] 
resolved: add dns_question_merge() helper

Very similar to dns_answer_merge(), but for DnsQuestion objects instead
of DnsAnswer.

3 years agoresolved: add generic formatters for RRs into JSON
Lennart Poettering [Wed, 28 Sep 2022 15:17:23 +0000 (17:17 +0200)] 
resolved: add generic formatters for RRs into JSON

For now we can use it to send broken-down records of JSON via the
monitor logic, but one day we can certainly reuse for dumping the
caches, or to implement a ResolveRecord() varlink call one day.

3 years agoresolved: split out helper for allocating DnsResourceRecord object from raw data
Lennart Poettering [Wed, 28 Sep 2022 10:44:43 +0000 (12:44 +0200)] 
resolved: split out helper for allocating DnsResourceRecord object from raw data

No change in behaviour, just some refactoring.

3 years agoresolved: split out main server listening code from manager_varlink_init()
Lennart Poettering [Tue, 27 Sep 2022 12:50:53 +0000 (14:50 +0200)] 
resolved: split out main server listening code from manager_varlink_init()

Just some minor refactoring, to make binding the two sockets (main +
minitor) symmetric

3 years agoresolved: don't make monitoring optional
Lennart Poettering [Tue, 27 Sep 2022 12:29:18 +0000 (14:29 +0200)] 
resolved: don't make monitoring optional

The socket is only accessible to privileged clients anyway, no need to
add another (user unfriendly) restriction via opt-in setting. let's just
allow this for privileged clients, mirroring "busctl monitor", or
"tcpdump" and similar, which all just work if you have privs.

(This does not break API, since we never did a release witht the
"Monitor" dbus property or config setting in place, i.e. with
cb456374e096f0ebe9b70d7ddd98e16a4be24ee6)

3 years agoresolved: rename 'notification' → 'monitor'
Lennart Poettering [Tue, 27 Sep 2022 12:28:32 +0000 (14:28 +0200)] 
resolved: rename 'notification' → 'monitor'

We expose this externally already as "monitor", name it internally the
same way. (Which is nice since it mirrors busctl monitor)

3 years agosd-event: add helper for exiting event loop on SIGTERM/SIGINT
Lennart Poettering [Wed, 28 Sep 2022 09:42:05 +0000 (11:42 +0200)] 
sd-event: add helper for exiting event loop on SIGTERM/SIGINT

In many (most?) of our event loops we want to exit once SIGTERM/SIGINT
is seen. Add a common helper for that, that does the right things in a
single call.

3 years agosd-event: if signal nr has high bit set sd_event_add_signal() auto-block it via sigpr...
Lennart Poettering [Wed, 28 Sep 2022 09:39:25 +0000 (11:39 +0200)] 
sd-event: if signal nr has high bit set sd_event_add_signal() auto-block it via sigprocmask()

So far we expected callers to block the signals manually. Which is
usually a good idea, since they should do that before forking off
threads and similar. But let's add a mode where we automatically block
it for the caller, to simplify things.

3 years agojson: explicitly support offsets relative to NULL when dispatching
Lennart Poettering [Fri, 30 Sep 2022 12:09:54 +0000 (14:09 +0200)] 
json: explicitly support offsets relative to NULL when dispatching

Let's trick out UndefinedBehaviourSanitizer:

https://github.com/systemd/systemd/pull/24853#issuecomment-1263380745

3 years agojson: add helper for json builder for octescape/base32hex
Lennart Poettering [Wed, 28 Sep 2022 15:13:00 +0000 (17:13 +0200)] 
json: add helper for json builder for octescape/base32hex

These encodings for binary data are mandated by DNS RFCs, so let's give
make them nice and easy to use with json builder logic.

3 years agojson: add dispatchers for 16bit integers
Lennart Poettering [Wed, 28 Sep 2022 09:35:47 +0000 (11:35 +0200)] 
json: add dispatchers for 16bit integers

3 years agoglyph-util: add left arrow special glyph entry
Lennart Poettering [Wed, 28 Sep 2022 09:34:46 +0000 (11:34 +0200)] 
glyph-util: add left arrow special glyph entry

3 years agoresolve: do not cache mDNS goodbye packet
Yu Watanabe [Thu, 29 Sep 2022 07:50:27 +0000 (16:50 +0900)] 
resolve: do not cache mDNS goodbye packet

Fixes #24842.

3 years agoMerge pull request #24820 from keszybz/tmpfiles-warning
Yu Watanabe [Fri, 30 Sep 2022 09:50:31 +0000 (18:50 +0900)] 
Merge pull request #24820 from keszybz/tmpfiles-warning

Downgrade warning about unitialized-/etc in tmpfiles

3 years agotest: wait until the unit finishes before checking the log
Frantisek Sumsal [Fri, 30 Sep 2022 07:31:47 +0000 (09:31 +0200)] 
test: wait until the unit finishes before checking the log

Otherwise we might read an incomplete log and fail:

```
test_added_after (__main__.ExecutionResumeTest) ... FAIL
test_added_before (__main__.ExecutionResumeTest) ... ok
test_interleaved (__main__.ExecutionResumeTest) ... ok
test_issue_6533 (__main__.ExecutionResumeTest) ... ok
test_no_change (__main__.ExecutionResumeTest) ... ok
test_removal (__main__.ExecutionResumeTest) ... ok
test_swapped (__main__.ExecutionResumeTest) ... ok

======================================================================
FAIL: test_added_after (__main__.ExecutionResumeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/./test/test-exec-deserialization.py", line 152, in test_added_after
    self.check_output(expected_output)
  File "/build/./test/test-exec-deserialization.py", line 107, in check_output
    self.assertEqual(output, expected_output)
AssertionError: 'foo\n' != 'foo\nbar\n'
  foo
+ bar

----------------------------------------------------------------------
Ran 7 tests in 27.470s
```

3 years agotest: kill the machine on oops/panic/soft_lockup
Frantisek Sumsal [Fri, 30 Sep 2022 06:48:53 +0000 (08:48 +0200)] 
test: kill the machine on oops/panic/soft_lockup

Otherwise the machine will hang on the panic until the timeout happens,
which might waste quite a considerable amount of time in certain cases.

3 years agomanager: make clear internal Dump() logic is debugging only. 24831/head
Lennart Poettering [Tue, 27 Sep 2022 10:18:47 +0000 (12:18 +0200)] 
manager: make clear internal Dump() logic is debugging only.

3 years agoman: document the Dump() calls of the PID 1 D-Bus interface, and what they are
Lennart Poettering [Tue, 27 Sep 2022 10:18:43 +0000 (12:18 +0200)] 
man: document the Dump() calls of the PID 1 D-Bus interface, and what they are

3 years agokbd-model-map: correct variants for cz-qwerty to include comma
Adam Williamson [Thu, 29 Sep 2022 19:58:03 +0000 (12:58 -0700)] 
kbd-model-map: correct variants for cz-qwerty to include comma

As explained by @poncovka , the 'xvariant' string should contain
the same number of comma-separated elements as 'xlayout'. When
we have two layouts we need two items in xvariant, in this case
one of them is empty.

See https://github.com/rhinstaller/anaconda/pull/4355#pullrequestreview-1119913870
for @poncovka's full explanation.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
3 years agoMerge pull request #24865 from yuwata/udevadm-tweaks
Frantisek Sumsal [Thu, 29 Sep 2022 22:01:48 +0000 (00:01 +0200)] 
Merge pull request #24865 from yuwata/udevadm-tweaks

udevadm: fix misleading error message

3 years agoAdd special keyboard combos for Thinkpad P1 Gen 3 (#24862)
JeroenHD [Thu, 29 Sep 2022 20:23:42 +0000 (22:23 +0200)] 
Add special keyboard combos for Thinkpad P1 Gen 3 (#24862)

* Add special keyboard combos for Thinkpad P1 Gen 3

These are based on the key codes I've found with evtest. See issue
https://github.com/systemd/systemd/issues/24814 for more details.

I'm not entirely sure what some of these keys are supposed to do,
notably Fn+RShift; this doesn't seem to do anything in Windows on
my machine. Binding them to prog# makes them available to desktop
managers' key bindings at least, in case someone wishes to make
use of this extra keybind possibility.

3 years agotest-64-udev-storage: use wait command instead of hackish "udevadm lock true" 24865/head
Yu Watanabe [Thu, 29 Sep 2022 17:38:22 +0000 (02:38 +0900)] 
test-64-udev-storage: use wait command instead of hackish "udevadm lock true"

Otherwise, "udevadm lock true" may lock a block device earlier than
"udevadm lock sfdisk &".

3 years agoudevadm: do not try to find device unit when a path like string is provided
Yu Watanabe [Thu, 29 Sep 2022 17:03:32 +0000 (02:03 +0900)] 
udevadm: do not try to find device unit when a path like string is provided

Otherwise, we provide misleading error message.
Before:
---
$ udevadm info /sys/class/foo
Bad argument "/sys/class/foo", expected an absolute path in /dev/ or /sys/ or a unit name: Invalid argument
---
After:
---
$ udevadm info /sys/class/foo
Unknown device "/sys/class/foo": No such device
---

3 years agodocs/CONTRIBUTING: explain various labels and add link to "reviewable" PRs
Zbigniew Jędrzejewski-Szmek [Thu, 29 Sep 2022 12:30:24 +0000 (14:30 +0200)] 
docs/CONTRIBUTING: explain various labels and add link to "reviewable" PRs

The linked filter gives an up-to-date list of pull requests that need review.
(Yes, there's too many.) We used to set 'needs-review' label, but that is
not available to non-members, and also every pull requests which is not labeled
'reviewed/needs-rework'/'ci-fails/needs-rework'/'needs-rebase' can and should
be reviewed.

If this is merged, I'll drop the 'needs-review' label.

3 years agotest: bump the `reattach` timeout when running w/ plain QEMU
Frantisek Sumsal [Thu, 29 Sep 2022 12:23:11 +0000 (14:23 +0200)] 
test: bump the `reattach` timeout when running w/ plain QEMU

As it might sometimes take slightly longer without the acceleration:

```
[  176.805681] testsuite-29.sh[534]: + cp /usr/share/app1.raw /tmp/app1_2.raw
[  176.885365] testsuite-29.sh[534]: + timeout 30 portablectl reattach --now --runtime --extension /tmp/app1_2.raw /usr/share/minimal_1.raw app1
[  177.053358] portablectl[993]: (Matching unit files with prefixes 'app1'.)
[  177.138770] kernel: loop0: detected capacity change from 0 to 2965504
[  177.343137] kernel: loop1: detected capacity change from 0 to 4096
...
[  201.932062] systemd[1]: app1.service: Deactivated successfully.
[  202.009310] systemd[1]: Stopped app1.service.
[  202.053776] systemd[1]: app1.service: Consumed 2.183s CPU time.
[  202.125061] systemd[1]: Stopping app1.service...
[  202.611760] systemd[1]: Starting modprobe@dm_mod.service...
[  202.851031] systemd[1]: Starting modprobe@dm_verity.service...
[  202.909352] systemd[1]: Starting modprobe@loop.service...
[  203.198918] systemd[1]: Starting app1.service...
[  207.145494] kernel: audit: type=1130 audit(1663770336.105:428): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=testsuite-29 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
[  207.652545] systemd[1]: testsuite-29.service: Main process exited, code=exited, status=124/n/a
[  207.665088] systemd[1]: testsuite-29.service: Failed with result 'exit-code'.
[  207.830522] systemd[1]: Failed to start testsuite-29.service.
...
[  208.889449] script1.sh[1035]: ID="centos"
[  208.889449] script1.sh[1035]: VERSION_ID="8"
[  208.889449] script1.sh[1035]: SYSEXT_SCOPE=portable
[  208.889449] script1.sh[1035]: PORTABLE_PREFIXES=app1
...
[  214.155097] systemd[1]: app1.service: Deactivated successfully.
```

Spotted in Ubuntu CI and CentOS CI.

Follow-up to 706c9a30ac.

3 years agostub: Remove unused function parameter
Jan Janssen [Thu, 29 Sep 2022 07:09:52 +0000 (09:09 +0200)] 
stub: Remove unused function parameter

3 years agoresolved: paranoia: restrict socket mode as much as we can
Lennart Poettering [Tue, 27 Sep 2022 12:32:35 +0000 (14:32 +0200)] 
resolved: paranoia: restrict socket mode as much as we can

3 years agotest: wrap `ls` and `stat` to make it work w/ sanitizers in specific cases
Frantisek Sumsal [Wed, 28 Sep 2022 15:01:55 +0000 (17:01 +0200)] 
test: wrap `ls` and `stat` to make it work w/ sanitizers in specific cases

When `/etc/nsswitch.conf` uses `systemd` together with `[SUCCESS=merge]`,
`ls -l` will pull in `libnss_systemd` causing `SIGABRT`, as `ls` is not
instrumented (by default):

```
-bash-5.1# strace -f -e %file ls -l /dev
execve("/usr/bin/ls", ["ls", "-l", "/dev"], 0x7ffc3bb211c8 /* 24 vars*/) = 0
...
openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=1896, ...}, AT_EMPTY_PATH) = 0
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=359, ...}, 0) = 0
openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=965, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=10779, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libnss_systemd.so.2", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=16195176, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libasan.so.8", O_RDONLY|O_CLOEXEC) = 3
...
readlink("/proc/self/exe", "/usr/bin/ls", 4096) = 11
open("/proc/self/cmdline", O_RDONLY)    = 3
open("/proc/self/environ", O_RDONLY)    = 3
==620==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=620, si_uid=0} ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)
```

This also happens with `stat`. Let's add both `ls` and `stat` to the "wrap list"
to work around this.

Spotted on Arch Linux.

3 years agoresolvectl: add line breaks for readability
Lennart Poettering [Wed, 28 Sep 2022 10:45:31 +0000 (12:45 +0200)] 
resolvectl: add line breaks for readability

3 years agoresolved: don't access sshfp fields from tlsa printer
Lennart Poettering [Wed, 28 Sep 2022 15:12:20 +0000 (17:12 +0200)] 
resolved: don't access sshfp fields from tlsa printer

3 years agoresolved: return regular varlink invalid parameter error if more is not specified...
Lennart Poettering [Wed, 28 Sep 2022 09:44:57 +0000 (11:44 +0200)] 
resolved: return regular varlink invalid parameter error if more is not specified on monitor call

No point in returning EINVAL if we can just return a proper varlink
invalid parameter error

3 years agoresolved: fix parameter reuse in DNS_ANSWER_FOREACH_ITEM() iterator macro
Lennart Poettering [Wed, 28 Sep 2022 09:44:18 +0000 (11:44 +0200)] 
resolved: fix parameter reuse in DNS_ANSWER_FOREACH_ITEM() iterator macro

3 years agotest: fix a copy-paste error
Frantisek Sumsal [Wed, 28 Sep 2022 09:30:13 +0000 (11:30 +0200)] 
test: fix a copy-paste error

3 years agoMerge pull request #24837 from yuwata/kernel-install
Daan De Meyer [Wed, 28 Sep 2022 08:50:55 +0000 (10:50 +0200)] 
Merge pull request #24837 from yuwata/kernel-install

kernel-install: two fixlets