Commit graph

38052 commits

Author SHA1 Message Date
Yu Watanabe 61a38e0265 wait-online: do not fail if we receive invalid messages
Fixes #11486.
2019-01-21 15:54:50 +01:00
Yu Watanabe 838b2f7a30 network: unset Network::manager when loading .network file fails
Otherwise, LIST_REMOVE() in network_free() fails.

This fixes the following assertion:
```
systemd-networkd[2595]: Bus bus-api-network: changing state UNSET → OPENING
systemd-networkd[2595]: Bus bus-api-network: changing state OPENING → AUTHENTICATING
systemd-networkd[2595]: timestamp of '/etc/systemd/network' changed
systemd-networkd[2595]: /etc/systemd/network/10-hoge.network:1: Invalid section header '[Network]Address=192.168.0.1'
systemd-networkd[2595]: /etc/systemd/network/10-hoge.network:1: Failed to parse file: Bad message
systemd-networkd[2595]: Assertion '*_head == _item' failed at ../../home/watanabe/git/systemd/src/network/networkd-network.c:378, function network_free(). Aborting.
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== Process terminating with default action of signal 6 (SIGABRT): dumping core
valgrind[2595]: ==2595==    at 0x4BCA53F: raise (in /usr/lib64/libc-2.28.so)
valgrind[2595]: ==2595==    by 0x4BB4894: abort (in /usr/lib64/libc-2.28.so)
valgrind[2595]: ==2595==    by 0x4955F09: log_assert_failed_realm (log.c:795)
valgrind[2595]: ==2595==    by 0x417101: network_free (networkd-network.c:378)
valgrind[2595]: ==2595==    by 0x415E99: network_freep (networkd-network.h:282)
valgrind[2595]: ==2595==    by 0x416AB2: network_load_one (networkd-network.c:101)
valgrind[2595]: ==2595==    by 0x416C39: network_load (networkd-network.c:293)
valgrind[2595]: ==2595==    by 0x414031: manager_load_config (networkd-manager.c:1502)
valgrind[2595]: ==2595==    by 0x40B258: run (networkd.c:82)
valgrind[2595]: ==2595==    by 0x40B74A: main (networkd.c:117)
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== HEAP SUMMARY:
valgrind[2595]: ==2595==     in use at exit: 32,621 bytes in 201 blocks
valgrind[2595]: ==2595==   total heap usage: 746 allocs, 545 frees, 241,027 bytes allocated
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== LEAK SUMMARY:
valgrind[2595]: ==2595==    definitely lost: 0 bytes in 0 blocks
valgrind[2595]: ==2595==    indirectly lost: 0 bytes in 0 blocks
valgrind[2595]: ==2595==      possibly lost: 0 bytes in 0 blocks
valgrind[2595]: ==2595==    still reachable: 32,621 bytes in 201 blocks
valgrind[2595]: ==2595==         suppressed: 0 bytes in 0 blocks
valgrind[2595]: ==2595== Reachable blocks (those to which a pointer was found) are not shown.
valgrind[2595]: ==2595== To see them, rerun with: --leak-check=full --show-leak-kinds=all
valgrind[2595]: ==2595==
valgrind[2595]: ==2595== For counts of detected and suppressed errors, rerun with: -v
valgrind[2595]: ==2595== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
systemd-coredump[2600]: Process 2595 (memcheck-amd64-) of user 192 dumped core.
```
2019-01-21 15:53:12 +01:00
Yu Watanabe d0d7e10241 man: mention that 'udevadm control --exit' restarts systemd-udevd.service
Closes #1802.
2019-01-21 11:42:29 +01:00
Mike Gilbert f356aabe98 test-process-util: do not assume PID 1 has UID=0
Gentoo's Portage package manager uses a PID namespace for process
isolation and cleanup. In this namespace, PID 1 has UID=250 (portage).

Bug: https://bugs.gentoo.org/674458
2019-01-21 11:41:37 +01:00
Jonathon Kowalski 78218e6243 Enable some more debug logging for transaction building 2019-01-21 11:39:06 +01:00
Topi Miettinen 10d44e72ec Document weaknesses with MDWE and suggest hardening
Closes #11473
2019-01-21 11:37:46 +01:00
Frantisek Sumsal e4e039bce4 test: mark plymouth as optional dependency
rescue.service pulls in /bin/plymouth, which doesn't exist on some
distributions (e.g. Arch Linux). Let's mark it as optional, as it's not
even required by the referencing unit and causes unwanted fails in the
integration testsuite.
2019-01-21 11:35:24 +01:00
Louis Taylor a77f438b6a NEWS: add section about backslashes in EnvironmentFile
As a follow-up from #11427.
2019-01-21 11:35:00 +01:00
Frantisek Sumsal bb0e960448 meson: bump timeout for test-udev to 180s
On some (mainly virtual) machines the last test takes more than 30
seconds, which causes unnecessary fails, as the test itself is working
properly.
2019-01-21 11:33:54 +01:00
Zbigniew Jędrzejewski-Szmek 4b8183c153 Revert "hwdb: Fix secondary backslash on MSI GS65 laptop"
This reverts commit e05c8b4462.

