1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00
Commit Graph

51704 Commits

Author SHA1 Message Date
Lennart Poettering
44ff2a5e9c core: align path inotify mask table a bit 2021-05-25 23:13:52 +02:00
Lennart Poettering
c473437862
Merge pull request #19322 from poettering/dep-split
core: rework dependency system to be based on atoms + add three new dep types
2021-05-25 22:07:11 +02:00
Lennart Poettering
9f48b4e40e man: documet that loginctl {terminate|kill}-{session|user} take the empty string, optionally
Fixes: #19711
2021-05-25 17:42:34 +02:00
Lennart Poettering
68892f94ae loginctl: kill calling user when invoked with empty string
A suggested by: #19711
2021-05-25 17:40:54 +02:00
Lennart Poettering
9caf9859b4
Merge pull request #19705 from bluca/bpf_dlopen
core: make libbpf a dlopen() dependency
2021-05-25 16:51:16 +02:00
Lennart Poettering
0760363274 test: add test for OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo= 2021-05-25 16:06:30 +02:00
Lennart Poettering
3ba471facb test-engine: ensure atom bits are properly packed
Let's make sure all atoms are actually used, and no holes are left.
2021-05-25 16:06:27 +02:00
Lennart Poettering
99e9af257a core: reorder where we add units to queues in unit_notify()
This moves all calls that shall do deferred work on detecting whether to
start/stop the unit or dependent units after a unit state change to the
end of the function, to make things easier to read.

So far, these calls were spread all over the function, and
conditionalized needlessly on MANAGER_RELOADING(). This is unnecessary,
since the queues are not dispatched while reloading anyway, and
immediately before acting on a queued unit we'll check if the suggested
operation really makes sense.

The only conditionalizaiton we leave in is on checking the new unit
state itself, since we have that in a local variable anyway.
2021-05-25 16:03:03 +02:00
Lennart Poettering
56c5959202 core: change BoundBy= dependency handling to be processed by a deferred work queue
So far StopWhenUnneeded= handling and UpheldBy= handling was already
processed by a queue that is dispatched in a deferred mode of operation
instead of instantly. This changes BoundBy= handling to be processed the
same way.

This should ensure that all *event*-to-job propagation is done directly
from unit_notify(), while all *state*-to-job propagation is done from a
deferred work queue, quite systematically. The work queue is submitted
to by unit_notify() too.

Key really is the difference between event and state: some jobs shall be
queued one-time on events (think: OnFailure= + OnSuccess= and similar),
others shall be queued continuously when a specific state is in effect
(think: UpheldBy=).  The latter cases are usually effect of the
combination of states of a few units (e.g. StopWhenUnneeded= checks
wether any of the Wants=/Requires=/… deps are still up before acting),
and hence it makes sense to trigger them to be run after an individual
unit's state changed, but process them on a queue that runs whenever
there's nothing else to do that ensures the decision on them is only
taken after all jobs/queued IO events are dispatched, and things
settled, so that it makes sense to come to a combined conclusion. If
we'd dispatch this work immediately inside of unit_notify() we'd always
act instantly, even though another event from another unit that is
already queued might make the work unnecessary or invalid.

This is mostly a commit to make things philosophically clean. It does
not add features, but it should make corner cases more robust.
2021-05-25 16:03:03 +02:00
Lennart Poettering
116654d2cf core: make unneeded check a bit tighter
Let's not consider a unit unneeded while it is reloading.

Uneeded should be a pretty weak concept: if there's any doubt that
something bit be needed, then assume it is.
2021-05-25 16:03:03 +02:00
Lennart Poettering
7e9212bf1a core: order reverse dep table in same way as enum 2021-05-25 16:03:03 +02:00
Lennart Poettering
0bc488c99a core: implement Uphold= dependency type
This is like a really strong version of Wants=, that keeps starting the
specified unit if it is ever found inactive.

This is an alternative to Restart= inside a unit, acknowledging the fact
that whether to keep restarting the unit is sometimes not a property of
the unit itself but the state of the system.

