1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00
Commit Graph

52437 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
3889fc6fc3 manager: print status text of the service when waiting for a job
This does two semi-independent but interleaved things: firstly, the manager now
prints the status text (if available) of a service when we have a job running
for that service and it is slow. Because it's hard to fit enough info on the
line, we only do this if the output mode uses unit names. The format of the
line "… job is running for …" is changed to be shorter. This way we can
somewhat reasonably fit two status messages on one line.

Secondly, the manager now sends more information using sd_notify. This mostly
matters for in case of the user manager. In particular, we notify when starting
one of the special units. Without this, when the system manager would display a
line about waiting for the user manager, it would show status like "Ready.",
which is confusing. Now it'll either show something like "Started special unit
shutdown.target", or the line about waiting for a user job.

Also, the timeouts for the user manager are lowered: the user manager usually
(always?) has status disabled, so we would wait for 25 seconds before showing
job progress. Normally we don't expect to have any jobs that take more than a
second. So let's start the progress output fairly quickly, like we would if
status showing was enabled. This obviously makes the output in the system
manager about the user manager more useful. The timeouts are "desynchronized"
by a fraction so if there are multiple jobs running, we'll cycle through
showing all combinations.

Example output:

         Stopping user@1000.service...
[  OK  ] Stopped dracut-shutdown.service.
[  OK  ] Stopped systemd-logind.service.
[  OK  ] Stopped systemd-logind.service - User Login Management.
[*     ] Job user@1000.service/stop running (2s / 2min): (1 of 2) User job slowstop.service/stop running (1s / 1min 30s)...
[***   ] Job user@1000.service/stop running (3s / 2min): (2 of 2) User job slowstop2.service/stop running (2s / 1min 30s)...
[   ***] Job user@1000.service/stop running (4s / 2min): (1 of 2) User job slowstop.service/stop running (4s / 1min 30s)...
[     *] Job user@1000.service/stop running (5s / 2min): (1 of 2) User job slowstop.service/stop running (5s / 1min 30s)...
[   ***] Job user@1000.service/stop running (6s / 2min): (2 of 2) User job slowstop2.service/stop running (6s / 1min 30s)...
[***   ] Job user@1000.service/stop running (8s / 2min): (1 of 2) User job slowstop.service/stop running (7s / 1min 30s)...
[***   ] Job user@1000.service/stop running (10s / 2min): (2 of 2) User job slowstop2.service/stop running (9s / 1min 30s)...
[  *** ] Job user@1000.service/stop running (11s / 2min): (1 of 2) User job slowstop.service/stop running (10s / 1min 30s)...
[     *] Job user@1000.service/stop running (12s / 2min): (2 of 2) User job slowstop2.service/stop running (12s / 1min 30s)...
[   ***] Job user@1000.service/stop running (13s / 2min): (1 of 2) User job slowstop.service/stop running (13s / 1min 30s)...
[***   ] Job user@1000.service/stop running (15s / 2min): (2 of 2) User job slowstop2.service/stop running (14s / 1min 30s)...
[*     ] Job user@1000.service/stop running (15s / 2min): (2 of 2) User job slowstop2.service/stop running (14s / 1min 30s)...
[***   ] Job user@1000.service/stop running (16s / 2min): User job slowstop.service/stop running (16s / 1min 30s)...
[   ***] Job user@1000.service/stop running (18s / 2min): User job slowstop.service/stop running (17s / 1min 30s)...
[     *] Job user@1000.service/stop running (19s / 2min): User job slowstop.service/stop running (18s / 1min 30s)...
[   ***] Job user@1000.service/stop running (20s / 2min): User job slowstop.service/stop running (19s / 1min 30s)...
[*     ] Job user@1000.service/stop running (22s / 2min): User job slowstop.service/stop running (22s / 1min 30s)...
[**    ] Job user@1000.service/stop running (30s / 2min): User job slowstop.service/stop running (29s / 1min 30s)...
[   ***] Job user@1000.service/stop running (32s / 2min): User job slowstop.service/stop running (31s / 1min 30s)...
[     *] Job user@1000.service/stop running (33s / 2min): User job slowstop.service/stop running (32s / 1min 30s)...
[   ***] Job user@1000.service/stop running (34s / 2min): User job slowstop.service/stop running (33s / 1min 30s)...
[**    ] Job user@1000.service/stop running (37s / 2min): User job slowstop.service/stop running (36s / 1min 30s)...
[  *** ] Job user@1000.service/stop running (41s / 2min): User job slowstop.service/stop running (41s / 1min 30s)...
[  OK  ] Stopped user@1000.service - User Manager for UID 1000.
         Stopping user-runtime-dir@1000.service - User Runtime Directory /run/user/1000...
