Commit graph

38109 commits

Author SHA1 Message Date
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
Zbigniew Jędrzejewski-Szmek a2cadef9cc Drop some unnecessary newlines 2019-01-16 18:14:34 +01:00
Zbigniew Jędrzejewski-Szmek fb4986fa95
Merge pull request #11441 from poettering/foreach-string-rework
FOREACH_STRING() rework
2019-01-16 18:10:54 +01:00
Lennart Poettering 57c03b1e6e seccomp: drop mincore() from @system-service syscall filter group
Previously, this system call was included in @system-service since it is
a "getter" only, i.e. only queries information, and doesn't change
anything, and hence was considered not risky.

However, as it turns out, mincore() is actually security sensitive, see
the discussion here:

https://lwn.net/Articles/776034/

Hence, let's adjust the system call filter and drop mincore() from it.

This constitues a compatibility break to some level, however I presume
we can get away with this as the systemcall is pretty exotic. The fact
that it is pretty exotic is also reflected by the fact that the kernel
intends to majorly change behaviour of the system call soon (see the
linked LWN article)
2019-01-16 18:08:35 +01:00
Zbigniew Jędrzejewski-Szmek 29cf0ff823 libsystemd-network: use xsprintf in one more place
DECIMAL_STR_MAX includes space for NUL, so we don't need 2 here.
2019-01-16 13:34:31 +01:00
Yu Watanabe 7e8bd58eb1 udev: 'val' may be NULL, use strempty() 2019-01-16 13:34:04 +01:00
Philip Withnall 35f2c0ba6a man: Fix a typo in systemd.exec.xml
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-16 21:33:38 +09:00
Zbigniew Jędrzejewski-Szmek ed30802324 Revert "Always rename an interface to its name specified in config if no NamePolicy= is specified"
This reverts commit 55b6530baa.

This commit description says "Always rename an interface to its name specified
in config if no NamePolicy= is specified", but it does much more:
1. It completely changes the meaning of NamePolicy=kernel. Before, it meant that an interface
   with type==NAMEPOLICY_KERNEL would not be renamed. After, the kernel name only works as
   a fallback, if no policy matches.
2. The "if no NamePolicy= is specified" part is not true at all, the interface will be renamed
   according to the specified NamePolicy=.

After 55b6530baa, the should_rename() function is named very misleadingly: it is only used
to mean "respect kernel predictable name if no naming policy matches".

Let's revert, and start with a clean slate. This fixes #11436.
2019-01-16 13:28:41 +01:00
bl33pbl0p 28d78d0726 Log the job being merged
Makes it easier to understand what was merged (and easier to realize why).

Example is a start job running, and another unit triggering a verify-active job. It is not clear what job was it that from baz.service that merged into the installed job for bar.service in the debug logs. This makes it useful when debugging issues.

Jan 15 11:45:58 jupiter systemd[1218]: baz.service: Trying to enqueue job baz.service/start/replace
Jan 15 11:45:58 jupiter systemd[1218]: baz.service: Installed new job baz.service/start as 498
Jan 15 11:45:58 jupiter systemd[1218]: bar.service: Merged into installed job bar.service/start as 497
Jan 15 11:45:58 jupiter systemd[1218]: baz.service: Enqueued job baz.service/start as 498

It becomes:
Jan 15 11:45:58 jupiter systemd[1218]: bar.service: Merged bar.service/verify-active into installed job bar.service/start as 497
2019-01-16 12:34:54 +01:00
Lennart Poettering 66a64081f8 strv: rework FOREACH_STRING() macro
So it's apparently problematic that we use STRV_MAKE() (i.e. a compound
initializer) outside of the {} block we use it in (and that includes
outside of the ({}) block, too). Hence, let's rework the macro to not
need that.

This also makes the macro shorter, which is definitely a good and more
readable. Moreover, it will now complain if the iterator is a "char*"
instead of a "const char*", which is good too.

Fixes: #11394
2019-01-16 12:29:30 +01:00
Lennart Poettering b2238e380e test,systemctl,nspawn: use "const char*" instead of "char*" as iterator for FOREACH_STRING()
The macro iterates through literal strings (i.e. constant strings),
hence it's more correct to have the iterator const too.
2019-01-16 12:29:30 +01:00
Lucas Werkmeister 2732587540 Enable regular file and FIFO protection
These sysctls were added in Linux 4.19 (torvalds/linux@30aba6656f), and
we should enable them just like we enable the older hardlink/symlink
protection since v199. Implements #11414.
2019-01-16 12:22:01 +01:00
Daniel Axtens 20ca06a669 tests: Add test for IPv6 source routing
The test is a bit messy because it must be done on a device that
enforces a tentative state for IPv6 addresses, and it appears
that the dummy device does not. So we use a bond instead.

Signed-off-by: Daniel Axtens <dja@axtens.net>
2019-01-16 12:54:06 +11:00
Daniel Axtens 6aa5773bff Install routes after addresses are ready
If an IPv6 route is added with a source address that is still
tentative, the kernel will refuse to install it.

