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

52565 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
9c46228b7d basic/fd-util: sort the 'except' array in place
We need a sorted list of fds to skip over when closing. We would allocate a
copy of the passed array to do the sort. But all callers construct a temporary
array to pass to us, so it is pointless to copy it again.

close_all_fds/safe_fork_full/namespace_fork/fork_agent are changed to pass
a non-const int array. I checked all users, and all callers are fine with
the array being sorted.

The function was returning some number (sometimes 1, sometimes the extent
of the range passed over to close_range(), ???). Anyway, all callers only
check for error, so let's return 0 on success.
2021-07-23 11:37:44 +02:00
Zbigniew Jędrzejewski-Szmek
becbc6dfa8
Merge pull request #20103 from flokli/nsswitch-nss-myhostname
man: stop recommending putting myhostname after dns
2021-07-23 09:44:26 +02:00
Florian Klink
946f7ce32c man: document nss-{resolve,myhostname} resolving in the other direction, too 2021-07-23 01:56:07 +02:00
Florian Klink
ce266330fc man: stop recommending putting myhostname after dns
nss-resolve also looks in /etc/hosts, and has the same local hostname
resolving logic as nss-myhostname. We shouldn't recommend another order
than nss-resolve uses internally.

When nss-resolve is used, there's no possibility to override
nss-myhostname hosts via DNS *anyway*.

On top of that, it's not a good idea to allow DNS to override local
hostnames as all - at least not something we should advertise in the
docs.

Followup of f918c67d38 /
https://github.com/systemd/systemd/pull/16754.
2021-07-23 01:53:07 +02:00
hikigaya58
d844b033a4 Typo correction on systemd.unit man page 2021-07-22 19:05:30 +02:00
Luca Boccassi
d9c4b385e1
Merge pull request #20273 from keszybz/extended-job-status
Propagate the original command line when reexecuting PID1
2021-07-22 15:47:21 +01:00
Zbigniew Jędrzejewski-Szmek
846f1da465 pid1: propagate the original command line when reexecuting
When we reexec the manager in a container, we lose configuration settings on
the kernel command line:

  $ systemd-nspawn -M rawhide -b systemd.status-unit-format=name systemd.show-status=yes
  ...
  # tr '\0' ' ' </proc/1/cmdline
  /usr/lib/systemd/systemd systemd.status_unit_format=combined systemd.show-status=yes
  # sudo systemctl daemon-reexec
  # tr '\0' ' ' </proc/1/cmdline
  /usr/lib/systemd/systemd --system --deserialize 20

  This means that after daemon-reexec, the settings that we gain from the
  commandline are reset to defaults.

