Yu Watanabe [Thu, 28 Sep 2017 06:38:50 +0000 (15:38 +0900)]
networkd: use assert_not_reached()
Yu Watanabe [Thu, 28 Sep 2017 06:37:38 +0000 (15:37 +0900)]
networkd: use IN_SET macro
Zbigniew Jędrzejewski-Szmek [Wed, 27 Sep 2017 17:37:25 +0000 (19:37 +0200)]
Merge pull request #6922 from poettering/symlink-sockets
Fixes for Symlinks= handling in socket units
Yu Watanabe [Wed, 27 Sep 2017 15:55:13 +0000 (00:55 +0900)]
network: change log level when sd_rtnl_message_get_family() returns invalid family (#6923)
From
bce67bbee359eec19e6778619b6651100a1c1477, systemd-networkd always shows
```
rtnl: received address with invalid family type 32, ignoring.
```
during boot-up. In the code, there are log_warning() and log_debug() for the
same situation, and the log_debug() is never called. So, let's lower the
log level and remove never called function.
Zbigniew Jędrzejewski-Szmek [Wed, 27 Sep 2017 15:54:06 +0000 (17:54 +0200)]
core/cgroup: add a helper macro for a common pattern (#6926)
Lennart Poettering [Wed, 27 Sep 2017 15:48:28 +0000 (17:48 +0200)]
socket: if RemoveOnStop= is turned on for a socket, try to unlink() pre-existing symlinks
Normally, Symlinks= failing is not considered fatal nor destructive.
Let's slightly alter behaviour here if RemoveOnStop= is turned on. In
that case the use in a way opted for destructive behaviour and we do
unlink all sockets and symlinks when the socket unit goes down. And that
means we might as well unlink any pre-existing if this mode is selected.
Yeah, it's a bit of a stretch to do this, but @OhNoMoreGit is right: if
RemoveOnStop= is on we are destructive regarding any pre-existing
symlinks on stop, and it would be quite weird if we wouldn't be on
start.
Lennart Poettering [Tue, 26 Sep 2017 16:36:41 +0000 (18:36 +0200)]
man: document that inability to execute Symlinks= is not fatal
Fixes: #6920
Lennart Poettering [Tue, 26 Sep 2017 16:27:56 +0000 (18:27 +0200)]
socket: create leading directories for socket symlinks
It really doesn't hurt creating prefix directories if necessary, as we
tend to do that for other file nodes we create, too.
Fixes: #6920
Lennart Poettering [Tue, 26 Sep 2017 16:27:09 +0000 (18:27 +0200)]
socket: make sure we warn loudly about symlinks we can't create
Note that this change does not make symlink creation failing fatal. I am
not entirely sure about whether it should be, but I am leaning towards
not making it fatal for two reasons: symlinks like this tend to be a
compatibility feature, and hence unlikely to be essential for operation,
in a way this breaks compatibility, and while doing that is not off the
table, we should probably avoid it if we are not entirely sure it's a
good thing.
Note that this also changes plain symlink() to symlink_idempotent() so
that existing symlinks with the right destination are nothing we log
about.
Fixes: #6920
Lennart Poettering [Tue, 26 Sep 2017 16:26:20 +0000 (18:26 +0200)]
fs-util: propagate EEXIST error in symlink_idempotent() as EEXIST
We really shouldn't silently translate the error code here for no
reason.
Zbigniew Jędrzejewski-Szmek [Wed, 27 Sep 2017 09:23:02 +0000 (11:23 +0200)]
Merge pull request #6919 from poettering/ebpf-followup
Some minor follow-ups for the ebpf/cgroup PR
Zbigniew Jędrzejewski-Szmek [Wed, 27 Sep 2017 09:16:24 +0000 (11:16 +0200)]
Merge pull request #6915 from poettering/log-execute
make execute.c logging a bit less special
Lennart Poettering [Wed, 27 Sep 2017 07:25:25 +0000 (09:25 +0200)]
udev: proc_cmdline_get_key() FTW! (#6925)
Let's use proc_cmdline_get_key() instead of some strstr() logic to find
a kernel command line key. Using strstr() gets confused by similarly
named keys, and we should reuse our own code as much as we can anyway...
Fixes: #6330
Lennart Poettering [Tue, 26 Sep 2017 14:46:17 +0000 (16:46 +0200)]
catalog: split out the one German language entry we have in systemd.catalog into its own file
All other languages have their own file, let's make sure German does
too.
Lennart Poettering [Tue, 26 Sep 2017 14:42:02 +0000 (16:42 +0200)]
catalog: add two recent message ID additions to catalog
Just brief texts for now, so that we have something
(And in the long rung we should beef all this up, and add a test that
every ID listed in sd-messages.h is accompanied by a matching catalog
entry)
Lennart Poettering [Tue, 26 Sep 2017 14:33:03 +0000 (16:33 +0200)]
run: also show IP traffic accounting data on "systemd-run --wait"
If we collect we should show it.
Lennart Poettering [Tue, 26 Sep 2017 14:18:50 +0000 (16:18 +0200)]
core: improve dbus-cgroup error message
As suggested by @keszybz in the review of #6764
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 20:38:02 +0000 (22:38 +0200)]
Merge pull request #6912 from poettering/mount-kill-control
mount unit state engine fixes
Alan Jenkins [Tue, 26 Sep 2017 17:47:50 +0000 (18:47 +0100)]
Revert "units: don't kill the emergency shell when sysinit.target is triggered (#6765)" (#6904)
This reverts commit
f1e24a259ca182b6cd8a723a56da43435ce48aac. Oops.
# systemctl emergency
Failed to start emergency.target: Transaction order is cyclic. See syste...
See system logs and 'systemctl status emergency.target' for details.
# systemctl status emergency.target
● emergency.target - Emergency Mode
Loaded: loaded (/usr/lib/systemd/system/emergency.target; static; vendor preset: disabled)
Active: inactive (dead) since Mon 2017-09-25 10:43:02 BST; 2h 42min ago
Docs: man:systemd.special(7)
systemd[1]: sysinit.target: Found dependency on sysinit.target/stop
sysinit.target: Unable to break cycle starting with sysinit.target/stop
network.target: Found ordering cycle on wpa_supplicant.service/stop
network.target: Found dependency on sysinit.target/stop
network.target: Found dependency on emergency.target/start
network.target: Found dependency on emergency.service/start
network.target: Found dependency on serial-getty@ttyS0.service/stop
network.target: Found dependency on systemd-user-sessions.service/stop
network.target: Found dependency on network.target/stop
network.target: Unable to break cycle starting with network.target/stop
IMO #6509 is ugly enough that we should aim to answer it. But it could
take some time to investigate, so let's re-open the issue as a first step.
Lennart Poettering [Tue, 26 Sep 2017 16:09:23 +0000 (18:09 +0200)]
Merge pull request #6902 from keszybz/two-property-printing-fixes
Two property printing fixes
Lennart Poettering [Tue, 26 Sep 2017 16:00:38 +0000 (18:00 +0200)]
update TODO
Lennart Poettering [Tue, 26 Sep 2017 15:52:25 +0000 (17:52 +0200)]
execute: let's close glibc syslog channels too
Just in case something opened them, let's make sure glibc invalidates
them too.
Thankfully so far no library opened log channels behind our back, at
least as far as I know, hence this is actually a NOP, but let's better
be safe than sorry.
Lennart Poettering [Tue, 26 Sep 2017 15:47:27 +0000 (17:47 +0200)]
execute: normalize logging in execute.c
Now that logging can implicitly reopen the log streams when needed we
can log errors without any special magic, hence let's normalize things,
and log the same way we do everywhere else.
Lennart Poettering [Tue, 26 Sep 2017 15:41:53 +0000 (17:41 +0200)]
execute: drop explicit log_open()/log_close() now that it is unnecessary
Lennart Poettering [Tue, 26 Sep 2017 15:45:32 +0000 (17:45 +0200)]
execute: make use of the new logging mode in execute.c
Lennart Poettering [Tue, 26 Sep 2017 15:45:09 +0000 (17:45 +0200)]
log: add a mode where we open the log fds for every single log message
This we can then make use in execute.c to make error logging a bit less
special when preparing for process execution, as we can still log but
don't have any fds open continously.
Lennart Poettering [Mon, 25 Sep 2017 18:26:47 +0000 (20:26 +0200)]
log: let's make use of the fact that our functions return the negative error code for log_oom() too
Lennart Poettering [Tue, 26 Sep 2017 15:42:17 +0000 (17:42 +0200)]
execute: downgrade a log message ERR → WARNING, since we proceed ignoring its result
Lennart Poettering [Tue, 26 Sep 2017 15:42:57 +0000 (17:42 +0200)]
execute: rework logging in setup_keyring() to include unit info
Let's use log_unit_error() instead of log_error() everywhere (and
friends).
Lennart Poettering [Mon, 25 Sep 2017 17:57:52 +0000 (19:57 +0200)]
swap: introduce SWAP_STATE_WITH_PROCESS() similar to MOUNT_STATE_WITH_PROCESS()
Lennart Poettering [Mon, 25 Sep 2017 17:53:19 +0000 (19:53 +0200)]
swap: adjust swap.c in a similar way to what we just did to mount.c
Also drop the redundant states and make all similar changes too.
Thankfully the swap.c state engine is much simpler than mount.c's, hence
this should be easier to digest.
Lennart Poettering [Mon, 25 Sep 2017 17:25:50 +0000 (19:25 +0200)]
mount: rename mount_state_active() → MOUNT_STATE_WITH_PROCESS()
The function returns true for all states that have a control process
running, and each time we call it that's what we want to know, hence
let's rename it accordingly. Moreover, the more generic unit states have
an ACTIVE state, and it is defined quite differently from the set of
states this function returns true for, hence let's avoid confusion and
not reuse the word "ACTIVE" here in a different context.
Finally, let's uppercase this, since in most ways it's pretty much
identical to a macro
Lennart Poettering [Mon, 25 Sep 2017 17:13:37 +0000 (19:13 +0200)]
mount: rework mount state engine
This changes the mount unit state engine in the following ways:
1. The MOUNT_MOUNTING_SIGTERM and MOUNT_MOUNTING_SIGKILL are removed.
They have been pretty much equivalent to MOUNT_UNMOUNTING_SIGTERM and
MOUNT_UNMOUNTING_SIGKILL in what they do, and the outcome has been
the same as well: the unit is stopped. Hence, let's simplify things a
bit, and merge them. Note that we keep
MOUNT_REMOUNTING_{SIGTERM|SIGKILL} however, as those states have a
different outcome: the unit remains started.
2. mount_enter_signal() will now honour the SendSIGKILL= option of the
mount unit if it was set. This was previously done already when we
entered the signal states through a timeout, and was simply missing
here.
3. A new helper function mount_enter_dead_or_mounted() is added that
places the mount unit in either MOUNT_DEAD or MOUNT_MOUNTED,
depending on what the kernel thinks about the mount's state. This
function is called at various places now, wherever we finished an
operation, and want to make sure our own state reflects again what
the kernel thinks. Previously we had very similar code in a number of
places and in other places didn't recheck the kernel state. Let's do
that with the same logic and function at all relevant places now.
4. Rework mount_stop(): never forget about running control processes.
Instead: when we have a start (i.e. a /bin/mount) process running,
and are asked to stop, then enter the kill states for it, so that it
gets cleaned up. This fixes #6048. Moreover, when we have a reload
process running convert the possible states into the relevant
unmounting states, so that we can properly execute the requested
operation.
Fixes #6048
Lennart Poettering [Mon, 25 Sep 2017 16:56:19 +0000 (18:56 +0200)]
mount: clean up reload_result management a bit
Let's only collect the first failure in the load result, and let's clear
it explicitly when we are about to enter a new reload operation. This
makes it more alike the handling of the main result value (which also
only stores the first failure), and also the handling of service.c's
reload state.
Lennart Poettering [Mon, 25 Sep 2017 15:17:30 +0000 (17:17 +0200)]
service: rework service_kill_control_processes()
Let's make sure we explicitly also kill any control process we know of,
given that it might have moved outside of our control group.
Lennart Poettering [Mon, 25 Sep 2017 15:15:59 +0000 (17:15 +0200)]
set: add new helper set_make() which is like set_new() + multiple set_put() in vararg
Jan Synacek [Tue, 26 Sep 2017 14:07:34 +0000 (16:07 +0200)]
test-cpu-set-util.c: fix typo in comment (#6916)
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 14:04:33 +0000 (16:04 +0200)]
basic/log: fix return value from log_struct_iovec_internal()
This returned value so far wasn't used anywhere, so there's no change
in behaviour.
Lennart Poettering [Tue, 26 Sep 2017 14:00:28 +0000 (16:00 +0200)]
Merge pull request #6917 from keszybz/restore-some-tests
Restore some tests
Jan Synacek [Tue, 26 Sep 2017 11:50:31 +0000 (13:50 +0200)]
test-cpu-set-util.c: fix typo in comment (#6916)
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 11:44:04 +0000 (13:44 +0200)]
meson: hook up hwdb-test.sh again
The motivation for the ./systemd-hwdb is the same as in the grandparent
for systemd-sysv-generator.
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 11:39:43 +0000 (13:39 +0200)]
meson: hook up udev-test.pl again
Seems it was dropped along with the automake rules in
72cdb3e783174dcf9223a49f03e3b0e2ca95ddb8.
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 11:34:55 +0000 (13:34 +0200)]
sysv-generator-test: do not query $builddir
This variable is not set by meson, so let's not try to use it.
We could use some more elaborate scheme (e.g. based on $MESON_BUILD_ROOT and
$MESON_SUBDIR) to find the path to systemd-sysv-generator, but it seems
that plain ./systemd-sysv-generator works just as well and has the advantage
that it's easy to invoke the test by hand (as long as one cd's to the
meson build dir).
Zbigniew Jędrzejewski-Szmek [Tue, 26 Sep 2017 09:59:08 +0000 (11:59 +0200)]
sysv-generator-test: drop python2 work-around
We require python3 for meson anyway, so support python2 doesn't seem
useful anymore.
Lennart Poettering [Mon, 25 Sep 2017 20:26:10 +0000 (22:26 +0200)]
journal-verfiy: add a couple of missing le64toh() calls (#6888)
Apparently BE users don't verify their journals...
Noticed as result of #6887
Jonathan Lebon [Mon, 25 Sep 2017 19:56:57 +0000 (15:56 -0400)]
string-util: use size_t for strjoina macro (#6914)
`strlen` returns a `size_t` and `alloca` expects a `size_t`.
Zbigniew Jędrzejewski-Szmek [Mon, 25 Sep 2017 17:59:49 +0000 (19:59 +0200)]
install: drop left-over debug message (#6913)
Zbigniew Jędrzejewski-Szmek [Mon, 25 Sep 2017 09:23:59 +0000 (11:23 +0200)]
shared/bus-util: format uid==-1 and gid==-1 as [not set]
$ systemctl show systemd-journald -p UID,GID
UID=
4294967295
GID=
4294967295
↓
$ systemctl show systemd-journald -p UID,GID
UID=[not set]
GID=[not set]
Just seeing the number is very misleading.
Fixes #6511.
Zbigniew Jędrzejewski-Szmek [Mon, 25 Sep 2017 09:09:57 +0000 (11:09 +0200)]
basic/cap-list: report empty capability set as ""
$ systemctl show systemd-journald -p CapabilityBoundingSet,AmbientCapabilities
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_setgid ...
AmbientCapabilities=(null)
↓
$ systemctl show systemd-journald -p CapabilityBoundingSet,AmbientCapabilities
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_setgid ...
AmbientCapabilities=
Partially fixes #6511. Add some basic tests for the printing function.
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 18:53:04 +0000 (20:53 +0200)]
Merge pull request #6893 from poettering/cgroup-delegate-yay
cgroup delegation fixes, as well as socket unit slice assignment
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 18:51:01 +0000 (20:51 +0200)]
Merge pull request #6891 from poettering/read-line
add read_line() helper as bounded getline() and make use of it at some places
Lennart Poettering [Sun, 24 Sep 2017 17:52:07 +0000 (19:52 +0200)]
Merge pull request #6887 from rantala/6447
journal: add object sanity check to journal_file_move_to_object() (#6447)
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 12:27:21 +0000 (14:27 +0200)]
fileio: return 0 from read_one_line_file on success
Fixup for
f4b51a2d09. Suggested by Evgeny Vereshchagin.
Tommi Rantala [Sun, 24 Sep 2017 08:56:52 +0000 (11:56 +0300)]
journal: add missing le64toh() calls in journal_file_check_object()
Lennart Poettering noticed missing le64toh() calls.
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 07:10:48 +0000 (09:10 +0200)]
test-fileio: also test read_line() with actual files
Just in case the real FILE and the one from fmemopen weren't exactly
the same.
Zbigniew Jędrzejewski-Szmek [Sun, 24 Sep 2017 06:59:49 +0000 (08:59 +0200)]
test-fileio: close two leaked file handles
Zbigniew Jędrzejewski-Szmek [Sat, 23 Sep 2017 14:51:41 +0000 (16:51 +0200)]
man: add missing verb in timedatectl(1) (#6896)
As noted by Michael Biebl.
Zbigniew Jędrzejewski-Szmek [Sat, 23 Sep 2017 11:31:02 +0000 (13:31 +0200)]
Merge pull request #6894 from poettering/read-full-file-optimize
fileio: various fixes
Lennart Poettering [Sat, 23 Sep 2017 10:44:49 +0000 (12:44 +0200)]
Merge pull request #6892 from keszybz/enablement-work
Fix various issues with enabled/disabled units
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 12:36:12 +0000 (14:36 +0200)]
test-conf-parser: add tests for the new long lines, including overflow handling
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 10:02:49 +0000 (12:02 +0200)]
test-conf-parser: use _cleanup_
Zbigniew Jędrzejewski-Szmek [Sat, 23 Sep 2017 08:48:09 +0000 (10:48 +0200)]
fileio: use _cleanup_ for FILE unlocking
Lennart Poettering [Fri, 22 Sep 2017 16:27:03 +0000 (18:27 +0200)]
update TODO
Lennart Poettering [Fri, 22 Sep 2017 16:26:35 +0000 (18:26 +0200)]
conf-parse: remove 4K line length limit
Let's use read_line() to solve our long line limitation.
Fixes #3302.
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 12:24:01 +0000 (14:24 +0200)]
test-conf-parser: add some basic tests for config_parse()
This function is pretty important, but we weren't calling it directly
even once in tests.
v2: add a few tests for escaping and line continuations
Lennart Poettering [Fri, 22 Sep 2017 19:05:03 +0000 (21:05 +0200)]
fileio: initialize errno to zero before we do fread()
if there was something in the read buffer already errno might not be set
on error, let's detect that case.
Lennart Poettering [Fri, 22 Sep 2017 19:03:33 +0000 (21:03 +0200)]
fileio: try to read one byte too much in read_full_stream()
Let's read one byte more than the file size we read from stat() on the
first fread() invocation. That way, the first read() will already be
short and indicate eof to fread().
This is a minor optimization, and replaces #3908.
Lennart Poettering [Fri, 22 Sep 2017 18:59:39 +0000 (20:59 +0200)]
fileio: move fsync() logic into write_string_stream_ts()
That way, write_string_stream_ts() becomes more powerful, and we can
remove duplicate code from write_string_file_atomic() and
write_string_file_ts().
Lennart Poettering [Fri, 22 Sep 2017 18:55:34 +0000 (20:55 +0200)]
fileio: make write_string_stream() accept flags parameter
Let's make write_string_stream() and write_string_file() more alike, and
pass the same flag set so that we can remove a number of boolean
parameters.
Lennart Poettering [Fri, 22 Sep 2017 18:45:06 +0000 (20:45 +0200)]
fileio: support writing atomic files with timestamp
Let's make sure "ts" is taken into account when writing atomic files,
too.
Lennart Poettering [Fri, 22 Sep 2017 16:25:45 +0000 (18:25 +0200)]
cgroup-util: replace one use of fgets() by read_line()
Lennart Poettering [Fri, 22 Sep 2017 16:01:32 +0000 (18:01 +0200)]
fileio: rework read_one_line_file() on top of read_line()
Lennart Poettering [Fri, 22 Sep 2017 18:23:58 +0000 (20:23 +0200)]
def: add new constant LONG_LINE_MAX
LONG_LINE_MAX is much like LINE_MAX, but longer.
As it turns out LINE_MAX at 4096 is too short for many usecases. Since
the general concept of having a common maximum line length limit makes
sense let's add our own, and make it larger (1MB for now).
Lennart Poettering [Fri, 22 Sep 2017 15:55:53 +0000 (17:55 +0200)]
fileio: add new helper call read_line() as bounded getline() replacement
read_line() is much like getline(), and returns a line read from a
FILE*, of arbitrary sizes. In contrast to gets() it will grow the buffer
dynamically, and in contrast to getline() it will place a user-specified
boundary on the line.
Lennart Poettering [Fri, 22 Sep 2017 18:09:21 +0000 (20:09 +0200)]
socket: assign socket units to a default slice unconditionally
Due to the chown() logic socket units might end up with processes even
if no explicit command is defined for them, hence let's make sure these
processes are in the right cgroup, and that means within a slice.
Mount, swap and service units unconditionally are assigned to a slice
already, let's do the same here, too.
(This becomes more important as soon as the ebpf/firewall stuff is
merged, as there'll be another reason to fork off processes then)
Lennart Poettering [Fri, 22 Sep 2017 18:02:23 +0000 (20:02 +0200)]
cgroup: make use of unit_cgroup_delegate() where useful
It's an easy-to-use wrapper, so let's take benefit of it.
Lennart Poettering [Fri, 22 Sep 2017 17:58:24 +0000 (19:58 +0200)]
cgroup: rework which files we chown() on delegation
On cgroupsv2 we should also chown()/chmod() the subtree_control file,
so that children can use controllers the way they like.
On cgroupsv1 we should also chown()/chmod() cgroups.clone_children, as
not setting this for new cgroups makes little sense, and hence delegated
clients should be able to write to it.
Note that error handling for both cases is different. subtree_control
matters so we check for errors, but the clone_children/tasks stuff
doesn't really, as it's legacy stuff. Hence we only log errors and
proceed.
Fixes: #6216
Lennart Poettering [Fri, 22 Sep 2017 17:57:07 +0000 (19:57 +0200)]
cgroup-util: downgrade log messages from library code to LOG_DEBUG
These errors don't really matter, that's why we log and proceed in the
current code. However, we currently log at LOG_WARNING, but we really
shouldn't given that this is library code. Hence downgrade this to
LOG_DEBUG.
John Lin [Fri, 22 Sep 2017 17:15:28 +0000 (01:15 +0800)]
man: Requires= needs After= to deactivate "this unit" (#6869)
Fixes: #6856
Lennart Poettering [Fri, 22 Sep 2017 16:47:59 +0000 (18:47 +0200)]
Merge pull request #6879 from marcelhollerbach/testsuite-fix
time-util: testsuite fix
Zbigniew Jędrzejewski-Szmek [Fri, 22 Sep 2017 12:46:09 +0000 (14:46 +0200)]
install: consider globally enabled units as "enabled" for the user
We would not consider symlinks in /etc/systemd/user/*.{wants,requires}/
towards the user unit being "enabled", because the symlinks were not
located in "config" paths. But this is confusing to users, since those units
are clearly enabled and will be started. So let's muddle the definition of
enablement a bit to include the paths only accessible to root when looking for
enabled user units.
Fixes #4432.
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 17:03:17 +0000 (19:03 +0200)]
install: consider non-Alias=/non-DefaultInstance= symlinks as "indirect" enablement
I think this matches the spirit of "indirect" well: the unit
*might* be active, even though it is not "installed" in the
sense of symlinks created based on the [Install] section.
The changes to test-install-root touch the same lines as in the previous
commit; the change in each case is from
assert_se(unit_file_get_state(...) >= 0 && state == UNIT_FILE_ENABLED)
to
assert_se(unit_file_get_state(...) >= 0 && state == UNIT_FILE_DISABLED)
to
assert_se(unit_file_get_state(...) >= 0 && state == UNIT_FILE_INDIRECT)
in the last two commits.
Zbigniew Jędrzejewski-Szmek [Thu, 21 Sep 2017 16:53:45 +0000 (18:53 +0200)]
install: only consider names in Alias= as "enabling"
When a unit has a symlink that makes an alias in the filesystem,
but that name is not specified in [Install], it is confusing
is the unit is shown as "enabled". Look only for names specified
in Alias=.
Fixes #6338.
v2:
- Fix indentation.
- Fix checking for normal enablement, when the symlink name is the same as the
unit name. This case wasn't handled properly in v1.
v3:
- Rework the patch to also handle templates properly:
A template templ@.service with DefaultInstance=foo will be considered
enabled only when templ@foo.service symlink is found. Symlinks with
other instance names do not count, which matches the logic for aliases
to normal units. Tests are updated.
Lennart Poettering [Thu, 7 Sep 2017 18:03:55 +0000 (20:03 +0200)]
update TODO
Lennart Poettering [Thu, 21 Sep 2017 18:38:07 +0000 (20:38 +0200)]
bpf: set BPF_F_ALLOW_OVERRIDE when attaching a cgroup program if Delegate=yes is set
Let's permit installing BPF programs in cgroup subtrees if
Delegeate=yes. Let's not document this precise behaviour for now though,
as most likely the logic here should become recursive, but that's only
going to happen if the kernel starts supporting that. Until then,
support this in a non-recursive fashion.
Lennart Poettering [Thu, 21 Sep 2017 18:22:06 +0000 (20:22 +0200)]
man: document two more special units
Lennart Poettering [Thu, 21 Sep 2017 18:12:40 +0000 (20:12 +0200)]
man: remove double newlines in systemd.special man page header
The <!-- --> comment lines resulted in double newlines in the man page
header, which looks quite ugly. Let's rearrange a bit so that these
comments don't result in changes in the output.
Lennart Poettering [Thu, 21 Sep 2017 18:12:11 +0000 (20:12 +0200)]
man: drop misplaced "," before "-.slice"
Lennart Poettering [Thu, 21 Sep 2017 17:43:07 +0000 (19:43 +0200)]
main: bump RLIMIT_NOFILE for the root user substantially
On current kernels BPF_MAP_TYPE_LPM_TRIE bpf maps are charged against
RLIMIT_MEMLOCK even for privileged users that have CAP_IPC_LOCK. Given
that mlock() generally ignores RLIMIT_MEMLOCK if CAP_IPC_LOCK is set
this appears to be an oversight in the kernel. Either way, until that's
fixed, let's just bump RLIMIT_MEMLOCK for the root user considerably, as
the default is quite limiting, and doesn't permit us to create more than
a few TRIE maps.
Lennart Poettering [Thu, 21 Sep 2017 17:37:11 +0000 (19:37 +0200)]
rlimit: don't assume getrlimit() always succeeds
In times of seccomp it might very well fail, and given that we return
failures from this function anyway, let's also propagate getrlimit()
failures, just to be safe.
Lennart Poettering [Thu, 21 Sep 2017 12:05:35 +0000 (14:05 +0200)]
core: whenever a unit terminates, log its consumed resources to the journal
This adds a new recognizable log message for each unit invocation that
contains structured information about consumed resources of the unit as
a whole after it terminated. This is particular useful for apps that
want to figure out what the resource consumption of a unit given a
specific invocation ID was.
The log message is only generated for units that have at least one
XyzAccounting= property turned on, and currently only covers IP traffic and CPU
time metrics.
Lennart Poettering [Thu, 21 Sep 2017 12:02:31 +0000 (14:02 +0200)]
nspawn: set up a new session keyring for the container process
keyring material should not leak into the container. So far we relied on
seccomp to deny access to the keyring, but given that we now made the
seccomp configurable, and access to keyctl() and friends may optionally
be permitted to containers now let's make sure we disconnect the callers
keyring from the keyring of PID 1 in the container.
Lennart Poettering [Thu, 21 Sep 2017 11:52:34 +0000 (13:52 +0200)]
io-util: add new IOVEC_INIT/IOVEC_MAKE macros
This adds IOVEC_INIT() and IOVEC_MAKE() for initializing iovec structures
from a pointer and a size. On top of these IOVEC_INIT_STRING() and
IOVEC_MAKE_STRING() are added which take a string and automatically
determine the size of the string using strlen().
This patch removes the old IOVEC_SET_STRING() macro, given that
IOVEC_MAKE_STRING() is now useful for similar purposes. Note that the
old IOVEC_SET_STRING() invocations were two characters shorter than the
new ones using IOVEC_MAKE_STRING(), but I think the new syntax is more
readable and more generic as it simply resolves to a C99 literal
structure initialization. Moreover, we can use very similar syntax now
for initializing strings and pointer+size iovec entries. We canalso use
the new macros to initialize function parameters on-the-fly or array
definitions. And given that we shouldn't have so many ways to do the
same stuff, let's just settle on the new macros.
(This also converts some code to use _cleanup_ where dynamically
allocated strings were using IOVEC_SET_STRING() before, to modernize
things a bit)
Lennart Poettering [Wed, 20 Sep 2017 16:29:08 +0000 (18:29 +0200)]
job: change result field for log message about job result RESULT= → JOB_RESULT=
So, currently, some of the structured log messages we generated based on
jobs carry the result in RESULT=, and others in JOB_RESULT=. Let's
streamline this, as stick to JOB_RESULT= in one place.
This is kind of an API break, but given that currently most software has
to check both fields anyway, I think we can get away with it.
Why unify on JOB_RESULT= rather than RESULT=? Well, we manage different
types of result codes in systemd. Most importanlty besides job results
there are also service results, and we should be explicit in what we
mean here.
Lennart Poettering [Wed, 20 Sep 2017 16:28:29 +0000 (18:28 +0200)]
documentation: document nss-systemd's internal environment variables in ENVIRONMENT.md
Lennart Poettering [Wed, 20 Sep 2017 16:27:53 +0000 (18:27 +0200)]
core: make sure to log invocation ID of units also when doing structured logging
Daniel Mack [Sat, 12 Nov 2016 12:38:38 +0000 (13:38 +0100)]
man: document the new ip accounting and filting directives
Lennart Poettering [Thu, 7 Sep 2017 14:31:01 +0000 (16:31 +0200)]
cgroup: refuse to return accounting data if accounting isn't turned on
We used to be a bit sloppy on this, and handed out accounting data even
for units where accounting wasn't explicitly enabled. Let's be stricter
here, so that we know the accounting data is actually fully valid. This
is necessary, as the accounting data is no longer stored exclusively in
cgroupfs, but is partly maintained external of that, and flushed during
unit starts. We should hence only expose accounting data we really know
is fully current.
Lennart Poettering [Thu, 7 Sep 2017 12:32:33 +0000 (14:32 +0200)]
core: when coming back from reload/reexec, reapply all cgroup properties
With this change we'll invalidate all cgroup settings after coming back
from a daemon reload/reexec, so that the new settings are instantly
applied.
This is useful for the BPF case, because we don't serialize/deserialize
the BPF program fd, and hence have to install a new, updated BPF program
when coming back from the reload/reexec. However, this is also useful
for the rest of the cgroup settings, as it ensures that user
configuration really takes effect wherever we can.
Lennart Poettering [Thu, 7 Sep 2017 12:07:13 +0000 (14:07 +0200)]
core: serialize/deserialize IP accounting across daemon reload/reexec
Make sure the current IP accounting counters aren't lost during
reload/reexec.
Note that we destroy all BPF file objects during a reload: the BPF
programs, the access and the accounting maps. The former two need to be
regenerated anyway with the newly loaded configuration data, but the
latter one needs to survive reloads/reexec. In this implementation I
opted to only save/restore the accounting map content instead of the map
itself. While this opens a (theoretic) window where IP traffic is still
accounted to the old map after we read it out, and we thus miss a few
bytes this has the benefit that we can alter the map layout between
versions should the need arise.