Commit Graph

72252 Commits

Author SHA1 Message Date
Martin Wilck
c072860593 99-systemd.rules: rework SYSTEMD_READY logic for device mapper
Device mapper devices are set up in multiple steps. The first step, which
generates the initial "add" event, only creates an empty container, which is
useless for higher layers. SYSTEMD_READY should be set to 0 on this event to
avoid premature device activation.

The event that matters is the "activation" event: the first "change" event on
which DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 is not set. When this event arrives,
the device is ready for being scanned by blkid and similar tools, and for being
activated by systemd.

Intermittent events with DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 should be ignored
as far as systemd or higher-level block layers are concerned. Previous device
properties and symlinks should be preserved: the device shouldn't be scanned or
activated, but shouldn't be deactivated, either.  In particular, SYSTEM_READY
shouldn't be set to 0 if it wasn't set before, because that might cause mounted
file systems to be unmounted. Such intermittent events may occur any time,
before or after the "activation" event.

DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 can have multiple reasons. One possible reason
is that the device is suspended. There are other reasons that depend on the
device-mapper subsystem (LVM, multipath, dm-crypt, etc.).

The current systemd rule set

1) sets SYSTEMD_READY=0 if DM_UDEV_DISABLE_OTHER_RULES_FLAG is set in "add"
events;
2) imports SYSTEMD_READY from the udev db if DM_SUSPENDED is set, and jumps to systemd_end;
3) sets SYSTEMD_READY=1, otherwise.

This logic has several flaws:

* 1) can cause file systems to be unmounted if an coldplug event arrives while
a file system is suspended. This rule shouldn't be applied for coldplug events
or in general, "synthetic" add events;
* 2) evaluates DM_SUSPENDED=1, which is a device-mapper internal property.
It's wrong to infer that a device is accessible if DM_SUSPENDED=0.
The jump to systemd_end may cause properties and/or symlinks to be lost;
* 3) is superfluous, because SYSTEMD_READY=1 is equivalent with SYSTEMD_READY
being unset, and can create the wrong impression that the device was explicitly
activated.

This patch fixes the logic as follows:

- apply 1) only if DM_NAME is empty, which is only the case for the first
"genuine add" event;
- change 2) to use DM_UDEV_DISABLE_OTHER_RULES_FLAG instead of DM_SUSPENDED,
and remove the GOTO directive;
- remove 3).

Fixes: b7cf1b6 ("udev: use SYSTEMD_READY to mask uninitialized DM devices")
Fixes: 35a6750 ("rules: set SYSTEMD_READY=0 on DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 only with ADD event (#2747)")

Signed-off-by: Martin Wilck <mwilck@suse.com>
2024-04-03 12:48:14 +01:00
Yu Watanabe
c099e8f21f
Merge pull request #32060 from YHNdnzj/timespec-minor-cleanup
Minor cleanup for timespec/efivars
2024-04-03 13:48:56 +09:00
Mike Yuan
80d1d9f5db
efivars: minor modernization for efi_set_variable 2024-04-03 10:03:53 +08:00
Mike Yuan
1ca89d32ae
signal-util: make struct timespec const 2024-04-03 10:03:53 +08:00
Mike Yuan
65b584334d
time-util: drop unneeded 'struct' 2024-04-03 10:03:53 +08:00
Yu Watanabe
dcc6256593 git-contrib: use 'git shortlog' command
Also, this drops Weblate (again) and dependabot from the contributers list.

Moreover, this makes the contributers sorted by git command, rather
than sort command. Then, the authors are sorted by their first name, e.g.
- before
Xiaotian Wu, Yuri Chornoivan, Yu Watanabe, Zbigniew Jędrzejewski-Szmek,
- after
Xiaotian Wu, Yu Watanabe, Yuri Chornoivan, Zbigniew Jędrzejewski-Szmek,

Suggested-by: Matteo Croce <teknoraver@meta.com>
2024-04-03 10:07:54 +09:00
Yu Watanabe
ffeb6a2e3b
Merge pull request #32059 from bluca/doc
Docs and TODO fixes
2024-04-03 09:15:15 +09:00
Daan De Meyer
c89b3e1dfd test: Always exit with 77 if we skip a test
Prep work for running the integration tests with meson, which requires
tests to exit with 77 to indicate they are skipped.

