Commit graph

39728 commits

Author SHA1 Message Date
Yu Watanabe 6ff79f7640 resolve: rename Link.name -> Link.ifname
This also changes the type from char[IF_NAMESIZE] to char*.
By changing the type, now resolved-link.h can drop the dependency to
the header net/if.h.
2019-04-13 17:51:59 +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 7a5de3f951 systemctl: show IO stats in 'status' output 2019-04-12 14:25:44 +02:00
Lennart Poettering 826f7cb15b run: show IO stats in --wait resource output 2019-04-12 14:25:44 +02:00
Lennart Poettering bc40a20ebe core: include IO data in per-unit resource log msg 2019-04-12 14:25:44 +02:00
Lennart Poettering fbe14fc9a7 croup: expose IO accounting data per unit
This was the last kind of accounting still not exposed on for each unit.
Let's fix that.

Note that this is a relatively simplistic approach: we don't expose
per-device stats, but sum them all up, much like cgtop does. This kind
of metric is probably the most interesting for most usecases, and covers
the "systemctl status" output best. If we want per-device stats one day
we can of course always add that eventually.
2019-04-12 14:25:44 +02:00
Lennart Poettering 83f18c91d0 core: use string_table_lookup() at more places 2019-04-12 14:25:44 +02:00
Lennart Poettering 9b2559a13e core: add new call unit_reset_accounting()
It's a simple wrapper for resetting both IP and CPU accounting in one
go.

This will become particularly useful when we also needs this to reset IO
accounting (to be added in a later commit).
2019-04-12 14:25:44 +02:00
Lennart Poettering cc6625212f core: no need to initialize ip_accounting twice 2019-04-12 14:25:44 +02:00
Lennart Poettering 0bbff7d638 cgroup: get rid of a local variable 2019-04-12 14:25:44 +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