Commit Graph

3581 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek cc5549ca12 scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)

Also remove the few vim config lines that were left. We should either have them
on all files, or none.

Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-12 08:30:31 +02:00
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 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 3b21fd06ed
Merge pull request #12219 from keszybz/bootctl-check-entries
bootctl: check entries when showing them
2019-04-11 18:57:18 +02:00
Zbigniew Jędrzejewski-Szmek 74b45889e4
Merge pull request #12252 from keszybz/libmount-dont-unescape
Don't unescape paths from libmount
2019-04-09 11:56:52 +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
Yu Watanabe daa4aca1cb calendarspec: fix possible integer overflow
Fixes oss-fuzz#14108.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14108
2019-04-08 00:50:07 +09:00
Yu Watanabe fb3ba5ec11 calendarspec: use _cleanup_ attributes for CalendarComponent 2019-04-08 00:50:02 +09:00
Yu Watanabe 9eef82e5a8 calendarspec: rename free_chain() to chain_free() 2019-04-08 00:21:37 +09:00
Yu Watanabe 4122b14b3a calendarspec: use structured initializers 2019-04-08 00:18:54 +09:00
Lennart Poettering 9f717d42cb meson: sort source files again 2019-04-05 16:58:30 +02:00
Zbigniew Jędrzejewski-Szmek 7f42be65b9 bootspec: remove now-unused boot_entry_type_table 2019-04-05 13:50:45 +02:00
Zbigniew Jędrzejewski-Szmek ce4c4f8108 bootctl: replace "type" with "source" in output
I think this is more useful (because it's easy to stick the path into an editor command
when one wants to change the options or inspect the files), and more self-explanatory.