This implements a part of what #4263 requests. i.e. there's no
distinction between "always" and "opportunistic". We just dumbly
implement "always" and become active whenever we see no job queued for
an inactive unit that is supposed to be upheld.
2021-05-25 16:03:03 +02:00
Lennart Poettering
294446dcb9 core: add new OnSuccess= dependency type
This is similar to OnFailure= but is activated whenever a unit returns
into inactive state successfully.

I was always afraid of adding this, since it effectively allows building
loops and makes our engine Turing complete, but it pretty much already
was it was just hidden.

Given that we have per-unit ratelimits as well as an event loop global
ratelimit I feel safe to add this finally, given it actually is useful.

Fixes: #13386
2021-05-25 16:03:03 +02:00
Lennart Poettering
47cd17ead4 core: use StopPropagatedFrom= as default for .mount → .device unit dependencies
Let's make use of the new dependency type for .mount/.device units,
after all we added it for this purpose.

Fixes: #9869
2021-05-25 16:03:03 +02:00
Lennart Poettering
ffec78c05b core: add new PropagateStopTo= dependency (and inverse)
This takes inspiration from PropagatesReloadTo=, but propagates
stop jobs instead of restart jobs.

This is defined based on exactly two atoms: UNIT_ATOM_PROPAGATE_STOP +
UNIT_ATOM_RETROACTIVE_STOP_ON_STOP. The former ensures that when the
unit the dependency is originating from is stopped based on user
request, we'll propagate the stop job to the target unit, too. In
addition, when the originating unit suddenly stops from external causes
the stopping is propagated too. Note that this does *not* include the
UNIT_ATOM_CANNOT_BE_ACTIVE_WITHOUT atom (which is used by BoundBy=),
i.e. this dependency is purely about propagating "edges" and not
"levels", i.e. it's about propagating specific events, instead of
continious states.

This is supposed to be useful for dependencies between .mount units and
their backing .device units. So far we either placed a BindsTo= or
Requires= dependency between them. The former gave a very clear binding
of the to units together, however was problematic if users establish
mounnts manually with different block device sources than our
configuration defines, as we there might come to the conclusion that the
backing device was absent and thus we need to umount again what the user
mounted. By combining Requires= with the new StopPropagatedFrom= (i.e.
the inverse PropagateStopTo=) we can get behaviour that matches BindsTo=
in every single atom but one: UNIT_ATOM_CANNOT_BE_ACTIVE_WITHOUT is
absent, and hence the level-triggered logic doesn't apply.

Replaces: #11340
2021-05-25 16:03:03 +02:00
Lennart Poettering
629b2a6f7b core: add a reverse dep for OnFailure=
Let's add an implicit reverse dep OnFailureOf=. This is exposed via the
bus to make things more debuggable: you can now ask systemd for which
units a specific unit is the failure handler.

OnFailure= was the only dependency type that had no inverse, this fixes
that.

Now that deps are a bit cheaper, it should be OK to add deps that only
serve debug purposes.
2021-05-25 16:03:03 +02:00
Lennart Poettering
39628fedac core: hide cgroup fields in unit_dump() for non-cgroup unit types
A bunch of properties in the main Unit strcture only make sense for
cgroup units. Let's hide them from unit types that have no relation to
cgroups.
2021-05-25 16:03:03 +02:00
Lennart Poettering
d219a2b07c core: convert Slice= into a proper dependency (and add a back dependency)
The slice a unit is assigned to is currently a UnitRef reference. Let's
turn it into a proper dependency, to simplify and clean up code a bit.
Now that new dep types are cheaper, deps should generally be preferable
over everything else, if the concept applies.

This brings one major benefit: we often have to iterate through all unit
a slice contains. So far we iterated through all Before= dependencies of
the slice unit to achieve that, filtering out unrelated units, and
taking benefit of the fact that slice units are implicitly ordered
Before= the units they contain. By making Slice= a proper dependency,
and having an accompanying SliceOf= dependency type, this is much
simpler and nicer as we can directly enumerate the units a slice
contains.

