Commit Graph

39624 Commits

Author SHA1 Message Date
Franck Bui 63f28cad3e tmpfiles: split tmp.conf out
tmp.conf was dealing with 2 different kind of paths: one dealing with general
temporary paths such as /var/tmp and /tmp and the other one dealing with
temporary directories owned by systemd.

If for example a user wants to adjust the age argument of the general paths
only, he had to overload the whole file which is cumbersome and error prone
since any future changes in tmp.conf shipped by systemd will be lost.

So this patch splits out tmp.conf so the systemd directories are dealt
separately in a dedicated conf file. It's named "systemd-tmp.conf" based on the
naming recommendation made in tmpfiles.d man page.

In practice it shouldn't cause any regression since it's very unlikely that
users override paths owned by systemd.
2019-04-13 12:07:03 +02:00
Dominick Grift 8f1ed04ad6 nspawn: Fix volatile SELinux label
nspawn should associate the specified nspawn container apifs object label instead of the nspawn container process label with the volatile tmpfs
2019-04-13 12:03:02 +02:00
Yu Watanabe cc83684947
Merge pull request #12296 from poettering/coding-style-sections
split CODING_STYLE document into multiple thematic sections
2019-04-13 18:23:13 +09:00
Yu Watanabe eeda619a1e
Merge pull request #12290 from poettering/json-foreach-love
some small JSON foreach macro love
2019-04-13 18:19:38 +09:00
Yu Watanabe c12e138f21
Merge pull request #12293 from poettering/tiny-journal-modernizations
four simple journal modernizations
2019-04-13 18:19:15 +09:00
Jan Klötzke dc653bf487 service: handle abort stops with dedicated timeout
When shooting down a service with SIGABRT the user might want to have a
much longer stop timeout than on regular stops/shutdowns. Especially in
the face of short stop timeouts the time might not be sufficient to
write huge core dumps before the service is killed.

This commit adds a dedicated (Default)TimeoutAbortSec= timer that is
used when stopping a service via SIGABRT. In all other cases the
existing TimeoutStopSec= is used. The timer value is unset by default
to skip the special handling and use TimeoutStopSec= for state
'stop-watchdog' to keep the old behaviour.

