Commit Graph

32163 Commits

Author SHA1 Message Date
Lennart Poettering 7cb609115c user-util: also consider /bin/false and /bin/true as non-shell 2018-02-12 11:34:00 +01:00
Lennart Poettering a6011d1887 core: update dbus policy file
This patch does four things:

1. Adds more comments that clarify the order in which things appear in
   the file

2. All entries are placed in the order in which their SD_BUS_METHOD()
   macros appear in the C vtables.

3. A couple of missing entries are added that should be open to all or
   do polkit

4. Corrects the interface name for the GetProcesses() calls. They belong
   to the per-unit interface, not to Unit
2018-02-12 11:34:00 +01:00
Lennart Poettering cedf508886 core: simplify manager_recheck_journal() a bit
No need for an if check if we just pass along a bool anyway.
2018-02-12 11:34:00 +01:00
Lennart Poettering 217677abb0 core: tweak manager_journal_is_running() a bit more
Let's also use the journal if it is currently reloading. In that state
it should also be able to process our requests. Moreover, we might
otherwise end up disconnecting/reconnecting from the journal without
really any need to hence, relax the check accordingly.
2018-02-12 11:34:00 +01:00
Lennart Poettering 7d814a197a manager: tweak manager_journal_is_running() a bit regarding test mode
In test mode, let's not consider the journal to be up ever: we want all
output to go to stderr.
2018-02-12 11:34:00 +01:00
Lennart Poettering 8559b3b75c core: rework how we connect to the bus
This removes the current bus_init() call, as it had multiple problems:
it munged  handling of the three bus connections we care about (private,
"api" and system) into one, even though the conditions when which was
ready are very different. It also added redundant logging, as the
individual calls it called all logged on their own anyway.

The three calls bus_init_api(), bus_init_private() and bus_init_system()
are now made public. A new call manager_dbus_is_running() is added that
works much like manager_journal_is_running() and is a lot more careful
when checking whether dbus is around. Optionally it checks the unit's
deserialized_state rather than state, in order to accomodate for cases
where we cant to connect to the bus before deserializing the
"subscribed" list, before coldplugging the units.

manager_recheck_dbus() is added, that works a lot like
manager_recheck_journal() and is invoked in unit_notify(), i.e. when
units change state.

All in all this should make handling a bit more alike to journal
handling, and it also fixes one major bug: when running in user mode
we'll now connect to the system bus early on, without conditionalizing
this in anyway.
2018-02-12 11:34:00 +01:00
Lennart Poettering 4502c40399 dbus: split up bus_done() into seperate functions
No functional changes, but let's make this a bit more finegrained.

(The individual functions are exported, which is used in a later commit)
2018-02-12 11:34:00 +01:00
Lennart Poettering 418cdd69d1 bpf-firewall: fix warning text
I figure saying "systemd" here was a typo, and it should have been
"system". (Yes, it becomes very hard after a while typing "system"
correctly if you type "systemd" so often.) That said, "systemd" in some
ways is actually more correct, since BPF might be available for the
system instance but not in the user instance.

Either way, talking of "this systemd" is weird, let's reword this to be
"this manager", to emphasize that it's the local instance of systemd
where BPF is not available, but that it might be available otherwise.
2018-02-12 11:34:00 +01:00
Lennart Poettering d66a98482b mkosi: update to fedora 27, it's released since a while 2018-02-12 11:34:00 +01:00
Lennart Poettering 36b5119a0c process-util: be more careful in is_kernel_thread()
This reworks is_kernel_thread() a bit. Instead of checking whether
/proc/$pid/cmdline is entirely empty we now parse the 'flags' field from
/proc/$pid/stat and check the PF_KTHREAD flag, which directly encodes
whether something is a kernel thread.

Why all this? With current kernels userspace processes can set their
command line to empty too (through PR_SET_MM_ARG_START and friends), and
could potentially confuse us. Hence, let's use a more reliable way to
detect kernels like this.
2018-02-12 11:34:00 +01:00
Lennart Poettering 004c7f169e core: fold manager_set_exec_params() into unit_set_exec_params()
Let's simplify things a bit: we so far called both functions every
single time, let's just merge one into the other, so that we have fewer
functions to call.
2018-02-12 11:34:00 +01:00
Lennart Poettering 1d9cc8768f cgroup: add a new "can_delegate" flag to the unit vtable, and set it for scope and service units only
Currently we allowed delegation for alluntis with cgroup backing
except for slices. Let's make this a bit more strict for now, and only
allow this in service and scope units.