Previously, once we sent the messages to the kernel to add the
addresses, we would immediately proceed to add the routes. The
addresses would usually still be tentative at this point, so
adding static IPv6 routes was broken - see issue #5882.

Now, only begin to configure routes once the addresses are ready,
by restructuring the state machine, and tracking when addresses are
ready, not just added.

Fixes: #5882
Signed-off-by: Daniel Axtens <dja@axtens.net>
2019-01-16 12:54:06 +11:00
Joost Heitbrink 850115b3a1 Fix omission in docs
change "if is missing" to "if /etc/machine-id is missing".
2019-01-15 21:45:06 +01:00
Zbigniew Jędrzejewski-Szmek 29a93cb19d
Merge pull request #11418 from yuwata/fix-11404
network: fix infinite loop in setting up wireguard
2019-01-15 21:04:32 +01:00
Zbigniew Jędrzejewski-Szmek 477fd8e886
Merge pull request #11345 from kirbyfan64/tmpfiles-c-empty
tmpfiles: Make C still copy if the destination directory is empty
2019-01-15 16:54:19 +01:00
Zbigniew Jędrzejewski-Szmek acd1220cff
Merge pull request #11428 from yuwata/network-issue-9130-v2
network: wait for kernel to reply ipv6 peer address
2019-01-15 16:44:27 +01:00
Zbigniew Jędrzejewski-Szmek 774d6375d6 NEWS: typos 2019-01-15 14:56:24 +01:00
Yu Watanabe 9e2bbf9915 network: make Link and NetDev always have the valid poiter to Manager
c4397d94c3 introduces
link_detach_from_manager() and netdev_detach_from_manager(), and they
set Link::manager or NetDev::manager NULL.
But, at the time e.g. link is removed, hence link_drop() is called,
there may be still some asynchronous netlink call is waiting, and
their callbacks hit assertion.

This make {link,netdev}_detach_from_manager() just drop all references
from manager, but keep the pointer to manager.

Fixes #11411.
2019-01-15 14:48:53 +01:00
Mikhail Kasimov 50198038c8 Update uk.po
Updated translation for ```src/timedate/org.freedesktop.timedate1.policy```
2019-01-15 14:37:50 +01:00
Zbigniew Jędrzejewski-Szmek 15ee6c204a Revert "pam_systemd: set $DBUS_SESSION_BUS_ADDRESS unconditionally"
This reverts commit 69bd76f2b9.

$DBUS_SESSION_BUS_ADDRESS is again set only if the socket exists.

Quoting https://github.com/systemd/systemd/pull/11327#issuecomment-452019027:
> [setting $DBUS_SESSION_BUS_ADDRESS unconditionally] makes pam_systemd
> incompatible with installations and distributions where dbus was not
> configured with --enable-user-session, and the session dbus-daemon is started
> by autolaunching or dbus-launch (as opposed to dbus.socket). I don't think
> that's wise: using autolaunching or dbus-launch, and disabling or not
> installing dbus.socket and dbus.service on the systemd user instance, is our
> compatibility story for people who still need a D-Bus session bus per X11
> session for whatever reason.
>
> For example, Debian can currently do either way, with a dbus-user-session
> package strongly recommended but not actually mandatory. dbus-user-session
> requires libpam-systemd; if pam_systemd now requires dbus.socket (which is in
> the dbus-user-session package), that's a circular dependency, which we
> normally try hard to avoid.

For systems that use dbus.socket this doesn't matter much, because the
user session is ordered after the user managaer, which pulls in dbus.socket
very early. For example, when logging over ssh:

sshd[20796]: pam_systemd(sshd:session): pam-systemd initializing
sshd[20796]: pam_systemd(sshd:session): Asking logind to create session: uid=1001 pid=20796 service=sshd type=tty class=user desktop= seat= vtnr=0 tty= display= remote=yes remote_user= remote_host=::1
sshd[20796]: pam_systemd(sshd:session): Session limits: memory_max=n/a tasks_max=n/a cpu_weight=n/a io_weight=n/a
systemd[1]: Created slice User Slice of UID 1001.
systemd[1]: Starting User Runtime Directory /run/user/1001...
systemd-logind[1210]: New session 3796 of user guest.
systemd[1]: Started User Runtime Directory /run/user/1001.
systemd[1]: Starting User Manager for UID 1001...
systemd[20805]: pam_systemd(systemd-user:session): pam-systemd initializing
systemd[20805]: Starting D-Bus User Message Bus Socket.
...
systemd[20805]: Reached target Sockets.
systemd[20805]: Reached target Basic System.
systemd[1]: Started User Manager for UID 1001.
systemd[1]: Started Session 3796 of user guest.
sshd[20796]: pam_systemd(sshd:session): Reply from logind: id=3796 object_path=/org/freedesktop/login1/session/_33796 runtime_path=/run/user/1001 session_fd=13 seat= vtnr=0 original_uid=1001
sshd[20796]: pam_unix(sshd:session): session opened for user guest by (uid=0)

Hence, everything in the ssh session is ordered after the user instance.
And in the user instance, services should be orderd after dbus.socket using
inter-unit dependencies. dbus.socket in turns does
systemctl --user set-environment DBUS_SESSION_BUS_ADDRESS=unix:path=%t/bus.