If the service is in state 'stop-watchdog' and the service should be
stopped explicitly we still go to 'stop-sigterm' and re-apply the usual
TimeoutStopSec= timeout.
2019-04-12 17:32:52 +02:00
Sebastian Jennen 1ace223ca7 code style format: clang-format applied to src/a*/*
[zj: this is a subset of changes generated by clang-format, just the ones
  I think improve readability or consistency.]

This is a part of https://github.com/systemd/systemd/pull/11811.
2019-04-12 17:26:33 +02:00
Chris Down c52db42b78 cgroup: Implement default propagation of MemoryLow with DefaultMemoryLow
In cgroup v2 we have protection tunables -- currently MemoryLow and
MemoryMin (there will be more in future for other resources, too). The
design of these protection tunables requires not only intermediate
cgroups to propagate protections, but also the units at the leaf of that
resource's operation to accept it (by setting MemoryLow or MemoryMin).

This makes sense from an low-level API design perspective, but it's a
good idea to also have a higher-level abstraction that can, by default,
propagate these resources to children recursively. In this patch, this
happens by having descendants set memory.low to N if their ancestor has
DefaultMemoryLow=N -- assuming they don't set a separate MemoryLow
value.

Any affected unit can opt out of this propagation by manually setting
`MemoryLow` to some value in its unit configuration. A unit can also
stop further propagation by setting `DefaultMemoryLow=` with no
argument. This removes further propagation in the subtree, but has no
effect on the unit itself (for that, use `MemoryLow=0`).

Our use case in production is simplifying the configuration of machines
which heavily rely on memory protection tunables, but currently require
tweaking a huge number of unit files to make that a reality. This
directive makes that significantly less fragile, and decreases the risk
of misconfiguration.

After this patch is merged, I will implement DefaultMemoryMin= using the
same principles.
2019-04-12 17:23:58 +02:00
Lennart Poettering b4f12824a0 CODING_STYLE: rename "Others" section to "Code Organization and Semantics"
This is a bit of a grabbag, but it's the best I could come up with
without having lots of single-item sections.
2019-04-12 17:01:05 +02:00
Lennart Poettering 4467d39315 CODING_STYLE: split out section about runtime behaviour 2019-04-12 16:59:48 +02:00
Lennart Poettering 78e5b4d7ee CODING_STYLE: add section about C constructs use 2019-04-12 16:53:27 +02:00
Lennart Poettering 3b75e079a8 CODING_STYLE: split out section about deadlocks 2019-04-12 16:50:24 +02:00
Lennart Poettering 96f6cfbf62 CODING_STYLE: split out section about logging 2019-04-12 16:49:02 +02:00
Lennart Poettering 5638076135 CODING_STYLE: export section about exporting symbols 2019-04-12 16:45:03 +02:00
Lennart Poettering c159efe341 CODING_STYLE: split out section about destructors 2019-04-12 16:42:44 +02:00
Lennart Poettering 996f119d97 CODING_STYLE: split out section about command line parsing 2019-04-12 16:40:34 +02:00
Lennart Poettering b065e1f176 CODING_STYLE: Split out section about error handling 2019-04-12 16:38:14 +02:00
Lennart Poettering 831781b9c9 CODING_STYLE: split out section about commiting to git 2019-04-12 16:35:17 +02:00
Lennart Poettering 25553cd9cd CODING_STYLE: split out section about file descriptors 2019-04-12 16:34:01 +02:00
Lennart Poettering 0485824030 CODING_STYLE: split out section about memory allocations 2019-04-12 16:31:58 +02:00
Lennart Poettering f42c1cd4b5 CODING_STYLE: move out section about Types 2019-04-12 16:28:35 +02:00
Lennart Poettering 971dfffab8 CODING_STYLE: add section about how to reference specific concepts 2019-04-12 16:28:35 +02:00
Lennart Poettering 8c9289e705 CODING_STYLE: split out bits about Formatting into its own section
(And, for now, add a section "Other" to separate the rest of the stuff)
2019-04-12 16:28:35 +02:00
Lennart Poettering 2d0dce2afe CODING_STYLE: add a section about functions not to use
Let's add sections to the document. First off, let's add one about
functions not to use.
2019-04-12 16:28:02 +02:00
Lennart Poettering e3d36a8da3 journald: modernize config_parse_compress() a bit 2019-04-12 14:23:12 +02:00
Lennart Poettering 337fabf749 journald: rebreak a few comments 2019-04-12 14:23:12 +02:00
Lennart Poettering e3d78cb160 journald: no need to check ptr for non-NULL before _unref(), as function does that anyway 2019-04-12 14:23:12 +02:00
Lennart Poettering e4d9c98512 journald: use structure initialization 2019-04-12 14:23:08 +02:00
Lennart Poettering b51629ad84
Merge pull request #12222 from yuwata/macsec
network: introduce MACsec
2019-04-12 13:59:30 +02:00
Lennart Poettering 3661dc349e
Merge pull request #12217 from keszybz/unlocked-operations
Refactor how we do unlocked file operations
2019-04-12 13:51:53 +02:00
Lennart Poettering 1b266e3c6f json: be more careful when iterating through a JSON object/array
Let's exit the loop early in case the variant is not actually an object
or array. This is safer since otherwise we might end up iterating
through these variants and access fields that aren't of the type we
expect them to be and then bad things happen.

Of course, this doesn't absolve uses of these macros to check the type
of the variant explicitly beforehand, but it makes it less bad if they
forget to do so.
2019-04-12 13:11:11 +02:00
Lennart Poettering 33d60b8d57 json: simplify JSON_VARIANT_OBJECT_FOREACH() macro a bit
There's no point in returning the "key" within each loop iteration as
JsonVariant object. Let's simplify things and return it as string. That
simplifies usage (since the caller doesn't have to convert the object to
the string anymore) and is safe since we already validate that keys are
strings when an object JsonVariant is allocated.
2019-04-12 13:11:11 +02:00
Zbigniew Jędrzejewski-Szmek 15de23a0b2
Merge pull request #12289 from poettering/news-pid-max
NEWS: explain the kernel.pid_max sysctl change
2019-04-12 12:12:18 +02:00
Lennart Poettering 6af9058324 NEWS: document kernel.pid_max change 2019-04-12 12:01:41 +02:00
Lennart Poettering 39e445c95d NEWS: fix typo 2019-04-12 12:01:23 +02:00
Zbigniew Jędrzejewski-Szmek 673a1e6fb9 Add fmemopen_unlocked() and use unlocked ops in fuzzers and some other tests
This might make things marginially faster. I didn't benchmark though.
2019-04-12 11:44:57 +02:00
Zbigniew Jędrzejewski-Szmek 2fe21124a6 Add open_memstream_unlocked() wrapper 2019-04-12 11:44:57 +02:00
Zbigniew Jędrzejewski-Szmek b636d78aee core/smack-setup: add helper function for openat+fdopen
Unlocked operations are used in all three places. I don't see why just one was
special.

This also improves logging, since we don't just log the final component of the
path, but the full name.
2019-04-12 11:44:57 +02:00
Zbigniew Jędrzejewski-Szmek 02e23d1a1a Add fdopen_unlocked() wrapper 2019-04-12 11:44:57 +02:00
Zbigniew Jędrzejewski-Szmek 41f6e627d7 Make fopen_temporary and fopen_temporary_label unlocked
This is partially a refactoring, but also makes many more places use
unlocked operations implicitly, i.e. all users of fopen_temporary().
AFAICT, the uses are always for short-lived files which are not shared
externally, and are just used within the same context. Locking is not
necessary.
2019-04-12 11:44:56 +02:00
Zbigniew Jędrzejewski-Szmek fdeea3f4f1 Add fopen_unlocked() wrapper 2019-04-12 11:44:52 +02:00
Lennart Poettering 25f31130f3
Merge pull request #12221 from keszybz/test-cleanups
Script indentation cleanups
2019-04-12 11:02:54 +02:00
Lennart Poettering d34f7bd247
Merge pull request #12287 from keszybz/patches-for-coverity-warnings
Patches for coverity warnings
2019-04-12 10:56:53 +02:00
Anita Zhang 7bc5e0b12b seccomp: check more error codes from seccomp_load()
We noticed in our tests that occasionally SystemCallFilter= would
fail to set and the service would run with no syscall filtering.
Most of the time the same tests would apply the filter and fail
the service as expected. While it's not totally clear why this happens,
we noticed seccomp_load() in the systemd code base would fail open for
all errors except EPERM and EACCES.

ENOMEM, EINVAL, and EFAULT seem like reasonable values to add to the
error set based on what I gather from libseccomp code and man pages:

-ENOMEM: out of memory, failed to allocate space for a libseccomp structure, or would exceed a defined constant
-EINVAL: kernel isn't configured to support the operations, args are invalid (to seccomp_load(), seccomp(), or prctl())
-EFAULT: addresses passed as args are invalid
2019-04-12 10:23:07 +02:00
Zbigniew Jędrzejewski-Szmek 17e4b07088 core: vodify one more call to mkdir
CID #1400460.
2019-04-12 09:05:02 +02:00
Zbigniew Jędrzejewski-Szmek 04193fb2ae test-exec-util: do not call setenv with NULL arg
The comment explains that $PATH might not be set in certain circumstances and
takes steps to handle this case. If we do that, let's assume that $PATH indeed
might be unset and not call setenv("PATH", NULL, 1). It is not clear from the
man page if that is allowed.

CID #1400497.
2019-04-12 09:05:02 +02:00
Zbigniew Jędrzejewski-Szmek 1890c53892 test-env-util: allow $PATH to be unset
Coverity was unhappy, because it doesn't know that $PATH is pretty much always
set. But let's not assume that in the test. CID #1400496.

$ (unset PATH; build/test-env-util)
[1]    31658 segmentation fault (core dumped)  ( unset PATH; build/test-env-util; )
2019-04-12 09:05:02 +02:00
Zbigniew Jędrzejewski-Szmek 3b69b18fbf CODING_STYLE: adjust indentation rules, and add note about config loading 2019-04-12 08:37:41 +02:00
Zbigniew Jędrzejewski-Szmek c1072f6473 shell-completion/zsh: add -*type*- headers
Since there's no file extension, emacs and other editors do not know that this is
supposed to be in shell syntax.
2019-04-12 08:36:18 +02:00
Zbigniew Jędrzejewski-Szmek 843cfcb15c shell-completion: use 4 space indentation too
The same as in other places, indentation levels were all over the place.
2019-04-12 08:34:44 +02:00