Commit Graph

46238 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 2aed63f427 tree-wide: fix spelling of "fallback"
Similarly to "setup" vs. "set up", "fallback" is a noun, and "fall back"
is the verb. (This is pretty clear when we construct a sentence in the
present continous: "we are falling back" not "we are fallbacking").
2020-08-20 17:45:32 +02:00
Zbigniew Jędrzejewski-Szmek bb5a34fb3e man: add conditionals to more man pages
Fixes #16701.
2020-08-20 17:42:13 +02:00
Zbigniew Jędrzejewski-Szmek b3259a6e5f meson: add ENABLE_ANALYZE conditional 2020-08-20 17:42:13 +02:00
Zbigniew Jędrzejewski-Szmek 4338ab8163 meson: fix build/man/{man,html} to support page redirects
Commands like build/man/man journald.conf.d would show the installed
man page (or an error if the page cannot be found in the global search
path), and not the one in the build directory. If the man page is
a redirect, or the .html is a symlink, resolve it, build the target,
and show that.
2020-08-20 17:42:13 +02:00
Zbigniew Jędrzejewski-Szmek 7eac7b4c62 test-string-util: add a test for strjoin()
Strangely, we didn't have one so far. I mostly wanted to verify
that NULL can be used in any spot at behaves the same as "".
2020-08-20 17:42:13 +02:00
Zbigniew Jędrzejewski-Szmek c32c4352b4 test-acl-util: output more debug info
For some reason this failed in koji build on s390x:
--- command ---
16:12:46 PATH='/builddir/build/BUILD/systemd-stable-246.1/s390x-redhat-linux-gnu:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin' SYSTEMD_LANGUAGE_FALLBACK_MAP='/builddir/build/BUILD/systemd-stable-246.1/src/locale/language-fallback-map' SYSTEMD_KBD_MODEL_MAP='/builddir/build/BUILD/systemd-stable-246.1/src/locale/kbd-model-map' /builddir/build/BUILD/systemd-stable-246.1/s390x-redhat-linux-gnu/test-acl-util
--- stdout ---
-rw-r-----. 1 mockbuild mock 0 Aug  7 16:12 /tmp/test-empty.7RzmEc
other::---
--- stderr ---
Assertion 'r >= 0' failed at src/test/test-acl-util.c:42, function test_add_acls_for_user(). Aborting.
2020-08-20 17:42:13 +02:00
Lennart Poettering 5b14956385
Merge pull request #16543 from poettering/nspawn-run-host
nspawn: /run/host/ tweaks
2020-08-20 16:20:05 +02:00
Lennart Poettering c1093c34d7 sd-bus: fix error handling on readv()
let's make sure we collect the right error code from errno, otherwise
we'll see EPERM (i.e. error 1) for all errors readv() returns (since it
returns -1 on error), including EAGAIN.

This is definitely backport material.

A fix-up for 3691bcf3c5.

