1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00
Commit Graph

57064 Commits

Author SHA1 Message Date
Gaël PORTAY
e502940be2 man: update root-hash-signature option with value
This documents two possible values expected by the option
root-hash-signature for veritytab and veritysetup-generator.
2022-03-30 23:45:26 +02:00
Yu Watanabe
72151060e8 udev: do not use sd_event_source_disable_unref() at more places
Fixes a bug introduced by 9612da361a.

Follow-up for f777e745a7.
2022-03-31 05:08:23 +09:00
Yu Watanabe
fb54461717 udev: do not append unknown errno or signal name
Follow-up for 6467bda59d.

Addresses https://github.com/systemd/systemd/pull/22871#discussion_r837705779.
2022-03-30 17:22:11 +02:00
Lennart Poettering
d360eafb36 update TODO 2022-03-30 16:13:41 +02:00
Frantisek Sumsal
5efefcdcff ci: drop clang 11 & add clang 14 2022-03-30 21:11:57 +09:00
Yu Watanabe
8b7378e145 fix typo 2022-03-30 21:10:06 +09:00
Luca Boccassi
8c70e8024b NEWS: specify that public headers are still C89 2022-03-29 21:54:01 +01:00
Luca Boccassi
7503fbd4a6 NEWS: mention that C11 is now used 2022-03-29 21:52:21 +01:00
Zbigniew Jędrzejewski-Szmek
0f6f9dc6cf NEWS: add entry for the unit enablement stuff
It should be merged soon.
2022-03-29 22:39:32 +02:00
Zbigniew Jędrzejewski-Szmek
c3a053c241 test-systemctl-enable: skip test for %v if kver is not a valid instance
On arm, we'd fail with:
target@v:5.16.8-200.fc35.armv7hl+lpae.socket: not a valid unit name "target@v:5.16.8-200.fc35.armv7hl+lpae.socket": Invalid argument
2022-03-29 22:39:32 +02:00
наб
d66b77b4d8 test-copy: use non-0 data block in copy_holes
Some filesystems (e.g. zfs with compression!=off, which is the default
configuration) automatically hole-punch all-zero blocks ‒ write a block
full of ones instead
2022-03-29 21:10:43 +02:00
Zbigniew Jędrzejewski-Szmek
53877d0385
Merge pull request #22649 from keszybz/symlink-enablement-yet-again-punish-me-harder
Fixups to the unit enablement logic
2022-03-29 21:10:03 +02:00
Zbigniew Jędrzejewski-Szmek
f8e07c5cb6
Merge pull request #22871 from yuwata/udev-worker-error-code
udev: append error code on failure
2022-03-29 21:08:44 +02:00
Zbigniew Jędrzejewski-Szmek
a6ea4dc13e meson: bump numbers for v251-rc1 2022-03-29 19:46:47 +02:00
Zbigniew Jędrzejewski-Szmek
7384940857 NEWS: update contributor list 2022-03-29 19:45:11 +02:00
Zbigniew Jędrzejewski-Szmek
e0a5fc7267 tools/git-contrib: list contributions not only from Weblate
It seems that --invert-grep used to affect --author, but now it doesn't (with
git-2.35.1-1.fc36.x86_64), so effectively we would only show the one entry that
was supposed to be filtered out.
2022-03-29 19:42:01 +02:00
Zbigniew Jędrzejewski-Szmek
942473dcc3 NEWS: two more small features and some rewordings 2022-03-29 19:36:29 +02:00
наб
0017be9d77 Fix typos in user-util.c and dbus-unit.c 2022-03-29 17:58:37 +01:00
Yu Watanabe
10176f0011 test: add tests for worker error code 2022-03-30 01:27:29 +09:00
Yu Watanabe
6467bda59d udev: append error code in broadcasted message
So, libudev listners can easily detect errors.

Addresses https://github.com/systemd/systemd/pull/22717#discussion_r834420878.
2022-03-30 01:27:29 +09:00
Yu Watanabe
71978a79fd sd-device: introduce device_add_propertyf() 2022-03-30 01:27:29 +09:00
Luca Boccassi
b586cbdefc NEWS: mention kernel requirement change 3.13 -> 3.15 2022-03-29 17:22:30 +01:00
Zbigniew Jędrzejewski-Szmek
47c6454d76
Merge pull request #22894 from keszybz/hwdb-update
Update hwdb again
2022-03-29 18:17:32 +02:00
Zbigniew Jędrzejewski-Szmek
f1589efb7f hwdb: update autosuspend entries 2022-03-29 18:15:06 +02:00
Zbigniew Jędrzejewski-Szmek
c53e6f641e hwdb: update for v251
As usual, there are mostly additions of new entries, and some spelling
correction and company renames, no big removals.
2022-03-29 18:15:06 +02:00
Zbigniew Jędrzejewski-Szmek
f73d689587 hwdb: fix parser to work with newer pyparsing
The handling of whitespace in pyparsing is a bother. There's some
global state, and per-element state, and it's hard to get a handle on
things. With python3-pyparsing-2.4.7-10.fc36.noarch the grammar would
not match. After handling of tabs was fixed to not accept duplicate tabs,
the grammar passes.

