Commit graph

17702 commits

Author SHA1 Message Date
Michal Koutný 171f12ced8 job: Ensure JobRunningTimeoutSec= survives serialization (#6128)
This is a fixup of commit a2df3ea4ae.
When there is a running job with JobRunningTimeoutSec= and systemd serializes
its state (e.g. during daemon-reload), the timer event source won't be properly
restored in job_coldplug().
Thus save and serialize begin_running_usec too and reinitialize the timer based
on that value.
2017-06-18 11:51:17 -04:00
Evgeny Vereshchagin f7b1c8d1fc udev: use interface before the string that interface points to is freed by device_add_property_internal (#6105)
This prevents udev from reading the data after freeing it.

See https://github.com/systemd/systemd/issues/6040#issuecomment-306589836
==264== Invalid read of size 1
==264==    at 0x4C2E112: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==264==    by 0x5943EBD: strdup (in /usr/lib/libc-2.25.so)
==264==    by 0x13E263: device_add_property_aux (sd-device.c:122)
==264==    by 0x14788C: device_add_property_internal (sd-device.c:150)
==264==    by 0x14788C: device_rename (device-private.c:786)
==264==    by 0x120DB6: udev_device_rename (libudev-device-private.c:213)
==264==    by 0x120DB6: udev_event_execute_rules (udev-event.c:895)
==264==    by 0x120DB6: worker_spawn (udevd.c:456)
==264==    by 0x1216E5: event_run (udevd.c:584)
==264==    by 0x1216E5: event_queue_start (udevd.c:823)
==264==    by 0x122213: on_uevent (udevd.c:927)
==264==    by 0x141F2F: source_dispatch (sd-event.c:2272)
==264==    by 0x142D52: sd_event_dispatch (sd-event.c:2631)
==264==    by 0x142D52: sd_event_run (sd-event.c:2690)
==264==    by 0x142D52: sd_event_loop (sd-event.c:2710)
==264==    by 0x1159CB: run (udevd.c:1643)
==264==    by 0x1159CB: main (udevd.c:1772)
==264==  Address 0x7b251a0 is 0 bytes inside a block of size 5 free'd
==264==    at 0x4C2C14B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==264==    by 0x13E2A2: freep (alloc-util.h:57)
==264==    by 0x13E2A2: device_add_property_aux (sd-device.c:111)
==264==    by 0x147873: device_add_property_internal (sd-device.c:150)
==264==    by 0x147873: device_rename (device-private.c:781)
==264==    by 0x120DB6: udev_device_rename (libudev-device-private.c:213)
==264==    by 0x120DB6: udev_event_execute_rules (udev-event.c:895)
==264==    by 0x120DB6: worker_spawn (udevd.c:456)
==264==    by 0x1216E5: event_run (udevd.c:584)
==264==    by 0x1216E5: event_queue_start (udevd.c:823)
==264==    by 0x122213: on_uevent (udevd.c:927)
==264==    by 0x141F2F: source_dispatch (sd-event.c:2272)
==264==    by 0x142D52: sd_event_dispatch (sd-event.c:2631)
==264==    by 0x142D52: sd_event_run (sd-event.c:2690)
==264==    by 0x142D52: sd_event_loop (sd-event.c:2710)
==264==    by 0x1159CB: run (udevd.c:1643)
==264==    by 0x1159CB: main (udevd.c:1772)
==264==  Block was alloc'd at
==264==    at 0x4C2AF1F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==264==    by 0x5943EC9: strdup (in /usr/lib/libc-2.25.so)
==264==    by 0x13E263: device_add_property_aux (sd-device.c:122)
==264==    by 0x143B45: device_add_property_internal (sd-device.c:150)
==264==    by 0x143B45: device_amend.lto_priv.235 (device-private.c:454)
==264==    by 0x1387B7: device_append (device-private.c:516)
==264==    by 0x1387B7: device_new_from_nulstr (device-private.c:620)
==264==    by 0x1387B7: udev_device_new_from_nulstr (libudev-device-private.c:268)
==264==    by 0x1387B7: udev_monitor_receive_device (libudev-monitor.c:682)
==264==    by 0x11FC69: worker_spawn (udevd.c:509)
==264==    by 0x1216E5: event_run (udevd.c:584)
==264==    by 0x1216E5: event_queue_start (udevd.c:823)
==264==    by 0x122213: on_uevent (udevd.c:927)
==264==    by 0x141F2F: source_dispatch (sd-event.c:2272)
==264==    by 0x142D52: sd_event_dispatch (sd-event.c:2631)
==264==    by 0x142D52: sd_event_run (sd-event.c:2690)
==264==    by 0x142D52: sd_event_loop (sd-event.c:2710)
==264==    by 0x1159CB: run (udevd.c:1643)
==264==    by 0x1159CB: main (udevd.c:1772)
==264==
2017-06-18 11:31:30 +02:00
Zbigniew Jędrzejewski-Szmek d4bf82fcac pid1: properly encode infinity when writing CPUQuota snippet (#6141)
We would write
  [Slice]
  CPUQuota=1844674407370955%
which is (numerically) correct, but it seems better to just write
  [Slice]
  CPUQuota=
which is interpreted as USEC_INFINITY by the parser in config_parse_cpu_quota().

Fixes #5965.
2017-06-18 11:18:41 +02:00
Lennart Poettering f1fccf5322 Merge pull request #6064 from keszybz/lock-session
Improvements to loginctl operating on current session
2017-06-18 11:16:53 +02:00
Lennart Poettering 99a812ad3b Merge pull request #6140 from keszybz/rm-rf-symlink
Allow symlinks to root to be removed
2017-06-18 11:15:13 +02:00
Yu Watanabe 42303dcb1a resolved: ignore DNSSEC= option when resolved is built without gcrypt (#6084)
Fixes #5583.
2017-06-17 16:22:32 -04:00
Zbigniew Jędrzejewski-Szmek 7cb53855dc basic/rm-rf: allow a symlink to / to be removed
We open the target path with O_DIRECTORY|O_NOFOLLOW, and if that doesn't work,
we call unlink() on the path. In neither case we will follow the symlink, so
we can relax our check to also not follow symlinks.

Fixes #5864.
2017-06-17 12:41:08 -04:00
Zbigniew Jędrzejewski-Szmek e3f791a2b3 basic/path-util: allow flags for path_equal_or_files_same
No functional change, just a new parameters and the tests that
AT_SYMLINK_NOFOLLOW works as expected.
2017-06-17 12:37:16 -04:00
Nate Clark a1bb2402cb udev-builtin-blkid: Use _cleanup_blkid_free_probe_ to free probe (#6108)
Use the _cleanup_blkid_free_probe_ to guarantee that the
blkid_probe will be freed when builtin_blkid exits.
2017-06-16 22:44:57 +02:00
Lennart Poettering c620f9b90b Merge pull request #6134 from pfl/radv_fixes
Router Advertisement fixes
2017-06-16 22:43:36 +02:00
Lennart Poettering 117e610075 Merge pull request #6133 from wbx-github/idn_config
make IDN support conditional
2017-06-16 22:06:48 +02:00
Waldemar Brodkorb 6326a14326 Make IDN support conditional
[zj: rename HAVE_IDN to ENABLE_IDN]
2017-06-16 09:13:16 -04:00
Patrik Flykt 6abd0ef387 networkd-address: Use DIV_ROUND_UP for consistency
Use DIV_ROUND_UP for consistency instead of the previous construct.
2017-06-16 09:46:25 +03:00
Patrik Flykt 945e32252e networkd-radv: Fix router lifetime assignment
Router lifetime is stored as usec_t, use value accordingly.
2017-06-16 09:45:46 +03:00
Patrik Flykt 301a2fb99a networkd: Fix comment
Comment about not being a router is in the wrong place. Router lifetime
is assigned with config_parse_sec().
2017-06-16 09:44:45 +03:00
Davide Cavalca ec36d052f7 meson: only run c++ tests when c++ compiler is available (#6123) 2017-06-15 10:55:13 +02:00
NeilBrown 83897d5470 core/mount: pass "-c" flag to /bin/umount (#6093)
"-c", which is short for "--no-canonicalize", tells /bin/umount
that the path name is canonical (no .. or symlinks etc).

systemd always uses a canonical name, so this flag is appropriate
for systemd to use.
Knowing that the path is canonical allows umount to avoid
some calls to lstat() on the path.

From v2.30 "-c" goes further and causes umount to avoid all
attempts to 'lstat()' (or similar) the path.  This is important
when automatically unmounting a filesystem, as lstat() can
hang indefinitely in some cases such as when an NFS server
is not accessible.

"-c" has been supported since util-linux 2.17 which is before the
earliest version supported by systemd.
So "-c" is safe to use now, and once util-linux v2.30 is in use,
it will allow mounts from non-responsive NFS servers to be
unmounted.
2017-06-07 15:28:23 +03:00
Evgeny Vereshchagin 3bd82598a1 udev: stop freeing value after using it for setting sysattr (#6094)
This prevents udev from double-freeing and crashing.

See https://github.com/systemd/systemd/issues/6040#issuecomment-306589836
==351== Invalid free() / delete / delete[] / realloc()
==351==    at 0x4C2C14B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==351==    by 0x13CBE8: hashmap_clear_free_free (hashmap.c:900)
==351==    by 0x13CBE8: hashmap_free_free_free (hashmap.c:852)
==351==    by 0x147F4F: sd_device_unref (sd-device.c:88)
==351==    by 0x130CCC: udev_device_unref (libudev-device.c:552)
==351==    by 0x130CD5: udev_device_unref (libudev-device.c:553)
==351==    by 0x11FBBB: worker_spawn (udevd.c:488)
==351==    by 0x1216E5: event_run (udevd.c:584)
==351==    by 0x1216E5: event_queue_start (udevd.c:823)
==351==    by 0x122213: on_uevent (udevd.c:927)
==351==    by 0x141F2F: source_dispatch (sd-event.c:2272)
==351==    by 0x142D52: sd_event_dispatch (sd-event.c:2631)
==351==    by 0x142D52: sd_event_run (sd-event.c:2690)
==351==    by 0x142D52: sd_event_loop (sd-event.c:2710)
==351==    by 0x1159CB: run (udevd.c:1643)
==351==    by 0x1159CB: main (udevd.c:1772)
==351==  Address 0x81745b0 is 0 bytes inside a block of size 1 free'd
==351==    at 0x4C2C14B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==351==    by 0x1447F0: freep (alloc-util.h:57)
==351==    by 0x1447F0: sd_device_set_sysattr_value (sd-device.c:1859)
==351==    by 0x132081: udev_device_set_sysattr_value (libudev-device.c:849)
==351==    by 0x12E777: set_trackpoint_sensitivity (udev-builtin-keyboard.c:180)
==351==    by 0x12E777: builtin_keyboard.lto_priv.170 (udev-builtin-keyboard.c:263)
==351==    by 0x14D03F: udev_builtin_run.constprop.75 (udev-builtin.c:133)
==351==    by 0x11FAEB: udev_event_execute_run (udev-event.c:957)
==351==    by 0x11FAEB: worker_spawn (udevd.c:461)
==351==    by 0x1216E5: event_run (udevd.c:584)
==351==    by 0x1216E5: event_queue_start (udevd.c:823)
==351==    by 0x122213: on_uevent (udevd.c:927)
==351==    by 0x141F2F: source_dispatch (sd-event.c:2272)
==351==    by 0x142D52: sd_event_dispatch (sd-event.c:2631)
==351==    by 0x142D52: sd_event_run (sd-event.c:2690)
==351==    by 0x142D52: sd_event_loop (sd-event.c:2710)
==351==    by 0x1159CB: run (udevd.c:1643)
==351==    by 0x1159CB: main (udevd.c:1772)
==351==  Block was alloc'd at
==351==    at 0x4C2CF35: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==351==    by 0x144853: sd_device_set_sysattr_value (sd-device.c:1888)
==351==    by 0x132081: udev_device_set_sysattr_value (libudev-device.c:849)
==351==    by 0x12E777: set_trackpoint_sensitivity (udev-builtin-keyboard.c:180)
==351==    by 0x12E777: builtin_keyboard.lto_priv.170 (udev-builtin-keyboard.c:263)
==351==    by 0x14D03F: udev_builtin_run.constprop.75 (udev-builtin.c:133)
==351==    by 0x11FAEB: udev_event_execute_run (udev-event.c:957)
==351==    by 0x11FAEB: worker_spawn (udevd.c:461)
==351==    by 0x1216E5: event_run (udevd.c:584)
==351==    by 0x1216E5: event_queue_start (udevd.c:823)
==351==    by 0x122213: on_uevent (udevd.c:927)
==351==    by 0x141F2F: source_dispatch (sd-event.c:2272)
==351==    by 0x142D52: sd_event_dispatch (sd-event.c:2631)
==351==    by 0x142D52: sd_event_run (sd-event.c:2690)
==351==    by 0x142D52: sd_event_loop (sd-event.c:2710)
==351==    by 0x1159CB: run (udevd.c:1643)
==351==    by 0x1159CB: main (udevd.c:1772)
2017-06-06 21:47:47 -04:00
Susant Sahani 14d20d2bfb networkd: fix route table from unsigned char to uint32_t (#6083)
[zj: struct Route is defined with uint32_t route, so this makes the type of the function
parameter match the field it is assigned to.]
2017-06-06 12:02:31 -04:00
Paul Kocialkowski a918b6738a sd-device: Try /sys/firmware for sysname to allow device-tree (#5837)
This adds /sys/firmware lookup for sysname when creating a new device,
which allows device-tree properties lookup. This look-up can then be
used in udev rules, allowing device-tree-based model detection.
2017-06-06 11:27:30 -04:00
Zbigniew Jędrzejewski-Szmek 3e7d14d78c sd-bus: silence format warnings in kdbus code (#6072)
The code is mostly correct, but gcc is trying to outsmart us, and emits a
warning for a "llu vs lu" mismatch, even though they are the same size (on alpha):

src/libsystemd/sd-bus/bus-control.c: In function ‘kernel_get_list’:
src/libsystemd/sd-bus/bus-control.c:267:42: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
                         if (asprintf(&n, ":1.%llu", name->id) < 0) {
                                          ^
src/libsystemd/sd-bus/bus-control.c: In function ‘bus_get_name_creds_kdbus’:
src/libsystemd/sd-bus/bus-control.c:714:47: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
                 if (asprintf(&c->unique_name, ":1.%llu", conn_info->id) < 0) {
                                               ^
This is hard to work around properly, because kdbus.h uses __u64 which is
defined-differently-despite-being-the-same-size then uint64_t. Thus the simple
solution of using %PRIu64 fails on amd64:

src/libsystemd/sd-bus/bus-control.c:714:47: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Werror=format=]
                 if (asprintf(&c->unique_name, ":1.%"PRIu64, conn_info->id) < 0) {
                                               ^~~~~~

Let's just avoid the whole issue for now by silencing the warning.
After the next release, we should just get rid of the kdbus code.

Fixes #5561.
2017-06-03 11:41:17 +02:00
Evgeny Vereshchagin af4af186b8 tests: skip test_exec_inaccessiblepaths_proc when inaccessible dir is unavailable (#6068)
test_exec_inaccessiblepaths_proc depends on
/run/systemd/inaccessible/dir, which may be unavailable.

See https://github.com/systemd/systemd/issues/5987#issuecomment-305448958.
2017-06-01 13:58:37 -04:00
Martin Pitt 5304b4ea72 Merge pull request #6058 from keszybz/chrooted-test-fixes
Chrooted test fixes
2017-06-01 09:37:13 +02:00
Zbigniew Jędrzejewski-Szmek 9cf8e2087b loginctl: also use $XDG_SESSION_ID for session-status 2017-05-31 22:42:50 -04:00
Zbigniew Jędrzejewski-Szmek bdb07fa5ac loginctl: use $XDG_SESSION_ID for "our" session
Instead of always letting logind guess what the caller's session is, let's
give it the value from $XDG_SESSION_ID when it is present in the caller's
environment.

Nowadays terminal emulators are often running as services under systemd --user,
and not as part of an actual session, so all loginctl calls which depend on
logind guessing the session will fail. I don't see a reason not to honour
$XDG_SESSION_ID.

This applies to LockSession, UnlockSession, TerminateSession, ActivateSession,
SetUserLinger.

Fixes #6032.
2017-05-31 22:32:14 -04:00
Zbigniew Jędrzejewski-Szmek cf82fda94e logind: nicer error message when we cannot guess the caller's session
Partial fix for #6032.
2017-05-31 22:10:15 -04:00
Michael Biebl 0aac506b64 hwdb: use path_join() to generate the hwdb_bin path (#6063)
This avoids having double slashes which can confuse selinux.
2017-05-31 21:21:11 -04:00
Yu Watanabe 76ed21e1e6 sd-login: sd_get_machine_names(): do not return -EINVAL when output parameter is NULL
Other functions in sd-login generally allow the output parameter to be NULL, in
which case only the number of items that would be stored in the array is returned.
Be nice and do the same here.
2017-05-31 19:22:38 -04:00
Yu Watanabe 2b5e92673d sd-login: treat missing /run/systemd/{seats,sessions,users} the same as empty
C.f. 0543105b0f.
This makes if /run/systemd/{seats,sessions,users} are missing, then
sd_get_seats(), sd_get_sessions() and sd_get_uids() return 0, that is,
an empty list, instead of -ENOENT.
2017-05-31 19:01:13 -04:00
Martin Pitt 8e1589269a Merge pull request #6053 from keszybz/doc-tweaks
Man page and unit file and mailmap and meson tweaks
2017-05-31 23:24:57 +02:00
Zbigniew Jędrzejewski-Szmek 19fbf49cde systemctl: avoid spurious warning about missing reboot-param file
$ reboot -f
Failed to read reboot parameter file: No such file or directory

It seems that the warning on ENOENT was inadvertently introduced in
27c06cb516.

The warning reported in #5646 comes from systemctl, but let's fix the other
call site in the same way too.

Fixes #5646.
2017-05-30 23:41:31 -04:00
Zbigniew Jędrzejewski-Szmek f00237563e test-bus-vtable: it's OK if dbus is not running
Fixes #5989.
2017-05-30 21:17:46 -04:00
Zbigniew Jędrzejewski-Szmek bc9e9af137 sd-login: translate -ENOMEDIUM to -ENODATA
The -ENOMEDIUM return value was introduced in v232-1001-g2977724b09,
('core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/systemd hierarchy'),
and would be returned by cg_pid_get_path_shifted(), but the documented and
expected return value is -ENODATA. Let's just catch ENXIO/ENOMEDIUM and translate
it to ENODATA in all cases.

Complements 171f8f591f, fixes #6012.
2017-05-30 21:17:46 -04:00
Zbigniew Jędrzejewski-Szmek ce241a493f sulogin-shell: avoid heredocs
They require a writable /tmp dir (in the bash implementation).
Let's use echo, and not 'echo -e' since that doesn't seem to be completely
portable.

Fixes #6052.
2017-05-30 17:03:25 -04:00
Yu Watanabe 9d8813b3b4 kernel-install: support the case /etc/machine-id is missing or empty (#5975)
Some .install plugins does not require that machine ID is set such as
20-grubby.install for Fedora and 50-depmod.install.
To support such plugins to run without valid machine-id, this commit
makes the following change:
* if /etc/machine-id is missing or empty, create temporary directory
  and set its path to BOOT_DIR_ABS,
* run the .install helpers with KERNEL_INSTALL_MACHINE_ID environment
  variable that'd be empty if /etc/machine-id is missing or empty.
This may be useful for installing kernel for e.g. stateless systems
which initialize machine-id while booting the systems.
2017-05-30 09:45:10 -04:00
Lennart Poettering c4c069121c timesyncd: properly handle OOM errors when parsing fallback servers (#6047) 2017-05-30 14:49:35 +02:00
Patrik Flykt 5a67ed2403 test-ndisc-rs.c: Test Router Solicitation timer computation
Test ICMPv6 Router Solicitation exponential backoff timer by
computing the minimum and maximum values according to RFC 7559,
Section 2 and the algorithm itself described in RFC 3315, Section
14. Reset the sd_ndisc timer to trigger after a zero second delay,
which causes the ndisc timeout to be triggered immediately once
the caller of the "sending" function returns to the main loop.
2017-05-30 10:34:15 +03:00
Patrik Flykt e82a19cb18 sd-ndisc.c: Move Router Solicitation sending after timer computaion
Move ICMPv6 Router Solicitation sending after timer computation so
that timers are already set up when the packet is being sent. This
makes it possible to create a test that inspects Router
Solicitation timer values when the Router Solicitation is sent out
on the network.
2017-05-30 10:34:15 +03:00
Patrik Flykt 1bd6f8953d sd-ndisc: Implement Router Solicitation backoff method
Instead of sending a fixed amount of Router Solicitiations, implement
the backoff algorithm proposed in RFC 7559. The backoff algorithm is
the same as used by DHCPv6.

Time out after 12s as specified in RFC 4861 in order not to delay
setting up a link for too long while sending Router Solicitations
in the background. Notice that after this change the callback will
receive a SD_NDISC_EVENT_TIMEOUT timeout event, and at a later point
when a router appears, a received Router Advertisment will cause the
callback to be called again with the SD_NDISC_EVENT_ROUTER event.
2017-05-30 10:34:15 +03:00
Tobias Jungel 0d6c68eba3 network: bridge vlan without PVID (#5899)
this patch makes it possible to configure a vlan aware bridge without the
PVID. To configure no PVID set DefaultPVID=none in the [BridgeVLAN] section.

fixes #5716
2017-05-29 17:20:01 +02:00
Lennart Poettering defdbbb6dc Merge pull request #5926 from fsateler/condition-uid
core: add ConditionUID and ConditionGID
2017-05-29 15:18:38 +02:00
Lennart Poettering 90b25159a6 Merge pull request #6031 from teg/monitor
busctl: fix up the monitor
2017-05-29 15:08:20 +02:00
Lennart Poettering 24c4b00b38 Merge pull request #6029 from keszybz/vconsole-no-vga
Avoid systemd-vconsole-setup failure on machines w/o VGA
2017-05-26 18:09:57 +02:00
Felipe Sateler 534bab66ab core: add @system special value to ConditionUser=
It allows checking if the user is a system user or a normal user
2017-05-26 09:42:47 -04:00
Felipe Sateler c465a29f24 core: add ConditionUser and ConditionGroup
This adds two options that are useful for user units. In particular, it
is useful to check ConditionUser=!0 to not start for the root user.

Closes: #5187
2017-05-26 09:42:44 -04:00
Zbigniew Jędrzejewski-Szmek 2340bfbfcc Merge pull request #5999 from mbiebl/timesyncd-fallback-server
timesyncd: don't use compiled-in list if FallbackNTP has been configured
2017-05-25 18:51:08 -04:00
Tom Gundersen d27d4637c8 busctl: monitor - ignore the final NameLost message
Commit f5938e8ff3 started dropping all
messages before we become a monitor, but the last one was getting
through.

This drops also the last NameLost message, which indicatse the switch
from a regular peer to a monitor.
2017-05-25 17:37:50 +02:00
Tom Gundersen 0bf7d7cc88 logn: tests - don't compare signed with unsigned 2017-05-25 17:37:50 +02:00
Zbigniew Jędrzejewski-Szmek c6c1ba8f64 test-timesync: add first test for timesyncd conf parsing
We parse the string supplied in NTP_SERVERS during configuration under an
assert_se(). Right now we will accept pretty much anything there, but in case
we are more picky in the future, add a simple test which checks that we can
actually parse whatever is in NTP_SERVERS so that we don't fail the assertion
at runtime.
2017-05-25 10:59:35 -04:00
Timothée Ravier c090d74dd9 test: ensure 'InaccessiblePaths=/proc' option works (#6017)
Test case for PR #5985.
2017-05-25 07:47:08 +03:00