So there should be no race between starting of the dbus socket and our check
if it exists.

The alternative would be to set the "DBUS_SESSION_BUS_ADDRESS=unix:path=%s/bus;autolaunch:".
AFAICT, this would work as well. But I don't see any case where it actually works
better. Since this is an area with many compatiblity concerns, let's stick to
the previous setup which seems to work well.
2019-01-15 14:24:10 +01:00
Zbigniew Jędrzejewski-Szmek 055c08ef67 pam_systemd: do no allocate the path of fixed length 2019-01-15 14:24:10 +01:00
Zbigniew Jędrzejewski-Szmek a6ca3c1921 udev: do logging before setting variables to NULL
gcc-9 diagnoses this as an error.
Reported by Jeff Law.
2019-01-15 13:58:45 +01:00
Mikhail Kasimov 06156ed2cf Update systemd-system.conf.xml
Updating due to phrase "Defaults to DefaultTimeoutStartSec= from the manager configuration file, except when Type=oneshot is used, in which case the timeout is disabled by default (see systemd-system.conf)" from [0] https://github.com/systemd/systemd/blob/master/man/systemd.service.xml
2019-01-15 13:56:35 +01:00
Topi Miettinen a1e92eee3e Remove 'inline' attributes from static functions in .c files (#11426)
Let the compiler perform inlining (see #11397).
2019-01-15 08:12:28 +01:00
Yu Watanabe b4356b5720 timedate: refuse to set time when previous request is not finished
If `timedatectl set-time` is invoked right after `timedatectl set-ntp true`,
then, the NTP service may not be started yet.

Fixes #11420.
2019-01-15 15:15:26 +09:00
Yu Watanabe 84a87726ee timedate: treat 'activating' or 'inactivating' NTP client status as 'active'
When `timedatectl set-time` is called, NTP client may be in
'activating' or something. For safety, let's treat such states as
'active'.

This also changes all unit file status except for 'masked' or 'disabled'
are treated as 'enabled'.
2019-01-15 14:44:32 +09:00
Yu Watanabe 7e6636196a test: add a testcase for Address.Peer= with ipv6
Testcase for #9130.
2019-01-15 07:37:15 +09:00
Susant Sahani dfef713f3e networkd: wait for kernel to reply ipv6 peer address
When we configure address with peer, peer address is repliedby kernel.
Hence add the peer when it is available.

Closes #9130.
2019-01-15 07:36:14 +09:00
Michael Biebl 1c8e48f506
Merge pull request #11417 from yuwata/fix-11416
udevadm: fix segfault
2019-01-14 02:39:11 +01:00
Yu Watanabe da44fb8a72 test: add a testcase for 23 wirguard peers 2019-01-14 10:08:58 +09:00
Yu Watanabe e1f717d4a0 network: wireguard: rename and split set_wireguard_interface()
This does not change the behavior except for fixing the issue #11404.

Fixes #11404.
2019-01-14 10:08:40 +09:00
Yu Watanabe 33c2ea8019 netlink: set maximum size of WGDEVICE_A_IFNAME 2019-01-14 09:47:31 +09:00
Yu Watanabe 0eba88dc9f udevadm: fix segfault
Fixes #11416.
2019-01-14 06:34:19 +09:00
Yu Watanabe 227bcd91b4 man: fix reference
Fixes #11396.
2019-01-13 11:12:20 +01:00
Zbigniew Jędrzejewski-Szmek 0d432661fa
Merge pull request #11409 from yuwata/udev-synthetic-errno
udev: update logs
2019-01-13 11:11:22 +01:00
Yu Watanabe 8d6c4b310d udev: use ENODATA when 'No entry found from hwdb'
Before:
IMPORT builtin 'hwdb' fails: No such file or directory

After:
IMPORT builtin 'hwdb' fails: No data available

Previous log is confusing and may be understood as hwdb file not exist.
2019-01-13 18:04:10 +09:00
Yu Watanabe a119328608 udev: use SYNTHETIC_ERRNO() macro in log_device_*_errno() 2019-01-13 17:50:47 +09:00
Evgeny Vereshchagin 9bbcfac1cf
Merge pull request #11393 from mrc0mmand/fix-service-masking-in-TEST-01-BASIC
test: drop service masking in TEST-01-BASIC
2019-01-13 04:45:48 +03:00
Yu Watanabe 40f116f53d README: mention that meson-0.49 is required to build PIEs
Follow-up for 4e4bbc439e.
2019-01-13 09:47:10 +09:00
Yu Watanabe bd36ef0a7c NEWS: add more entries 2019-01-13 09:47:10 +09:00
Zbigniew Jędrzejewski-Szmek 455027c98f NEWS: document deprecation of PermissionsStartOnly= in v240
https://github.com/systemd/systemd/pull/10802#issuecomment-453772058
2019-01-13 09:47:10 +09:00
Zbigniew Jędrzejewski-Szmek b4ff3dbb66 NEWS: update for v241 2019-01-13 09:47:10 +09:00