It seems that the entry for usb:v8087p8087*
was generated incorrectly because we treated the interface line
(with two TABs) as a device line (with one TAB).
2022-03-29 18:15:05 +02:00
Zbigniew Jędrzejewski-Szmek
88a65c936e cryptsetup: shorten message a bit
If it is reported as missing, we don't need to say that we assume
it is missing.
2022-03-29 18:14:51 +02:00
Zbigniew Jędrzejewski-Szmek
b64f6d841d
Merge pull request #22843 from poettering/bootspec-json
bootctl: bootspec improvements and clean-ups
2022-03-29 18:11:32 +02:00
Zbigniew Jędrzejewski-Szmek
b380b64383 Rename UnitFileScope to LookupScope
As suggested in
8b3ad3983f (r837345892)

The define is generalized and moved to path-lookup.h, where it seems to fit
better. This allows a recursive include to be removed and in general makes
things simpler.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
5c29de29b4 test-systemctl-enable: disable the test for %a for now 2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
2a2d002fb0 test-systemctl-enable: also use freshly-built systemd-id128
Tests were failing on centos7 because systemd-id128 is not in path.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
d6c51c485a test-systemctl-enable: use magic syntax to allow inverted tests
Inspired by 7910ec3bcd.
'! true' passes, because it's a conditional expression.
But '( ! true )' fails, because '( … )' creates a subshell, i.e. a separate
program, and '! true' becomes the return value of that program, and the whole
thing apparently is not a conditional expression for the outer shell.

This is shorter, so let's just do this.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
3fc53351dc shared/install: when creating symlinks, accept different but equivalent symlinks
We would only accept "identical" links, but having e.g. a symlink
/usr/lib/systemd/system/foo-alias.service → /usr/lib/systemd/system/foo.service
when we're trying to create /usr/lib/systemd/system/foo-alias.service →
./foo.service is OK. This fixes an issue found in ubuntuautopkg package
installation, where we'd fail when enabling systemd-resolved.service, because
the existing alias was absolute, and (with the recent patches) we were trying
to create a relative one.

A test is added.
(For .wants/.requires symlinks we were already doing OK. A test is also
added, to verify.)
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
84fdced62c test-systemctl-enable: make shellcheck happy
Quoting is not necessary in many places, but I think it's nicer
to use it consistently.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
48eadb9d9b shared/install: fix handling of a linked unit file
When we have a symlink that goes outside of our search path, we should just
ignore the target file name. But we were verifying it, and rejecting in
the case where a symlink was created manually.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
48ed75adab shared/install: split UNIT_FILE_SYMLINK into two states
The two states are distinguished, but are treated everywhere identically,
so there is no difference in behaviour except for slighlty different log
output.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
bd177c6215 basic/unit-file: reverse negative conditional
Having the reverse condition first makes changes that I want to do
later awkward, so reverse it as a separate step first.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
38e8a6c7fd shared/install: stop passing duplicate root argument to install_name_printf()
All callers were just passing info + info->root, we can simplify this.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
466f6979c9 shared/install: when looking for symlinks in .wants/.requires, ignore symlink target
We'd say that file is enabled indirectly if we had a symlink like:
  foo@.service ← bar.target.wants/foo@one.service
but not when we had
  foo@one.servicebar.target.wants/foo@one.service

The effect of both link types is the same. In fact we don't care
about the symlink target. (We'll warn if it is mismatched, but we honour
it anyway.)

So let's use the original match logic only for aliases.
For .wants/.requires we instead look for a matching source name,
or a source name that matches after stripping of instance.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
d6c9411072 shared/install: create relative symlinks for enablement and aliasing
This is a fairly noticable change, but I think it needs to be done.
So far we'd create an absolute symlink to the target unit file:
  .wants/foo.service → /usr/lib/systemd/system/foo.service
or
  alias.service → /etc/systemd/system/aliased.service.

