Commit Graph

4847 Commits

Author SHA1 Message Date
Yu Watanabe 01234e1fe7 tree-wide: drop several missing_*.h and import relevant headers from kernel-5.0 2019-04-11 19:00:37 +02:00
Lennart Poettering aa46c28418
Merge pull request #12153 from benjarobin/killall-show-not-killed
shutdown/killall: Show in the console the processes not yet killed
2019-04-11 18:58:43 +02:00
Lennart Poettering 54f802ff8a
Merge pull request #12037 from poettering/oom-state
add cgroupv2 oom killer event handling to service management
2019-04-11 18:57:47 +02:00
Lennart Poettering 4ff9bc2ea6 tree-wide: port users over to use new ERRNO_IS_ACCEPT_AGAIN() call 2019-04-10 22:11:18 +02:00
Benjamin Robin 763e7b5da6 core/killall: Add documentation about broadcast_signal() 2019-04-10 19:30:38 +02:00
Benjamin Robin 2c32f4f47d core/killall: Log the process names not killed after 10s 2019-04-10 19:27:38 +02:00
Lennart Poettering afcfaa695c core: implement OOMPolicy= and watch cgroups for OOM killings
This adds a new per-service OOMPolicy= (along with a global
DefaultOOMPolicy=) that controls what to do if a process of the service
is killed by the kernel's OOM killer. It has three different values:
"continue" (old behaviour), "stop" (terminate the service), "kill" (let
the kernel kill all the service's processes).

On top of that, track OOM killer events per unit: generate a per-unit
structured, recognizable log message when we see an OOM killer event,
and put the service in a failure state if an OOM killer event was seen
and the selected policy was not "continue". A new "result" is defined
for this case: "oom-kill".

All of this relies on new cgroupv2 kernel functionality: the
"memory.events" notification interface and the "memory.oom.group"
attribute (which makes the kernel kill all cgroup processes
automatically).
2019-04-09 11:17:58 +02:00
Lennart Poettering a5b5aece01 service: beautify debug log message a bit 2019-04-09 11:17:58 +02:00
Lennart Poettering 0bb814c2c2 core: rename cgroup_inotify_wd → cgroup_control_inotify_wd
Let's rename the .cgroup_inotify_wd field of the Unit object to
.cgroup_control_inotify_wd. Let's similarly rename the hashmap
.cgroup_inotify_wd_unit of the Manager object to
.cgroup_control_inotify_wd_unit.

Why? As preparation for a later commit that allows us to watch the
"memory.events" cgroup attribute file in addition to the "cgroup.events"
file we already watch with the fields above. In that later commit we'll
add new fields "cgroup_memory_inotify_wd" to Unit and
"cgroup_memory_inotify_wd_unit" to Manager, that are used to watch these
other events file.

No change in behaviour. Just some renaming.
2019-04-09 11:17:57 +02:00
Lennart Poettering 5210387ea6 core: check for redundant operation before doing allocation 2019-04-09 11:17:57 +02:00
Lennart Poettering cbe83389d5 core: rearrange cgroup empty events a bit
So far the priorities for cgroup empty event handling were pretty weird.
The raw events (on cgroupsv2 from inotify, on cgroupsv1 from the agent
dgram socket) where scheduled at a lower priority than the cgroup empty
queue dispatcher. Let's swap that and ensure that we can coalesce events
more agressively: let's process the raw events at higher priority than
the cgroup empty event (which remains at the same prio).
2019-04-09 11:17:57 +02:00
Zbigniew Jędrzejewski-Szmek 9d1b2b2252 pid1,shutdown: do not cunescape paths from libmount
The test added in previous commit shows that libmount does the unescaping
internally.
2019-04-09 09:07:40 +02:00
Benjamin Robin a012f9f7cf core/killall: Propagate errors and return the number of process left 2019-04-08 19:41:16 +02:00
Zbigniew Jędrzejewski-Szmek fb36b1339b shared: add a single definition of libmount cleanup functions
Use a trivial header file to share mnt_free_tablep and mnt_free_iterp.
It would be nicer put this in mount-util.h, but libmount.h is not in the
default include path, and the build system would have to be adjusted to pass
pkg-config include path in various places, and it's just not worth the trouble.
A separate header file works nicely.
2019-04-05 10:18:21 +02:00
Zbigniew Jędrzejewski-Szmek 58f6ab4454 pid1: pass unit name to seccomp parser when we have no file location
Building on previous commit, let's pass the unit name when parsing
dbus message or builtin whitelist, which is better than nothing.

seccomp_parse_syscall_filter() is not needed anymore, so it is removed,
and seccomp_parse_syscall_filter_full() is renamed to take its place.
2019-04-03 09:17:42 +02:00
Zbigniew Jędrzejewski-Szmek e7ccdfa809 core: use a temporary variable for calculation of seccomp flags
I think it is easier to read this way.
2019-04-03 08:56:06 +02:00
Davide Cavalca 639dd43a36 core: fix build failure if seccomp is disabled 2019-04-03 13:46:32 +09:00
Lennart Poettering b2b33eb064 Revert "build: install /etc/systemd/{system,user}-generators"
This reverts commit 509276f2b7.
2019-04-02 21:09:35 +02:00
Lennart Poettering bf65b7e0c9 core: imply NNP and SUID/SGID restriction for DynamicUser=yes service
Let's be safe, rather than sorry. This way DynamicUser=yes services can
neither take benefit of, nor create SUID/SGID binaries.

Given that DynamicUser= is a recent addition only we should be able to
get away with turning this on, even though this is strictly speaking a
binary compatibility breakage.
2019-04-02 16:56:48 +02:00
Lennart Poettering f69567cbe2 core: expose SUID/SGID restriction as new unit setting RestrictSUIDSGID= 2019-04-02 16:56:48 +02:00
Lennart Poettering 42561fc99c core: add a generic helper that forwards per-unit method calls from Manager
Quite often we have a method DoSomethingWithUnit() on the Manager object
that is the same as a function DoSomething() on a Unit object. Let's
shorten things by introducing a common function that forwards the
former to the latter, instead of writing this again and again.
2019-04-02 16:38:20 +02:00
Zbigniew Jędrzejewski-Szmek 237ebf61e2
Merge pull request #12013 from yuwata/fix-switchroot-11997
core: on switching root do not emit device state change based on enumeration results
2019-04-02 16:06:07 +02:00
Lennart Poettering efebb613c7 core: optionally, trigger .timer units on timezone and clock changes
Fixes: #6228
2019-04-02 08:20:10 +02:00
Lennart Poettering 7dd1e315b2 core: use more structured initialization 2019-04-02 08:19:35 +02:00
Topi Miettinen 509276f2b7 build: install /etc/systemd/{system,user}-generators
Manual page systemd.generators refers to /etc/systemd/{system,user}-generators,
but the paths do not exist, so let's install them.
2019-04-02 07:53:32 +02:00
Lennart Poettering ca006fc640 core: refactor transaction.c to use fewer gotos
In particular, let's not use gotos that jump up, i.e. are loops. gotos
that jump down for the purpose of clean-up are cool, but using them for
loops is evil.

No change in behaviour, just some refactoring.
2019-04-02 07:28:58 +09:00
Lennart Poettering ebf8d79a58 core: export ReloadResult value on the bus
We keep track of it, but never exposed it. Let's fix that.
2019-04-02 05:39:05 +09:00
Lennart Poettering 4659bf6f76 core: add a common function for bus calls that return unit dbus path
Let's shorten the code a bit by using a single function for similar
cases.

No change in behaviour, just some refactoring and shortening.
2019-04-02 05:34:03 +09:00
Lennart Poettering dc44c96d97 core: pass parse error to log functions when parsing timer expressions 2019-04-01 18:25:43 +02:00
Lennart Poettering 25a04ae55e core: simply timer expression parsing by using ".ltype" field of conf-parser logic
No change of behaviour. Let's just not parse the lvalue all the time
with timer_base_from_string() if we can already pass it in parsed.
2019-04-01 18:25:43 +02:00
Zbigniew Jędrzejewski-Szmek d923021aeb
Merge pull request #12048 from jengelh/master
rpm: avoid hiding errors from systemd commands
2019-03-29 22:27:31 +01:00
Zbigniew Jędrzejewski-Szmek 983616735e
Merge pull request #12137 from poettering/socket-var-run
warn about sockets in /var/run/ too
2019-03-29 15:00:25 +01:00
Zbigniew Jędrzejewski-Szmek 2818ddc8f4
Merge pull request #12133 from poettering/rseq-whitelist
whitelist rseq() system call in `@default` syscall group
2019-03-29 14:59:00 +01:00
Lennart Poettering 4a66b5c9bf core: complain and correct /var/run/ → /run/ for listening sockets
We already do that for PIDFile= paths, and for tmpfiles.d/ snippets,
let's also do this for .socket paths.
2019-03-28 16:59:57 +01:00
Lennart Poettering 7d2c9c6b50 load-fragment: use TAKE_PTR() where we can 2019-03-28 16:46:27 +01:00
Lennart Poettering e8413b651b
Merge pull request #12130 from keszybz/fix-ndebug-builds
Fix ndebug builds
2019-03-28 15:52:27 +01:00
Lennart Poettering acd142af79 core: break overly long line 2019-03-28 12:09:38 +01:00
Lennart Poettering 2f6b9110fc core: parse '@default' seccomp group permissively
We are about to add system calls (rseq()) not available on old
libseccomp/old kernels, and hence we need to be permissive when parsing
our definitions.
2019-03-28 12:09:38 +01:00
Zbigniew Jędrzejewski-Szmek c6335c3b51
Merge pull request #12115 from poettering/verbose-job-enqueue
add "systemctl --show-transaction start" as a more verbose "systemctl start" that shows enqueued jobs
2019-03-28 11:04:26 +01:00
Zbigniew Jędrzejewski-Szmek ee36fed438 core: avoid unnecessary cast 2019-03-28 09:45:19 +01:00
Lennart Poettering 0a6991e0bb tree-wide: reorder various structures to make them smaller and use fewer cache lines
Some "pahole" spelunking.
2019-03-27 18:11:11 +01:00
Lennart Poettering 6990fb6bc6 tree-wide: (void)ify a few unlink() and rmdir()
Let's be helpful to static analyzers which care about whether we
knowingly ignore return values. We do in these cases, since they are
usually part of error paths.
2019-03-27 18:09:56 +01:00
Zbigniew Jędrzejewski-Szmek 330b8fb379 journalctl: voidify mkdir_p() call and unify two similar code paths
Let's unify the two similar code paths to watch /run/systemd/journal.
The code in manager.c is similar, but it uses mkdir_p_label(), and unifying
that would be too much trouble, so let's just adjust the error messages to
be the same.

CID #1400224.
2019-03-27 13:01:44 +01:00
Lennart Poettering 50cbaba4fe core: add new API for enqueing a job with returning the transaction data 2019-03-27 12:37:37 +01:00
Zbigniew Jędrzejewski-Szmek 6e5dcce4b1 Voidify more mkdir_p calls 2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek e1af3bc62a
Merge pull request #12106 from poettering/nosuidns
add "nosuid" flag to exec directory mounts of DynamicUser=1 services
2019-03-26 08:58:00 +01:00
Lennart Poettering 607b358ef2 core: drop suid/sgid bit of files/dirs when doing recursive chown
This adds some extra paranoia: when we recursively chown a directory for
use with DynamicUser=1 services we'll now drop suid/sgid from all files
we chown().

Of course, such files should not exist in the first place, and noone
should get access to those dirs who isn't root anyway, but let's better
be safe than sorry, and drop everything we come across.
2019-03-26 08:29:37 +01:00
Lennart Poettering 9ce4e4b0f6 namespace: when DynamicUser=1 is set, mount StateDirectory= bind mounts "nosuid"
Add even more suid/sgid protection to DynamicUser= envionments: the
state directories we bind mount from the host will now have the nosuid
flag set, to disable the effect of nosuid on them.
2019-03-25 19:57:15 +01:00
Lennart Poettering 64e82c1976 mount-util: beef up bind_remount_recursive() to be able to toggle more than MS_RDONLY
The function is otherwise generic enough to toggle other bind mount
flags beyond MS_RDONLY (for example: MS_NOSUID or MS_NODEV), hence let's
beef it up slightly to support that too.
2019-03-25 19:33:55 +01:00