The forward dependency is actually called InSlice internally, since we
already used the UNIT_SLICE name as UnitType field. However, since we
don't intend to expose the dependency to users as dep anyway (we already
have the regular Slice D-Bus property for this) this shouldn't matter.
The SliceOf= implicit dependency type (the erverse of Slice=/InSlice=)
is exported over the bus, to make things a bit nicer to debug and
discoverable.
2021-05-25 16:03:01 +02:00
Lennart Poettering
12f64221b0 core: add UNIT_GET_SLICE() helper
In a later commit we intend to move the slice logic to use proper
dependencies instead of a "UnitRef" object. This preparatory commit
drops direct use of the slice UnitRef object for a static inline
function UNIT_GET_SLICE() that is both easier to grok, and allows us to
easily replace its internal implementation later on.
2021-05-25 16:02:00 +02:00
Lennart Poettering
8ddba3f266 test-engine: extend engine test
Let's verify that the dependency type to atom mapping is consistent.

Let's also verify that dependency merging works correctly.
2021-05-25 15:54:19 +02:00
Lennart Poettering
defe63b0f3 core: rebreak a few comments 2021-05-25 15:54:19 +02:00
Lennart Poettering
15ed3c3a18 core: split dependency types into atoms 2021-05-25 15:54:19 +02:00
Lennart Poettering
641d3761d4 hashmap: add helper to test if iterator is still at beginning 2021-05-25 15:47:09 +02:00
Yu Watanabe
13eeefe1a8
Merge pull request #19716 from yuwata/sd-netlink-NETLINK_GET_STRICT_CHK
sd-netlink: enable NETLINK_GET_STRICT_CHK socket option to filter out message on kernel
2021-05-25 22:38:59 +09:00
Luca Boccassi
c5fd89adcd core: make libbpf a dlopen() dependency 2021-05-25 12:59:26 +01:00
Luca Boccassi
936cfad7e5 meson: look for bpftool in /usr/sbin too
On Debian, bpftool is installed in /usr/sbin, which is not in $PATH for
non-root users by default, so finding it fails.
Add a secondary, hard-coded '/usr/sbin/bpftool' after 'bpftool' so that
meson can find it.

https://packages.debian.org/sid/amd64/bpftool/filelist
2021-05-25 12:59:26 +01:00
Khem Raj
850f0008bf test-parse-argument: Include signal.h
Fixes
src/test/test-parse-argument.c:49:29: error: use of undeclared identifier 'SIGABRT'

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-05-25 13:53:51 +02:00
Mantas Mikulėnas
fb906b00c6 README: point at IRC channel on the new network 2021-05-25 12:27:22 +02:00
Zbigniew Jędrzejewski-Szmek
dd30da133a
Merge pull request #19709 from keszybz/sysusers-no-proc
Add more logs and make sysusers works in dnf --installroot
2021-05-25 08:20:56 +02:00
Yu Watanabe
5de0d10bee
Merge pull request #19715 from yuwata/network-link-group
network: allow to set Group=0 in [Link] section
2021-05-25 13:29:50 +09:00
Zbigniew Jędrzejewski-Szmek
ffcd683852 systemctl: avoid crash when pattern expands to empty unit list
Fixes #19652.
2021-05-25 13:29:29 +09:00
Yu Watanabe
5709c7fe4e
Merge pull request #19713 from nabijaczleweli/bootctlpsko-liter
The "obviously good stuff" from #19006 again
2021-05-25 08:31:38 +09:00
Yu Watanabe
922a653090 test: add testcases of filtering on dumping addresses 2021-05-25 08:26:00 +09:00
Yu Watanabe
6a28b78f2e local-addresses: set ifindex when dump addresses on an interface 2021-05-25 08:26:00 +09:00
Yu Watanabe
c31298be7a network: set ifindex when dump addresses on an interface 2021-05-25 08:26:00 +09:00
Yu Watanabe
d7418b3bb2 sd-netlink: set NETLINK_GET_STRICT_CHK socket option
Then kernel filters out unnecessary info on dumping, e.g. RTM_GETADDR.
2021-05-25 08:26:00 +09:00
Yu Watanabe
3e0eeb8e33 sd-netlink: do not set route type and table by default for RTM_GETROUTE or friends 2021-05-25 08:26:00 +09:00
Yu Watanabe
3ca619061d sd-netlink: do not set action for RTM_GETRULE message
Otherwise, when NETLINK_GET_STRICT_CHK socket option is enabled, no rule
will be dumped.
2021-05-25 08:26:00 +09:00
Yu Watanabe
f318f64388 sd-netlink: do not enable dump flag by default for RTM_GETADDR message 2021-05-25 08:26:00 +09:00
Yu Watanabe
97bb863c25 sd-netlink: do not append prefixlen by default
Otherwise, when NETLINK_GET_STRICT_CHK socket option is enabled, no
address will be dumped.
2021-05-25 08:26:00 +09:00
Yu Watanabe
5aafd5b190 network: add several assertions in conf parsers 2021-05-25 07:12:05 +09:00
Yu Watanabe
f0c09831bd network: allow to set Group=0 in [Link] section
Previously, when a link has already in a numbered group, we cannot
remove the link from the group.