Note this only deals with the easy cases where there's only tests. The
hard ones where there's subtests of which only some are skipped are left
for another PR.
2024-04-03 09:14:15 +09:00
Luca Boccassi
485bb19d55 docs: notify example was moved to sd_notify manpage
Reference in the portability doc was forgot

Follow-up for 383917ac67
2024-04-02 22:24:38 +01:00
Luca Boccassi
edc2c26d54 TODO: drop line about bzip2/gzip
These are only used in the importd binary, which is a leaf optional
binary that also depends on libcurl, so it's not worth the
additional complications
2024-04-02 22:22:29 +01:00
Luca Boccassi
52c15e9c9b
Merge pull request #32055 from mrc0mmand/pre-rc-coccinelle
Coccinelle-suggested tweaks, pre-rc edition
2024-04-02 21:58:39 +01:00
Luca Boccassi
792b942405
Merge pull request #32052 from mrc0mmand/even-more-test-tweaks
A couple of assorted tweaks
2024-04-02 21:49:05 +01:00
Frantisek Sumsal
5d7b7bf1d4 test: don't hide exit code of the systemd-run process 2024-04-02 19:00:42 +02:00
Frantisek Sumsal
347756ed81 core: correctly deserialize credentials with empty payload
For example with SetCredential=mycred: the data payload is empty, but it
is still a valid credential.

This reorders the arguments when serializing credentials, so the
possibly empty argument is not at the end of the serialized string. This
way we can still easily use the extract_many_words() machinery, and with
the use of EXTRACT_DONT_COALESCE_SEPARATORS properly deserialize even an
empty credential. This changes LoadCredentials= as well just to keep the
code for (de)serializing both directives in sync.
2024-04-02 19:00:42 +02:00
Frantisek Sumsal
c956bf31f8 test: check if sd-executor doesn't complain during (de)serializing
This was usually caught by "accident" by other tests that parse output
of commands executed by sd-executor, so let's have an explicit check for
this.
2024-04-02 19:00:42 +02:00
Frantisek Sumsal
38d072a175 test: bump the container boot timeout when running w/o acceleration
With plain QEMU on a saturated AWS region we might just barely miss the
timeout window, causing unexpected test fails:

[  688.681324] systemd-nspawn[1332]: [  OK  ] Finished systemd-user-sessions.service.
[  689.451267] systemd-nspawn[1332]: [  OK  ] Started console-getty.service.
[  689.572874] systemd-nspawn[1332]: [  OK  ] Reached target getty.target.
[  693.634609] testsuite-74.sh[1223]: + at_exit
[  693.634609] testsuite-74.sh[1223]: + rm -fv -- /tmp/test-dump /tmp/test-usr-dump /tmp/make-dump
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/test-dump'
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/test-usr-dump'
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/make-dump'
[  693.951114] testsuite-74.sh[670]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-74.coredump.sh failed'
[  693.951114] testsuite-74.sh[670]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-74.coredump.sh failed
[  693.951114] testsuite-74.sh[670]: + return 1
[  694.659094] systemd[1]: testsuite-74.service: Main process exited, code=exited, status=1/FAILURE
[  694.719563] systemd[1]: testsuite-74.service: Failed with result 'exit-code'.
[  694.882069] systemd[1]: Failed to start testsuite-74.service.
[  695.574445] systemd[1]: Reached target testsuite.target.
[  696.174844] systemd[1]: Starting end.service...
[  699.509408] systemd-nspawn[1332]:
[  699.509408] systemd-nspawn[1332]: CentOS Stream 9
[  699.509408] systemd-nspawn[1332]: Kernel 5.14.0-432.el9.x86_64 on an x86_64 (pts/0)
[  699.509408] systemd-nspawn[1332]:

