]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
7 years agoMerge pull request #4225 from keszybz/coredump
Martin Pitt [Fri, 30 Sep 2016 09:16:51 +0000 (11:16 +0200)] 
Merge pull request #4225 from keszybz/coredump

coredump: remove Storage=both support, various fixes for sd-coredump and coredumpctl

7 years agoresolved: don't query domain-limited DNS servers for other domains (#3621)
Martin Pitt [Fri, 30 Sep 2016 07:30:08 +0000 (09:30 +0200)] 
resolved: don't query domain-limited DNS servers for other domains (#3621)

DNS servers which have route-only domains should only be used for
the specified domains. Routing queries about other domains there is a privacy
violation, prone to fail (as that DNS server was not meant to be used for other
domains), and puts unnecessary load onto that server.

Introduce a new helper function dns_server_limited_domains() that checks if the
DNS server should only be used for some selected domains, i. e. has some
route-only domains without "~.". Use that when determining whether to query it
in the scope, and when writing resolv.conf.

Extend the test_route_only_dns() case to ensure that the DNS server limited to
~company does not appear in resolv.conf. Add test_route_only_dns_all_domains()
to ensure that a server that also has ~. does appear in resolv.conf as global
name server. These reproduce #3420.

Add a new test_resolved_domain_restricted_dns() test case that verifies that
domain-limited DNS servers are only being used for those domains. This
reproduces #3421.

Clarify what a "routing domain" is in the manpage.

Fixes #3420
Fixes #3421

7 years agopid1: more informative error message for ignored notifications
Zbigniew Jędrzejewski-Szmek [Thu, 29 Sep 2016 14:07:41 +0000 (16:07 +0200)] 
pid1: more informative error message for ignored notifications

It's probably easier to diagnose a bad notification message if the
contents are printed. But still, do anything only if debugging is on.

7 years agopid1: process zero-length notification messages again
Zbigniew Jędrzejewski-Szmek [Thu, 29 Sep 2016 14:06:02 +0000 (16:06 +0200)] 
pid1: process zero-length notification messages again

This undoes 531ac2b234. I acked that patch without looking at the code
carefully enough. There are two problems:
- we want to process the fds anyway
- in principle empty notification messages are valid, and we should
  process them as usual, including logging using log_unit_debug().

7 years agopid1: don't return any error in manager_dispatch_notify_fd() (#4240)
Franck Bui [Thu, 29 Sep 2016 17:44:34 +0000 (19:44 +0200)] 
pid1: don't return any error in manager_dispatch_notify_fd() (#4240)

If manager_dispatch_notify_fd() fails and returns an error then the handling of
service notifications will be disabled entirely leading to a compromised system.

For example pid1 won't be able to receive the WATCHDOG messages anymore and
will kill all services supposed to send such messages.

7 years agoIf the notification message length is 0, ignore the message (#4237)
Jorge Niedbalski [Wed, 28 Sep 2016 21:25:50 +0000 (18:25 -0300)] 
If the notification message length is 0, ignore the message (#4237)

Fixes #4234.

Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
7 years agocoredump,catalog: give better notice when a core file is truncated 4225/head
Zbigniew Jędrzejewski-Szmek [Tue, 27 Sep 2016 10:40:54 +0000 (12:40 +0200)] 
coredump,catalog: give better notice when a core file is truncated

coredump had code to check if copy_bytes() hit the max_bytes limit,
and refuse further processing in that case.
But in 84ee0960443, the return convention for copy_bytes() was changed
from -EFBIG to 1 for the case when the limit is hit, so the condition
check in coredump couldn't ever trigger.
But it seems that *do* want to process such truncated cores [1].
So change the code to detect truncation properly, but instead of
returning an error, give a nice log entry.

[1] https://github.com/systemd/systemd/issues/3883#issuecomment-239106337

Should fix (or at least alleviate) #3883.

7 years agocoredump: log if the core is too large to store or generate backtrace
Zbigniew Jędrzejewski-Szmek [Tue, 27 Sep 2016 09:32:36 +0000 (11:32 +0200)] 
coredump: log if the core is too large to store or generate backtrace

Another fix for #4161.

7 years agocoredumpctl: delay the "on tty" refusal until as late as possible
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 22:32:42 +0000 (00:32 +0200)] 
coredumpctl: delay the "on tty" refusal until as late as possible

For the user, if the core file is missing or inaccessible, it is
more interesting that the fact that they forgot to pipe to a file.
So delay the failure from the check until after we have verified
that the file or the COREDUMP field are present.

Partially fixes #4161.

Also, error reporting on failure was duplicated. save_core() now
always prints an error message (because it knows the paths involved,
so can the most useful message), and the callers don't have to.

7 years agocoredumpctl: tighten print_field() code
Zbigniew Jędrzejewski-Szmek [Tue, 27 Sep 2016 08:52:10 +0000 (10:52 +0200)] 
coredumpctl: tighten print_field() code

Propagate errors properly, so that if we hit oom or an error in the
journal, the whole command will fail. This is important when using
the output in scripts.

Support the output of multiple values for the same field with -F.
The journal supports that, and our official commands should too, as
far as it makes sense. -F can be used to print user-defined fields
(e.g. somebody could use a TAG field with multiple occurences), so
we should support that too. That seems better than silently printing
the last value found as was done before.

We would iterate trying to match the same field with all possible
field names. Once we find something, cut the loop short, since we
know that nothing else can match.

7 years agocoredumpctl: rework presence reporting
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 23:41:38 +0000 (01:41 +0200)] 
coredumpctl: rework presence reporting

