Jason A. Donenfeld [Mon, 29 Jan 2018 20:05:36 +0000 (21:05 +0100)]
networkd: clean up link_get_type_string
The return value is always ignored, so get rid of it.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason A. Donenfeld [Mon, 29 Jan 2018 20:01:46 +0000 (21:01 +0100)]
networkd: simplify and display all devtypes
Every place the kernel actually calls SET_NETDEV_DEVTYPE, it's adding a
piece of information that looks useful and relevant for us to use. So
let's use it when it's there.
The previous matching based on the corresponding ARPHRD didn't really
make much sense. The more sensible logic for getting a textual
representation of the link type is to see if the kernel supplies a
devtype. If it does, great. If not, then we can fall back on the ARPHRD,
as before.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason A. Donenfeld [Mon, 29 Jan 2018 19:58:24 +0000 (20:58 +0100)]
networkd: display wireguard devtype
It's not useful to simply show "none", when we have more interesting
information to display.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Vito Caputo [Sun, 28 Jan 2018 21:03:39 +0000 (13:03 -0800)]
Merge pull request #8031 from mrq1/MRQ1_20180128_typo_fix
journalctl: typo fix
Hermann Gausterer [Sun, 28 Jan 2018 19:49:55 +0000 (20:49 +0100)]
journalctl: typo fix
Lennart Poettering [Sun, 28 Jan 2018 15:58:17 +0000 (16:58 +0100)]
Merge pull request #8030 from keszybz/another-news-update
NEWS: reword one sentence
Zbigniew Jędrzejewski-Szmek [Sun, 28 Jan 2018 15:54:18 +0000 (16:54 +0100)]
NEWS: add missing equal sign
Important!
Zbigniew Jędrzejewski-Szmek [Sun, 28 Jan 2018 15:52:47 +0000 (16:52 +0100)]
NEWS: reword one sentence
Lennart Poettering [Sun, 28 Jan 2018 15:36:03 +0000 (16:36 +0100)]
NEWS: let's get this thing done
Zbigniew Jędrzejewski-Szmek [Sun, 28 Jan 2018 14:52:06 +0000 (15:52 +0100)]
NEWS: mention --grep (#8029)
Lennart Poettering [Sun, 28 Jan 2018 14:29:10 +0000 (15:29 +0100)]
Merge pull request #7881 from keszybz/pcre
Add new --grep option to journalctl
Zbigniew Jędrzejewski-Szmek [Sat, 27 Jan 2018 12:00:09 +0000 (13:00 +0100)]
journalctl: add highlighting for matched substring
Red is used for highligting, the same as grep does. Except when the line is
highlighted red already, because it has high priority, in which case plain ansi
highlight is used for the matched substring.
Coloring is implemented for short and cat outputs, and not for other types.
I guess we could also add it for verbose output in the future.
Zbigniew Jędrzejewski-Szmek [Fri, 12 Jan 2018 13:31:49 +0000 (14:31 +0100)]
journalctl: make matching optionally case sensitive
Case sensitive or case insensitive matching can be requested using
--case-sensitive[=yes|no].
Unless specified, matching is case sensitive if the pattern contains any
uppercase letters, and case insensitive otherwise. This matches what
forward-search does in emacs, and recently also --ignore-case in less. This
works surprisingly well, because usually when one is wants to do case-sensitive
matching, the pattern is usually camel-cased. In the less frequent case when
case-sensitive matching is required with an all-lowercase pattern,
--case-sensitive can be used to override the automatic logic.
dana [Sun, 28 Jan 2018 12:29:58 +0000 (06:29 -0600)]
Slightly improve performance of startable/restartable unit completion (#7839)
Lennart Poettering [Sun, 28 Jan 2018 12:28:58 +0000 (13:28 +0100)]
NEWS: update NEWS again, we didn't release yesterday (#8027)
Fix tons of whitespace issues, also add a sysusers.d/ change and update
to contributors list again
Lennart Poettering [Sun, 28 Jan 2018 10:02:24 +0000 (11:02 +0100)]
Merge pull request #8025 from sourcejedi/pid1_journal_or2
pid1: when we can't log to journal, remember our fallback log target
Martin Pitt [Sat, 27 Jan 2018 08:35:19 +0000 (09:35 +0100)]
hwdb: Fix bouncing brightness keys on MSI-PR200
Thanks to djfd for the patch!
Fixes #6972
Michael Biebl [Sat, 27 Jan 2018 23:08:16 +0000 (00:08 +0100)]
Merge pull request #8026 from phomes/NEWS-fix
NEWS: typo fix
Thomas Hindoe Paaboel Andersen [Sat, 27 Jan 2018 23:05:27 +0000 (00:05 +0100)]
NEWS: typo fix
Alan Jenkins [Sat, 27 Jan 2018 18:02:06 +0000 (18:02 +0000)]
systemd-shutdown: use log_set_prohibit_ipc(true)
Now we have log_set_prohibit_ipc(), let's use it to clarify that
systemd-shutdown is not expected to try and log via journald (which it is
about to kill). We avoided ever asking systemd-shutdown to do this, but
it's more convenient for the reader if they don't have to think about that.
In that sense, it's similar to using assert() to validate a function's
arguments.
Alan Jenkins [Fri, 26 Jan 2018 13:42:53 +0000 (13:42 +0000)]
rationalize interface for opening/closing logging
log_open_console() did not switch from stderr to /dev/console, when
"always_reopen_console" was set. It was necessary to call
log_close_console() first.
By contrast, log_open() did switch between e.g. journald and kmsg according
to the value of "prohibit_ipc".
Let's fix log_open() to respect the values of all the log options, and we
can make log_close_*() private.
Also log_close_console() is changed. There was some precaution, avoiding
closing the console fd if we are not PID 1. I think commit
48a601fe made
a little mistake in leaving this in, and it only served to confuse
readers :).
Also I changed systemd-shutdown. Now we have log_set_prohibit_ipc(), let's
use it to clarify that systemd-shutdown is not expected to try and log via
journald (which it is about to kill). We avoided ever asking it to, but
it's more convenient for the reader if they don't have to think about that.
In that sense, it's similar to using assert() to validate a function's
arguments.
bleep_blop [Sat, 27 Jan 2018 16:33:52 +0000 (22:03 +0530)]
Update NEWS to reflect changes made in #8020 (#8024)
Batuhan Osman Taşkaya [Sat, 27 Jan 2018 13:03:08 +0000 (16:03 +0300)]
[gdb-sd_dump_hashmaps.py] String Formatting Update (#7819)
Changes: % changed as .format()
Lennart Poettering [Sat, 27 Jan 2018 12:52:09 +0000 (13:52 +0100)]
NEWS: get ready for release today (#8019)
Yu Watanabe [Sat, 27 Jan 2018 12:51:32 +0000 (21:51 +0900)]
analyze: merge {get,set}-log-{level,target} to log-{level,target} (#8020)
Also, service-watchdogs now shows current watchdog state when
no optional argument is provided.
Zbigniew Jędrzejewski-Szmek [Fri, 12 Jan 2018 06:55:45 +0000 (07:55 +0100)]
journalctl: regexp matching
Evgeny Vereshchagin [Sat, 27 Jan 2018 09:56:42 +0000 (12:56 +0300)]
Merge pull request #7933 from keszybz/fuzz-regression
test: add fuzzer regression testing
Andrew Jeddeloh [Thu, 25 Jan 2018 21:17:17 +0000 (13:17 -0800)]
login/meson.build: require ACL for uaccess rules
Don't install udev rules that requires the uaccess builtin if systemd is
being built without the uaccess builtin.
Lennart Poettering [Sat, 27 Jan 2018 08:32:36 +0000 (09:32 +0100)]
journal: losen restrictions on journal file suffix (#8013)
Previously, we'd refuse open journal files with suffixes that aren't
either .journal or .journal~. With this change we only care when we are
creating the journal file.
I looked over the sources to see whether we ever pass files discovered
by directory enumeration to journal_file_open() without first checking
the suffix (in which case the old check made sense), but I couldn't find
any. hence I am pretty sure removing this check is safe.
Fixes: #7972
Yu Watanabe [Sat, 27 Jan 2018 08:31:02 +0000 (17:31 +0900)]
Merge pull request #8006 from zx2c4-forks/jd/no-wg-ll
networkd: assume no link local addresses for where it isn't used
Yu Watanabe [Sat, 27 Jan 2018 08:24:39 +0000 (17:24 +0900)]
Merge pull request #7973 from mvo5/sysusers-uid-gid
sysusers: allow uid:gid in sysusers.conf files
Zbigniew Jędrzejewski-Szmek [Fri, 26 Jan 2018 15:15:17 +0000 (16:15 +0100)]
meson: use env object instead of string in tags targets
I used 'tags' before because this way we avoided a unnecessary
line about 'env' detection. But we cannot use 'env' in test(), so
previous commit added 'env' detection. We might just as well use
it in custom_target().
Zbigniew Jędrzejewski-Szmek [Fri, 19 Jan 2018 06:54:30 +0000 (17:54 +1100)]
Hook up oss-fuzz test cases as tests
This is a bit painful because a separate build of systemd is necessary. The
tests are guarded by tests!=false and slow-tests==true. Running them is not
slow, but compilation certainly is. If this proves unwieldy, we can add a
separate option controlling those builds later.
The build for each sanitizer has its own directory, and we build all fuzzer
tests there, and then pull them out one-by-one by linking into the target
position as necessary. It would be nicer to just build the desired fuzzer, but
we need to build the whole nested build as one unit.
[I also tried making systemd and nested meson subproject. This would work
nicely, but meson does not allow that because the nested target names are the
same as the outer project names. If that is ever fixed, that would be the way
to go.]
v2:
- make sure things still work if memory sanitizer is not available
v3:
- switch to syntax which works with meson 0.42.1 found in Ubuntu
Alan Jenkins [Fri, 26 Jan 2018 22:47:16 +0000 (22:47 +0000)]
pid1: when we can't log to journal, remember our fallback log target
If we have to force the logging to close the journal fd, then we can open
any fallback log target. E.g. kmsg, if the target was the default
JOURNAL_OR_KMSG.
This is the behaviour I would expect from the documentation. I couldn't
find any justification in the code, for why we would want to start dropping
log messages instead of sending them to the fallback target.
This means we will match the behaviour of processes which we fork and which
set `open_when_needed`, and with generators - which use
log_set_prohibit_ipc(true) - which we fork+exec during a reload.
IMO this illustrates that the log_open/log_close interface is too clunky.
So with the behaviour settled, I will refactor the interface in the next
commit :).
Jason A. Donenfeld [Thu, 25 Jan 2018 20:16:38 +0000 (21:16 +0100)]
NEWS: add self to news file for this late commit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason A. Donenfeld [Fri, 26 Jan 2018 14:34:09 +0000 (15:34 +0100)]
networkd: assume no link local addresses for where it isn't used
It turns out that link local doesn't make much sense in its context.
Since link local is disabled by the kernel driver, it's important that
networkd assumes it's off too, so that the link can reach the
"configured" stage, without waiting indefinitely for link local
addresses which will never come.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Zbigniew Jędrzejewski-Szmek [Wed, 24 Jan 2018 04:43:41 +0000 (07:43 +0300)]
zsh: add service-watchdogs
A zsh counterpart to
21a6abdf0ea9ce1fa5b6edf3b9314347cc0dbca1.
Clinton Roy [Fri, 26 Jan 2018 10:44:11 +0000 (21:44 +1100)]
News: some fixes and improvements (#8010)
* missing whitespace.
* NEWS: some small fixes and improvements.
Yu Watanabe [Fri, 26 Jan 2018 04:03:25 +0000 (13:03 +0900)]
Merge pull request #7738 from yuwata/fix-7721
core: manager logs firmware and loader time when startup finished
AsciiWolf [Fri, 26 Jan 2018 03:51:21 +0000 (04:51 +0100)]
l10n: update Czech Translation (#8007)
Fix typo
Zbigniew Jędrzejewski-Szmek [Thu, 25 Jan 2018 22:48:34 +0000 (01:48 +0300)]
Merge pull request #7997 from poettering/systemctl-is-active-fix
systemctl is-active fix
Michael Vogt [Thu, 25 Jan 2018 11:50:14 +0000 (12:50 +0100)]
sysusers: ensure GID in uid:gid syntax exists
Ensure that the GID already exists or is created when the new
"uid:gid" syntax is used. This ensures the behaviour is always
predictable.
Zbigniew Jędrzejewski-Szmek [Sat, 20 Jan 2018 00:06:34 +0000 (11:06 +1100)]
core: initalize buffer
Yu Watanabe [Mon, 25 Dec 2017 04:08:23 +0000 (13:08 +0900)]
core: manager logs firmware and loader time when startup finished
Zbigniew Jędrzejewski-Szmek [Thu, 25 Jan 2018 14:41:25 +0000 (17:41 +0300)]
Merge pull request #7996 from poettering/v237-prepare
preparation for v237
Björn Esser [Thu, 25 Jan 2018 14:30:15 +0000 (15:30 +0100)]
firstboot: Include <crypt.h> for declaration of crypt() if needed (#7944)
Not every target system may provide a crypt() function in its stdlibc
and may use an external or replacement library, like libxcrypt, for
providing such functions.
See https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt.
Lennart Poettering [Thu, 25 Jan 2018 14:18:27 +0000 (15:18 +0100)]
Revert "man: mention that systemctl is-active or is-failed do not load units"
This reverts commit
c7612b20052d9151f60a96623b8743cbac88390d.
Lennart Poettering [Thu, 25 Jan 2018 14:14:25 +0000 (15:14 +0100)]
systemctl: load unit if needed in "systemctl is-active"
Previously, we'd explicitly use "GetUnit()" on the server side to
convert a unit name into a bus path, as that function will return an
error if the unit is not currently loaded. If we'd convert the path on
the client side, and access the unit this way directly the unit would be
loaded automatically in the background.
The old logic was done in order to minimize the effect of "is-active" on
the system, i.e. that a monoitoring command does not itself alter the
state of the system.
however, this is problematic as this can lead to confusing results if
the queried unit name is an alias that currently is not loaded: we'd
claim the unit wasn't active even though this isn't strictly true: the
unit the name is an alias for might be.
Hence, let's simplify the code, and accept that we might end up loading
a unit briefly here, and let's make "systemctl is-active" skip the
GetUnit() thing and calculate the unit path right away.
Fixes: #7875
Raphael Vogelgsang [Tue, 23 Jan 2018 17:58:21 +0000 (18:58 +0100)]
boot/efi: TPM V2 fix for GetEventLog EFI function
Yu Watanabe [Thu, 25 Jan 2018 08:45:53 +0000 (17:45 +0900)]
bus-util: fix format of NextElapseUSecRealtime= and LastTriggerUSec=
Before this, `systemctl show` for calendar type timer unit outputs
something like below.
```
NextElapseUSecRealtime=48y 3w 3d 15h
NextElapseUSecMonotonic=0
LastTriggerUSec=48y 3w 3d 3h 41min 44.093095s
LastTriggerUSecMonotonic=0
```
As both NextElapseUSecRealtime= and LastTriggerUSec= are not timespan
but timestamp, this makes format these values by `format_timestamp()`.
Nicolas Chauvet [Wed, 24 Jan 2018 09:05:28 +0000 (10:05 +0100)]
gpt-auto: discard boot0/1 hw partitions along rpmb
/dev/mmcblk0boot0 is a partition found in eMMC
This is not relevant for mounting
This complement the previous fix as reported in
https://github.com/systemd/systemd/issues/5806
Signed-off-by: Nicolas Chauvet <kwizart@gmail.com>
Lennart Poettering [Thu, 25 Jan 2018 13:18:14 +0000 (14:18 +0100)]
meson: bump so revision and systemd version in preparation for v237
Lennart Poettering [Thu, 25 Jan 2018 13:16:25 +0000 (14:16 +0100)]
hwdb: run "update-hwdb" in preparation for v237
Lennart Poettering [Thu, 25 Jan 2018 13:14:35 +0000 (14:14 +0100)]
update TODO
Lennart Poettering [Thu, 25 Jan 2018 12:18:28 +0000 (13:18 +0100)]
NEWS: start putting together an entry for v237
Michael Vogt [Wed, 24 Jan 2018 10:46:10 +0000 (11:46 +0100)]
sysusers: make ADD_GROUP always create a group
Do not merge group creation with user creation because with the
new uid:gid syntax this can result in confusing (and unwanted)
behavior.
Michael Vogt [Wed, 24 Jan 2018 10:18:46 +0000 (11:18 +0100)]
test: add TEST-21-SYSUSERS test
This test tests the systemd-sysuser binary via the --root=$TESTDIR
option and ensures that for the given inputs the expected passwd
and group files will be generated.
Michael Vogt [Wed, 24 Jan 2018 08:26:51 +0000 (09:26 +0100)]
sysuser: use OrderedHashmap
This means we have more predicable behavior for "u foo uid:gid" lines
and also makes the generated files appear in the same order as the
inputs. So e.g.
```
u root 0 - /root
u daemon 1 - /usr/sbin
u games 5:60 - /usr/games
```
will generate
```
root:x:0:0::/root:/bin/sh
daemon:x:1:1::/usr/sbin:/sbin/nologin
games:x:5:60::/usr/games:/sbin/nologin
```
Michael Vogt [Tue, 23 Jan 2018 18:53:08 +0000 (19:53 +0100)]
sysusers: allow uid:gid in sysusers.conf files
This PR allows to write sysuser.conf lines like:
```
u games 5:60 -
```
This will create an a "games" user with uid 5 and games group with
gid 60. This is arguable ugly, however it is required to represent
certain configurations like the default passwd file on Debian and
Ubuntu.
When the ":" syntax is used and there is a group with the given
gid already then no new group is created. This allows writing the
following:
```
g unrelated 60
u games 5:60 -
```
which will create a "games" user with the uid 5 and the primary
gid 60. No group games is created here (might be useful for [1]).
[1] https://pagure.io/packaging-committee/issue/442
Zbigniew Jędrzejewski-Szmek [Thu, 25 Jan 2018 10:48:08 +0000 (13:48 +0300)]
Merge pull request #7991 from poettering/n-on-console
a comprehensive fix for the n_on_console miscounting issue
Lennart Poettering [Thu, 25 Jan 2018 10:34:15 +0000 (11:34 +0100)]
Merge pull request #7983 from poettering/tmpfiles-eexist
make "f" tmpfiles.d behaviour work like documentation suggests + coccinelle fixes
Zbigniew Jędrzejewski-Szmek [Thu, 25 Jan 2018 09:24:35 +0000 (10:24 +0100)]
Merge pull request #7915 from poettering/pids-max-tweak
Lennart Poettering [Thu, 25 Jan 2018 09:06:19 +0000 (10:06 +0100)]
Merge pull request #7990 from poettering/log-deadlock
fix for logging deadlock
Lennart Poettering [Wed, 24 Jan 2018 18:59:55 +0000 (19:59 +0100)]
core: rework how we count the n_on_console counter
Let's add a per-unit boolean that tells us whether our unit is currently
counted or not. This way it's unlikely we get out of sync again and
things are generally more robust.
This also allows us to remove the counting logic specific to service
units (which was in fact mostly a copy from the generic implementation),
in favour of fully generic code.
Replaces: #7824
Lennart Poettering [Wed, 24 Jan 2018 18:54:26 +0000 (19:54 +0100)]
core: add a new unit_needs_console() call
This call determines whether a specific unit currently needs access to
the console. It's a fancy wrapper around
exec_context_may_touch_console() ultimately, however for service units
we'll explicitly exclude the SERVICE_EXITED state from when we report
true.
Lennart Poettering [Wed, 24 Jan 2018 18:52:29 +0000 (19:52 +0100)]
manager: minor manager_get_show_status() simplification
Since the the whole function ultimately is just a fancy getter for the
show_status field, let's actually return it as last step literally
without an extra needless "if".
Lennart Poettering [Wed, 24 Jan 2018 18:52:14 +0000 (19:52 +0100)]
manager: add some explanatory comments to manager_dispatch_idle_pipe_fd()
Lennart Poettering [Wed, 24 Jan 2018 17:01:01 +0000 (18:01 +0100)]
log: remove LOG_TARGET_SAFE pseudo log target
This removes LOG_TARGET_SAFE. It's made redundant by the new
"prohibit-ipc" logging flag, as it used to have a similar effect: avoid
logging to the journal/syslog, i.e. any local services in order to avoid
deadlocks when we lock from PID 1 or its utility processes (such as
generators).
All previous users of LOG_TARGET_SAFE are switched over to the new
setting. This makes things a bit safer for all, as not even the
SYSTEMD_LOG_TARGET env var can be used to accidentally log to the
journal anymore in these programs.
Lennart Poettering [Wed, 24 Jan 2018 16:45:14 +0000 (17:45 +0100)]
log: add brief comment for log_set_open_when_needed() and log_set_always_reopen_console()
These two deserve some explanation...
Lennart Poettering [Wed, 24 Jan 2018 16:42:12 +0000 (17:42 +0100)]
pid1: make use of new "prohibit_ipc" logging flag in PID 1
Let's set it initially, and then toggle it only when we know its safe.
Lennart Poettering [Wed, 24 Jan 2018 16:36:25 +0000 (17:36 +0100)]
log: add new "prohibit_ipc" flag to logging system
If set, we'll avoid logging to any IPC log targets, i.e. syslog or the
journal, but allow stderr, kmsg, console logging.
This is useful as PID 1 wants to turn this off explicitly as long as the
journal is not up.
Previously we'd open/close the log stream to these services whenever
needed but this is incompatible with the "open_when_needed" logic
introduced in #6915, which might open the log streams whenever it likes,
including possibly inside of the child process we fork off that'll
become journald later on. Hence, let's make this all explicit, and
instead of managing when we open/close log streams add a boolean that
clearly prohibits the IPC targets when needed, so that opening can be
done at any time, but will honour this.
See: #7985
Lennart Poettering [Wed, 24 Jan 2018 16:33:07 +0000 (17:33 +0100)]
log: make log_set_upgrade_syslog_to_journal() take effect immediately
This doesn't matter much, and we don't rely on it, but I think it's much
nicer if we log_set_target() and log_set_upgrade_syslog_to_journal() can
be called in either order and have the same effect.
Nathaniel McCallum [Wed, 24 Jan 2018 14:45:48 +0000 (09:45 -0500)]
Add fd close support to sd_event_source
It is often the case that a file descriptor and its corresponding IO
sd_event_source share a life span. When this is the case, developers will
have to unref the event source and close the file descriptor. Instead, we
can just have the event source take ownership of the file descriptor and
close it when the event source is freed. This is especially useful when
combined with cleanup attributes and sd_event_source_unrefp().
This patch adds two new public functions:
sd_event_source_get_io_fd_own()
sd_event_source_set_io_fd_own()
Nathaniel McCallum [Wed, 24 Jan 2018 14:53:49 +0000 (09:53 -0500)]
Include time.h in sd-event.h
The time-related functions in sd-event.h take as inputs constants (CLOCK_*)
defined in time.h. By including time.h in sd-event.h, we free the developer
from having to do this manually.
Lennart Poettering [Wed, 24 Jan 2018 15:15:26 +0000 (16:15 +0100)]
Merge pull request #7988 from ssahani/follow-7712
Networkd: cleanup code a bit
Susant Sahani [Wed, 24 Jan 2018 14:57:53 +0000 (20:27 +0530)]
networkd: routing policy rules rename Manager object m to manager.
Susant Sahani [Wed, 24 Jan 2018 14:57:27 +0000 (20:27 +0530)]
networkd: remove unused variable manager -> m
Ewout van Mansom [Wed, 24 Jan 2018 12:58:43 +0000 (13:58 +0100)]
hwdb: Workaround Purism Librem 13 V2 change 43 to backslash (#7984)
hwdb: use symbolic name rather than numeric key value for Purism Librem 13 entry
Fixes: #7978
Susant Sahani [Wed, 24 Jan 2018 09:17:07 +0000 (14:47 +0530)]
networkd: sd_ndisc reset mac address when MAC address change detected.
When there is a change in mac address we are not currently not changing
the MAC address and resulting v6 connectivity is gone.
When kernel reports a change in mac address change the MAC of ndisc
client too.
Closes # 7806
Lennart Poettering [Wed, 24 Jan 2018 10:18:04 +0000 (11:18 +0100)]
Merge pull request #7860 from poettering/watch-pids-rework
rework how the manager watches PIDs
Lennart Poettering [Wed, 24 Jan 2018 10:09:29 +0000 (11:09 +0100)]
coccinelle: O_NDELAY → O_NONBLOCK
Apparently O_NONBLOCK is the modern name used in most documentation and
for most cases in our sources. Let's hence replace the old alias
O_NDELAY and stick to O_NONBLOCK everywhere.
Lennart Poettering [Wed, 24 Jan 2018 10:07:47 +0000 (11:07 +0100)]
coccinelle: let's use STRLEN() rather strlen() at one more place
Lennart Poettering [Wed, 24 Jan 2018 09:54:10 +0000 (10:54 +0100)]
tmpfiles: make "f" lines behaviour match what the documentation says
CHANGE OF BEHAVIOUR — with this commit "f" line's behaviour is altered
to match what the documentation says: if an "argument" string is
specified it is written to the file only when the file didn't exist
before. Previously, it would be appended to the file each time
systemd-tmpfiles was invoked — which is not a particularly useful
behaviour as the tool is not idempotent then and the indicated files
grow without bounds each time the tool is invoked.
I did some spelunking whether this change in behaviour would break
things, but afaics nothing relies on the previous O_APPEND behaviour of
this line type, hence I think it's relatively safe to make "f" lines
work the way the docs say, rather than adding a new modifier for it or
so.
Triggered by:
https://lists.freedesktop.org/archives/systemd-devel/2018-January/040171.html
Lennart Poettering [Wed, 24 Jan 2018 08:40:04 +0000 (09:40 +0100)]
Merge pull request #7979 from yuwata/unused-variables
Small cleanups
Michael Biebl [Wed, 24 Jan 2018 03:58:04 +0000 (12:58 +0900)]
resolve: fix build without gcrypt
Follow-up for
73a4cd17c37f61159a365e55bdd5ff2b8327d439.
Fixes #7977.
Yu Watanabe [Wed, 24 Jan 2018 03:54:12 +0000 (12:54 +0900)]
systemctl: remove unused variable
Follow-up for
98f609368723529a98f44948569fd2eb2dd9685d.
Yu Watanabe [Wed, 24 Jan 2018 03:52:21 +0000 (12:52 +0900)]
core/device: remove unused variable
Follow-up for
bf70ff2cff719905f9dc3f726eaba79780dcae55.
Lennart Poettering [Tue, 23 Jan 2018 20:37:55 +0000 (21:37 +0100)]
Merge pull request #7964 from poettering/tmpfiles-more-fixes
a number of tmpfiles fixes
Lennart Poettering [Fri, 12 Jan 2018 14:26:11 +0000 (15:26 +0100)]
update TODO
Lennart Poettering [Mon, 22 Jan 2018 16:51:53 +0000 (17:51 +0100)]
service: simplify condition
The left side of the || expression is conditionalized on SERVICE_START,
but SERVICE_START is blanket listed on the right side anyway, hence we
can drop the left side entirely without any change in behaviour.
Moreover, if main_pid is initialized, it should be watched, hence this
is even the safe and right thing to do.
Lennart Poettering [Mon, 22 Jan 2018 16:44:43 +0000 (17:44 +0100)]
service: don't bother with watching PIDs during deserialization
service_coldplug() takes care of that anyway, hence drop the
unit_watch_pid() invocation entirely during serialization, it's
redundant.
Lennart Poettering [Fri, 12 Jan 2018 12:41:05 +0000 (13:41 +0100)]
core: rework how we track which PIDs to watch for a unit
Previously, we'd maintain two hashmaps keyed by PIDs, pointing to Unit
interested in SIGCHLD events for them. This scheme allowed a specific
PID to be watched by exactly 0, 1 or 2 units.
With this rework this is replaced by a single hashmap which is primarily
keyed by the PID and points to a Unit interested in it. However, it
optionally also keyed by the negated PID, in which case it points to a
NULL terminated array of additional Unit objects also interested. This
scheme means arbitrary numbers of Units may now watch the same PID.
Runtime and memory behaviour should not be impact by this change, as for
the common case (i.e. each PID only watched by a single unit) behaviour
stays the same, but for the uncommon case (a PID watched by more than
one unit) we only pay with a single additional memory allocation for the
array.
Why this all? Primarily, because allowing exactly two units to watch a
specific PID is not sufficient for some niche cases, as processes can
belong to more than one unit these days:
1. sd_notify() with MAINPID= can be used to attach a process from a
different cgroup to multiple units.
2. Similar, the PIDFile= setting in unit files can be used for similar
setups,
3. By creating a scope unit a main process of a service may join a
different unit, too.
4. On cgroupsv1 we frequently end up watching all processes remaining in
a scope, and if a process opens lots of scopes one after the other it
might thus end up being watch by many of them.
This patch hence removes the 2-unit-per-PID limit. It also makes a
couple of other changes, some of them quite relevant:
- manager_get_unit_by_pid() (and the bus call wrapping it) when there's
ambiguity will prefer returning the Unit the process belongs to based on
cgroup membership, and only check the watch-pids hashmap if that
fails. This change in logic is probably more in line with what people
expect and makes things more stable as each process can belong to
exactly one cgroup only.
- Every SIGCHLD event is now dispatched to all units interested in its
PID. Previously, there was some magic conditionalization: the SIGCHLD
would only be dispatched to the unit if it was only interested in a
single PID only, or the PID belonged to the control or main PID or we
didn't dispatch a signle SIGCHLD to the unit in the current event loop
iteration yet. These rules were quite arbitrary and also redundant as
the the per-unit handlers would filter the PIDs anyway a second time.
With this change we'll hence relax the rules: all we do now is
dispatch every SIGCHLD event exactly once to each unit interested in
it, and it's up to the unit to then use or ignore this. We use a
generation counter in the unit to ensure that we only invoke the unit
handler once for each event, protecting us from confusion if a unit is
both associated with a specific PID through cgroup membership and
through the "watch_pids" logic. It also protects us from being
confused if the "watch_pids" hashmap is altered while we are
dispatching to it (which is a very likely case).
- sd_notify() message dispatching has been reworked to be very similar
to SIGCHLD handling now. A generation counter is used for dispatching
as well.
This also adds a new test that validates that "watch_pid" registration
and unregstration works correctly.
Lennart Poettering [Tue, 23 Jan 2018 20:23:19 +0000 (21:23 +0100)]
Merge pull request #7968 from poettering/manager-mini-tweak
some manager fixes
Lennart Poettering [Fri, 12 Jan 2018 12:06:48 +0000 (13:06 +0100)]
core: unify call we use to synthesize cgroup empty events when we stopped watching any unit PIDs
This code is very similar in scope and service units, let's unify it in
one function. This changes little for service units, but for scope units
makes sure we go through the cgroup queue, which is something we should
do anyway.
Lennart Poettering [Fri, 12 Jan 2018 12:05:07 +0000 (13:05 +0100)]
service: don't send out dbus change notifications spuriously on SIGCHLD
Let's send them out only if the main or control processe exited and we
recorded a new exit status that is worth reporting. But if any other
service process died this is nothing to report since we don't expose any
properties about that anyway.
Lennart Poettering [Thu, 11 Jan 2018 22:38:46 +0000 (23:38 +0100)]
core: fix manager_get_unit_by_pid() special casing of manager PID
Previously, we'd hard map PID 1 to the manager scope unit. That's wrong
however when we are run in --user mode, as the PID 1 is outside of the
subtree we manage and the manager PID might be very differently. Correct
that by checking for getpid() rather than hardcoding 1.
Lennart Poettering [Thu, 11 Jan 2018 15:02:47 +0000 (16:02 +0100)]
test: test-process-util additions
Add some extra paranoia tests that PTR_TO_PID() and PID_TO_PTR() deals
correctly with negative PID.
Lennart Poettering [Thu, 11 Jan 2018 15:02:13 +0000 (16:02 +0100)]
process-util: replace PTR_TO_PID() and PID_TO_PTR macro by inline functions
This way we gain some typesafety at no cost.
Lennart Poettering [Mon, 15 Jan 2018 10:33:20 +0000 (11:33 +0100)]
cgroup: fix handling of TasksAccounting= property
Lennart Poettering [Tue, 23 Jan 2018 20:16:59 +0000 (21:16 +0100)]
UIDS-GIDS.md: explicitly mention one more user of the overflowuid
File systems with only 16bit UID support (i.e. old ext2) also use the
overflowuid to map users they can't map. Briefly mention this.