The key in question is labeled as "|\" in the US version, and e.g. "<>" in
European version. In the US version there are two keys with the same label
and they are both mapped to the same keycode. Let's revert the patch, to unbreak
the non-US users.

US users should apply some local work-around, possibly simply keeping the
contents of the patch as a file in hwdb.d/.
2019-01-21 09:59:29 +01:00
Louis Taylor 8464d9e0dc mkosi: add qrencode to arch package list
Before adding this, I got errors about the library being missing such
as:

        journalctl: error while loading shared libraries: libqrencode.so.4: cannot open shared object file: No such file or directory

Fixes #7367.
2019-01-19 07:41:34 +09:00
Lennart Poettering 0efa18d636
Merge pull request #11424 from yuwata/fix-11420
timedate: refuse setting time when unit is in 'activating' or friends
2019-01-18 17:58:20 +01:00
Zbigniew Jędrzejewski-Szmek b0a28c2956
Merge pull request #11349 from yuwata/udevadm-control-ping
Add 'udevadm control --ping'
2019-01-18 17:41:00 +01:00
Yu Watanabe f77bb3a3bd bash-completion: udevadm: support recently added options 2019-01-18 16:10:01 +01:00
Yu Watanabe d30f43eec5 udevd: rename control command SYNC -> PING in log message 2019-01-18 16:10:01 +01:00
Yu Watanabe 2001622c58 udevadm: add --wait-daemon option to 'trigger' command 2019-01-18 16:10:01 +01:00
Yu Watanabe a82340cc03 udevadm: add --ping option to 'control' command
This exposes `udev_ctrl_send_ping()`.
2019-01-18 16:10:01 +01:00
Zbigniew Jędrzejewski-Szmek f26ad32197 NEWS: retroactively describe .include deprecation
Closes #11479.
2019-01-18 13:55:16 +01:00
Yu Watanabe 3e4eb8e73d sd-event: introduce event_free_signal_data()
We already have event_free_inotify_data() and event_free_inode_data().
2019-01-18 13:53:43 +01:00
Lennart Poettering 37b8602fb8
Merge pull request #11450 from keszybz/drop-nolegacy
Drop unused NOLEGACY define
2019-01-18 13:51:15 +01:00
Jonathon Kowalski 03ff2dc71e Change job mode of manager triggered restarts to JOB_REPLACE
Fixes: #11305
Fixes: #3260
Related: #11456

So, here's what happens in the described scenario in #11305. A unit goes
down, and that triggeres stop jobs for the other two units as they were
bound to it. Now, the timer for manager triggered restarts kicks in and
schedules a restart job with the JOB_FAIL job mode. This means there is
a stop job installed on those units, and now due to them being bound to
us they also get a restart job enqueued. This however is a conflicts, as
neither stop can merge into restart, nor restart into stop. However,
restart should be able to replace stop in any case. If the stop
procedure is ongoing, it can cancel the stop job, install itself, and
then after reaching dead finish and convert itself to a start job.
However, if we increase the timer, then it can always take those units
from inactive -> auto-restart.

We change the job mode to JOB_REPLACE so the restart job cancels the
stop job and installs itself.

Also, the original bug could be worked around by bumping RestartSec= to
avoid the conflicting.

This doesn't seem to be something that is going to break uses. That is
because for those who already had it working, there must have never been
conflicting jobs, as that would result in a desctructive transaction by
virtue of the job mode used.

After this change, the test case is able to work nicely without issues.
2019-01-18 13:50:52 +01:00
Lennart Poettering 8d4798e821
Merge pull request #11427 from kragniz/10659-env-file-quotes
util-lib: follow shell syntax for escape in quotes
2019-01-18 13:50:15 +01:00
Mike Auty 0912c0b80e Add multiple initrd file support to kernel-install
Instead of having just a single INITRD field, add support for all
additional parameters being INITRD fields in order.