The column for "present" was easy to miss, especially if somebody had no
coredumps present at all, in which case the column of spaces of width one
wasn't visually distinguished from the neighbouring columns. Replace this
with an explicit text, one of: "missing", "journal", "present", "error".

$ coredumpctl
TIME                            PID   UID   GID SIG COREFILE EXE
Mon 2016-09-26 22:46:31 CEST   8623     0     0  11 missing  /usr/bin/bash
Mon 2016-09-26 22:46:35 CEST   8639  1001  1001  11 missing  /usr/bin/bash
Tue 2016-09-27 01:10:46 CEST  16110  1001  1001  11 journal  /usr/bin/bash
Tue 2016-09-27 01:13:20 CEST  16290  1001  1001  11 journal  /usr/bin/bash
Tue 2016-09-27 01:33:48 CEST  17867  1001  1001  11 present  /usr/bin/bash
Tue 2016-09-27 01:37:55 CEST  18549     0     0  11 error    /usr/bin/bash

Also, use access(…, R_OK), so that we can report a present but inaccessible
file different than a missing one.

7 years agocoredumpctl: report corefile presence properly
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 23:19:01 +0000 (01:19 +0200)] 
coredumpctl: report corefile presence properly

In 'list', show present also for coredumps stored in the journal.

In 'status', replace "File" with "Storage" line that is always present.
Possible values:
   Storage: none
   Storage: journal
   Storage: /path/to/file (inacessible)
   Storage: /path/to/file

Previously the File field be only present if the file was accessible, so users
had to manually extract the file name precisely in the cases where it was
needed, i.e. when coredumpctl couldn't access the file. It's much more friendly
to always show something. This output is designed for human consumption, so
it's better to be a bit verbose.

The call to sd_j_set_data_threshold is moved, so that status is always printed
with the default of 64k, list uses 4k, and coredump retrieval is done with the
limit unset. This should make checking for the presence of the COREDUMP field
not too costly.

7 years agocoredumpctl: report user unit properly
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 23:18:48 +0000 (01:18 +0200)] 
coredumpctl: report user unit properly

7 years agocoredumpctl: fix spurious "more than one entry matches" warning
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 22:40:55 +0000 (00:40 +0200)] 
coredumpctl: fix spurious "more than one entry matches" warning

sd_journal_previous() returns 0 if it didn't do any move, so the
warning was stupidly always printed.

7 years agocoredumpctl: fix handling of files written to fd
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 22:10:04 +0000 (00:10 +0200)] 
coredumpctl: fix handling of files written to fd