[  OK  ] Unmounted run-user-1000.mount - /run/user/1000.
[  OK  ] Stopped user-runtime-dir@1000.service - User Runtime Directory /run/user/1000.

If the output width is lower than approximately 100 columns, the output stops
being very useful. No idea what to do about that.
2021-07-19 11:42:55 +02:00
Zbigniew Jędrzejewski-Szmek
6d93265955 manager: rework sending of STATUS=
We would send READY=1,STATUS="Startup finished in …" once after finishing
boot. This changes the message to just "Ready.". The time used to reach
readiness is not part of the ongoing status — it's just a bit of debug
information that it useful in some scenarious, but completely uninteresting
most of the time. Also, when we start sending status about other things in
subsequent patches, we can't really go back to showing "Startup finished in …"
later on. So let's just show "Ready." whenever we're in the steady state.

In manager_check_finished(), more steps are skipped if MANAGER_IS_FINISHED().
Those steps are idempotent, but no need to waste cycles trying to do them
more than once.

We'll now also check whether to send the status message whenever the job queue
runs empty. If we already sent the exact same message already, we'll not send
again.
2021-07-19 11:36:25 +02:00
Zbigniew Jędrzejewski-Szmek
5f96809628 manager: always log when starting a "special unit"
This is the initiatation of the machine shutdown/reboot/etc, so it's
useful to log about this. We log about the steps that we take, but
so far we didn't really log why we started the sequence (except at
debug level).

The function is renamed, because we also use it for dbus.service,
not just targets.
2021-07-19 11:33:52 +02:00
Zbigniew Jędrzejewski-Szmek
5e1669ff26 core: add helper to retrieve service.status_text 2021-07-19 11:33:52 +02:00
Zbigniew Jędrzejewski-Szmek
48d83e3368 core: align string tables 2021-07-19 11:33:52 +02:00
Zbigniew Jędrzejewski-Szmek
305757d808 core: modernize asprintf error handling
The man page says asprintf() pointer is "undefined" on error, but the
only meaningful interpretation is that it's either NULL or points to
something that should be freed with free().
2021-07-19 11:33:44 +02:00
Zbigniew Jędrzejewski-Szmek
a01ba4b2b8 core: split out manager-serialize.[ch]
The file is super long, so let's split this out one subject to a new file.
2021-07-19 11:27:11 +02:00
Luca Boccassi
95b63c755b git-contrib: copypaste-friendly output
Format output in a manner that can be copypasted as-is to NEWS.
That is, with 8 spaces indentation and wrapped at 80 columns.

Before:

$ tools/git-contrib.sh
        Ben Stockett,
        Carl Lei,
        Frantisek Sumsal,
        Gibeom Gwon,
        Hugo Osvaldo Barrera,
        James Hilliard,
        Jan Palus,
        Lennart Poettering,
        Luca Boccassi,
        Luca BRUNO,
        Mike Gilbert,
        nassir90,
        nl6720,
        Raul Tambre,
        Yegor Alexeyev,
        Yu Watanabe,
        Zbigniew Jędrzejewski-Szmek,

