1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00
Commit Graph

52440 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
fce9abb227 meson: use a/b instead of join_paths(a,b)
It is nicer and shorter.
2021-07-27 19:32:35 +02:00
Zbigniew Jędrzejewski-Szmek
0b5f1bd49e meson: use maps for udev program paths 2021-07-27 18:58:42 +02:00
Zbigniew Jędrzejewski-Szmek
68e101da7a meson: adjust comment about find_program() usage
The FIXME was not correct: with 'dirs' we'd put the fixed path first
(see the docs for find_program()).
2021-07-27 18:53:31 +02:00
Zbigniew Jędrzejewski-Szmek
81875efe20 meson: use project_build_root
As documented in /meson.build where the variable is defined,
meson.build_root() doesn't work as expected with project nesting. I have
no idea why anyone would want to embed systemd in another meson project,
but let's use the variable if we have it.
2021-07-27 18:53:22 +02:00
Zbigniew Jędrzejewski-Szmek
9247df5a88 meson: require 0.53.2 and drop some workarounds for old meson
Ubuntu Bionic 18.04 has 0.45, so it was below the previously required
minimum version already. Focal 20.04 has 0.53.2. Let's require that
and use various features that are available.
2021-07-27 16:46:46 +02:00
Riccardo Schirone
148369deef Check return value of pam_get_item/pam_get_data functions 2021-07-27 11:59:46 +02:00
Khem Raj
2a0d07d6a0 networkd: Include linux/netdevice.h header
This header provides definitions for NET_NAME_UNKNOWN ånd NET_NAME_ENUM
Fixes build issue found with non-glibc systems

../git/src/network/networkd-link.c:1203:52: error: 'NET_NAME_UNKNOWN' undeclared (first use in this function)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-07-26 22:48:57 +01:00
Zbigniew Jędrzejewski-Szmek
b4f0261337 udev: when setting up lo, do not return an error
From #20300:
> commit 70f32a260b
> Author: Yu Watanabe <watanabe.yu+github@gmail.com>
> Date:   Sun May 23 16:59:40 2021 +0900

>     udev/net: do not manage loopback interfaces

>     There are nothing we can configure in udevd for loopback interfaces;
>     no ethertool configs can be applied, MAC address, interface name should

> introduced a regression for 'udevadm test-builtin net_setup_link /sys/class/net/lo/'.
> Prior to this commit this command would exit with 0 whereas after this commit
> it exists with 1. This causes cloud-init on Archlinux to fail as this command
> is run by it and likely also netplan to have networkd rescan and re-apply a
> bunch of things on NICs.

I think it's reasonable to keep returning 0 here: we are intentatinally doing
nothing for the device, and that is not an error, but a (noop) success.

Fixes #20300.
2021-07-26 14:47:03 +01:00
Ondrej Kozina
d1ae38d85a Add support for systemd-tpm2 libcryptsetup plugin.
Add support for systemd-tpm2 based LUKS2 device activation
via libcryptsetup plugin. This make the feature (tpm2 sealed
LUKS2 keyslot passphrase) usable from both systemd utilities
and cryptsetup cli.

The feature is configured via -Dlibcryptsetup-plugins combo
with default value set to 'auto'. It get's enabled automatically
when cryptsetup 2.4.0 or later is installed in build system.
2021-07-26 15:15:16 +02:00
Luca Boccassi
c5a421b3b9
Merge pull request #20276 from keszybz/rpm-restart-wip
Reload user daemons and restart user services at the end of the rpm transaction
2021-07-26 11:02:37 +01:00
Zbigniew Jędrzejewski-Szmek
1262e824a4 update-helper: also add "user-reexec" verb
This is not called from the systemd.triggers or systemd.macros files. Instead,
it would be called from the scriptlets in systemd rpm package itself, at the
place where we call systemctl daemon-reexec.

See https://github.com/systemd/systemd/pull/20289#issuecomment-885622200 .
2021-07-24 13:11:13 +02:00
Zbigniew Jędrzejewski-Szmek
36d55958cc rpm: restart user services at the end of the transaction
This closes an important gap: so far we would reexecute the system manager and
restart system services that were configured to do so, but we wouldn't do the
same for user managers or user services.

The scheme used for user managers is very similar to the system one, except
that there can be multiple user managers running, so we query the system
manager to get a list of them, and then tell each one to do the equivalent
operations: daemon-reload, disable --now, set-property Markers=+needs-restart,
reload-or-restart --marked.

The total time that can be spend on this is bounded: we execute the commands in
parallel over user managers and units, and additionally set SYSTEMD_BUS_TIMEOUT
to a lower value (15 s by default). User managers should not have too many
units running, and they should be able to do all those operations very
quickly (<< 1s). The final restart operation may take longer, but it's done
asynchronously, so we only wait for the queuing to happen.

The advantage of doing this synchronously is that we can wait for each step to
happen, and for example daemon-reloads can finish before we execute the service
restarts, etc. We can also order various steps wrt. to the phases in the rpm
transaction.

When this was initially proposed, we discussed a more relaxed scheme with bus
property notifications. Such an approach would be more complex because a bunch
of infrastructure would have to be added to system manager to propagate
appropriate notifications to the user managers, and then the user managers
would have to wait for them. Instead, now there is no new code in the managers,
all new functionality is contained in src/rpm/. The ability to call 'systemctl
--user user@' makes this approach very easy. Also, it would be very hard to
order the user manager steps and the rpm transaction steps.

Note: 'systemctl --user disable' is only called for a user managers that are
running. I don't see a nice way around this, and it shouldn't matter too much:
we'll just leave a dangling symlink in the case where the user enabled the
service manually.