Added in 9fe13294a9 (by me :[```), and later obfuscated in d0c8806d4ab, if an
uncompressed external file or an internally stored coredump was supposed to be
written to a file descriptor, nothing would be written.

7 years agocoredump: remove Storage=both option
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 21:40:20 +0000 (23:40 +0200)] 
coredump: remove Storage=both option

Back when external storage was initially added in 34c10968cb, this mode of
storage was added. This could have made some sense back when XZ compression was
used, and an uncompressed core on disk could be used as short-lived cache file
which does require costly decompression. But now fast LZ4 compression is used
(by default) both internally and externally, so we have duplicated storage,
using the same compression and same default maximum core size in both cases,
but with different expiration lifetimes. Even the uncompressed-external,
compressed-internal mode is not very useful: for small files, decompression
with LZ4 is fast enough not to matter, and for large files, decompression is
still relatively fast, but the disk-usage penalty is very big.

An additional problem with the two modes of storage is that it complicates
the code and makes it much harder to return a useful error message to the user
if we cannot find the core file, since if we cannot find the file we have to
check the internal storage first.

This patch drops "both" storage mode. Effectively this means that if somebody
configured coredump this way, they will get a warning about an unsupported
value for Storage, and the default of "external" will be used.
I'm pretty sure that this mode is very rarely used anyway.

7 years agoman: remove duplicate "the" for systemctl --plain (#4230)
Alfie John [Wed, 28 Sep 2016 09:10:26 +0000 (09:10 +0000)] 
man: remove duplicate "the" for systemctl --plain (#4230)

7 years agojournal: add stdout_stream_scan() comment (#4102)
Vito Caputo [Wed, 28 Sep 2016 05:35:48 +0000 (22:35 -0700)] 
journal: add stdout_stream_scan() comment (#4102)

When s->length is zero this function doesn't do anything, note that in a
comment.

7 years agoMerge pull request #4185 from endocode/djalal-sandbox-first-protection-v1
Evgeny Vereshchagin [Wed, 28 Sep 2016 01:50:30 +0000 (04:50 +0300)] 
Merge pull request #4185 from endocode/djalal-sandbox-first-protection-v1

core:sandbox: Add new ProtectKernelTunables=, ProtectControlGroups=, ProtectSystem=strict and fixes

7 years agoMerge pull request #4220 from keszybz/show-and-formatting-fixes
Martin Pitt [Tue, 27 Sep 2016 14:25:27 +0000 (16:25 +0200)] 
Merge pull request #4220 from keszybz/show-and-formatting-fixes

Show and formatting fixes

7 years agobasic: fix for IPv6 status (#4224)
Susant Sahani [Tue, 27 Sep 2016 13:55:13 +0000 (19:25 +0530)] 
basic: fix for IPv6 status (#4224)

Even if
```
   cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1
```

is disabled

cat /proc/net/sockstat6

```
TCP6: inuse 2
UDP6: inuse 1
UDPLITE6: inuse 0
RAW6: inuse 0
FRAG6: inuse 0 memory 0
 ```

Looking for /proc/net/if_inet6 is the right choice.

7 years agotest: make sure that {readonly|inaccessible|readwrite}paths disconnect mount propagation 4185/head
Djalal Harouni [Sun, 25 Sep 2016 17:50:25 +0000 (19:50 +0200)] 
test: make sure that {readonly|inaccessible|readwrite}paths disconnect mount propagation

Better safe.

7 years agotest: add tests for simple ReadOnlyPaths= case
Djalal Harouni [Sun, 25 Sep 2016 17:24:25 +0000 (19:24 +0200)] 
test: add tests for simple ReadOnlyPaths= case

7 years agotest-bus-creds: are more debugging info 4220/head
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 20:22:28 +0000 (22:22 +0200)] 
test-bus-creds: are more debugging info

This test sometimes fails in semaphore, but not when run interactively,
so it's hard to debug.

7 years agoudev/path_id: introduce support for NVMe devices (#4169)
Keith Busch [Mon, 26 Sep 2016 19:01:07 +0000 (13:01 -0600)] 
udev/path_id: introduce support for NVMe devices (#4169)

This appends the nvme name and namespace identifier attribute the the
PCI path for by-path links. Symlinks like the following are now present:

lrwxrwxrwx. 1 root root 13 Sep 16 12:12 pci-0000:01:00.0-nvme-1 -> ../../nvme0n1
lrwxrwxrwx. 1 root root 15 Sep 16 12:12 pci-0000:01:00.0-nvme-1-part1 -> ../../nvme0n1p1

Cc: Michal Sekletar <sekletar.m@gmail.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
7 years agocore: Fix USB functionfs activation and clarify its documentation (#4188)
Paweł Szewczyk [Mon, 26 Sep 2016 16:45:47 +0000 (18:45 +0200)] 
core: Fix USB functionfs activation and clarify its documentation (#4188)

There was no certainty about how the path in service file should look
like for usb functionfs activation. Because of this it was treated
differently in different places, which made this feature unusable.

This patch fixes the path to be the *mount directory* of functionfs, not
ep0 file path and clarifies in the documentation that ListenUSBFunction should be
the location of functionfs mount point, not ep0 file itself.

7 years agomachinectl: prefer user@ to --uid=user for shell (#4006)
Zbigniew Jędrzejewski-Szmek [Mon, 26 Sep 2016 15:45:31 +0000 (11:45 -0400)] 
machinectl: prefer user@ to --uid=user for shell (#4006)

It seems to me that the explicit positional argument should have higher
priority than "an option".

7 years agojournald,ratelimit: fix wrong calculation of burst_modulate() (#4218)
HATAYAMA Daisuke [Mon, 26 Sep 2016 15:36:20 +0000 (00:36 +0900)] 
journald,ratelimit: fix wrong calculation of burst_modulate() (#4218)

This patch fixes wrong calculation of burst_modulate(), which now calculates
the values smaller than really expected ones if available disk space is
strictly more than 1MB.

In particular, if available disk space is strictly more than 1MB and strictly
less than 16MB, the resulted value becomes smaller than its original one.

>>> (math.log2(1*1024**2)-16) / 4
1.0
>>> (math.log2(16*1024**2)-16) / 4
2.0
>>> (math.log2(256*1024**2)-16) / 4
3.0
→ This matches the comment in the function.

7 years agocoredump: initialize coredump_size in submit_coredump() (#4219)
Matej Habrnal [Mon, 26 Sep 2016 15:28:58 +0000 (17:28 +0200)] 
coredump: initialize coredump_size in submit_coredump() (#4219)

If ulimit is smaller than page_size(), function save_external_coredump()
returns -EBADSLT and this causes skipping whole core dumping part in
submit_coredump(). Initializing coredump_size to UINT64_MAX prevents
evaluating a condition with uninitialized varialbe which leads to
calling allocate_journal_field() with coredump_fd = -1 which causes
aborting.

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
7 years agotreewide: fix typos (#4217)
Torstein Husebø [Mon, 26 Sep 2016 09:32:47 +0000 (11:32 +0200)] 
treewide: fix typos (#4217)

7 years agotest: add CAP_MKNOD tests for PrivateDevices=
Djalal Harouni [Sun, 25 Sep 2016 11:04:30 +0000 (13:04 +0200)] 
test: add CAP_MKNOD tests for PrivateDevices=

7 years agocore: Use @raw-io syscall group to filter I/O syscalls when PrivateDevices= is set
Djalal Harouni [Sun, 25 Sep 2016 10:52:27 +0000 (12:52 +0200)] 
core: Use @raw-io syscall group to filter I/O syscalls when PrivateDevices= is set

Instead of having a local syscall list, use the @raw-io group which
contains the same set of syscalls to filter.

7 years agocore:namespace: simplify ProtectHome= implementation
Djalal Harouni [Sun, 25 Sep 2016 10:41:16 +0000 (12:41 +0200)] 
core:namespace: simplify ProtectHome= implementation

As with previous patch simplify ProtectHome and don't care about
duplicates, they will be sorted by most restrictive mode and cleaned.

7 years agocore: simplify ProtectSystem= implementation
Djalal Harouni [Sun, 25 Sep 2016 10:21:25 +0000 (12:21 +0200)] 
core: simplify ProtectSystem= implementation

ProtectSystem= with all its different modes and other options like
PrivateDevices= + ProtectKernelTunables= + ProtectHome= are orthogonal,
however currently it's a bit hard to parse that from the implementation
view. Simplify it by giving each mode its own table with all paths and
references to other Protect options.

With this change some entries are duplicated, but we do not care since
duplicate mounts are first sorted by the most restrictive mode then
cleaned.

7 years agocore:sandbox: add more /proc/* entries to ProtectKernelTunables=
Djalal Harouni [Sun, 25 Sep 2016 09:30:11 +0000 (11:30 +0200)] 
core:sandbox: add more /proc/* entries to ProtectKernelTunables=

Make ALSA entries, latency interface, mtrr, apm/acpi, suspend interface,
filesystems configuration and IRQ tuning readonly.

Most of these interfaces now days should be in /sys but they are still
available through /proc, so just protect them. This patch does not touch
/proc/net/...

7 years agodoc: explicitly document that /dev/mem and /dev/port are blocked by PrivateDevices...
Djalal Harouni [Mon, 19 Sep 2016 19:46:17 +0000 (21:46 +0200)] 
doc: explicitly document that /dev/mem and /dev/port are blocked by PrivateDevices=true

7 years agodoc: documentation fixes for ReadWritePaths= and ProtectKernelTunables=
Djalal Harouni [Mon, 19 Sep 2016 19:46:17 +0000 (21:46 +0200)] 
doc: documentation fixes for ReadWritePaths= and ProtectKernelTunables=

Documentation fixes for ReadWritePaths= and ProtectKernelTunables=
as reported by Evgeny Vereshchagin.

7 years agocore:namespace: simplify mount calculation
Djalal Harouni [Sun, 25 Sep 2016 09:25:00 +0000 (11:25 +0200)] 
core:namespace: simplify mount calculation

Move out mount calculation on its own function. Actually the logic is
smart enough to later drop nop and duplicates mounts, this change
improves code readability.
---
 src/core/namespace.c | 47 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 11 deletions(-)

7 years agocore:namespace: put paths protected by ProtectKernelTunables= in
Djalal Harouni [Sun, 25 Sep 2016 09:16:44 +0000 (11:16 +0200)] 
core:namespace: put paths protected by ProtectKernelTunables= in

Instead of having all these paths everywhere, put the ones that are
protected by ProtectKernelTunables= into their own table. This way it
is easy to add paths and track which ones are protected.

7 years agocore:namespace: minor improvements to append_mounts()
Djalal Harouni [Sun, 25 Sep 2016 09:03:21 +0000 (11:03 +0200)] 
core:namespace: minor improvements to append_mounts()

7 years agoexecute: move SMACK setup code into its own function
Lennart Poettering [Fri, 26 Aug 2016 15:40:42 +0000 (17:40 +0200)] 
execute: move SMACK setup code into its own function

While we are at it, move PAM code #ifdeffery into setup_pam() to simplify the
main execution logic a bit.

7 years agonamespace: drop all mounts outside of the new root directory
Lennart Poettering [Fri, 26 Aug 2016 15:25:40 +0000 (17:25 +0200)] 
namespace: drop all mounts outside of the new root directory

There's no point in mounting these, if they are outside of the root directory
we'll move to.

7 years agomain: minor simplification
Lennart Poettering [Fri, 26 Aug 2016 15:25:08 +0000 (17:25 +0200)] 
main: minor simplification

7 years agoUpdate TODO
Lennart Poettering [Wed, 24 Aug 2016 18:53:56 +0000 (20:53 +0200)] 
Update TODO

7 years agoexecute: filter low-level I/O syscalls if PrivateDevices= is set
Lennart Poettering [Fri, 26 Aug 2016 14:39:04 +0000 (16:39 +0200)] 
execute: filter low-level I/O syscalls if PrivateDevices= is set

If device access is restricted via PrivateDevices=, let's also block the
various low-level I/O syscalls at the same time, so that we know that the
minimal set of devices in our virtualized /dev are really everything the unit
can access.

7 years agoNEWS: update news about systemd-udevd.service
Lennart Poettering [Mon, 19 Sep 2016 19:29:06 +0000 (21:29 +0200)] 
NEWS: update news about systemd-udevd.service

7 years agounits: further lock down our long-running services
Lennart Poettering [Fri, 26 Aug 2016 11:23:27 +0000 (13:23 +0200)] 
units: further lock down our long-running services

Let's make this an excercise in dogfooding: let's turn on more security
features for all our long-running services.

Specifically:

- Turn on RestrictRealtime=yes for all of them

- Turn on ProtectKernelTunables=yes and ProtectControlGroups=yes for most of
  them

- Turn on RestrictAddressFamilies= for all of them, but different sets of
  address families for each

Also, always order settings in the unit files, that the various sandboxing
features are close together.

Add a couple of missing, older settings for a numbre of unit files.

Note that this change turns off AF_INET/AF_INET6 from udevd, thus effectively
turning of networking from udev rule commands. Since this might break stuff
(that is already broken I'd argue) this is documented in NEWS.

7 years agounits: permit importd to mount stuff
Lennart Poettering [Fri, 26 Aug 2016 10:45:10 +0000 (12:45 +0200)] 
units: permit importd to mount stuff

Fixes #3996

7 years agoman: shorten the exit status table a bit
Lennart Poettering [Fri, 26 Aug 2016 10:29:52 +0000 (12:29 +0200)] 
man: shorten the exit status table a bit

Let's merge a couple of columns, to make the table a bit shorter. This
effectively just drops whitespace, not contents, but makes the currently
humungous table much much more compact.

7 years agoman: the exit code/signal is stored in $EXIT_CODE, not $EXIT_STATUS
Lennart Poettering [Fri, 26 Aug 2016 10:29:28 +0000 (12:29 +0200)] 
man: the exit code/signal is stored in $EXIT_CODE, not $EXIT_STATUS

7 years agoman: rework documentation for ReadOnlyPaths= and related settings
Lennart Poettering [Fri, 26 Aug 2016 10:24:37 +0000 (12:24 +0200)] 
man: rework documentation for ReadOnlyPaths= and related settings

This reworks the documentation for ReadOnlyPaths=, ReadWritePaths=,
InaccessiblePaths=. It no longer claims that we'd follow symlinks relative to
the host file system. (Which wasn't true actually, as we didn't follow symlinks
at all in the most recent releases, and we know do follow them, but relative to
RootDirectory=).

This also replaces all references to the fact that all fs namespacing options
can be undone with enough privileges and disable propagation by a single one in
the documentation of ReadOnlyPaths= and friends, and then directs the read to
this in all other places.

Moreover a hint is added to the documentation of SystemCallFilter=, suggesting
usage of ~@mount in case any of the fs namespacing related options are used.

7 years agoman: in user-facing documentaiton don't reference C function names
Lennart Poettering [Fri, 26 Aug 2016 10:22:23 +0000 (12:22 +0200)] 
man: in user-facing documentaiton don't reference C function names

Let's drop the reference to the cap_from_name() function in the documentation
for the capabilities setting, as it is hardly helpful. Our readers are not
necessarily C hackers knowing the semantics of cap_from_name(). Moreover, the
strings we accept are just the plain capability names as listed in
capabilities(7) hence there's really no point in confusing the user with
anything else.

7 years agonamespace: don't make the root directory of a namespace a mount if it already is one
Lennart Poettering [Fri, 26 Aug 2016 09:27:38 +0000 (11:27 +0200)] 
namespace: don't make the root directory of a namespace a mount if it already is one

Let's not stack mounts needlessly.

7 years agonamespace: chase symlinks for mounts to set up in userspace
Lennart Poettering [Sat, 24 Sep 2016 10:41:30 +0000 (12:41 +0200)] 
namespace: chase symlinks for mounts to set up in userspace

This adds logic to chase symlinks for all mount points that shall be created in
a namespace environment in userspace, instead of leaving this to the kernel.
This has the advantage that we can correctly handle absolute symlinks that
shall be taken relative to a specific root directory. Moreover, we can properly
handle mounts created on symlinked files or directories as we can merge their
mounts as necessary.

(This also drops the "done" flag in the namespace logic, which was never
actually working, but was supposed to permit a partial rollback of the
namespace logic, which however is only mildly useful as it wasn't clear in
which case it would or would not be able to roll back.)

Fixes: #3867
7 years agonamespace: invoke unshare() only after checking all parameters
Lennart Poettering [Thu, 25 Aug 2016 15:30:47 +0000 (17:30 +0200)] 
namespace: invoke unshare() only after checking all parameters

Let's create the new namespace only after we validated and processed all
parameters, right before we start with actually mounting things.

This way, the window where we can roll back is larger (not that it matters
IRL...)

7 years agoexecute: drop group priviliges only after setting up namespace
Lennart Poettering [Thu, 25 Aug 2016 15:29:12 +0000 (17:29 +0200)] 
execute: drop group priviliges only after setting up namespace

If PrivateDevices=yes is set, the namespace code creates device nodes in /dev
that should be owned by the host's root, hence let's make sure we set up the
namespace before dropping group privileges.

7 years agonspawn: let's mount /proc/sysrq-trigger read-only by default
Lennart Poettering [Thu, 25 Aug 2016 14:25:49 +0000 (16:25 +0200)] 
nspawn: let's mount /proc/sysrq-trigger read-only by default

LXC does this, and we should probably too. Better safe than sorry.

7 years agocore: imply ProtectHome=read-only and ProtectSystem=strict if DynamicUser=1
Lennart Poettering [Thu, 25 Aug 2016 14:12:46 +0000 (16:12 +0200)] 
core: imply ProtectHome=read-only and ProtectSystem=strict if DynamicUser=1

Let's make sure that services that use DynamicUser=1 cannot leave files in the
file system should the system accidentally have a world-writable directory
somewhere.

This effectively ensures that directories need to be whitelisted rather than
blacklisted for access when DynamicUser=1 is set.

7 years agocore: introduce ProtectSystem=strict
Lennart Poettering [Thu, 25 Aug 2016 13:57:21 +0000 (15:57 +0200)] 
core: introduce ProtectSystem=strict

Let's tighten our sandbox a bit more: with this change ProtectSystem= gains a
new setting "strict". If set, the entire directory tree of the system is
mounted read-only, but the API file systems /proc, /dev, /sys are excluded
(they may be managed with PrivateDevices= and ProtectKernelTunables=). Also,
/home and /root are excluded as those are left for ProtectHome= to manage.

In this mode, all "real" file systems (i.e. non-API file systems) are mounted
read-only, and specific directories may only be excluded via
ReadWriteDirectories=, thus implementing an effective whitelist instead of
blacklist of writable directories.

While we are at, also add /efi to the list of paths always affected by
ProtectSystem=. This is a follow-up for
b52a109ad38cd37b660ccd5394ff5c171a5e5355 which added /efi as alternative for
/boot. Our namespacing logic should respect that too.

7 years agonamespace: add some debug logging when enforcing InaccessiblePaths=
Lennart Poettering [Thu, 25 Aug 2016 13:51:37 +0000 (15:51 +0200)] 
namespace: add some debug logging when enforcing InaccessiblePaths=

7 years agonamespace: rework how ReadWritePaths= is applied
Lennart Poettering [Sun, 25 Sep 2016 08:40:51 +0000 (10:40 +0200)] 
namespace: rework how ReadWritePaths= is applied

Previously, if ReadWritePaths= was nested inside a ReadOnlyPaths=
specification, then we'd first recursively apply the ReadOnlyPaths= paths, and
make everything below read-only, only in order to then flip the read-only bit
again for the subdirs listed in ReadWritePaths= below it.

This is not only ugly (as for the dirs in question we first turn on the RO bit,
only to turn it off again immediately after), but also problematic in
containers, where a container manager might have marked a set of dirs read-only
and this code will undo this is ReadWritePaths= is set for any.

With this patch behaviour in this regard is altered: ReadOnlyPaths= will not be
applied to the children listed in ReadWritePaths= in the first place, so that
we do not need to turn off the RO bit for those after all.

This means that ReadWritePaths=/ReadOnlyPaths= may only be used to turn on the
RO bit, but never to turn it off again. Or to say this differently: if some
dirs are marked read-only via some external tool, then ReadWritePaths= will not
undo it.

This is not only the safer option, but also more in-line with what the man page
currently claims:

        "Entries (files or directories) listed in ReadWritePaths= are
        accessible from within the namespace with the same access rights as
        from outside."

To implement this change bind_remount_recursive() gained a new "blacklist"
string list parameter, which when passed may contain subdirs that shall be
excluded from the read-only mounting.

A number of functions are updated to add more debug logging to make this more
digestable.

7 years agonamespace: when enforcing fs namespace restrictions suppress redundant mounts
Lennart Poettering [Thu, 25 Aug 2016 09:29:32 +0000 (11:29 +0200)] 
namespace: when enforcing fs namespace restrictions suppress redundant mounts

If /foo is marked to be read-only, and /foo/bar too, then the latter may be
suppressed as it has no effect.

7 years agonamespace: simplify mount_path_compare() a bit
Lennart Poettering [Thu, 25 Aug 2016 08:44:09 +0000 (10:44 +0200)] 
namespace: simplify mount_path_compare() a bit

7 years agoexecute: if RuntimeDirectory= is set, it should be writable
Lennart Poettering [Thu, 25 Aug 2016 08:42:38 +0000 (10:42 +0200)] 
execute: if RuntimeDirectory= is set, it should be writable

Implicitly make all dirs set with RuntimeDirectory= writable, as the concept
otherwise makes no sense.

7 years agoexecute: move suppression of HOME=/ and SHELL=/bin/nologin into user-util.c
Lennart Poettering [Thu, 25 Aug 2016 08:24:10 +0000 (10:24 +0200)] 
execute: move suppression of HOME=/ and SHELL=/bin/nologin into user-util.c

This adds a new call get_user_creds_clean(), which is just like
get_user_creds() but returns NULL in the home/shell parameters if they contain
no useful information. This code previously lived in execute.c, but by
generalizing this we can reuse it in run.c.

7 years agoexecute: split out creation of runtime dirs into its own functions
Lennart Poettering [Thu, 25 Aug 2016 08:12:57 +0000 (10:12 +0200)] 
execute: split out creation of runtime dirs into its own functions

7 years agonamespace: make sure InaccessibleDirectories= masks all mounts further down
Lennart Poettering [Wed, 24 Aug 2016 21:17:42 +0000 (23:17 +0200)] 
namespace: make sure InaccessibleDirectories= masks all mounts further down

If a dir is marked to be inaccessible then everything below it should be masked
by it.

7 years agocore: add two new service settings ProtectKernelTunables= and ProtectControlGroups=
Lennart Poettering [Mon, 22 Aug 2016 16:43:59 +0000 (18:43 +0200)] 
core: add two new service settings ProtectKernelTunables= and ProtectControlGroups=

If enabled, these will block write access to /sys, /proc/sys and
/proc/sys/fs/cgroup.

7 years agocore: enforce seccomp for secondary archs too, for all rules
Lennart Poettering [Mon, 22 Aug 2016 17:01:14 +0000 (19:01 +0200)] 
core: enforce seccomp for secondary archs too, for all rules

Let's make sure that all our rules apply to all archs the local kernel
supports.

7 years agojournal-remote: fix error format string
Zbigniew Jędrzejewski-Szmek [Sun, 25 Sep 2016 01:46:48 +0000 (21:46 -0400)] 
journal-remote: fix error format string

Bug introduced in 1b4cd64683.

7 years agosystemctl: suppress errors with "show" for nonexistent units and properties
Zbigniew Jędrzejewski-Szmek [Sun, 25 Sep 2016 00:58:04 +0000 (20:58 -0400)] 
systemctl: suppress errors with "show" for nonexistent units and properties

Show is documented to be program-parseable, and printing the warning about
about a non-existent unit, while useful for humans, broke a lot of scripts.
Restore previous behaviour of returning success and printing empty or useless
stuff for units which do not exist, and printing empty values for properties
which do not exists.

With SYSTEMD_LOG_LEVEL=debug, hints are printed, but the return value is
still 0.

This undoes parts of e33a06a and 3dced37b7 and fixes #3856.

We might consider adding an explicit switch to fail on missing units/properties
(e.g. --ensure-exists or similar), and make -P foobar equivalent to
--ensure-exists --property=foobar.

7 years agosystemctl,networkctl,busctl,backlight: use STRPTR_IN_SET
Zbigniew Jędrzejewski-Szmek [Sun, 25 Sep 2016 00:18:02 +0000 (20:18 -0400)] 
systemctl,networkctl,busctl,backlight: use STRPTR_IN_SET

7 years agobasic/strv: add STRPTR_IN_SET
Zbigniew Jędrzejewski-Szmek [Sun, 25 Sep 2016 00:13:28 +0000 (20:13 -0400)] 
basic/strv: add STRPTR_IN_SET

Also some trivial tests for STR_IN_SET and STRPTR_IN_SET.

7 years agosystemctl: use STR_IN_SET
Zbigniew Jędrzejewski-Szmek [Sat, 24 Sep 2016 23:17:31 +0000 (19:17 -0400)] 
systemctl: use STR_IN_SET

7 years agoMerge pull request #4194 from bboozzoo/bboozzoo/nss-rootlib
Zbigniew Jędrzejewski-Szmek [Sat, 24 Sep 2016 15:40:15 +0000 (11:40 -0400)] 
Merge pull request #4194 from bboozzoo/bboozzoo/nss-rootlib

7 years agoMerge pull request #4182 from jkoelker/routetable
Zbigniew Jędrzejewski-Szmek [Sat, 24 Sep 2016 14:56:13 +0000 (10:56 -0400)] 
Merge pull request #4182 from jkoelker/routetable

7 years agonetworkd: do not drop config for pending interfaces (#4187)
Martin Pitt [Sat, 24 Sep 2016 14:07:45 +0000 (16:07 +0200)] 
networkd: do not drop config for pending interfaces (#4187)

While an interface is still being processed by udev, it is in state "pending",
instead of "unmanaged". We must not flush device configuration then.

Further fixes commit 3104883ddc24 after commit c436d55397.

Fixes #4186

7 years agobuild-sys: get rid of move-to-rootlibdir 4194/head
Maciek Borzecki [Sat, 24 Sep 2016 12:17:30 +0000 (14:17 +0200)] 
build-sys: get rid of move-to-rootlibdir

Replace move-to-rootlibdir calls in post-install hooks with explicitly
used ${rootlibdir} where needed.

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
7 years agokernel-install: allow plugins to terminate the procedure (#4174)
Zbigniew Jędrzejewski-Szmek [Sat, 24 Sep 2016 13:03:54 +0000 (09:03 -0400)] 
kernel-install: allow plugins to terminate the procedure (#4174)

Replaces #4103.

7 years agoMerge pull request #4207 from fbuihuu/fix-journal-hmac-calculation
Zbigniew Jędrzejewski-Szmek [Sat, 24 Sep 2016 12:57:49 +0000 (08:57 -0400)] 
Merge pull request #4207 from fbuihuu/fix-journal-hmac-calculation

Fix journal hmac calculation.

7 years agosysctl: configure kernel parameters in the order they occur in each sysctl configurat...
HATAYAMA Daisuke [Sat, 24 Sep 2016 12:56:07 +0000 (21:56 +0900)] 
sysctl: configure kernel parameters in the order they occur in each sysctl configuration files (#4205)

Currently, systemd-sysctl command configures kernel parameters in each sysctl
configuration files in random order due to characteristics of iterator of
Hashmap.

However, kernel parameters need to be configured in the order they occur in
each sysctl configuration files.

- For example, consider fs.suid_coredump and kernel.core_pattern. If
  fs.suid_coredump=2 is configured before kernel.core_pattern= whose default
  value is "core", then kernel outputs the following message:

      Unsafe core_pattern used with suid_dumpable=2. Pipe handler or fully qualified core dump path required.

  Note that the security issue mentioned in this message has already been fixed
  on recent kernels, so this is just a warning message on such kernels. But
  it's still confusing to users that this message is output on some boot and
  not output on another boot.

- I don't know but there could be other kernel parameters that are significant
  in the order they are configured.

- The legacy sysctl command configures kernel parameters in the order they
  occur in each sysctl configuration files. Although I didn't find any official
  specification explaining this behavior of sysctl command, I don't think there
  is any meaningful reason to change this behavior, in particular, to the
  random one.

This commit does the change by simply using OrderedHashmap instead of Hashmap.

7 years agonspawn: decouple --boot from CLONE_NEWIPC (#4180)
Luca Bruno [Sat, 24 Sep 2016 12:30:42 +0000 (12:30 +0000)] 
nspawn: decouple --boot from CLONE_NEWIPC (#4180)

This commit is a minor tweak after the split of `--share-system`, decoupling the `--boot`
option from IPC namespacing.

Historically there has been a single `--share-system` option for sharing IPC/PID/UTS with the
host, which was incompatible with boot/pid1 mode. After the split, it is now possible to express
the requirements with better granularity.

For reference, this is a followup to #4023 which contains references to previous discussions.
I realized too late that CLONE_NEWIPC is not strictly needed for boot mode.

7 years agojournal: fix HMAC calculation when appending a data object 4207/head
Franck Bui [Fri, 23 Sep 2016 11:33:01 +0000 (13:33 +0200)] 
journal: fix HMAC calculation when appending a data object

Since commit 5996c7c295e073ce21d41305169132c8aa993ad0 (v190 !), the
calculation of the HMAC is broken because the hash for a data object
including a field is done in the wrong order: the field object is
hashed before the data object is.

However during verification, the hash is done in the opposite order as
objects are scanned sequentially.

7 years agojournal: warn when we fail to append a tag to a journal
Franck Bui [Fri, 23 Sep 2016 10:12:13 +0000 (12:12 +0200)] 
journal: warn when we fail to append a tag to a journal

We shouldn't silently fail when appending the tag to a journal file
since FSS protection will simply be disabled in this case.

7 years agol10n: update Czech translation (#4203)
AsciiWolf [Fri, 23 Sep 2016 05:11:26 +0000 (07:11 +0200)] 
l10n: update Czech translation (#4203)

7 years agomachine: Disable more output when quiet flag is set (#4196)
Wilhelm Schuster [Thu, 22 Sep 2016 19:49:22 +0000 (21:49 +0200)] 
machine: Disable more output when quiet flag is set (#4196)

7 years agol10n: add Czech Translation (#4195)
Daniel Maixner [Wed, 21 Sep 2016 12:42:35 +0000 (14:42 +0200)] 
l10n: add Czech Translation (#4195)

7 years agonss: install nss modules to ${rootlibdir}
Maciek Borzecki [Tue, 20 Sep 2016 19:24:45 +0000 (21:24 +0200)] 
nss: install nss modules to ${rootlibdir}

NSS modules (libnss_*.so.*) need to be installed into
${rootlibdir} (typically /lib) in order to be used. Previously, the
modules were installed into ${libdir}, thus usually ending up in
/usr/lib, even on systems where split usr is enabled, or ${libdir} is
passed explicitly.

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
7 years agonspawn: fix comment typo in setup_timezone example (#4183)
Michael Pope [Tue, 20 Sep 2016 05:30:48 +0000 (22:30 -0700)] 
nspawn: fix comment typo in setup_timezone example (#4183)

7 years agonetworkd: Allow specifying RouteTable for RAs 4182/head
Jason Kölker [Mon, 19 Sep 2016 02:59:11 +0000 (02:59 +0000)] 
networkd: Allow specifying RouteTable for RAs

7 years agonetworkd: Allow specifying RouteTable for DHCP
Jason Kölker [Mon, 19 Sep 2016 02:26:12 +0000 (02:26 +0000)] 
networkd: Allow specifying RouteTable for DHCP

7 years agojournal: fix typo in comment (#4176)
Felix Zhang [Sun, 18 Sep 2016 09:14:50 +0000 (17:14 +0800)] 
journal: fix typo in comment (#4176)

7 years agoRevert "kernel-install: Add KERNEL_INSTALL_NOOP (#4103)"
Martin Pitt [Sat, 17 Sep 2016 14:39:00 +0000 (16:39 +0200)] 
Revert "kernel-install: Add KERNEL_INSTALL_NOOP (#4103)"

Further discussion showed that this better gets addressed at the packaging
level.

This reverts commit 34210af7c63640fca1fd4a09fc23b01a8cd70bf3.

7 years agoMerge pull request #4123 from keszybz/network-file-dropins
Martin Pitt [Sat, 17 Sep 2016 08:00:19 +0000 (10:00 +0200)] 
Merge pull request #4123 from keszybz/network-file-dropins

Network file dropins

7 years agonspawn: clarify log warning for /etc/localtime not being a symbolic link (#4163)
Michael Pope [Sat, 17 Sep 2016 07:59:28 +0000 (00:59 -0700)] 
nspawn: clarify log warning for /etc/localtime not being a symbolic link (#4163)

7 years agonetworkd: change message about missing Kind 4123/head
Zbigniew Jędrzejewski-Szmek [Sat, 10 Sep 2016 16:44:50 +0000 (17:44 +0100)] 
networkd: change message about missing Kind

If Kind is not specied, the message about "Invalid Kind" was misleading.
If Kind was specified in an invalid way, we get a message in the parsing
phase anyway. Reword the message to cover both cases better.

7 years agoman: mention that netdev,network files support dropins
Zbigniew Jędrzejewski-Szmek [Sat, 10 Sep 2016 13:34:07 +0000 (14:34 +0100)] 
man: mention that netdev,network files support dropins

Also update the description of drop-ins in systemd.unit(5) to say that .d
directories, not .conf files, are in /etc/system/system, /run/systemd/system,
etc.

7 years agonetworkd: support drop-in dirs for .network files
Zbigniew Jędrzejewski-Szmek [Sat, 10 Sep 2016 13:32:19 +0000 (14:32 +0100)] 
networkd: support drop-in dirs for .network files

7 years agoshared/conf-parser: add config_parse_many which takes strv with dirs
Zbigniew Jędrzejewski-Szmek [Sat, 10 Sep 2016 11:19:41 +0000 (12:19 +0100)] 
shared/conf-parser: add config_parse_many which takes strv with dirs

This way we don't have to create a nulstr just to unpack it in a moment.

7 years agotree-wide: rename config_parse_many to …_nulstr
Zbigniew Jędrzejewski-Szmek [Sat, 10 Sep 2016 10:02:40 +0000 (11:02 +0100)] 
tree-wide: rename config_parse_many to …_nulstr

In preparation for adding a version which takes a strv.