Fixes: #16699
2020-08-20 14:14:36 +02:00
Luca Boccassi 7489ccc350 coding style: document how to break a function declaration 2020-08-20 13:19:28 +02:00
Lennart Poettering 037857507a man: fix xml tags 2020-08-20 13:19:01 +02:00
Lennart Poettering 7b24e6e3fa
Merge pull request #16221 from bluca/show_microsec
systemctl: add --timestamp to change timestamp print format
2020-08-20 13:15:04 +02:00
Lennart Poettering 5d1e68b494 user-runtime-dir: deal gracefully with missing logind properties
Fixes: #16685
2020-08-20 13:12:02 +02:00
Zbigniew Jędrzejewski-Szmek ec673ad4ab
Merge pull request #16559 from benzea/benzea/memory-recursiveprot
mount-setup: Enable memory_recursiveprot for cgroup2
2020-08-20 13:05:07 +02:00
Zbigniew Jędrzejewski-Szmek 0cd9ccb654
Merge pull request #16677 from poettering/statx-mntid
make use of new kernel 5.8 statx() mount id/mountpoint APIs
2020-08-20 10:58:14 +02:00
Zbigniew Jędrzejewski-Szmek a4df0c004a
Merge pull request #16782 from keszybz/seccomp-use-cleanup
Use less iffedeffery around syscall names and _cleanup_ in one more place
2020-08-20 10:27:55 +02:00
brainrom 1fbeddebb1
hwdb: ACCEL_MOUNT_MATRIX for Irbis TW118 (#16786)
This was required to get orientation sensor work properly in my tablet.
2020-08-20 10:23:35 +02:00
Lennart Poettering 3242980582 core: create per-user inaccessible node from the service manager
Previously, we'd create them from user-runtime-dir@.service. That has
one benefit: since this service runs privileged, we can create the full
set of device nodes. It has one major drawback though: it security-wise
problematic to create files/directories in directories as privileged
user in directories owned by unprivileged users, since they can use
symlinks to redirect what we want to do. As a general rule we hence
avoid this logic: only unpriv code should populate unpriv directories.

Hence, let's move this code to an appropriate place in the service
manager. This means we lose the inaccessible block device node, but
since there's already a fallback in place, this shouldn't be too bad.
2020-08-20 10:18:02 +02:00
Lennart Poettering 00e64c6d06 doc: document what we now place in /run/host 2020-08-20 10:17:59 +02:00
Lennart Poettering 0f48ba7b84 nspawn: provide $container and $container_uuid in /run/host too
This has the major benefit that the entire payload of the container can
access these files there. Previously, we'd set them only as env vars,
but that meant only PID 1 could read them directly or other privileged
payload code with access to /run/1/environ.
2020-08-20 10:17:55 +02:00
Lennart Poettering 9fac502920 nspawn,pid1: pass "inaccessible" nodes from cntr mgr to pid1 payload via /run/host
Let's make /run/host the sole place we pass stuff from host to container
in and place the "inaccessible" nodes in /run/host too.

In contrast to the previous two commits this is a minor compat break, but
not a relevant one I think. Previously the container manager would place
these nodes in /run/systemd/inaccessible/ and that's where PID 1 in the
container would try to add them too when missing. Container manager and
PID 1 in the container would thus manage the same dir together.

With this change the container manager now passes an immutable directory
to the container and leaves /run/systemd entirely untouched, and managed
exclusively by PID 1 inside the container, which is nice to have clear
separation on who manages what.

In order to make sure systemd then usses the /run/host/inaccesible/
nodes this commit changes PID 1 to look for that dir and if it exists
will symlink it to /run/systemd/inaccessible.

Now, this will work fine if new nspawn and new pid 1 in the container
work together. as then the symlink is created and the difference between
the two dirs won't matter.

For the case where an old nspawn invokes a new PID 1: in this case
things work as they always worked: the dir is managed together.

For the case where different container manager invokes a new PID 1: in
this case the nodes aren't typically passed in, and PID 1 in the
container will try to create them and will likely fail partially (though
gracefully) when trying to create char/block device nodes. THis is fine
though as there are fallbacks in place for that case.

For the case where a new nspawn invokes an old PID1: this is were the
(minor) incompatibily happens: in this case new nspawn will place the
nodes in the /run/host/inaccessible/ subdir, but the PID 1 in the
container won't look for them there. Since the nodes are also not
pre-created in /run/systed/inaccessible/ PID 1 will try to create them
there as if a different container manager sets them up. This is of
course not sexy, but is not a total loss, since as mentioned fallbacks
are in place anyway. Hence I think it's OK to accept this minor
incompatibility.
2020-08-20 10:17:52 +02:00
Lennart Poettering e96ceabac9 nspawn: move $NOTIFY_SOCKET into /run/host/ too
The sd_notify() socket that nspawn binds that the payload can use to
talk to it was previously stored in /run/systemd/nspawn/notify, which is
weird (as in the previous commit) since this makes /run/systemd
something that is cooperatively maintained by systemd inside the
container and nspawn outside of it.

We now have a better place where container managers can put the stuff
they want to pass to the payload: /run/host/, hence let's make use of
that.

This is not a compat breakage, since the sd_notify() protocol is based
on the $NOTIFY_SOCKET env var, where we place the new socket path.
2020-08-20 10:17:48 +02:00
Lennart Poettering 5a27b39518 nspawn/machine: move mount propagation dir to /run/host/incoming
Previously we'd use a directory /run/systemd/nspawn/incoming for
accepting mounts to propagate from the host. This is a bit weird, since
we have a shared namespace: /run/systemd/ contains both stuff managed by
the surround nspawn as well as from the systemd inside.

We now have the /run/host/ hierarchy that has special stuff we want to
pass from host to container. Let's make use of that here, and move this
directory here too.

This is not a compat breakage, since the payload never interfaces with
that directory natively: it's only nspawn and machined that need to
agree on it.
2020-08-20 10:17:25 +02:00
Zbigniew Jędrzejewski-Szmek 2eecdd1d69
Merge pull request #16790 from poettering/core-if-block-merge
core: merge a few if blocks
2020-08-20 10:15:01 +02:00
Wen Yang abac810b96 basic/virt: treat "pouch" as a container type (id: pouch) 2020-08-20 09:48:13 +02:00
Anita Zhang 174fff9acf
Merge pull request #16792 from poettering/machine-id-chroot
machine-id-setup: don't use KVM or container manager supplied uuid if…
2020-08-19 23:21:56 -07:00
Anita Zhang e3897c1aff
Merge pull request #16793 from poettering/path-join-more
path-lookup: path_join() all the things!
2020-08-19 23:12:50 -07:00
Phaedrus Leeds c2892a244c man: Fix typo in systemd-tmpfiles 2020-08-19 23:44:47 +01:00
Lennart Poettering df778749b4 path-lookup: path_join() all the things!
When we talk about paths, better use path_join(), who knows what callers
pass to us, i.e. prefixed with "/" or not.
2020-08-19 18:28:39 +02:00
Lennart Poettering 1f894e682c machine-id-setup: don't use KVM or container manager supplied uuid if in chroot env
Fixes: #16758
2020-08-19 18:23:11 +02:00
Lennart Poettering 4428c49db9 mount-setup: drop pointless zero initialization 2020-08-19 18:11:00 +02:00
Lennart Poettering 3196e42393 core: merge a few if blocks
arg_system == true and getpid() == 1 hold under the very same condition
this early in the main() function (this only changes later when we start
parsing command lines, where arg_system = true is set if users invoke us
in test mode even when getpid() != 1.

Hence, let's simplify things, and merge a couple of if branches and not
pretend they were orthogonal.
2020-08-19 18:06:12 +02:00
Luca Boccassi 46ad9c5378 systemctl: add --timestamp to change timestamp print format
Timestamps for unit start/stop are recorded with microsecond granularity,
but status and show truncate to second granularity by default.
Add a --timestamp=pretty|us|utc option to allow including the microseconds
or to use the UTC TZ to all timestamps printed by systemctl.
2020-08-19 15:30:13 +01:00
Luca Boccassi 7b3eb5c97e basic/time-util: add function to format timestamps with different styles
Instead of a multiple fixed format helper functions, add an enum and
a single helper, so that it's easier to extend in the future.
2020-08-19 15:30:13 +01:00
Lennart Poettering caf6bd166f homed: default to "btrfs" as fs type in the LUKS backend
Apparently both Fedora and suse default to btrfs now, it should hence be
good enough for us too.

This enables a bunch of really nice things for us, most importanly we
can resize home directories freely (i.e. both grow *and* shrink) while
online. It also allows us to add nice subvolume based home directory
snapshotting later on.

Also, whenever we mention the three supported types, alaways mention
them in alphabetical order, which is also our new order of preference.
2020-08-19 15:46:07 +02:00
Lennart Poettering 1b13600948
Merge pull request #16771 from poettering/dyn-pwq
make libpwquality a dlopen() dependency + use it in systemd-firstboot, too
2020-08-19 15:40:41 +02:00
Zbigniew Jędrzejewski-Szmek 843ce053b4
Merge pull request #16762 from poettering/homed-fixlets
homed: five fixlets
2020-08-19 11:43:49 +02:00
Benjamin Berg 29bb3d7fc4 man: Improve MemoryMin=/MemoryLow= description
The description didn't really explain how the distribution mechanism
works exactly and the relationship of leaf and slice units.

Update the documentation and also explicitly explain the expected
behaviour as it is created by the memory_recursiveprot cgroup2 mount
option.
2020-08-19 11:17:02 +02:00
Benjamin Berg 56f47800d8 mount-setup: Enable memory_recursiveprot for cgroup2
When available, enable memory_recursiveprot. Realistically it always
makes sense to delegate MemoryLow= and MemoryMin= to all children of a
slice/unit.

The kernel option is not enabled by default as it might cause
regressions in some setups. However, it is the better default in
general, and it results in a more flexible and obvious behaviour.

The alternative to using this option would be for user's to also set
DefaultMemoryLow= on slices when assigning MemoryLow=. However, this
makes the effect of MemoryLow= on some children less obvious, as it
could result in a lower protection rather than increasing it.

From the kernel documentation:

  memory_recursiveprot

        Recursively apply memory.min and memory.low protection to
        entire subtrees, without requiring explicit downward
        propagation into leaf cgroups.  This allows protecting entire
        subtrees from one another, while retaining free competition
        within those subtrees.  This should have been the default
        behavior but is a mount-option to avoid regressing setups
        relying on the original semantics (e.g. specifying bogusly
        high 'bypass' protection values at higher tree levels).

This was added in kernel commit 8a931f801340c (mm: memcontrol:
recursive memory.low protection), which became available in 5.7 and was
subsequently fixed in kernel 5.7.7 (mm: memcontrol: handle div0 crash
race condition in memory.low).
2020-08-19 11:17:01 +02:00
Zbigniew Jędrzejewski-Szmek b4eaa6cc99 shared/seccomp: use _cleanup_ in one more place
(cherry picked from commit 27605d6a836d85563faf41db9f7a72883d44c0ff)
2020-08-19 10:57:30 +02:00
Zbigniew Jędrzejewski-Szmek 6da432fd54 shared/seccomp: do not use ifdef guards around textual syscall names
It is possible that we will be running with an upgraded libseccomp, in which
case libseccomp might know the syscall name, even if the number is not known at
the time when systemd is being compiled. The guard only serves to break such
upgrades, by requiring that we also recompile systemd.

For s390-specific syscalls, use a define to exclude them, so that that we don't
try to filter them on other arches.

(cherry picked from commit 6cf852e79eb0eced2f77653941f9c75c3bd79386)
2020-08-19 10:57:18 +02:00
Lennart Poettering b0073a017b
Merge pull request #16640 from keszybz/various-patches
Improve systemd-analyze security a bit and other assorted bits
2020-08-19 10:30:45 +02:00
Anita Zhang e71f5585b9 meson: add min version for libfdisk
Was trying to run src/partition/test-repart.sh on CentOS 8 and the first
resize call kept failing with ERANGE. Turned out that CentOS 8 comes
with libfdisk-devel-2.32.1 which is missing
2f35c1ead6
(in libfdisk 2.33 and up).
2020-08-19 10:18:33 +02:00
Lennart Poettering 8609bb80dd update TODO 2020-08-19 10:08:33 +02:00
Lennart Poettering 5f10408044 mountpoint-util: use new kernel 5.8 statx() API for determining mount points
We finally have an explicit API for this in the kernel. It's great and
simple. Let's use it!
2020-08-19 10:08:29 +02:00
Lennart Poettering 69b3fa14cd mountpoint-util: use new kernel 5.8 statx() API for determining mnt_id
The kernel finally has a proper API to determine the mnt_id of a file.
Let's use it.

This adds support for the STATX_MNT_ID field of statx(), added in
kernel 5.8.
2020-08-19 10:08:24 +02:00
Lennart Poettering ffaf45e4f3 mountpoint-util: minor modernizations 2020-08-19 10:07:49 +02:00
Lennart Poettering 4d89db12fc update TODO 2020-08-19 10:04:08 +02:00
Lennart Poettering 7baf10a7be firstboot: hook up with libpwquality 2020-08-19 10:03:56 +02:00
Lennart Poettering 679badd7ba home: make libpwquality dep a runtime dlopen() one
Also, let's move the glue for this to src/shared/ so that we later can
reuse this in sysemd-firstboot.

Given that libpwquality is a more a leaf dependency, let's make it
runtime optional, so that downstream distros can downgrade their package
deps from Required to Recommended.
2020-08-19 10:03:24 +02:00
Anita Zhang 9c23ce7363
Merge pull request #16780 from alyssais/grammar
load-fragment: fix grammar in error messages
2020-08-18 22:41:34 -07:00