Also, move the rest of container the setup for the user xattrs test into
the condition, since doing it without the actual test is pretty
pointless.
2024-04-02 19:00:24 +02:00
Frantisek Sumsal
ef6a2df7fe ci: fix commit SHA for stefanbuck/github-issue-parser
The SHA for this action was updated by Dependabot in #25900 to a commit
which later disappeared from the repo. Since then Dependabot kept
(silently) failing to bump the SHA further:

updater | 2024/03/31 21:22:13 ERROR <job_807574419> Error processing stefanbuck/github-issue-parser (Dependabot::SharedHelpers::HelperSubprocessFailed)
updater | 2024/03/31 21:22:13 ERROR <job_807574419> error: no such commit c1a559d78bfb8dd05216dab9ffd2b91082ff5324

See: https://github.com/systemd/systemd/pull/25900#issuecomment-2028912672

Let's bump the SHA manually to v3.1.0 to get Dependabot back on the track.

Co-authored-by: Evgeny Vereshchagin <evvers@ya.ru>
2024-04-02 17:19:16 +01:00
Luca Boccassi
f98e2b33ea
Merge pull request #32030 from bluca/dlopen_document
man: document that using sd_journal APIs might cause dlopen to happen and add self-contained notify protocol example
2024-04-02 17:18:02 +01:00
Frantisek Sumsal
861316e5ab test: use free() instead of mfree()
Since we don't use the returned value anyway.
2024-04-02 18:08:50 +02:00
Frantisek Sumsal
f9ecb07672 sysext: use mfree() in one more place 2024-04-02 18:08:30 +02:00
Frantisek Sumsal
516bb9c0be Simplify a couple of conditions 2024-04-02 18:08:22 +02:00
Frantisek Sumsal
a30fdf857b Use IN_SET() more 2024-04-02 18:08:15 +02:00
Luca Boccassi
7a829af384
Merge pull request #32004 from YHNdnzj/umount-new-cycle
core/mount: if mount is gone eventually, consider it success
2024-04-02 15:52:46 +01:00
Luca Boccassi
383917ac67 man: add self-contained example of notify protocol
We are saying in public that the protocl is stable and can be easily
reimplemented, so provide an example doing so in the documentation,
license as MIT-0 so that it can be copied and pasted at will.
2024-04-02 14:53:31 +01:00
Luca Boccassi
5aa8180392 man: document that using sd_journal APIs might cause dlopen to happen 2024-04-02 14:53:31 +01:00
Luca Boccassi
bcb353bc79
Merge pull request #32042 from YHNdnzj/implicit-mounts-for
units: remove one implicit RequiresMountsFor=
2024-04-02 13:24:56 +01:00
dependabot[bot]
427dbbab8c build(deps): bump systemd/mkosi
Bumps [systemd/mkosi](https://github.com/systemd/mkosi) from 31af101620fc2996517d87e86da310f7ba553d58 to 4dfdf98ed2877a1e40f37234e0b8fbba0fec3584.
- [Release notes](https://github.com/systemd/mkosi/releases)
- [Changelog](https://github.com/systemd/mkosi/blob/main/NEWS.md)
- [Commits](31af101620...4dfdf98ed2)

---
updated-dependencies:
- dependency-name: systemd/mkosi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 12:38:00 +02:00
Daan De Meyer
42e2ec23f4 mkosi: Use '-' instead of '.' to separate upstream version and debian revision
The debian revision starts after the '-' character, so make sure the
timestamp we append is treated as the revision instead of being a part
of the upstream version.
2024-04-02 12:31:34 +02:00
dependabot[bot]
34b130faaa build(deps): bump pkg/debian from 44fe1d4 to e780b50
Bumps pkg/debian from `44fe1d4` to `e780b50`.

---
updated-dependencies:
- dependency-name: pkg/debian
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 11:37:01 +02:00
Mike Yuan
e3783068c6
core/mount: if mount is gone eventually, consider it success
Currently, if unmount initiated by us fails, we record
that in result. Later, if we tried again and succeeded,
or someone else successfully unmounted it, the unit
state is still considered failed. Let's be more tolerant
instead, and forget about previous failure.

Alternative to #32002
2024-04-02 17:16:04 +08:00
Mike Yuan
9c7c3d9cdb
core/mount: if unmount retries exceeded max, record as failure 2024-04-02 17:15:22 +08:00
Mike Yuan
9c96ffe003
man/tmpfiles.d: drop doubled space 2024-04-02 17:12:55 +08:00
Eisuke Kawashima
86f36e87ff doc(tmpfiles.d): remove deprecated F type
close #32044
2024-04-02 02:46:19 +01:00
Mike Yuan
4f156b1078
units: remove implicit RequiresMountsFor= 2024-04-01 19:44:51 +08:00
Mike Yuan
5e7022033f
core/unit: use FOREACH_ARRAY at one more place 2024-04-01 19:42:02 +08:00
Mike Yuan
8959e17d73 core/service: ensure we don't restart on SERVICE_SKIP_CONDITION
service_shall_restart() always returns false if result
is SERVICE_SKIP_CONDITION, so drop unreachable code.
2024-04-01 19:14:15 +08:00
dependabot[bot]
76dddd6323 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 5.1.0 to 5.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/docs/CHANGELOG.md)
- [Commits](b9df2a9417...c15070885a)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-01 12:11:52 +02:00
Burak Gerz
911e2d479e sysupdate: print assumed value
The MatchPattern= in Target specification is documented as mandatory,
but if not defined sysupdate will assume the same value as definied
in Source specification and continue execution. Print this
assumptions to the user
2024-03-31 23:41:08 +01:00
Daan De Meyer
cde08933a9 Fix assertion in socknameinfo_pretty() 2024-03-31 23:40:38 +01:00
Daan De Meyer
5afea28add mkosi: Update centos to latest
Due to dependabot and pagure not playing nice with each other, we're
going to have to update this one manually for a while.

See https://github.com/systemd/systemd/issues/31773
2024-03-31 23:09:11 +02:00
Daan De Meyer
3799fa803e repart: Add DefaultSubvolume= setting
We already have Subvolumes= to create subvolumes, let's add
DefaultSubvolume= as well to set the default subvolume.
2024-03-30 00:08:12 +00:00
Adrian Vovk
e50bfc89ce manager: Freeze/Thaw: Don't fail units w/o cgroup
Previously, it was impossible to freeze or thaw a slice if it is an
ancestor to a unit that had no running cgroup (i.e. a service with
RemainAfterExit=yes). Instead of failing with EBUSY (which would
confusingly get reported as "Unit has pending job") we just silently
no-op.

I noticed this because we now have user-runtime-dir@.service, which
would make it impossible to freeze/thaw user.slice or user-<UID>.slice
2024-03-30 02:58:53 +08:00
Luca Boccassi
a7f2019055
Merge pull request #32010 from bluca/reexec_rate_limit
core: serialize reload rate limit and apply ReloadLimit to reexec too
2024-03-29 17:16:36 +00:00
Daan De Meyer
e5cd051724 mkosi: Switch to linux-virtual on Ubuntu
This now finally has support for credentials and erofs so let's switch
to this much smaller kernel package that doesn't pull in linux-firmware.
2024-03-29 15:58:13 +01:00
Yu Watanabe
03b6879f4d udevadm-test: prettify test results 2024-03-29 12:44:11 +00:00
Luca Boccassi
8312b17a29 core: apply ReloadLimit to reexec too
Same reason as the reload, reexec is disruptive and it requires the
same privileges, so if somebody wants to limit reloads, they'll also
want to limit reexecs, so use the same setting.
2024-03-29 12:03:32 +00:00
Luca Boccassi
9b1db2dbc4 core: serialize reload rate limit
Otherwise the rate limit is lost on reexec, and the privileges to call it
are the same as reloads
2024-03-29 12:03:32 +00:00
Daan De Meyer
f2c946f872
Merge pull request #32013 from yuwata/align-table
core: align table
2024-03-29 08:30:59 +01:00
Yu Watanabe
0966933b3d unit-def: append trailing comma for the last entry 2024-03-29 13:53:01 +09:00
Yu Watanabe
17f6b64038 core: align table 2024-03-29 13:51:15 +09:00