Example output:
        title: Fedora 30 (Workstation Edition) (4.20.16-200.fc29.x86_64)
           id: 08a5690a2eed47cf92ac0a5d2e3cf6b0-4.20.16-200.fc29.x86_64
       source: /boot/efi/loader/entries/08a5690a2eed47cf92ac0a5d2e3cf6b0-4.20.16-200.fc29.x86_64.conf
      version: 4.20.16-200.fc29.x86_64
          ...

        title: Fedora 30 (Workstation Edition)
           id: fedora-30
       source: /boot/efi/EFI/Linux/linux-5.0.5-300.fc30.x86_64-08a5690a2eed47cf92ac0a5d2e3cf6b0.efi
        linux: EFI/Linux/linux-5.0.5-300.fc30.x86_64-08a5690a2eed47cf92ac0a5d2e3cf6b0.efi
          ...

        title: Reboot Into Firmware Interface
           id: auto-reboot-to-firmware-setup
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
2019-04-05 13:50:34 +02:00
Zbigniew Jędrzejewski-Szmek 74b3e52b99 efivars: add helper to format efivarfs path 2019-04-05 13:50:12 +02:00
Zbigniew Jędrzejewski-Szmek bd44566c4d tree-wide: use SD_ID128_UUID_FORMAT_STR as appropriate 2019-04-05 13:48:38 +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
Yu Watanabe 8c69fe79df bus-util: treat org.freedesktop.DBus.Error.ServiceUnknown nicely when polkit does not exist
Fixes #12209.
2019-04-04 08:06:04 +02:00
Yu Watanabe ad2d50f840
Merge pull request #12208 from poettering/base-file-system-tweaks
base-filesystem: be nicer to read-only fs images
2019-04-04 13:05:12 +09:00
Lennart Poettering fc40bfa7e2 udev-util: allocate an event loop of our own for waiting
We can't use the per-thread default one here, as it might already be
running (for example, that's the case in portabled), and our event loops
are not recursive, hence running them a second time is not OK.
2019-04-04 02:15:14 +09:00
Lennart Poettering 8258578fb1 shared: be friendly to EROFS images
There are environments where /lib might not be necessary (think:
statically compiled portable service binary), hence don't insist on it
if the image is read-only.
2019-04-03 17:27:20 +02:00
Lennart Poettering 65290fbf3f shared: path_join() is your friend 2019-04-03 17:27:20 +02:00
Lennart Poettering 8a383bf2c0 shared: no need to initialize variable 2019-04-03 17:27:19 +02:00
Zbigniew Jędrzejewski-Szmek b3e8032bb4
Merge pull request #12198 from keszybz/seccomp-parsing-logging
Seccomp parsing logging cleanup
2019-04-03 17:19:14 +02:00
Zbigniew Jędrzejewski-Szmek da4dc9a674 seccomp: rework how the S[UG]ID filter is installed
If we know that a syscall is undefined on the given architecture, don't
even try to add it.

Try to install the filter even if some syscalls fail. Also use a helper
function to make the whole a bit less magic.

This allows the S[UG]ID test to pass on arm64.
2019-04-03 13:33:06 +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
Yu Watanabe 33ca308f38
Merge pull request #12188 from poettering/coccinelle-fixlets
tree-wide: let's run coccinelle again
2019-04-03 01:46:54 +09:00
Lennart Poettering f69567cbe2 core: expose SUID/SGID restriction as new unit setting RestrictSUIDSGID= 2019-04-02 16:56:48 +02:00
Lennart Poettering 3c27973b13 seccomp: introduce seccomp_restrict_suid_sgid() for blocking chmod() for suid/sgid files 2019-04-02 16:56:48 +02:00
Lennart Poettering 9e6e543c17 seccomp: add debug messages to seccomp_protect_hostname() 2019-04-02 16:56:48 +02:00
Lennart Poettering 02dab76e93 json: use SYNTHETIC_ERRNO() where appropriate 2019-04-02 14:54:42 +02:00
Lennart Poettering 0c21dafb54 util-lib: use FLAGS_SET() where appropriate 2019-04-02 14:54:38 +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
Yu Watanabe 3f8f021541
Merge pull request #12030 from poettering/condition-memory
add ConditionCPUs= + ConditionMemory=
2019-04-02 08:01:42 +09:00
Lennart Poettering c25c118710 shared: add some minor comments 2019-04-02 05:34:53 +09:00
Yu Watanabe 18268197fa bootspec: fix memleak caused by setting invalid cleanup function 2019-03-31 23:31:29 +09:00
Yu Watanabe 7226337574 bootspec: add missing free() in boot_config_free() 2019-03-31 23:30:30 +09:00
Zbigniew Jędrzejewski-Szmek 6ea07d4fb4
Merge pull request #12140 from poettering/copy-early
chattr/copy.c fixes
2019-03-29 15:02:50 +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 8a016c746e util-lib: when copying files make sure to apply some chattrs early, some late
Some chattrs only work sensible if you set them right after opening a
file for create (think: FS_NOCOW_FL). Others only work when they are
applied when the file is fully written (think: FS_IMMUTABLE_FL). Let's
take that into account when copying files and applying a chattr to them.
2019-03-28 18:43:04 +01:00
Lennart Poettering 6fee3be0b4 seccomp: add rseq() to default list of syscalls to whitelist
Apparently glibc is going to call this implicitly soon, hence let's
whitelist this by default.

Fixes: #12127
2019-03-28 12:09:38 +01:00
Zbigniew Jędrzejewski-Szmek 10c353e1c5 Remove variable only used for an assert
When compiled with -DNDEBUG, we get warnings about set-but-unused variables.
In general, it's not something we care about, but since removing those
variables arguably makes the code nicer, let's just to it in this case.
2019-03-28 09:03:06 +01:00
Lennart Poettering 36dbf97170
Merge pull request #12119 from keszybz/voidify-mkdir-p
Voidify mkdir_p() and normalize util.h includes
2019-03-27 15:05:51 +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
Lennart Poettering 49bd196d69
Merge pull request #12110 from keszybz/sysv-compat-fix
Sysv-compat compilation fix
2019-03-27 09:29:13 +01:00
Lennart Poettering 175b43cb8e
Merge pull request #12116 from keszybz/mock-compilation-fixes
Fixes for compilation in Fedora 30 mock
2019-03-27 09:27:20 +01:00
Zbigniew Jędrzejewski-Szmek 10fd1d46fc shared/install: try even harder to make sure variable is initalized
Apparently the fix in a05294ff05 was
not sufficient. Let's declare the two arrays as static variables.
2019-03-26 19:58:17 +01:00
Zbigniew Jędrzejewski-Szmek be3f37528e util-lib: fix sentence in comment 2019-03-26 19:06:48 +01:00
Lennart Poettering 427646ea9d sleep: use negative_errno() where appropriate 2019-03-26 11:17:23 +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