This also fixes the range mentioned in the man page.
2021-05-25 07:12:05 +09:00
наб
44230fa2b0
kernel-install: don't erase previous errors if a hook returns 77
The manpage says that exiting 77 is the same as exiting 0,
then skipping all other hooks, but the behaviour heretofor
was to exit 0, skip all, and behave as if all hooks exited 0
2021-05-24 21:56:35 +02:00
Zbigniew Jędrzejewski-Szmek
82855aa610 sysusers: make sysusers work with dnf --installroot
This is not very pretty, but the code in fs-util.c already provisions for
missing /proc. We ourselves are careful to set up /proc, but not everybody
is and it is important for sysusers to also work where shadow-utils would:
I would like to replace calls to useradd and groupadd in Fedora systemd rpm
scriptlets with a call to sysusers. It has a number of advantages:
- dogfooding
- we don't need to manually duplicate the information from our sysusers
  files to scriptlets
- a dependency on shadow-utils is dropped, which transitively drops dependencies
  on setup and fedora-repos and bunch of other stuff.

We could try to get 'dnf' and 'rpm --root' and such to be reworked,
but not in any reasonable timeframe. And even if this was done, we'd still
want to support older rpm/dnf versions.
2021-05-24 21:41:24 +02:00
Zbigniew Jędrzejewski-Szmek
0520564dcf basic: allow copy_rights() to work without mounted /proc
This will be used in sysusers later on.
2021-05-24 21:41:22 +02:00
Zbigniew Jędrzejewski-Szmek
335f6ab4f1 sysusers: add debug lines to failing getent/putent operations
I'm trying to use systemd-sysusers for systemd.rpm itself, and the invocation
in dnf chroot is failing like this:
...
Creating group input with gid 999.
Creating group kvm with gid 36.
Creating group render with gid 998.
Creating group sgx with gid 997.
Creating group systemd-journal with gid 190.
Creating group systemd-network with gid 192.
Creating user systemd-network (systemd Network Management) with uid 192 and gid 192.
Creating group systemd-oom with gid 996.
Creating user systemd-oom (systemd Userspace OOM Killer) with uid 996 and gid 996.
Creating group systemd-resolve with gid 193.
Creating user systemd-resolve (systemd Resolver) with uid 193 and gid 193.
Creating group systemd-timesync with gid 995.
Creating user systemd-timesync (systemd Time Synchronization) with uid 995 and gid 995.
Creating group systemd-coredump with gid 994.
Creating user systemd-coredump (systemd Core Dumper) with uid 994 and gid 994.
Failed to write files: Function not implemented

Let's add more info to make such failures easier to debug.
2021-05-24 21:41:10 +02:00
Zbigniew Jędrzejewski-Szmek
62d1c93a02 sysusers: reduce scope of variables and drop unnecessary initializations 2021-05-24 21:39:04 +02:00
наб
0ad401dc5d
kernel-install/90-loaderentry: use install(1) instead of cp/chown/chmod chains
Also fix typo in error message
2021-05-24 21:35:12 +02:00
Roshan Shariff
07c0e5eeaf rules.d: Properly quote $env{MODALIAS}
Add quotes around use of $env{MODALIAS} in rules.d/80-drivers.rules. The
 modalias can contain whitespace, for example when it is dynamically generated
 using device or vendor IDs.
2021-05-24 18:40:01 +01:00
Vincent Dechenaux
f0c7e594ed Typo in service.c
use => user
2021-05-24 14:47:29 +02:00