After:

        Contributions from: Ben Stockett, Carl Lei, Frantisek Sumsal,
        Gibeom Gwon, Hugo Osvaldo Barrera, James Hilliard, Jan Palus,
        Lennart Poettering, Luca Boccassi, Luca BRUNO, Mike Gilbert,
        nassir90, nl6720, Raul Tambre, Yegor Alexeyev, Yu Watanabe,
        Zbigniew Jędrzejewski-Szmek
2021-07-19 15:39:26 +09:00
duament
3f49d1faf5 shell-completion/zsh/_systemd-run: Fix completion of command names and arguments 2021-07-17 22:55:40 +01:00
Luca Boccassi
942a69e3e3
Merge pull request #20225 from mrc0mmand/selinux-nspawn-sanity
test: add a sanity test for #19976
2021-07-15 22:21:11 +01:00
Luca Boccassi
a7a8335f05
Merge pull request #20228 from yuwata/follow-ups-20109
tree-wide: FORMAT_TIMESPAN() or friends must be used as a function argument
2021-07-15 17:06:20 +01:00
Yu Watanabe
f843f85da8 tree-wide: FORMAT_TIMESTAMP() or friends must be used as a function argument
Follow-ups for #20109.
2021-07-15 20:03:46 +09:00
Yu Watanabe
fa3f917a25 network: slightly simplify log_address_debug() 2021-07-15 19:18:45 +09:00
Yu Watanabe
0fd97a2533 network: introduce FORMAT_LIFETIME()
Fixes a bug introduced by 5291f26d4a.

Fixes #20227.
2021-07-15 19:17:32 +09:00
Yu Watanabe
6c39b39aa8
Merge pull request #20209 from yuwata/network-dhcp4-semi-static-route-with-use-gateway-no
network: dhcp4: support semi-static route with Gateway=_dhcp4 with UseGateway=no
2021-07-15 11:57:11 +09:00
Yu Watanabe
4df8a8e809 test-network: add a testcase for semi-static route with Gateway=_dhcp4 when UseGateway=no 2021-07-15 04:17:14 +09:00
Yu Watanabe
87e62d32b4 test-network: adjust testcases to follow the previous changes 2021-07-15 04:17:14 +09:00
Yu Watanabe
0ebab55f4f network: dhcp4: also support semi-static routes with Gateway=_dhcp4 when UseGateway=no or UseRoutes=no
This makes the default gateway is read from classless static routes or
router option even if UseGateway=no or UseRoutes=no, and will be used
when configuring semi-static routes such that specified with Gateway=_dhcp4.

This also changes the behavior of RoutesToDNS= or RoutesToNTP=.
Previously, the DNS or NTP servers are not in the same network, then the
routes to the servers were not configured when UseGateway=no or
UseRoutes=no. With this commit, the default gateway in classless static
routes or router option will used to connecting the servers even if
UseGateway=no or UseRoutes=no.

Fixes #20208.
2021-07-15 04:17:09 +09:00
Frantisek Sumsal
dc916a167e test: add a sanity test for systemd/systemd#19976
which should ensure we can use nspawn containers with SELinux context set via
the `--selinux-context=` and `--selinux-apifs-context=` options.
2021-07-14 20:29:37 +02:00
Frantisek Sumsal
eca81d0792 test: don't explicitly disable SELinux
We don't install any policies by default, so it shouldn't interfere with
anything (and it would save me some headache).
2021-07-14 20:27:23 +02:00
Yu Watanabe
77976a6877 network: further unification of MUD url parsers
Follow-up for 89fa9a6b7b.
2021-07-14 17:41:00 +01:00
Raul Tambre
534b5abce1 man/systemd.network: Fix duplicate Xfrm description
It's already listed along with others (Tunnel, VLAN, etc.) and its description matches those. The duplication was introduced by commit c3006a485c.
2021-07-14 21:48:48 +09:00
Yu Watanabe
e18f21e349
Merge pull request #20109 from keszybz/timestamp-macros
Add macros that define scratch buffer internally for timestamp/timespan formatting
2021-07-14 16:14:08 +09:00
Yu Watanabe
54d1fdb244 network: update interface name stored in various network engines 2021-07-14 00:40:47 +01:00
Yu Watanabe
bedc15706e
Merge pull request #20120 from yuwata/test-oomd-debug
test: enable debug logging of oomd
2021-07-13 23:30:16 +09:00
Yu Watanabe
176b8be10f network: check the received interface name is actually new
For some reasons I do not know, on interface renaming, kernel once send
netlink message with old interface name, and then send with new name.
If eth0 is renamed, and then new interface appears as eth0, then the
message with the old name 'eth0' makes the interface enters failed
state.