Signed-off-by: Mike Auty <mike.auty@gmail.com>
2019-01-18 13:49:52 +01:00
dcanuhe 72de945726 add hwdb rule for Bangho touchpad (#11475)
add hwdb rule for Bangho touchpad
2019-01-18 13:49:29 +01:00
Lennart Poettering 5356ad6c36
Merge pull request #11465 from poettering/daemon-bus-flush
flush+close bus connections explicitly when our daemons go down
2019-01-18 13:48:52 +01:00
Lennart Poettering 8274a4132c
Merge pull request #11449 from keszybz/udev-link-naming-again
Make udev link re-renaming conditional
2019-01-17 20:06:55 +01:00
Lennart Poettering 92e29d82e6 tree-wide: fix some trailing whitespace
@bl33pbl0p, please fix your editor

(Apparently you never configured the source tree? If you did, then the
git pre-commit hook would have been enabled which doesn't allow
commiting non-whitespace clean stuff...)
2019-01-17 20:06:28 +01:00
Lennart Poettering c1642d7bf8
Merge pull request #11378 from keszybz/export-dbus-address-conditionally
Export dbus address conditionally
2019-01-17 18:36:01 +01:00
Lennart Poettering a8ea2833cf
Merge pull request #11375 from daxtens/issue5882
network: Fix IPv6 PreferredSource routes
2019-01-17 18:08:01 +01:00
Jörg Thalheim 990bb60a6f tools/choose-default-locale.sh: set shebang to /bin/sh
The script does not use any bash features.
On NixOS we have /bin/sh and /usr/bin/env for posix compatibility
but not /bin/bash as it is stored in our nix store.
With this change one can run the `meson configure` without patching
which greatly helps, when working on upstream contributions.
2019-01-17 18:06:16 +01:00
Louis Taylor e768a4f032 tree-wide: use '"' instead of '\"'
The escape used previously was redundant and made things more confusing.
2019-01-17 16:46:29 +00:00
Lennart Poettering 81a40363f5 core: shorten code by using new helper 2019-01-17 16:12:38 +01:00
Lennart Poettering b1a4981aed tree-wide: whenever we allocate a new bus object, close it before dropping final ref
This doesn't really change much, but feels more correct to do, as it
ensures that all messages currently queued in the bus connections are
definitely unreffed and thus destryoing of the connection object will
follow immediately.

Strictly speaking this change is entirely unnecessary, since nothing
else could have acquired a ref to the connection and queued a message
in, however, now that we have the new sd_bus_close_unref() helper it
makes a lot of sense to use it here, to ensure that whatever happens
nothing that might have been queued fucks with us.
2019-01-17 16:12:38 +01:00
Lennart Poettering aae82d1a36 initctl: shorten and update code a bit 2019-01-17 16:12:38 +01:00
Lennart Poettering 92e31da100 tree-wide: make sure to flush/close all bus connections when our daemons exit
Let's make sure everything is written out ebfore we exit, so that no
messages keep our bus connections referenced.

Fixes: #11462
2019-01-17 16:12:38 +01:00
Lennart Poettering bd62b74486 sd-bus: add sd_bus_close_unref() helper
It's similar to sd_bus_flush_close_unref() but doesn't do the flushing.
This is useful since this will still discnnect the connection properly
but not synchronously wait for the peer to take our messages.

Primary usecase is within _cleanup_() expressions where synchronously
waiting on the peer is not OK.
2019-01-17 16:12:38 +01:00
Louis Taylor e4a8db1fbd util-lib: follow shell syntax for escape in quotes
Fixes #10659.

This changes the behaviour of parsing environment files to more closely
follow POSIX shell standards.

This has the effect that these variables defined in a file:

    VAR1='\value'
    VAR2="\value"

Are now interpreted as `\value` instead of interpreting the `\`
character and interpreting them as `value`.

For more information about the behaviour followed, see:

	http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02
2019-01-17 13:42:54 +00:00
Zbigniew Jędrzejewski-Szmek d7dce7b6fb man: use <varname> and <option> instead of <literal> in systemd.link(5)
This looks better and allows those terms to be indexed in systemd.directives.
In particular, <literal></literal> is dropped from around section names
([Match] and others) because the parens are distinctive enough on their own.
The same style is used in systemd.unit(5) and other pages that describe
sections.
2019-01-17 13:56:02 +01:00
Zbigniew Jędrzejewski-Szmek 08e1fe4249 NEWS: describe the naming scheme updates 2019-01-17 13:56:02 +01:00
Zbigniew Jędrzejewski-Szmek 73d2bb0881 link-config: default to "keep" policy if naming-scheme<=239 is used
This makes the new (>=240) behaviour conditional, restoring backwards compat, as least
as long as an old naming scheme is used.
2019-01-17 13:56:02 +01:00
Zbigniew Jędrzejewski-Szmek 35b351900f udev: move naming-scheme bits into their own file 2019-01-17 13:56:02 +01:00
Zbigniew Jędrzejewski-Szmek 3907446f02 link-config: add "keep" policy and use it by default
If "keep" policy is specified, and the interface has a name that is
NET_NAME_USER or NET_NAME_RENAMED, we stop processing rules. "keep" should
probably be specified either first or last depending on the preference.

This partially reimplements 55b6530baa, in the
sense that if the "keep" policy is not specified, and if the interface has
a NamingPolicy, it will be renamed, even if it had a name previously.
So this breaks backwards compatibility in this case, but that's more in line
with what users expect.

Closes #9006.
2019-01-17 13:56:02 +01:00
Ayman Bagabas 80aff27aeb hwdb: Add Huawei section and remap keys (#11406)
hwdb: Add support for 'Huawei WMI hotkeys' driver

Since 'Huawei WMI hotkeys' driver finally got merged into kernel
[commit](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86/huawei-wmi.c?id=bf4fb28c6e74495de9e1e4ad359cd2272ac12c53),
this remaps 'KEY_MICMUTE' to 'F20' to make the key work and disables
brightness keys on (MACH-WX9) since it's already supported by kernel.
2019-01-17 13:47:43 +01:00
bl33pbl0p 05d4db2051 Add note about transactions being genereated independently of a unit's state.
Meanwhile, change dead -> inactive as it is not a unit state.
2019-01-17 13:10:53 +01:00
Chris Morin f36712b7c3 CODING_STYLE: fix grammar mistake 2019-01-17 12:37:40 +01:00
Aaron Plattner 119f0f2876 core: Fix -EOPNOTSUPP emergency action error string
The error string for operations that are not supported (e.g. "shutdown" for
user-defined units) should take two arguments, where the first one is the type
of action being defined (i.e. "FailureAction" vs. "SuccessAction") and the
second is the string that was invalid.

Currently, the code prints this:

 $ systemd-run --user --wait -p SuccessAction=poweroff true
 Failed to start transient service unit: EmergencyAction setting invalid for manager type: SuccessAction

Change the format string to instead print:

 $ systemd-run --user --wait -p SuccessAction=poweroff true
 Failed to start transient service unit: SuccessAction setting invalid for manager type: poweroff
2019-01-17 09:17:15 +01:00
Aaron Plattner db2df5500e core: Fix return argument check for parse_emergency_action
This function returns 0 on success and a negative value on failure. On success,
it writes the parsed action to the address passed in its third argument.

`bus_set_transient_emergency_action` does this:

 r = parse_emergency_action(s, system, &v);
 if (v < 0)
     // handle failure

However, `v` is not updated if the function fails, and this should be checking
`r` instead of `v`.

The result of this is that if an invalid failure (or success) action is
specified, systemd ends up creating the unit anyway and then misbehaves if it
tries to run the failure action because the action value comes from
uninitialized stack data. In my case, this resulted in a failed assertion:

 Program received signal SIGABRT, Aborted.
 0x00007fe52cca0d7f in raise () from /snap/usr/lib/libc.so.6
 (gdb) bt
 #0  0x00007fe52cca0d7f in raise () from /snap/usr/lib/libc.so.6
 #1  0x00007fe52cc8b672 in abort () from /snap/usr/lib/libc.so.6
 #2  0x00007fe52d66f169 in log_assert_failed_realm (realm=LOG_REALM_SYSTEMD, text=0x56177ab8e000 "action < _EMERGENCY_ACTION_MAX", file=0x56177ab8dfb8 "../src/core/emergency-action.c", line=33, func=0x56177ab8e2b0 <__PRETTY_FUNCTION__.14207> "emergency_action") at ../src/basic/log.c:795
 #3  0x000056177aa98cf4 in emergency_action (m=0x56177c992cb0, action=2059118610, options=(unknown: 0), reboot_arg=0x0, exit_status=1, reason=0x7ffdd2df4290 "unit run-u0.service failed") at ../src/core/emergency-action.c:33
 #4  0x000056177ab2b739 in unit_notify (u=0x56177c9eb340, os=UNIT_ACTIVE, ns=UNIT_FAILED, flags=(unknown: 0)) at ../src/core/unit.c:2504
 #5  0x000056177aaf62ed in service_set_state (s=0x56177c9eb340, state=SERVICE_FAILED) at ../src/core/service.c:1104
 #6  0x000056177aaf8a29 in service_enter_dead (s=0x56177c9eb340, f=SERVICE_SUCCESS, allow_restart=true) at ../src/core/service.c:1712
 #7  0x000056177aaf9233 in service_enter_signal (s=0x56177c9eb340, state=SERVICE_FINAL_SIGKILL, f=SERVICE_SUCCESS) at ../src/core/service.c:1854
 #8  0x000056177aaf921b in service_enter_signal (s=0x56177c9eb340, state=SERVICE_FINAL_SIGTERM, f=SERVICE_SUCCESS) at ../src/core/service.c:1852
 #9  0x000056177aaf8eb3 in service_enter_stop_post (s=0x56177c9eb340, f=SERVICE_SUCCESS) at ../src/core/service.c:1788
 #10 0x000056177aaf91eb in service_enter_signal (s=0x56177c9eb340, state=SERVICE_STOP_SIGKILL, f=SERVICE_SUCCESS) at ../src/core/service.c:1850
 #11 0x000056177aaf91bc in service_enter_signal (s=0x56177c9eb340, state=SERVICE_STOP_SIGTERM, f=SERVICE_FAILURE_EXIT_CODE) at ../src/core/service.c:1848
 #12 0x000056177aaf9759 in service_enter_running (s=0x56177c9eb340, f=SERVICE_FAILURE_EXIT_CODE) at ../src/core/service.c:1941
 #13 0x000056177ab005b7 in service_sigchld_event (u=0x56177c9eb340, pid=112, code=1, status=1) at ../src/core/service.c:3296
 #14 0x000056177aad84b5 in manager_invoke_sigchld_event (m=0x56177c992cb0, u=0x56177c9eb340, si=0x7ffdd2df48f0) at ../src/core/manager.c:2444
 #15 0x000056177aad88df in manager_dispatch_sigchld (source=0x56177c994710, userdata=0x56177c992cb0) at ../src/core/manager.c:2508
 #16 0x00007fe52d72f807 in source_dispatch (s=0x56177c994710) at ../src/libsystemd/sd-event/sd-event.c:2846
 #17 0x00007fe52d730f7d in sd_event_dispatch (e=0x56177c993530) at ../src/libsystemd/sd-event/sd-event.c:3229
 #18 0x00007fe52d73142e in sd_event_run (e=0x56177c993530, timeout=18446744073709551615) at ../src/libsystemd/sd-event/sd-event.c:3286
 #19 0x000056177aad9f71 in manager_loop (m=0x56177c992cb0) at ../src/core/manager.c:2906
 #20 0x000056177aa7c876 in invoke_main_loop (m=0x56177c992cb0, ret_reexecute=0x7ffdd2df4bff, ret_retval=0x7ffdd2df4c04, ret_shutdown_verb=0x7ffdd2df4c58, ret_fds=0x7ffdd2df4c70, ret_switch_root_dir=0x7ffdd2df4c48, ret_switch_root_init=0x7ffdd2df4c50, ret_error_message=0x7ffdd2df4c60) at ../src/core/main.c:1792
 #21 0x000056177aa7f251 in main (argc=2, argv=0x7ffdd2df4e78) at ../src/core/main.c:2573

Fix this by checking the correct variable.
2019-01-17 09:17:15 +01:00
Jan Janssen a0e1ad10ea ethtool: Make sure advertise is actually set when autonegotiation is used 2019-01-17 09:15:09 +01:00
Zbigniew Jędrzejewski-Szmek 0b189e8fa7 link-config: unentangle the renaming logic and add logging
What policy we dicide to use it rather important, but this bit of information
wasn't logged. Let's always do that.

The code was also written in a confusing way, which probably contributed to the
unintended effects of 55b6530baa and other commits.
We would loop over all policies, and note if "kernel" was specified, and then
possibly unset the result at the end. Let's immediately log the result and cut
to the end if we can figure out the answer.

No functional change intended, except for the new log lines.
Using goto is not very elegant, but we can't use break because of the switch,
and there are multiple conditions to break the loop, so using goto is cleanest.
2019-01-16 22:20:04 +01:00
Zbigniew Jędrzejewski-Szmek 4919fe1352 user-util: remove unsed NOLEGACY define
AFAICT, it was never hooked up to meson, so it'd only work if somebody manually
defined the flag. I think it's preferable to drop the ifdef: it removes only a
single access call to a fixed location, which is realy cheap. If poeple don't
want to make use of this, they should just not create the file. Making this
both compile-time optional and opt-in in the filesystem is unnecessary.
2019-01-16 18:14:50 +01:00