This works reasonably well, except in one case: where the unit file
is linked. When we look at a file link, the name of the physical file
isn't used, and we only take the account the symlink source name.
(In fact, the destination filename may not even be a well-formed unit name,
so we couldn't use it, even if we wanted to.) But this means that if
a file is linked, and specifies aliases, we'd create absolute links for
those aliases, and systemd would consider each "alias" to be a separate
unit. This isn't checked by the tests here, because we don't have a running
systemd instance, but it is easy enough to check manually.

The most reasonable way to fix this is to create relative links to the
unit file:
  .wants/foo.service → ../foo.service
  alias.service → aliased.service.

I opted to use no prefix for aliases, both normal and 'default.target',
and to add "../" for .wants/ and .requires/. Note that the link that is
created doesn't necessarily point to the file. E.g. if we're enabling
a file under /usr/lib/systemd/system, and create a symlink in /etc/systemd/system,
it'll still be "../foo.service", not "../../usr/lib/systemd/system/foo.service".
For our unit loading logic this doesn't matter, and figuring out a path
that actually leads somewhere would be more work. Since the user is allowed
to move the unit file, or add a new unit file in a different location, and
we don't actually follow the symlink, I think it's OK to create a dangling
symlink. The prefix of "../" is useful to give a hint that the link points
to files that are conceptually "one level up" in the directory hierarchy.

With the relative symlinks, systemd knows that those are aliases.

The tests are adjusted to use the new forms. There were a few tests that
weren't really testing something useful: 'test -e x' fails if 'x' is a
a dangling symlink. Absolute links in the chroot would be dangling, even
though the target existed in the expected path, but become non-dangling
when made relative and the test fails.

This should be described in NEWS, but I'm not adding that here, because
it'd likely result in conflicts.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
9f61c9f79e shared/install: also remove symlinks like .wants/foo@one.service → ../foo@one.service
So far 'systemctl enable' would create absolute links to the target template
name. And we would remove such symlinks just fine. But the user may create
symlinks manually in a different form. In particular, symlinks for instanced
units *must* have the instance in the source name, and then it is natural to
also include it in the target name (.wants/foo@one.service../foo@one.service
rather than .wants/foo@one.service → ../foo@.service). We would choke on such
links, or not remove them at all. A test is added:

before:

+ build-rawhide/systemctl --root=/tmp/systemctl-test.001xda disable templ1@.service
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@seven.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@six.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@five.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@four.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@three.service".
Failed to disable unit, refusing to operate on linked unit file /tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@two.service.
Failed to disable unit, refusing to operate on linked unit file /tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@two.service.

after:

+ build-rawhide/systemctl --root=/tmp/systemctl-test.QVP0ev disable templ1@.service
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@seven.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@six.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@five.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@four.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@three.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@two.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@one.service".
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@one.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@two.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@three.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@four.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@five.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@six.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@seven.service
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
7a6c73dabf shared/install: skip unnecessary chasing of symlinks in disable
We use the symlink source name and destination names to decide whether to remove
the symlink. But if the source name is enough to decide to remove the symlink,
we'd still look up the destination for no good reason. This is a slow operation,
let's skip it.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
85516075a2 test-systemctl-enable: enhance the test for unit file linking
Current behaviour is wrong, but it cannot be shown in this test, because we
don't have a running systemd instance here.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
40276314af shared/install: do not try to resolve symlinks outside of root directory
I linked a file as root, so I had a symlink /root/test.service ← /etc/systemd/system/test.service.
To my surpise, when running test-systemctl-enable, it failed with a cryptic EACCES.
The previous commit made the logs a bit better. Strace shows that we
were trying to follow the symlink without taking --root into account.

It seems that this bug was introduced in 66a19d85a5:
before it, we'd do readlink_malloc(), which returned a path relative to root. But
we only used that path for checking if the path is in remove_symlinks_to set, which
contains relative paths. So if the path was relative, we'd get a false-negative
answer, but we didn't go outside of the root. (We need to canonicalize the symlink
to get a consistent answer.) But after 66a19 we use chase_symlinks(), without taking
root into account which is completely bogus.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
212a24f0bb shared/install: when we fail to chase a symlink, show some logs
When chase_symlinks() fails, we'd get the generic error:

  Failed to disable: Permission denied.

Let's at least add the failure to changes list, so the user gets
a slightly better message. Ideally, we'd say where exactly the permission
failure occured, but chase_symlinks() is a library level function and I don't
think we should add logging there. The output looks like this now:

  Failed to resolve symlink "/tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias2.service": Permission denied
  Failed to resolve symlink "/tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias.service": Permission denied
  Failed to disable unit, file /tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias2.service: Permission denied.
  Failed to disable unit, file /tmp/systemctl-test.1r7Roj/etc/systemd/system/link5alias.service: Permission denied.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
0c003e8305 test-systemctl-enable: extend the test for repeated WantedBy/RequiredBy
I was considering deduplicating the list of target units in
WantedBy/RequiredBy. But to do this meaningfully, we'd need to do alias
expansion first, i.e. after the initial parsing is done. This seems to be
more trouble than it would be worth.

Instead, I added tests that we're doing the right thing and creating symlinks
as expected. For duplicate links, we create the link, and on the second time we
see that the link is already there, so the output is correct.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
29a7c59abb shared/install: fix reenable on linked unit files 2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
ec7eaff3c2 shared/install: split unit_file_{disable,enable}() so _reenable doesn't do setup twice
It was pretty ugly that we were creating LookupPaths twice.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
20d68b3aec install: when linking a file, create the link first or abort
We'd create aliases and other symlinks first, and only then try to create
the main link. Since that can fail, let's do things in opposite order, and
abort immediately if we can't link the file itself.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
17a2679e99 man: fix invalid description of template handling in WantedBy=
We don't need to talk about Alias=. The approach of using Alias= to enable
units is still supported, but hasn't been advertised as the way to do thing
for many years. Using it as an explanation is just confusing.

Also, the description of templated units did not take DefaultInstance=
into account. It is updated and extended.
2022-03-29 16:17:56 +02:00