To ignore such invalid(?) rename event messages, let's confirm the
received interface name.

Fixes #20203.
2021-07-13 19:20:31 +09:00
Gibeom Gwon
85e424c0c8 homed: allow systemd-homed access to FIDO2 devices
Add DeviceAllow= option for FIDO2 devices in systemd-homed.service.
2021-07-12 23:35:32 +01:00
Luca Boccassi
8b213bf12e TODO: note cgroup.kill and memfd_secret 2021-07-12 22:47:59 +01:00
Luca Boccassi
b1f8d02557
Merge pull request #20202 from yuwata/network-fix-manage-foreign-routes-no
network: fix ManageForeignRoutes=no
2021-07-12 19:11:37 +01:00
Zbigniew Jędrzejewski-Szmek
75312ada53 systemctl: show error when help for unknown unit is requested
Fixes #20189. We would only log at debug level and return failure, which looks
like a noop for the user.

('help' accepts multiple arguments and will show multiple concatenated man
pages in that case. Actually, it will also show multiple concatenated man pages
if the Documentation= setting lists multiple pages. I don't think it's very
terribly useful, but, meh, I don't think we can do much better. If a user
requests a help for a two services, one known and one unknown, there'll now be
a line in the output. It's not very user friendly, but not exactly wrong too.)
2021-07-12 15:26:40 +01:00
Yu Watanabe
1d26d4cd14 test-network: add a testcase for ManageForeignRoutes=no 2021-07-12 20:59:42 +09:00
Luca BRUNO
c68c87d023 man/dnssec-trust-anchors: fix an XML syntax typo
This fixes an XML syntax typo in the 'dnssec-trust-anchors'
documentation.
2021-07-12 12:09:20 +01:00
Yu Watanabe
11046cea14 network: also check addresses when determine a gateway address is reachable or not
Fixes #20201.
2021-07-12 16:35:48 +09:00
Carl Lei
9de0c7f4ae man: fix RFC number
#19947 didn't fix both.
2021-07-12 14:10:32 +09:00
Mike Gilbert
f2c57d4f38 libudev: add "Libs.private: -lrt -pthread" to libudev.pc
This resolves a failure when linking cryptsetup.static against libudev.a.

```
libtool: link: x86_64-pc-linux-gnu-gcc -Wall -O2 -pipe -march=amdfam10 -static -O2 -o cryptsetup.static lib/utils_crypt.o lib/utils_loop.o lib/utils_io.o lib/utils_blkid.o src/utils_tools.o src/utils_password.o src/utils_luks2.o src/utils_blockdev.o src/cryptsetup.o -pthread -pthread  -Wl,--as-needed ./.libs/libcryptsetup.a -largon2 -lrt -ljson-c -lpopt -luuid -lblkid -lssl -lcrypto -lz -ldl -ldevmapper -lm -lpthread -ludev -pthread
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib64/libudev.a(src_libsystemd_sd-daemon_sd-daemon.c.o): in function `sd_is_mq':
(.text.sd_is_mq+0x3a): undefined reference to `mq_getattr'
```
2021-07-11 11:01:54 +01:00
James Hilliard
d6d1fd995f Disable non-explicit sbatvars autodetection for cross builds.
Since autodetection is unlikely to work reliably for cross builds
disable it unless explicitly enabled.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2021-07-10 23:46:26 +01:00
Ben Stockett
4226dfafba Updated manpage for sd_bus_set_property
Updated manpage for sd_bus_set_property and sd_bus_set_propertyv. In the old manpage, these functions included the parameter sd_bus_message **reply when the actual function had no such argument.
2021-07-10 13:19:50 +01:00
nassir90
a814eae728
Fixed typo (#20187)
* Fixed typo

Before, the file claimed that some systemd units are created "from other
configuration". It should have read "from other configuration files".

Co-authored-by: Nozz <nozolo90@gmail.com>
2021-07-09 21:16:02 +01:00
Luca Boccassi
af55491028
Merge pull request #20186 from keszybz/coverity-fixes
Coverity fixes
2021-07-09 21:15:08 +01:00
Frantisek Sumsal
2f0927626a tree-wide: coccinelle fixes
Yet another batch of Coccinelle fixes.
2021-07-09 20:54:22 +01:00
Frantisek Sumsal
0de0ba573b
Merge pull request #20185 from mrc0mmand/ci-tweaks
test: assorted test tweaks to address flakiness
2021-07-09 20:21:59 +02:00
Luca Boccassi
5c8cf104e7
Merge pull request #20157 from keszybz/numerical-uids-in--M
Allow numerical UIDs in systemctl -M uid@ and similar
2021-07-09 16:58:45 +01:00
Zbigniew Jędrzejewski-Szmek
d1829af943 creds: fix leak of arg_tpm2_device
IIUC, "auto" is the same as NULL. There is no need to strdup() anything.

Coverity CID#1458113.
2021-07-09 15:29:47 +02:00
Frantisek Sumsal
7e8cfa4bb6 test: make the strace check a bit more clever
We still sometimes try to grep an empty strace log because strace is not
yet properly initialized. Let's make the check a bit clever and wait
until strace is attached to PID 1 by checking the `TracerPid` field in
`/proc/1/status`.
2021-07-09 15:26:07 +02:00
Zbigniew Jędrzejewski-Szmek
89fa9a6b7b networkd: add shared parser for mud urls
The same buggy code was triplicated…
2021-07-09 15:13:12 +02:00
Zbigniew Jędrzejewski-Szmek
bc1f27ff55 creds: drop unnecessary initialization
Coverity also thinks a leak happens here, CID #1458112.
This seems wrong, but let's add an assert, maybe that'll help.
2021-07-09 15:13:12 +02:00
Zbigniew Jędrzejewski-Szmek
1421705d9a core: drop unnecessary initialization
cunescape() sets output on success, so initialization is not necessary. There
was no comment, but I think they may have been added because the compiler
wasn't convinced that the return value is non-negative on success. It could
have been confused by the int return type on escape*(), which was changed by
the one of preceeding commits to ssize_t, or by the length calculation, so add
an assert to help the compiler.

For some reason coverity thinks the output can be leaked here (CID #1458111).
I don't see how.
2021-07-09 15:12:18 +02:00
Zbigniew Jędrzejewski-Szmek
2744c7bb01 xdg-autostart: minor refactoring
We can't say free_and_replace(exec_split[n++], quoted), because the the
argument is evaluated multiple times. But I think that this form is
still easier to read.
2021-07-09 15:07:40 +02:00
Zbigniew Jędrzejewski-Szmek
12d729b2ec nspawn: inline one iterator variable declaration 2021-07-09 15:07:40 +02:00
Zbigniew Jędrzejewski-Szmek
e437538f35 tree-wide: make cunescape*() functions return ssize_t
Strictly speaking, we are returning the size of a memory chunk of
arbitrary size, so ssize_t is more appropriate than int.
2021-07-09 15:07:40 +02:00