Commit graph

27447 commits

Author SHA1 Message Date
Lennart Poettering add005357d core: add new RestrictNamespaces= unit file setting
This new setting permits restricting whether namespaces may be created and
managed by processes started by a unit. It installs a seccomp filter blocking
certain invocations of unshare(), clone() and setns().

RestrictNamespaces=no is the default, and does not restrict namespaces in any
way. RestrictNamespaces=yes takes away the ability to create or manage any kind
of namspace. "RestrictNamespaces=mnt ipc" restricts the creation of namespaces
so that only mount and IPC namespaces may be created/managed, but no other
kind of namespaces.

This setting should be improve security quite a bit as in particular user
namespacing was a major source of CVEs in the kernel in the past, and is
accessible to unprivileged processes. With this setting the entire attack
surface may be removed for system services that do not make use of namespaces.
2016-11-04 07:40:13 -06:00
Yu Watanabe 9156493171 kernel-install: use exit instead of return (#4565)
/bin/kernel-install: line 143: return: can only `return' from a function or sourced script

https://bugzilla.redhat.com/show_bug.cgi?id=1391829
2016-11-04 08:58:41 -04:00
Zbigniew Jędrzejewski-Szmek c4c50112ec man: update kernel-install(8) to match reality (#4563) 2016-11-04 06:40:58 -06:00
Zbigniew Jędrzejewski-Szmek cf88547034 Merge pull request #4548 from keszybz/seccomp-help
systemd-analyze syscall-filter
2016-11-03 20:27:45 -04:00
Kees Cook d974f949f1 doc: clarify NoNewPrivileges (#4562)
Setting no_new_privs does not stop UID changes, but rather blocks
gaining privileges through execve(). Also fixes a small typo.
2016-11-03 20:26:59 -04:00
Martin Pitt e2df6e90b2 build-sys: link test-seccomp against seccomp libs (#4560)
Fixes build error on recent toolchains:

  ../src/test/test-seccomp.c:35: error: undefined reference to 'seccomp_arch_native'
  collect2: error: ld returned 1 exit status
2016-11-03 23:15:33 +02:00
Zbigniew Jędrzejewski-Szmek 1720590bfd analyze: fix build w/o seccomp 2016-11-03 16:23:12 -04:00
Lennart Poettering 493fd52f1a Merge pull request #4510 from keszybz/tree-wide-cleanups
Tree wide cleanups
2016-11-03 13:59:20 -06:00
Zbigniew Jędrzejewski-Szmek a1e2ef7ec9 Revert "sd-bus: use PRIu64 instead of casting" (#4556)
This reverts commit 75ead2b753.

Follow up for #4546:
> @@ -848,8 +848,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
         if (k->src_id == KDBUS_SRC_ID_KERNEL)
                 bus_message_set_sender_driver(bus, m);
         else {
-                xsprintf(m->sender_buffer, ":1.%llu",
-                         (unsigned long long)k->src_id);
+                xsprintf(m->sender_buffer, ":1.%"PRIu64, k->src_id);

This produces:

src/libsystemd/sd-bus/bus-kernel.c: In function ‘bus_kernel_make_message’:
src/libsystemd/sd-bus/bus-kernel.c:851:44: warning: format ‘%lu’ expects argument of type ‘long
unsigned int’, but argument 4 has type ‘__u64 {aka long long unsigned int}’ [-Wformat=]
                 xsprintf(m->sender_buffer, ":1.%"PRIu64, k->src_id);
                                            ^
2016-11-03 13:16:42 -04:00
Lennart Poettering c14eff367c hwdb update for 232 (#4557) 2016-11-03 13:16:01 -04:00
Lennart Poettering 54b24597b8 final NEWS update for 232 (#4558)
let's get this out today!
2016-11-03 08:56:26 -06:00
Zbigniew Jędrzejewski-Szmek d5efc18b60 seccomp-util, analyze: export comments as a help string
Just to make the whole thing easier for users.
2016-11-03 09:35:36 -04:00
Zbigniew Jędrzejewski-Szmek 40eb6a8014 seccomp-util: move @default to the first position
Now that the list is user-visible, @default should be first.
2016-11-03 09:35:36 -04:00
Zbigniew Jędrzejewski-Szmek 869feb3388 analyze: add syscall-filter verb
This should make it easier for users to understand what each filter
means as the list of syscalls is updated in subsequent systemd versions.
2016-11-03 09:35:35 -04:00
Djalal Harouni 34f139c526 Merge pull request #4543 from endocode/djalal/fix-dynamicuser-supplementary-groups
core: intialize user aux groups and SupplementaryGroups= when DynamicUser= is set
2016-11-03 11:48:28 +01:00
Djalal Harouni 5c67067f0e test: test DynamicUser= with SupplementaryGroups= 2016-11-03 08:38:28 +01:00
Djalal Harouni 2b9ac11ed9 test: test DynamicUser= with a fixed user 2016-11-03 08:37:15 +01:00
Djalal Harouni cdc5d5c55e core: intialize user aux groups and SupplementaryGroups= when DynamicUser= is set
Make sure that when DynamicUser= is set that we intialize the user
supplementary groups and that we also support SupplementaryGroups=

Fixes: https://github.com/systemd/systemd/issues/4539

Thanks Evgeny Vereshchagin (@evverx)
2016-11-03 08:36:53 +01:00
Lennart Poettering b2c82a7f2f Merge pull request #4547 from keszybz/two-testsuite-tweaks
Two testsuite tweaks
2016-11-02 23:06:53 -06:00
Lennart Poettering b23f2b72bf Merge pull request #4546 from keszybz/xsprintf-revert
xsprintf revert
2016-11-02 22:44:36 -06:00
Zbigniew Jędrzejewski-Szmek 1258f08898 parse_hwdb: add import fallback for python2 2016-11-02 22:48:43 -04:00
Zbigniew Jędrzejewski-Szmek e02c613560 udev/udev-watch: calculate the real buffer sizes needed 2016-11-02 22:36:43 -04:00
Zbigniew Jędrzejewski-Szmek a6eccc3647 Do not raise in switch root if paths are too long
If we encounter the (unlikely) situation where the combined path to the
new root and a path to a mount to be moved together exceed maximum path length,
we shouldn't crash, but fail this path instead.
2016-11-02 22:36:43 -04:00
Zbigniew Jędrzejewski-Szmek 75ead2b753 sd-bus: use PRIu64 instead of casting 2016-11-02 22:36:43 -04:00
Zbigniew Jędrzejewski-Szmek e68eedbbdc Revert some uses of xsprintf
This reverts some changes introduced in d054f0a4d4.
xsprintf should be used in cases where we calculated the right buffer
size by hand (using DECIMAL_STRING_MAX and such), and never in cases where
we are printing externally specified strings of arbitrary length.

Fixes #4534.
2016-11-02 22:36:29 -04:00
Zbigniew Jędrzejewski-Szmek 7fa6328cc4 Merge pull request #4481 from poettering/perpetual
Add "perpetual" unit concept, sysctl fixes, networkd fixes, systemctl color fixes, nspawn discard.
2016-11-02 21:03:26 -04:00
Zbigniew Jędrzejewski-Szmek f57ee147e8 Merge pull request #4542 from poettering/v232prep
preparation for 232
2016-11-02 20:13:27 -04:00
Lennart Poettering ac334b2cfb core: make a constant table actually constant 2016-11-02 20:10:58 -04:00
Lennart Poettering 07ecca0dc9 core: don't hit an assert when printing status messages about units with overly long description strings
This essentially reverts one part of d054f0a4d4.

(We might also choose to use proper ellipsation here, but I wasn't sure the
memory allocation this requires wouöld be a good idea here...)

Fixes: #4534
2016-11-02 20:10:58 -04:00
Lucas Werkmeister 0cc6064c3c man: fix two typos (is → are) (#4544) 2016-11-02 18:10:29 -06:00
Lennart Poettering 31887c73b9 Merge pull request #4456 from keszybz/stored-fds
Preserve stored fds over service restart
2016-11-02 16:29:04 -06:00
Lucas Werkmeister 5b9635d166 systemctl: fix incorrect "need reload" on cat (#4535)
Reported by @evverx in #4493.
2016-11-02 16:12:03 -06:00
Lennart Poettering 32e134c19f Merge pull request #4483 from poettering/exec-order
more seccomp fixes, and change of order of selinux/aa/smack and seccomp application on exec
2016-11-02 16:09:59 -06:00
Lennart Poettering 515958c9eb build-sys: bump package and library version in preparation for v232 2016-11-02 16:04:40 -06:00
Lennart Poettering b4eed568b9 add two additional entries to NEWS 2016-11-02 16:02:12 -06:00
Lennart Poettering 07393b6ea9 NEWS: add contributor list to news file
Unfortunately, github drops the original commiter when a PR is "squashed" (even
if it is only a single commit) and replaces it with some rubbish
github-specific user id. Thus, to make the contributors list somewhat useful,
update the .mailmap file and undo all the weirdness github applied there.
2016-11-02 15:52:57 -06:00
Zbigniew Jędrzejewski-Szmek b09246352f pid1: fix fd memleak when we hit FileDescriptorStoreMax limit
Since service_add_fd_store() already does the check, remove the redundant check
from service_add_fd_store_set().

Also, print a warning when repopulating FDStore after daemon-reexec and we hit
the limit. This is a user visible issue, so we should not discard fds silently.
(Note that service_deserialize_item is impacted by the return value from
service_add_fd_store(), but we rely on the general error message, so the caller
does not need to be modified, and does not show up in the diff.)
2016-11-02 15:07:17 -04:00
Lennart Poettering 1201cae704 core: change mount_synthesize_root() return to int
Let's propagate the error here, instead of eating it up early.

In a later change we should probably also change mount_enumerate() to propagate
errors up, but that would mean we'd have to change the unit vtable, and thus
change all unit types, hence is quite an invasive change.
2016-11-02 11:39:49 -06:00
Lennart Poettering c69305ff4f networkd: flush DNSSL/RDNSS lists when we lose carrier
Fixes: #3870
2016-11-02 11:39:49 -06:00
Lennart Poettering 02affb4e6a netword: minor memory leak fix 2016-11-02 11:39:49 -06:00
Lennart Poettering 2bce2acce8 nspawn: if we set up a loopback device, try to mount it with "discard"
Let's make sure that our loopback files remain sparse, hence let's set
"discard" as mount option on file systems that support it if the backing device
is a loopback.
2016-11-02 11:39:49 -06:00
Lennart Poettering b5d7f1bbfa systemctl: tweak the "systemctl list-units" output a bit
Make the underlining between the header and the body and between the units of
different types span the whole width of the table.

Let's never make the table wider than necessary (which is relevant due the
above).

When space is limited and we can't show the full ID or description string
prefer showing the full ID over the full description. The ID is after all
something people might want to copy/paste, while the description is mostly just
helpful decoration.
2016-11-02 11:39:49 -06:00
Lennart Poettering 835a19e02f systemctl: properly turn off color after active column
If we turn on red color for the active column and it is not combined with
underlining, then we need to turn it off explicitly afterwards. Do that.
2016-11-02 11:39:49 -06:00
Lennart Poettering e510508115 sysctl: minor simplification
Let's place only one ternary operator.
2016-11-02 11:39:48 -06:00
Lennart Poettering 4f14f2bb6f sysctl: no need to check for eof twice
Let's only check for eof once after the fgets(). There's no point in checking
EOF before the first read, and twice in each loop.
2016-11-02 11:29:59 -06:00
Lennart Poettering 98bf5011fe sysctl: when failing to process a config line, show line nr 2016-11-02 11:29:59 -06:00
Lennart Poettering 9c37b41c61 sysctl: split out condition check into its own function
This way, we can get rid of a label/goto.
2016-11-02 11:29:59 -06:00
Lennart Poettering 39540de8ab sysctl: do not fail systemd-sysctl.service if /proc/sys is mounted read-only
Let's make missing write access to /proc/sys non-fatal to the sysctl service.

This is a follow-up to 411e869f49 which altered
the condition for running the sysctl service to check for /proc/sys/net being
writable, accepting that /proc/sys might be read-only. In order to ensure the
boot-up stays clean in containers lower the log level for the EROFS errors
generated due to this.
2016-11-02 11:29:59 -06:00
Lennart Poettering a581e45ae8 unit: unify some code with new unit_new_for_name() call 2016-11-02 11:29:59 -06:00
Lennart Poettering 11222d0fe0 core: make the root mount perpetual too
Now that have a proper concept of "perpetual" units, let's make the root mount
one too, since it also cannot go away.
2016-11-02 11:29:59 -06:00