Let's also add a generic accessor unit_cgroup_delegate() for checking
whether a unit has delegation turned on that checks the new bool first.

Also, when doing transient units, let's explcitly refuse turning on
delegation for unit types that don#t support it. This is mostly
cosmetical as we wouldn't act on the delegation request anyway, but
certainly helpful for debugging.
2018-02-12 11:34:00 +01:00
Yu Watanabe b8e2400586
Merge pull request #8143 from yuwata/drop-unused-func
Drop several unused functions
2018-02-10 12:47:12 +09:00
Yu Watanabe 92db49a0c2 socket-util: drop getnameinfo_pretty() 2018-02-10 11:10:07 +09:00
Zbigniew Jędrzejewski-Szmek aa9122bf3d Revert "Periodically call sd_journal_process in journalctl" (#8147)
This reverts commit 992149c07e.

https://github.com/systemd/systemd/pull/8144#issuecomment-364464627
$ (set -o pipefail; sudo ./build/journalctl --no-pager | wc -l; echo $?)
Failed to process inotify events: Bad file descriptor
1025
1
2018-02-09 20:10:00 +01:00
Zbigniew Jędrzejewski-Szmek cadc80b873 basic/socket-util: drop use of NI_IDN_USE_STD3_ASCII_RULES
The only use of socknameinfo_pretty() is in src/journal-remote/journal-remote.c,
to determine the output filename.

Replaces #8120.
2018-02-09 19:29:51 +01:00
Lennart Poettering 7fe2903c23 fd-util: move certain fds above fd #2 (#8129)
This adds some paranoia code that moves some of the fds we allocate for
longer periods of times to fds > 2 if they are allocated below this
boundary. This is a paranoid safety thing, in order to avoid that
external code might end up erroneously use our fds under the assumption
they were valid stdin/stdout/stderr. Think: some app closes
stdin/stdout/stderr and then invokes 'fprintf(stderr, …' which causes
writes on our fds.

This both adds the helper to do the moving as well as ports over a
number of users to this new logic. Since we don't want to litter all our
code with invocations of this I tried to strictly focus on fds we keep
open for long periods of times only and only in code that is frequently
loaded into foreign programs (under the assumptions that in our own
codebase we are smart enough to always keep stdin/stdout/stderr
allocated to avoid this pitfall). Specifically this means all code used
by NSS and our sd-xyz API:

1. our logging APIs
2. sd-event
3. sd-bus
4. sd-resolve
5. sd-netlink

This changed was inspired by this:

https://github.com/systemd/systemd/issues/8075#issuecomment-363689755

This shows that apparently IRL there are programs that do close
stdin/stdout/stderr, and we should accomodate for that.

Note that this won't fix any bugs, this just makes sure that buggy
programs are less likely to interfere with out own code.
2018-02-09 17:53:28 +01:00
Simon Fowler e25937a3ed Suspend on lid close based on power status. (#8016)
This change adds support for controlling the suspend-on-lid-close
behaviour based on the power status as well as whether the machine is
docked or has an external monitor. For backwards compatibility the new
configuration file variable is ignored completely by default, and must
be set explicitly before being considered in any decisions.
2018-02-09 17:37:39 +01:00
Zbigniew Jędrzejewski-Szmek 9e42c9373c
Merge pull request #8066 from LittleCVR/udevadm-trigger-and-settle
udevadm: allow trigger command to be synchronous
2018-02-09 17:09:42 +01:00
Zbigniew Jędrzejewski-Szmek 91761b1846
Merge pull request #8134 from keszybz/unit-load-paths
Various fixes to unit load paths, and systemd-analyze load-paths verb to list them
2018-02-09 17:08:23 +01:00
Lennart Poettering 73969ab61c service: relax PID file symlink chain checks a bit (#8133)
Let's read the PID file after all if there's a potentially unsafe
symlink chain in place. But if we do, then refuse taking the PID if its
outside of the cgroup.

Fixes: #8085
2018-02-09 17:05:17 +01:00
Oleander Reis 2d06ddb7b4 man:systemd.service(5): fix description of specifiers in command lines (#8146)
Command lines now accept specifiers within the first argument.

see issues #3061, #679 and pr #4835
2018-02-09 17:03:09 +01:00
Zbigniew Jędrzejewski-Szmek 230cc99a0f analyze: slight simplification 2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek baa4880bac analyze: remove implicit conversions of numbers to booleans 2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 80efdacd08 man: make Notes section in systemd.geneator(5) toplevel
This is mostly a indentation change and rewrapping.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek b82f27e7a3 man: document unit load paths
So far we didn't document control, transient, dbus config, or generator paths.
But those paths are visible to users, and they need to understand why systemd
loads units from those paths, and how the precedence hierarchy looks.
The whole thing is a bit messy, since the list of paths is quite long.
I made the tables a bit shorter by combining rows for the alternatives
where $XDG_* is set and the fallback.

In various places, tags are split like <element
  param="blah">
this. This is necessary to keep everyting in one logical XML line so that
docbook renders the table properly.

Replaces #8050.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 0d6671b2ef shared/path-lookup: rename user control dirs to "user.control"
$ diff -u <(old/systemd-analyze --user unit-paths) <(new/systemd-analyze --user unit-paths)|colordiff
--- /proc/self/fd/14	2018-02-08 14:36:34.190046129 +0100
+++ /proc/self/fd/15	2018-02-08 14:36:34.190046129 +0100
@@ -1,5 +1,5 @@
-/home/zbyszek/.config/systemd/system.control
-/run/user/1000/systemd/system.control
+/home/zbyszek/.config/systemd/user.control
+/run/user/1000/systemd/user.control
 /run/user/1000/systemd/transient
 ...

Strictly speaking, online upgrades of user instances through daemon-reexec will
be broken. We can get away with this since
a) reexecs of the user instance are not commonly done, at least package upgrade
   scripts don't do this afawk.
b) cgroups aren't delegateable on cgroupsv1 there's little reason to use "systemctl
   set-property" for --user mode
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 7e684baf90 shared/path-lookup: rearrange paths in --global mode to match --user mode
It's not good if the paths are in different order. With --user, we expect
more paths, but it must be a strict superset, and the order for the ones
that appear in both sets must be the same.

$  diff -u <(build/systemd-analyze --global unit-paths) <(build/systemd-analyze --user unit-paths)|colordiff
--- /proc/self/fd/14	2018-02-08 14:11:45.425353107 +0100
+++ /proc/self/fd/15	2018-02-08 14:11:45.426353116 +0100
@@ -1,6 +1,17 @@
+/home/zbyszek/.config/systemd/system.control
+/run/user/1000/systemd/system.control
+/run/user/1000/systemd/transient
+/run/user/1000/systemd/generator.early
+/home/zbyszek/.config/systemd/user
 /etc/systemd/user
+/run/user/1000/systemd/user
 /run/systemd/user
+/run/user/1000/systemd/generator
+/home/zbyszek/.local/share/systemd/user
+/home/zbyszek/.local/share/flatpak/exports/share/systemd/user
+/var/lib/flatpak/exports/share/systemd/user
 /usr/local/share/systemd/user
 /usr/share/systemd/user
 /usr/local/lib/systemd/user
 /usr/lib/systemd/user
+/run/user/1000/systemd/generator.late

A test is added so that we don't regress on this.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 7b6344d35f path-lookup: include paths from --global in --user search path too
This doesn't matter that much, because set-property --global does not work,
so at least those paths wouldn't be used automatically. It is still possible
to create such snippets manually, so we better fix this.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek c59479e790 path-lookup: fix confusion between persistent_control and persistent_config
persistent_config would not appear in the search path at all, hence
those overrides would not work at all.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek ecd3717a74 shell-completion: add --global and unit-paths 2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 31a5924ed8 analyze: add unit-paths verb 2018-02-09 12:27:27 +01:00
Lennart Poettering af77d6f8da
Merge pull request #8083 from shawnl/close-ssh
sd-bus: cleanup ssh sessions (Closes: #8076)
2018-02-09 12:17:26 +01:00
Zbigniew Jędrzejewski-Szmek 6bcc09bea1 udevadm: check for oom and other style fixes 2018-02-09 12:04:03 +01:00
Mao 792cc203a6 udevadm: allow trigger command to be synchronous
There are cases that we want to trigger and settle only specific
commands. For example, let's say at boot time we want to make sure all
the graphics devices are working correctly because it's critical for
booting, but not the USB subsystem (we'll trigger USB events later). So
we do:

  udevadm trigger --action="add" --subsystem-match="graphics"
  udevadm settle

However, we cannot block the kernel from emitting kernel events from
discovering USB devices. So if any of the USB kernel event was emitted
before the settle command, the settle command would still wait for the
entire queue to complete. And if the USB event takes a long time to be
processed, the system slows down.

The new `settle` option allows the `trigger` command to wait for only
the triggered events, and effectively solves this problem.
2018-02-09 11:59:03 +01:00
Lennart Poettering 8c2dbc8779
Merge pull request #8142 from yuwata/sd-bus-memleak
Fix potential memory leaks and several code style updates
2018-02-09 11:39:26 +01:00
Yu Watanabe 01e4793de6 fs-util: drop readlink_and_make_absolute_root() 2018-02-09 16:58:56 +09:00
Yu Watanabe 842e456e79 fs-util: drop readlink_and_canonicalize() 2018-02-09 16:49:54 +09:00
Yu Watanabe f2e18ef1a3 core: remove unnecessary initialization 2018-02-09 16:36:37 +09:00
Yu Watanabe 43beb0cf68 udev: use "#pragma once" 2018-02-09 16:33:30 +09:00
Yu Watanabe e5c8029e13 sd-bus: explicitly convert int to bool 2018-02-09 16:22:00 +09:00
Yu Watanabe cad4fb19c8 sd-bus: use free_and_replace() 2018-02-09 16:21:51 +09:00
Yu Watanabe b4ca3f45dc sd-bus: avoid potential memory leaks 2018-02-09 16:21:29 +09:00
Lucas Werkmeister 3c84514d07 man: fix capability name in man:systemd-tmpfiles(8) (#8139)
CAP_ADMIN does not exist (the closest existing capability name would be
CAP_SYS_ADMIN), and according to man:open(2) and man:capabilities(7),
the capability required to specify O_NOATIME is actually CAP_FOWNER.
2018-02-09 11:05:49 +09:00
Peter Portante 992149c07e Periodically call sd_journal_process in journalctl
If `journalctl` take a long time to process messages, and during that
time journal file rotation occurs, a `journalctl` client will keep
those rotated files open until it calls `sd_journal_process()`, which
typically happens as a result of calling `sd_journal_wait()` below in
the "following" case.  By periodically calling `sd_journal_process()`
during the processing loop we shrink the window of time a client
instance has open file descriptors for rotated (deleted) journal
files.

**Warning**

This change does not appear to solve the case of a "paused" output
stream. If somebody is using `journalctl | less` and pauses the
output, then without a background thread periodically listening for
inotify delete events and cleaning up, journal logs will eventually
stop flowing in cases where a journal client with enough open files
causes the "free" disk space threshold to be crossed.
2018-02-08 20:04:18 +01:00
Shawn Landden 392cf1d05d sd-bus: cleanup ssh sessions (Closes: #8076)
we still invoke ssh unnecessarily when there in incompatible or erreneous input
The fallow-up to finish that would make the code a bit more verbose,
as it would require repeating this bit:
```
        r = bus_connect_transport(arg_transport, arg_host, false, &bus);
        if (r < 0) {
                log_error_errno(r, "Failed to create bus connection: %m");
                goto finish;
        }

        sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
```
in every verb, after parsing.

v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL
v3: refactor, wait in bus_start_address()
2018-02-08 10:14:48 -08:00
Shawn Landden ade681a861 machine: add some missing asserts 2018-02-08 10:10:40 -08:00
Zbigniew Jędrzejewski-Szmek 28b35ef23a analyze: add --global option
This is somewhat useful for 'verify', and will be used later with 'unit-paths'.
2018-02-08 16:35:24 +01:00
Zbigniew Jędrzejewski-Szmek 87ac8d998f tree-wide: use "cannot" instead of "can not"
This is the usual spelling, and a bit shorter.
2018-02-08 10:34:52 +01:00
Susant Sahani bf443be995 networkd: vxlan require Remote= to be a non multicast address (#8117)
Remote= must be a non multicast address. ip-link(8) says:
> remote IPADDR - specifies the unicast destination IP address to
>                      use in outgoing packets when the destination link layer address
>                      is not known in the VXLAN device forwarding database.

Closes #8088.
2018-02-08 10:22:46 +01:00