So let's reeexecute with the original arguments copied over, modulo some
filtering.
2021-07-22 11:54:10 +02:00
Luca BRUNO
6fe23ff31c docs: move /var/log/README to a tmpfiles.d symlink
This moves the /var/log/README content out of /var and into the
docs location, replacing the previous file with a symlink
created through a tmpfiles.d entry.
2021-07-21 17:29:06 +02:00
Luca Boccassi
cac38a9803
Merge pull request #20123 from keszybz/extended-job-status
Nested job status for systemd+user service managers
2021-07-21 11:39:10 +01:00
Matthijs van Duin
654eaa4030
sd-bus: fix missing initializer in SD_BUS_VTABLE_END (#20253)
When two fields were added to the vtable.x.start struct, no initializers
for these were added to SD_BUS_VTABLE_END which also (ab)used that
struct (albeit sneakily by using non-designated initialization).

While C tolerates this, C++ prohibits these missing initializers, and
both g++ and clang++ will complain when using -Wextra.

This patch gives SD_BUS_VTABLE_END its own case in the union and
clarifies its initialization.

I tested the behaviour of g++ 10.2 and clang 11 in various cases. Both will warn
(-Wmissing-field-initializers, implied by -Wextra) if you provide initializers for some
but not all fields of a struct. Declaring x.end as empty struct or using an empty initializer
{} to initialize the union or one of its members is valid C++ but not C, although both gcc
and clang accept it without warning (even at -Wall -Wextra -std=c90/c++11) unless you
use -pedantic (which requires -std=c99/c++2a to support designated initializers).

Interestingly, .x = { .start = { 0, 0, NULL } } is the only initializer I found for the union
(among candidates for SD_BUS_VTABLE_END) where gcc doesn't zero-fill it entirely
when allocated on stack, it looked like it did in all other cases (I only examined this on
32-bit arm). clang always seems to initialize all bytes of the union.

[zjs: test case:
$ cat vtable-test.cc                                                          
#include "sd-bus.h"

const sd_bus_vtable vtable[] = {
   SD_BUS_VTABLE_END
};

$ g++ -I src/systemd/ -Wall -Wmissing-field-initializers -c vtable-test.cc
vtable-test.cc:5:1: warning: missing initializer for member ‘sd_bus_vtable::<unnamed union>::<unnamed struct>::features’ [-Wmissing-field-initializers]
    5 | };
      | ^
vtable-test.cc:5:1: warning: missing initializer for member ‘sd_bus_vtable::<unnamed union>::<unnamed struct>::vtable_format_reference’ [-Wmissing-field-initializers]

$ clang++ -I src/systemd/ -Wmissing-field-initializers -c vtable-test.cc 
vtable-test.cc:4:4: warning: missing field 'features' initializer [-Wmissing-field-initializers]
   SD_BUS_VTABLE_END
   ^
src/systemd/sd-bus-vtable.h:188:28: note: expanded from macro 'SD_BUS_VTABLE_END'
                .x = { { 0 } },                                         \
                           ^
1 warning generated.

Both warnings are gone with the patch.]
2021-07-21 11:10:36 +02:00
Zbigniew Jędrzejewski-Szmek
7d9ee15d0f rpm: don't specify the full path for systemctl and other commands
We can make things a bit simpler and more readable by not specifying the path.
Since we didn't specify the full path for all commands (including those invoked
recursively by anythign we invoke), this didn't really privide any security or
robustness benefits. I guess that full paths were used because this style of
rpm packagnig was popular in the past, with macros used for everything
possible, with special macros for common commands like %{__ln} and %{__mkdir}.
2021-07-21 10:57:35 +02:00
Zbigniew Jędrzejewski-Szmek
3cfd5ddd59
Merge pull request #20087 from xen0n/loongarch64-gpt
gpt: support LoongArch 64-bit
2021-07-21 10:50:08 +02:00
Zbigniew Jędrzejewski-Szmek
b34a4f0e67
Merge pull request #20256 from keszybz/one-alloca-too-many
basic/unit-name: do not use strdupa() on a path
2021-07-20 14:39:23 +02:00
WANG Xuerui
f15f2ab42e
gpt: reformat for restoring vertical alignment 2021-07-20 17:32:59 +08:00
WANG Xuerui
4e76715489
gpt: support LoongArch 64-bit 2021-07-20 17:32:59 +08:00
Aakash Singh
30c9faff0d hwdb: 60-keyboard::remove hardcoded definition for KEYBOARD_KEY_56 for MSI Prestige And Modern 2021-07-20 09:42:04 +01:00
rene
b838bc1126
Minor typo (#20254)
Correct resoulution with resolution.
2021-07-20 14:45:04 +09:00
Yu Watanabe
8bdef77400
Merge pull request #20251 from keszybz/test-format-lifetime
Add test for format_lifetime() and fix prefix
2021-07-20 06:13:50 +09:00
monosans
99c6a49c70 log-generator: count arguments as offset from an iterator 2021-07-19 19:39:40 +01:00
Zbigniew Jędrzejewski-Szmek
c543f4d7dd basic/time-util: inline one more variable declaration 2021-07-19 19:58:13 +02:00
Zbigniew Jędrzejewski-Szmek
971f369761 udev-event: drop unused assignments
clang's static analyzer reports:
  Value stored to 'l' is never read
2021-07-19 18:54:26 +01:00
Zbigniew Jędrzejewski-Szmek
a35f3128e6 networkd: fix and simplify format_lifetime()
We would copy "forever" into the buffer. This is a fairly common case, so let's
do a microoptimization and return a static string. (All callers use the return
pointer, so this works just as well.)

The prefix "for " was not displayed, because the pointer to the part of the
buffer after "for " was returned. (Maybe it's just me, but I find strpcpy()
and associated functions really hard to use… I always have to look up what the
do exactly and what the return value is.)

A simple test is added.
2021-07-19 19:43:57 +02:00
Yu Watanabe
2d302d88e4 network: configure address with requested lifetime
When assigning the same address provided by a dynamic addressing
protocol, the new lifetime is stored on Request::Address, but not
Address object in Link object, which can be obtained by address_get().
So, we need to configure address with Address object in Request.

Fixes #20245.
2021-07-19 17:38:16 +01:00
Frantisek Sumsal
a2efdaac07 ci: add ppc64le Rawhide chroot to the Packit chroot set 2021-07-19 12:16:36 +01:00
James Hilliard
e5d86ebed5 Add meson option to disable urlify.
Useful for systems that don't use a version of less with hyperlink
support.
2021-07-19 11:57:51 +02:00
Zbigniew Jędrzejewski-Szmek
ff3a701923 core/main: wrap long comment lines 2021-07-19 11:47:52 +02:00
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