Commit Graph

17359 Commits

Author SHA1 Message Date
Michael Biebl 29f3265584 units: simplify rescue.service and emergency.service (#5623)
The emergency.service and rescue.service units have become rather
convoluted. We spawn multiple shells and the help text spans multiple lines
which makes the units hard to read.

Move the logic into a single shell script and call that via ExecStart.
2017-03-22 23:37:06 -04:00
John Paul Adrian Glaubitz f652c62d71 basic/journal-importer: Fix unaligned access in get_data_size() (#5622) 2017-03-21 22:36:50 -04:00
Yu Watanabe 007ef0a224 resolved: detect and warn other running LLMNR stack
Previously, `SO_REUSEADDR` is set before `bind`-ing socket, Thus,
even if another LLMNR stack is running, `bind` always success and
we cannot detect the other stack. By this commit, we first try to
`bind` without `SO_REUSEADDR`, and if it fails, show warning and
retry with `SO_REUSEADDR`.
2017-03-21 13:35:12 +09:00
Yu Watanabe 77525fdc8d resolved: add global config option to control mDNS stack 2017-03-21 13:35:08 +09:00
Yu Watanabe 71a047d2f7 resolved: detect and warn other running mDNS stack
Previously, `SO_REUSEADDR` is set before `bind`-ing socket, Thus,
even if another mDNS stack (e.g. avahi) is running, `bind` always
success and we cannot detect the other stack.
By this commit, we first try to `bind` without `SO_REUSEADDR`,
and if it fails, show warning and retry with `SO_REUSEADDR`.
2017-03-21 13:34:52 +09:00
Yu Watanabe c6a8f6f66d resolved: do not start LLMNR or mDNS stack when no network enables them
When no network enables LLMNR or mDNS, it is not necessary to create
LLMNR or mDNS related sockets. So, let's create them only when
LLMNR- or mDNS-enabled network becomes active or at least one network
enables `LLMNR=` or `MulticastDNS=` options.
2017-03-21 13:14:04 +09:00
Felix Zhang 6070504015 systemctl: fix broken vertical lines in list-dependencies --all (#5608) 2017-03-20 11:27:39 +01:00
Zbigniew Jędrzejewski-Szmek 825fd3cd41 Merge (¾ of) pull request #5596 from matijaskala/master 2017-03-16 08:42:22 -04:00
Djalal Harouni d1d59eeb47 base-filesystem: skip fchownat() if the previous mkdirat() on same path failed (#5548)
If we are working on a path that was marked to be ignored on errors, and
the mkdirat() fails then add a continue statement and skip fchownat() call.
This avoids the case where UID/GID are valid and we run fchownat() on
non existent path which will fail hard even on paths that we want to
ignore in case of errors.
2017-03-15 22:30:15 -04:00
Matija Skala 2797366cd2 check for _POSIX_C_SOURCE instead of __USE_POSIX*
check for _GNU_SOURCE as well as sd_event_child_handler_t needs to be
defined correctly while compiling systemd
2017-03-16 03:29:53 +01:00
Matija Skala e5276995ae assigning stdout and stderr is not allowed 2017-03-16 03:24:49 +01:00
Matija Skala 284d1cd0a1 fix includes
linux/sockios.h is needed for the SIOCGSTAMPNS macro

xlocale.h is included indirectly in glibc and doesn't even exist in
other libcs
2017-03-15 13:21:10 +01:00
Michal Sekletar 3c302cddfb machinectl: don't return 1 in case we couldn't figure out container IP addresses (#5587)
This is in spirit very similar to commit
4b2419165c.

Fixes: #5581
2017-03-14 17:38:19 -04:00
Tobias Stoeckmann ff8017c4a2 Never call unmap with MAP_FAILED. (#5590)
When mmap is called, the code in correctly checks for p == MAP_FAILED.

But the resource cleanup at the end of busname_peek_message checks for
p == NULL, and if that's not true, munmap is called.

Therefore in error case, munmap is called with a MAP_FAILED argument
which can result in unexpected behaviour depending on sz's value.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-03-14 17:33:22 -04:00
Tobias Stoeckmann 6f94e420e8 journal: prevent integer overflow while validating header (#5569)
It is possible to overflow uint64_t while validating the header of
a journal file. To prevent this, the addition itself is checked to
be within the limits of UINT64_MAX first.

To keep this readable, I have introduced two stack variables which
hold the converted values during validation.
2017-03-13 08:14:42 +01:00
Zbigniew Jędrzejewski-Szmek 1070d271fa headers: check that __INCLUDE_LEVEL__ is defined before using it (#5575)
That macro is a gcc extension, and while widely supported, not ubiquitous.
In particular the coverity scanner is having trouble with it.
2017-03-13 08:11:24 +01:00
Yu Watanabe 44ccb3d723 resolve: add missing space in output message (#5574) 2017-03-12 20:12:03 -04:00
AsciiWolf 7ebf71ee03 sd-bus: drop kdbus-related docs (#5533) 2017-03-07 07:51:35 +01:00
Thomas H. P. Andersen 557e36934d cgtop: use PRIu64 to print uint64_t (#5544)
Commit 59f448cf replaced usage of off_t with uint64_t. Change the
format string to use PRIu64 to match it.
2017-03-07 07:47:18 +01:00
Djalal Harouni 81687ee338 Merge pull request #5540 from keszybz/coredump-eof-fix
coredump: fix handling of premature-eof for --backtrace
2017-03-06 17:25:40 +01:00
Zbigniew Jędrzejewski-Szmek d74dc4f2d0 coredump: fix handling of premature-eof data for --backtrace
We'd fail with an assert in journal_importer_process_data(),
because that function requires the caller to handle EOF themselves.
2017-03-05 10:35:44 -05:00
Djalal Harouni 77313738fe Merge pull request #5525 from martinpitt/khash-notsupp
test: skip instead of fail if crypto kmods are not available
2017-03-05 14:55:48 +01:00
Dax Kelson 055c521ad4 import: bump image size safety limit for machinectl pull (#5535)
We currenly use 40GB images in our environment
2017-03-05 13:03:53 +01:00
Martin Pitt 2e914f34eb test: skip instead of fail if crypto kmods are not available
Package build machines may have module loading disabled, thus AF_ALG
sockets are not available. Skip the tests that cover those (khash and
id128) instead of failing them in this case.

Fixes #5524
2017-03-03 16:45:44 +01:00
Michael Biebl dcce98a4bd Avoid strict DM interface version dependencies (#5519)
Compiling against the dm-ioctl.h header as provided by the Linux kernel
will embed the DM interface version number. Running an older kernel can
result in an error like this on shutdown:

Could not detach DM dm-11: ioctl mismatch, kernel(4.34.4), user(4.35.4)

Work around this by shipping a local copy of dm-ioctl.h. We need at
least the version from 3.13 for DM_DEFERRED_REMOVE [1], so bump the
requirements in README accordingly.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2c140a246dc0bc085b98eddde978060fcec1080c

Fixes: #5492
2017-03-02 19:11:37 +01:00
John Paul Adrian Glaubitz 9da2a0ac4e basic/architecture: Add sub-architecture types for SuperH
On SuperH, there are multiple sub-architectures defined with
different values for LIB_ARCH_TUPLE. The different sub-
architectures can be detected by checking whether __SH1__,
__SH2__, __SH3__, __SH4__, and so on are defined.
2017-03-02 10:29:43 +01:00
John Paul Adrian Glaubitz 202145c07a basic/architecture: Properly set LIB_ARCH_TUPLE for powerpcspe
On powerpc, there are two possible ABIs and hence values for
LIB_ARCH_TUPLE. The convential type with an FPU and the embedded
variant, called powerpcspe, which does not have a convential FPU
but a special Signal Processing Engine (SPE). The latter can be
detected by checking whether __NO_FPRS__ is defined.
2017-03-02 01:51:11 +01:00
John Paul Adrian Glaubitz 4c7c70c7c2 basic/architecture: Properly set LIB_ARCH_TUPLE for x32
On x86_64, there are two possible ABIs and hence values for
LIB_ARCH_TUPLE. The convential 64-bit type and the 32-bit
variant, called x32. The latter can be detected by checking
whether __ILP32__ is defined.
2017-03-02 01:50:36 +01:00
Lennart Poettering 268b6e1932 Merge pull request #5283 from poettering/tighten-sandbox
Tighten sandbox of long-running services
2017-03-01 23:35:06 +01:00
Lennart Poettering 47ef78b27f Merge pull request #5502 from poettering/coredump-mini-fixes
Coredump mini improvments
2017-03-01 22:14:33 +01:00
Viktor Mihajlovski fb92fbb1b1 udev: Use parent bus id for virtio disk builtin path-id (#5500)
The builtin path id for virtio block devices has been changed
to use the bus id without a prefix "virtio-pci" to be
compatible with all virtio transport types.

In order to not break existing setups, the by-path symlinks for
virtio block devices on the PCI bus are reintroduced by udev rules.
The virtio-pci symlinks are considered to be deprecated and
should be replaced by the native PCI symlinks.

Example output for a virtio disk in PCI slot 7:
 $ ls  /dev/disk/by-path
 pci-0000:00:07.0
 pci-0000:00:07.0-part1
 virtio-pci-0000:00:07.0
 virtio-pci-0000:00:07.0-part1

See also
[1] https://lists.freedesktop.org/archives/systemd-devel/2017-February/038326.html
[2] https://lists.freedesktop.org/archives/systemd-devel/2017-March/038397.html

This reverts f073b1b but keeps the same symlinks for compatibility.
2017-03-01 15:30:17 -05:00
Lennart Poettering d6d0473dc9 Revert "util: Fine tune running_in_chroot() a bit" (#5506)
This reverts commit 295ee9845c.

Let'd revert this for now, see #5446 for discussions.

We want systemd-detect-virt --chroot to return true for all chroot-like stuff, for
example mock environments which have use a mount namespace. The downside
of this revert that systemctl will not work from our own namespaced services, anything
with RootDirectory=/RootImage= set.
2017-03-01 15:22:02 -05:00
Lennart Poettering 501551e803 coredump: define a macro for a "short bus call timeout"
I think it would be a good idea to move such fixed, picked values out of
the main sources into the head of a file, to make sure they are
ultimately tunables.
2017-03-01 18:13:00 +01:00
Lennart Poettering b8cda92df5 coredump: introduce is_journald_crash() and is_pid1_crash() helpers
We check these a number of times, hence let's unify these checks here.
This also allows us to make the PID 1 check more elaborate as we can
check both the PID and the cgroup. Checking the PID has the benefit that
we'll also cover cases where PID 1 might still be in the root cgroup, and
the cgroup check has the benefit that we also cover crashes in forked
off crasher processes (the way we actually do it in systemd)
2017-03-01 18:13:00 +01:00
Lennart Poettering 32a1575fbd coredump: normalize generation/parsing of COREDUMP_TRUNCATED=
Given that this is a field primarily processed by computers, and not so
much by humans, assign "1" instead of "yes". Also, use parse_boolean()
as we usually do for parsing it again.

This makes things more alike udev options (as one example), such as
SYSTEMD_READY where we also spit out "1" and "0", and parse with
parse_boolean().
2017-03-01 18:13:00 +01:00
Lennart Poettering 059c35f507 mount-util: accept that name_to_handle_at() might fail with EPERM (#5499)
Container managers frequently block name_to_handle_at(), returning
EACCES or EPERM when this is issued. Accept that, and simply fall back
to to fdinfo-based checks.

Note that we accept either EACCES or EPERM here, as container managers
can choose the error code and aren't very good on agreeing on just one.

(note that this is a non-issue with nspawn, as we permit
name_to_handle_at() there, only block open_by_handle_at(), which should
be sufficiently safe).
2017-03-01 11:35:05 -05:00
Lennart Poettering 77969722aa core: when a unit's SourcePath points to API VFS pretend we are never out-of-date (#5487)
If the unit's SourcePath is below /proc then it's a unit genreated from
a kernel resource (such as a .mount or .swap unit). And those we watch
anyway, and hence should never be out-of-date.

Fixes: #5461
2017-03-01 10:25:08 -05:00
Lennart Poettering ecadd9b3fd Merge pull request #5458 from keszybz/coredump
Fix for coredump crash
2017-03-01 14:37:15 +01:00
Zbigniew Jędrzejewski-Szmek 92d6f2f348 Merge pull request #5494 from poettering/run-fixes
systemd-run --user fixes.
2017-02-28 23:03:12 -05:00
Lennart Poettering 3401f0e145 resolved: add the new KSK to the built-in resolved trust anchor (#5486)
Fixes: #5482
2017-02-28 22:49:19 -05:00
Lennart Poettering e350ca3f1e automount: if an automount unit is masked, don't react to activation anymore (#5445)
Otherwise we'll hit an assert sooner or later.

This requires us to initialize ->where even if we come back in "masked"
mode, as otherwise we don't know how to operate on the automount and
detach it.

Fixes: #5441
2017-02-28 22:03:48 -05:00
Zbigniew Jędrzejewski-Szmek eb5877a024 coredumpctl: avoid spurious warning about systemd-coredump@0.service
Fixes #5477.
2017-02-28 21:47:45 -05:00
Zbigniew Jędrzejewski-Szmek b9aaa7f480 coredumpctl: print a hint when no journal files are found
[guest@fedora ~]$ coredumpctl
No coredumps found.

[guest@fedora ~]$ ./coredumpctl
Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal', 'wheel' can see all messages.
      Pass -q to turn off this notice.
No coredumps found.

Fixes #1733.
2017-02-28 21:38:47 -05:00
Zbigniew Jędrzejewski-Szmek 4f37cbd911 journalctl: move access_check() to shared/
The only functional change is that log_notice("No journal files were found.")
is not printed any more with --quiet. log_error("No journal files were opened
due to insufficient permissions.") is still printed.

I wasn't quite sure where to put this function, but shared/ seems to be the
right place and none of the existing files seem to fit too well.

v2: rename journal_access_check to journal_access_check_and_warn.
2017-02-28 21:37:35 -05:00
Zbigniew Jędrzejewski-Szmek 7d8e7c0e19 coredumpctl: use a 3s timeout for checking units
This is just a hint, so we shouldn't wait too long. A short timeout
helps for the case where pid1 of dbus have crashed.
2017-02-28 21:34:53 -05:00
Zbigniew Jędrzejewski-Szmek 92e92d71fa coredump: process special crashes in an (almost) normal way
We would only log a terse message when pid1 or systemd-journald crashed.
It seems better to reuse the normal code paths as much as possible,
with the following differences:
- if pid1 crashes, we cannot launch the helper, so we don't analyze the
 coredump, just write it to file directly from the helper invoked by the
 kernel;
- if journald crashes, we can produce the backtrace, but we don't log full
  structured messages.

With comparison to previous code, advantages are:
- we go through most of the steps, so for example vacuuming is performed,
- we gather and log more data. In particular for journald and pid1 crashes we
  generate a backtrace, and for pid1 crashes we record the metadata (fdinfo,
  maps, etc.),
- coredumpctl shows pid1 crashes.

A disavantage (inefficiency) is that we gather metadata for journald crashes
which is then ignored because _TRANSPORT=kernel does not support structued
messages.

Messages for the systemd-journald "crash" have _TRANSPORT=kernel, and
_TRANSPORT=journal for the pid1 "crash".

Feb 26 16:27:55 systemd[1]: systemd-journald.service: Main process exited, code=dumped, status=11/SEGV
Feb 26 16:27:55 systemd[1]: systemd-journald.service: Unit entered failed state.
Feb 26 16:37:54 systemd-coredump[18801]: Process 18729 (systemd-journal) of user 0 dumped core.
Feb 26 16:37:54 systemd-coredump[18801]: Coredump diverted to /var/lib/systemd/coredump/core.systemd-journal.0.36c14bf3c6ce4c38914f441038990979.18729.1488145074000000.lz4
Feb 26 16:37:54 systemd-coredump[18801]: Stack trace of thread 18729:
Feb 26 16:37:54 systemd-coredump[18801]: #0  0x00007f46d6a06b8d fsync (libpthread.so.0)
Feb 26 16:37:54 systemd-coredump[18801]: #1  0x00007f46d71bfc47 journal_file_set_online (libsystemd-shared-233.so)
Feb 26 16:37:54 systemd-coredump[18801]: #2  0x00007f46d71c1c31 journal_file_append_object (libsystemd-shared-233.so)
Feb 26 16:37:54 systemd-coredump[18801]: #3  0x00007f46d71c3405 journal_file_append_data (libsystemd-shared-233.so)
Feb 26 16:37:54 systemd-coredump[18801]: #4  0x00007f46d71c4b7c journal_file_append_entry (libsystemd-shared-233.so)
Feb 26 16:37:54 systemd-coredump[18801]: #5  0x00005577688cf056 write_to_journal (systemd-journald)
Feb 26 16:37:54 systemd-coredump[18801]: #6  0x00005577688d2e98 dispatch_message_real (systemd-journald)
Feb 26 16:37:54 kernel: systemd-coredum: 9 output lines suppressed due to ratelimiting
Feb 26 16:37:54 systemd-journald[18810]: Journal started

Feb 26 16:50:59 systemd-coredump[19229]: Due to PID 1 having crashed coredump collection will now be turned off.
Feb 26 16:51:00 systemd[1]: Caught <SEGV>, dumped core as pid 19228.
Feb 26 16:51:00 systemd[1]: Freezing execution.
Feb 26 16:51:00 systemd-coredump[19229]: Process 19228 (systemd) of user 0 dumped core.

                                         Stack trace of thread 19228:
                                         #0  0x00007fab82075c47 kill (libc.so.6)
                                         #1  0x000055fdf7c38b6b crash (systemd)
                                         #2  0x00007fab824175c0 __restore_rt (libpthread.so.0)
                                         #3  0x00007fab82148573 epoll_wait (libc.so.6)
                                         #4  0x00007fab8366f84a sd_event_wait (libsystemd-shared-233.so)
                                         #5  0x00007fab836701de sd_event_run (libsystemd-shared-233.so)
                                         #6  0x000055fdf7c4a380 manager_loop (systemd)
                                         #7  0x000055fdf7c402c2 main (systemd)
                                         #8  0x00007fab82060401 __libc_start_main (libc.so.6)
                                         #9  0x000055fdf7c3818a _start (systemd)

Poor machine ;)
2017-02-28 21:33:52 -05:00
Martin Pitt 74278ce567 Merge pull request #5493 from poettering/service-mini-fixes
three small mini-fixes for src/core/service.c
2017-02-28 23:23:18 +01:00
David Herrmann b4227dbb45 hostname: detect detachable dmi chassis type (#5489)
Detect the 'Detachable' dmi chassis type properly. Use the new
'convertible' chassis class of hostnamed, instead of returning the
generic 'computer' chassis class.
2017-02-28 21:57:58 +01:00
Mauricio Faria de Oliveira a6f8786a56 cryptsetup-generator: run cryptsetup service before swap unit (#5480)
If the cryptsetup service unit and swap unit for a swap device
are not strictly ordered, it might happen that the swap unit
activates/mounts the swap device before its cryptsetup service unit
has a chance to run the 'mkswap' command (that it is programmed to).

This leads to the following error:

             Starting Cryptography Setup for sda3_crypt...
    [  OK  ] Found device /dev/mapper/sda3_crypt.
             Activating swap /dev/mapper/sda3_crypt...
    [  OK  ] Activated swap /dev/mapper/sda3_crypt.
    [  OK  ] Reached target Swap.
    [FAILED] Failed to start Cryptography Setup for sda3_crypt.
    See 'systemctl status systemd-cryptsetup@sda3_crypt.service' for
    details.
    [DEPEND] Dependency failed for Encrypted Volumes.

Which happens because the swap device is already mounted:

    # systemctl status systemd-cryptsetup@sda3_crypt.service
    <...>
       Active: failed (Result: exit-code) since Mon 2017-02-27 14:21:43 CST;
    54s ago
    <...>

    <...> systemd[1]: Starting Cryptography Setup for sda3_crypt...
    <...> mkswap[2420]: mkswap: error: /dev/mapper/sda3_crypt is mounted;
    will not make swapspace
    <...>

So, modify cryptsetup-generator to include a 'Before=' option for the
respective 'dev-mapper-%i.swap' device in the cryptsetup service unit.

Now, correct ordering is ensured, and the error no longer occurs:

             Starting Cryptography Setup for sda3_crypt...
    [  OK  ] Found device /dev/mapper/sda3_crypt.
    [  OK  ] Started Cryptography Setup for sda3_crypt.
             Activating swap /dev/mapper/sda3_crypt...
    [  OK  ] Reached target Encrypted Volumes.
    [  OK  ] Activated swap /dev/mapper/sda3_crypt.
    [  OK  ] Reached target Swap.
2017-02-28 21:30:22 +01:00
Lennart Poettering a625def6ea run: also pin unit when we we are in --pty mode
Since 95f1d6bfec we'll subscribe to unit
signals to figure out when to disconnect the pty. But that can only work
correctly if we actually subscribe to the unit's signals. Hence,
explicitly pin (and thus subscribe to) the unit we just created not only
in --wait mode but also in --pty mode.

Or to say this differently: we need to pin the unit in the same cases as
we install the signal match. 95f1d6bfec
forgot to do that.

This is relevant to make sure systemd-run works correctly in --user
mode, and correctly exits when the spawned service dies. To test:

systemd-run --user -t /bin/bash

And then press ^D. This will hang before this change, but exit cleanly
after it.
2017-02-28 18:35:05 +01:00