A follow-up for https://bugzilla.redhat.com/show_bug.cgi?id=1792468 and
fa97d2fcf6.
2021-07-24 11:53:31 +02:00
Zbigniew Jędrzejewski-Szmek
3598aff4d9 rpm: call +needs-restart in parallel
Some rpms install a bunch of units… It seems nicer to invoke them all in
parallel. In particular, timeouts in systemctl also run in parallel, so if
there's some communication mishap, we will wait less.
2021-07-24 11:46:26 +02:00
Zbigniew Jędrzejewski-Szmek
6d825ab2d4 rpm: use a helper script to actually invoke systemctl commands
Instead of embedding the commands to invoke directly in the macros,
let's use a helper script as indirection. This has a couple of advantages:

- the macro language is awkward, we need to suffix most commands by "|| :"
  and "\", which is easy to get wrong. In the new scheme, the macro becomes
  a single simple command.
- in the script we can use normal syntax highlighting, shellcheck, etc.
- it's also easier to test the invoked commands by invoking the helper
  manually.
- most importantly, the logic is contained in the helper, i.e. we can
  update systemd rpm and everything uses the new helper. Before, we would
  have to rebuild all packages to update the macro definition.

This raises the question whether it makes sense to use the lua scriptlets when
the real work is done in a bash script. I think it's OK: we still have the
efficient lua scripts that do the short scripts, and we use a single shared
implementation in bash to do the more complex stuff.

The meson version is raised to 0.47 because that's needed for install_mode.
We were planning to raise the required version anyway…
2021-07-24 11:46:23 +02:00
Frantisek Sumsal
f571d9d5f0 test: make sure we don't access an unbound variable
```
testsuite-60.sh[759]: + grep -q '(mount-monitor-dispatch) entered rate limit'
testsuite-60.sh[571]: + sleep 5
testsuite-60.sh[761]: ++ date -u +%s
testsuite-60.sh[571]: + [[ 1627037066 -le 1627037061 ]]
testsuite-60.sh[571]: /usr/lib/systemd/tests/testdata/units/testsuite-60.sh: line 41: entered_rl: unbound variable
```
2021-07-23 16:20:42 +01:00
Luca Boccassi
80362ec56f
Merge pull request #20288 from keszybz/freeze-no-malloc
Don't call malloc from freeze which is called in a signal handler
2021-07-23 15:35:34 +01:00
Luca Boccassi
a11e7c0b4c TODO: homed + user session namespace 2021-07-23 14:57:39 +01:00
ratijas
d2e84b6018 man: Fix incorrect EFI vendor UUID (last missing nibble) 2021-07-23 14:20:29 +02:00
Luca Boccassi
f6f4ec7951 discover-image: mount as read-only when extracting metadata
We don't need to modify the image, and the loopback device is already set to read-only.
2021-07-23 14:07:58 +02:00
Cristian Rodríguez
14f4b1b568 malloc() uses getrandom now
glibc master uses getrandom in malloc since https://sourceware.org/git/?p=glibc.git;a=commit;h=fc859c304898a5ec72e0ba5269ed136ed0ea10e1  ,  getrandom should be in the default set so to avoid all non trivial programs to fallback to a PRNG.
2021-07-23 12:24:57 +02:00
Franck Bui
878e32b614 logind: action* parameters can't be NULL in verify_shutdown_creds()
"action", "action_multiple_sessions" and "action_ignore_inhibit" can't be NULL
in practice so let's simplify a bit the code.

No functional change.
2021-07-23 12:10:04 +02:00
chlorophyll-zz
6999521ba9 Sensor Y Axis is inverted for TrekStor Surftab W1
IIO Sensor Y Axis is inverted for TrekStor Surftab W1.
When iio-sensor-proxy is running, up is down and down is up. 
This fixes the inversion.
2021-07-23 12:08:00 +02:00
Zbigniew Jędrzejewski-Szmek
cbcf371abc Add variant of close_all_fds() that does not allocate and use it in freeze()
Even though it's just a fallback path, let's not be sloppy and allocate in
the crash handler.

> The deadlock happens because systemd crash in malloc() then in signal
> handler, it calls malloc() (close_all_fds()-> opendir()-> __alloc_dir())
> again. malloc() is not a signal-safe function, maybe we should re-think
> the logic here.

Fixes #20266.
2021-07-23 11:39:45 +02:00
Zbigniew Jędrzejewski-Szmek
45a68ed307 Move freeze() into shared/
Library code should not call freeze(), this is something that should
only be done by "application code", so moving it into shared/ is appropriate.

The fallback to call _exit() is dropped: let's trust that the infinite loop
is infinite.
2021-07-23 11:39:45 +02:00
Zbigniew Jędrzejewski-Szmek
3e24e8cd64 Move fork_agent() into shared/
Currently it's only used in two places in src/shared/, so the function was
already included just once in compiled code. But it seems appropriate to
move it there anyway, because library code should have no need to fork
agents, so it doesn't belong in basic/.
2021-07-23 11:39:45 +02:00
Zbigniew Jędrzejewski-Szmek
3bd6a01c01 basic/process-util: use xsprintf() in one more place 2021-07-23 11:39:45 +02:00
Zbigniew Jędrzejewski-Szmek
6bf3c6c900 Make oom_score_adjust_is_valid() static
It has only one user and we don't need to put it in basic/.
2021-07-23 11:39:45 +02:00
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 f918c67d38ba6ccd4eb0dc657f3f3155e5010cae /
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