Commit graph

17986 commits

Author SHA1 Message Date
Lennart Poettering d5dd44b01c logind: make use of EVIOCSMASK input ioctl to mask out events we aren't interested in
This way logind will get woken up only when an actual event took place,
and not for every key press on the system.

The ioctl EVIOCSMASK was added by @dvdhrm already in October 2015, for
the use in logind, among others, hence let's actually make use of it
now.

While we are at it, also fix usage of the EVIOCGSW ioctl, where we
assumed a byte array, even though a unsigned long native endian array is
returned.
2017-06-27 19:25:46 +02:00
Zbigniew Jędrzejewski-Szmek db848813ba resolved: simplify alloc size calculation
The allocation size was calculated in a complicated way, and for values
close to the page size we would actually allocate less than requested.

Reported by Chris Coulson <chris.coulson@canonical.com>.

CVE-2017-9445
2017-06-27 13:19:52 -04:00
Zbigniew Jędrzejewski-Szmek 751ca3f1de test-resolved-packet: add a simple test for our allocation functions 2017-06-27 13:19:31 -04:00
Zbigniew Jędrzejewski-Szmek 180f6dbd2c Merge pull request #6067 from ssahani/networkctl
networkctl: display address labels
2017-06-27 11:41:09 -04:00
Susant Sahani d37b7627c2 networkctl: display address labels
```
 ./networkctl label

    Prefix/Prefixlen                          Label
        ::/0                                  1
    fc00::/7                                  5
    fec0::/10                                11
    2002::/16                                 2
    3ffe::/16                                12
 2001:10::/28                                 7
    2001::/32                                 6
::ffff:0.0.0.0/96                                 4
        ::/96                                 3
       ::1/128                                0

```
2017-06-27 10:15:27 -04:00
Zbigniew Jędrzejewski-Szmek 887a40521d Merge pull request #6201 from poettering/bus-driver-creds
shortcut credential querying of the "org.freedesktop.DBus" bus driver pseudo-service
2017-06-27 10:11:21 -04:00
Michal Suchanek 8e46eba454 hwdb: weed out key defines which do not designate events
The defines

KEY_MAX
KEY_CNT
KEY_MIN_INTERESTING
BTN_MISC
BTN_MOUSE
BTN_JOYSTICK
BTN_GAMEPAD
BTN_DIGI
BTN_WHEEL
BTN_TRIGGER_HAPPY

mark start/end of key blocks and do not designate events.

Exclude them from the list of recognized key events.
2017-06-27 13:29:02 +02:00
Michal Suchanek 22811ad065 input_id: fix button detection
Due to remapping some devices might not have the first button.

Check whole button range.
2017-06-27 13:28:11 +02:00
Michal Suchanek 0c21944e24 input_id: fix detection of devices with mouse buttons
Assign ID_INPUT_MOUSE property to devices with mouse buttons and no axis.

Libinput tries to use libwacom on devices with tablet-pad capability
which are detected by ID_INPUT_TABLET_PAD=1 property so assign pointer
class by setting ID_INPUT_MOUSE=1 to devices with mouse buttons and let
libwacom override the class for Wacom pads.
2017-06-27 13:28:11 +02:00
Michal Suchanek c6dce24573 hwdb: support pressing buttons on a keyboard
Support BTN_* codes with btn_ prefix and keys with KEY_ prefix
optionally removed.
2017-06-27 13:28:07 +02:00
Michal Suchanek 1b83323719 Use same script to build key list in Makefile and meson 2017-06-27 13:27:37 +02:00
Franck Bui fc5bc384c7 gpt-auto-generator: disable gpt auto logic for swaps if at least one is defined in fstab
If a swap partition is created on a disk using GPT then the unit generated by
the gpt-generator can shadow the one generated by the fstab-generator.

This can be an issue if the fstab entry for the swap has options since they are
simply ignored if PID1 decides to use the unit created by the gpt-generator
since this unit carries no information about the swap options.

This patch simply disables the GPT auto logic for swaps if at least one entry
for swap is defined in /etc/fstab.

Fixes: #6192
2017-06-27 10:06:36 +02:00
Franck Bui 6c1921e9f3 fstab-util: introduce fstab_has_fstype() helper 2017-06-27 10:04:46 +02:00
Franck Bui b9088048b1 fstab-util: don't eat up errors in fstab_is_mount_point()
That way the caller can decide what to do with failures, whether to consider
them or ignore them.
2017-06-27 10:04:20 +02:00
Zbigniew Jędrzejewski-Szmek 23e4a234fc Merge pull request #6200 from poettering/ioprio-transient 2017-06-26 21:30:36 -04:00
Zbigniew Jędrzejewski-Szmek 3cdd4e487e Merge pull request #6197 from ssahani/ethtool-port
ethtool: Fix speed in 593022fa37
2017-06-26 20:19:53 -04:00
Lennart Poettering 3285baa857 udev: fix some incorrect usages of CLOCK_BOOTTIME (#6198)
CLOCK_BOOTTIME should only be used if we actually want the clock to
count on while we are suspended, and it is hence not useful for normal
code execution time limits, fix that.

Moreover, a couple of uses were even more broken, as
clock_bottime_or_monotonic() was called where actually
now(clock_boottime_or_monotic()) was supposed to be called. Ouch!

Fixes: #5903
2017-06-26 20:17:39 -04:00
Zbigniew Jędrzejewski-Szmek 3e875a71e8 Merge pull request #6199 from poettering/systemctl-quiet
systemctl: be truly quiet in systemctl when -q is used
2017-06-26 20:16:39 -04:00
Zbigniew Jędrzejewski-Szmek 8a380e9603 Merge pull request #6203 from poettering/import-assert
remove misplaced importd assert
2017-06-26 20:03:14 -04:00
Evgeny Vereshchagin 82891136d7 Merge pull request #6160 from poettering/non-pollable-fdstore
support for non-pollable fds in the service fdstore
2017-06-27 00:22:58 +03:00
Yu Watanabe 9017f5d88d systemd-mount: support device names and multiple arguments for umount (#6096)
This makes systemd-umount (or systemd-mount -u) supports multiple arguments
which can be path, device, or fstab style node name, like
`systemd-umount /path/to/umount /dev/sda1 UUID=xxxxxx-xxxx LABEL=xxxxx`.

C.f. https://github.com/systemd/systemd/pull/5235#issuecomment-277731314.
2017-06-26 16:07:07 -04:00
WaLyong Cho 217f95db7b smack: handling smack onlycap list (#5542)
To support smack onlycap, read onlycap list from /etc/smack/onlycap and write
to /sys/fs/smackfs/onlycap.

https://lwn.net/Articles/292128/
http://lkml.iu.edu/hypermail/linux/kernel/1505.2/04718.html
http://schaufler-ca.com/description_from_the_linux_source_tree
2017-06-26 21:00:03 +02:00
Lennart Poettering b1d25c25e1 Merge pull request #6116 from richardmaw-codethink/networkd-carrier-fixes
Networkd fixes related to carrier status
2017-06-26 20:55:36 +02:00
Lennart Poettering 60675884cb systemctl: quieten a few more messages if -q is specified
As suggested by @mbiebl in https://github.com/systemd/systemd/pull/6199
2017-06-26 20:42:08 +02:00
Lennart Poettering dc38f65a72 importd: log more information when renaming files 2017-06-26 20:32:40 +02:00
Lennart Poettering e0061812b0 import: remove misplaced assert()
We shouldn't assume the final path for the settings file is already
known, it unlikely is unless we already downloaded the image once. Also
add some commenting to explain the code surrounding the assert a bit.

Fixes: #6188
2017-06-26 20:25:07 +02:00
Lennart Poettering 40f355052f sd-bus: use GetConnectionCredentials() when querying credentials, if available
Newer D-Bus versions implement the GetConnectionCredentials() driver
call to get all connection creds in one go. Make use of that to reduce
the number of bus calls we do.

When only a single credential field is queried we will still use the old
calls, which we'll also use if the new call isn't implemented.
2017-06-26 18:52:47 +02:00
Lennart Poettering 51c7d5aa36 sd-bus: when credentials of the "org.freedesktop.DBus" service are queried return the bus owner's credentials
The bus driver service is always implemented by the owner of the bus,
hence let's shortcut the credential operation and use our cached data.
This makes sure things simply work, given that dbus itself doesn't
support GetConnectionSELinuxSecurityContext() on the bus driver name
itself.

Fixes: #6120
2017-06-26 18:24:58 +02:00
Lennart Poettering 8d1dd6abe2 core: when parsing integers passed over the bus use int32_t, not int
sd-bus will return "i" integers as "int32_t", not "int". Now on all
archs we care about that's the same, but we still should do this
properly.
2017-06-26 17:43:18 +02:00
Lennart Poettering 7f452159b8 core: make IOSchedulingClass= and IOSchedulingPriority= settable for transient units
This patch is a bit more complex thant I hoped. In particular the single
IOScheduling= property exposed on the bus is split up into
IOSchedulingClass= and IOSchedulingPriority= (though compat is
retained). Otherwise the asymmetry between setting props and getting
them is a bit too nasty.

Fixes #5613
2017-06-26 17:43:18 +02:00
Susant Sahani bb79318e21 ethtool: warn when ethtool_set_glinksettings not supported
This is useful when port is not set and should be notified to user.
2017-06-26 21:05:52 +05:30
Lennart Poettering 8ecc68f430 systemctl: be truly quiet in systemctl -q is-enabled
Fixes: #6196
2017-06-26 16:11:20 +02:00
Franck Bui d31ae54818 swap: make use of IN_SET()
Minor cleanups, no functional changes.
2017-06-26 15:26:39 +02:00
Franck Bui cabf58b24f swap: make use of manager_get_unit() in swap.c
Minor cleanup, no functional changes.
2017-06-26 15:26:39 +02:00
Lennart Poettering 9efb9df9e3 core: make NotifyAccess= and FileDescriptorStoreMax= available to transient services
This is helpful for debugging/testing #5606.
2017-06-26 15:14:41 +02:00
Lennart Poettering 3ceb72e558 core: permit FDSTORE=1 messages with non-pollable fds
This also alters the documentation to recommend memfds rather than /run
for serializing state across reboots. That's because /run doesn't
actually have the same lifecycle as the fd store, as it is cleared out
on restarts.

Fixes: #5606
2017-06-26 15:14:41 +02:00
Susant Sahani 9c5e117239 ethtool: Fix speed in 593022fa37
We should use the DIV_ROUND_UP
2017-06-26 18:37:38 +05:30
Zbigniew Jędrzejewski-Szmek f900f5825d core: allow specifiers to be resolved in Environment= passed over dbus (#6144)
When specifiers are included in the Environment block in StartTransientUnit,
we resolve specifiers on the PID1 side. Nevertheless we store the unresolved
version in the transient unit file, so that it'll be resolved when loading
the unit. I think this looks nicer.

I also removed the writing of the merged Environment block to the transient
file. Afaict, this resulted in variables being written multiple times, but
this needs to be tested properly.

Fixes #5699.
2017-06-26 11:26:59 +02:00
Zbigniew Jędrzejewski-Szmek 92369d5eea Copy defines for renameat2 from casync (#6181) 2017-06-26 09:34:03 +02:00
Zbigniew Jędrzejewski-Szmek 2d2a815c90 core/loopback-setup: set a timeout for the kernel reply (#6187)
This shouldn't happen, but just in case for any reason the kernel
doesn't answer, it's probably much better to continue.

Follow-up for fb8939274a.
2017-06-26 09:33:37 +02:00
Susant Sahani 593022fa37 systemd-link: add support to configure the device port (#6153)
This work allows to configure device port:

tp — An Ethernet interface using Twisted-Pair cable as the medium.
aui — Attachment Unit Interface (AUI). Normally used with hubs.
bnc — An Ethernet interface using BNC connectors and co-axial cable.
mii — An Ethernet interface using a Media Independent Interface (MII).
fibre — An Ethernet interface using Optical Fibre as the medium.
2017-06-25 18:42:57 -04:00
Zbigniew Jędrzejewski-Szmek 7e867138f5 Merge pull request #5600 from fbuihuu/make-logind-restartable
Make logind restartable.
2017-06-24 18:58:36 -04:00
Evgeny Vereshchagin a4bdea5e31 Merge pull request #6185 from keszybz/env-serialization
Environment serialization fixes
2017-06-24 19:37:45 +03:00
Zbigniew Jędrzejewski-Szmek a096d8c88f tests: add tests for environment serialization 2017-06-23 20:46:33 -04:00
Zbigniew Jędrzejewski-Szmek 417eefb170 basic/env-util: when serializing, actually use escaping
Fixes #6152.
2017-06-23 20:46:33 -04:00
Zbigniew Jędrzejewski-Szmek d233c99ac8 manager: just warn about an invalid environment entry
Apart from bugs (as in #6152), this can happen if we ever make
our requirements for environment entries more stringent. As with
the rest of deserialization, we should just warn and continue.
2017-06-23 20:46:33 -04:00
Zbigniew Jędrzejewski-Szmek 62c460c6e2 manager: raise level of notices about failed deserialization
This is something that shouldn't happen. If it does, we want to
know about it.
2017-06-23 20:46:33 -04:00
Torstein Husebø 3561eafa92 core: fix typo (#6183) 2017-06-23 18:53:29 -04:00
Lennart Poettering fb8939274a loopback-setup: also add IP addresses to loopback devices
This changes loopback setup to not only start the loopback device but
also add the relevant IP addresses to it. This way, we can synchronously
wait until that's complete, and properly guarantee that loopback setup
is complete at the time we start our first processes.

This is a semi-revert of f3fc48150b, but
heavily updated.

Fixes: #5641
2017-06-23 12:07:03 +02:00
Lennart Poettering 3becdb8ac6 test: show debug log output during test-loopback 2017-06-23 12:06:58 +02:00
Lennart Poettering a877b1d9a7 Merge pull request #6151 from speakinghedge/6150-LLDP-messages-containing-padding-are-dropped
accept LLDP messages containing padding
2017-06-23 09:57:23 +02:00
hecke 8c7c7100b5 add note that explains relaxed bytes-left check #6150 2017-06-23 08:55:01 +02:00
Lennart Poettering a462478539 nspawn: make sure to send SIGTERM/SIGHUP to the main nspawn process if stubinit receives SIGRTMIN+3 (#6167)
This code already existed in some form, however commented. Remove the
comments, as this was most likely simply a forgotten commenting for
debugging purposes.

This also extends the logic a bit, by sending SIGHUP right after the
SIGTERM, so that shells will also terminate, when PID 1 gets a
SIGRTMIN+3.

Fixes: #5711
2017-06-22 22:20:09 -04:00
Zbigniew Jędrzejewski-Szmek 9fe4a3d98e Merge pull request #6176 from poettering/timer-boottime-monotonic
WakeSystem= and other timer fixes.
2017-06-22 21:34:39 -04:00
Zbigniew Jędrzejewski-Szmek 53ec2a3226 Merge pull request #6164 from poettering/bus-non-existant-object
sd-bus: don't treat requests for non-existent objects as connection errors
2017-06-22 20:56:59 -04:00
Lennart Poettering 00c83b4300 core: return a friendlier error for a dbus path referring to a non-existent unit
See: #6059
2017-06-22 20:54:54 -04:00
Michal Sekletar 05e33aa1d5 core: unset sysfs path after transition to dead state (#6174)
Device is gone and most likely it will get garbage collected. However in
cases when it doesn't get gc'ed (because it is referenced by some
other unit, e.g. mount from fstab) we need to unset sysfs. This is
because when device appears next time, possibly, with different sysfs
path we need to update the sysfs path. Current code could end up caching
stale sysfs path forever.

In reality this is not a problem for normal disks (unless you swap them
during system runtime). However this issue causes failures to mount
filesystems on LVM where sysfs path depends on activation
order (i.e. logical volumes from volume group that is activated first
get assigned lower dm-X numbers and corresponding syspaths).

Fixes #6126.
2017-06-22 20:29:15 -04:00
Michal Koutný b007626897 core: dbus: Interpret released names properly (#6175)
When a DBus name is released, NameOwnerChanged signal contains an empty string
as new_owner. Commit bbc2908 changed interpretation of the empty string to a
valid name, which is not consistent with values that are sent by dbus-daemon.

As a side effect, this masks symptoms of systemd-logind dbus disconnections
(#2925) by completely restarting it so it can freshly reconnect to dbus.
2017-06-22 20:26:04 -04:00
Lennart Poettering c4834ffaef tests: show current monotonic/boottime/realtime clock values in test-time
When debugging time issues its kinda handy to have an easy way to query
the three clocks, hence let's just output them at the beginning of
test-time.
2017-06-22 21:10:34 +02:00
Lennart Poettering c54be90b28 timer: make sure we use the right monotonic timestamp
This reworks timer_enter_waiting() in a couple of ways in order to clean
it up a bit and fix #5629.

Most importantly, we previously we initialized ts_monotonic to either
the current time in CLOCK_MONOTONIC or in CLOCK_BOOTTIME, depending on
t->wake_system. Then given specific conditions we'd use this time as
base for our timers. And afterwards, if t->wake_system was on we'd
convetr the resulting value from CLOCK_MONOTONIC to CLOCK_BOOTTIME again
— which of course is wrong since we already were in CLOCK_BOOTTIME! This
fixes this logic, by using a triple timestamp so that we always have the
right base around, and initially only calculate in CLOCK_MONOTONIC and
only convert as last step.

Conversion between the clocks is now done with the generic
usec_shift_clock(), and additions via usec_add() making these
calculations a bit safer.

Fixes: #5629
2017-06-22 21:04:20 +02:00
Lennart Poettering 79fc8b9623 timer: convert property_get_next_elapse_monotonic() to use usec_shift_clock()
Let's use the generic clock shifting logic here.
2017-06-22 20:59:48 +02:00
Lennart Poettering 1007ec60e6 time-util: add new call usec_shift_clock() for converting times between clocks
We use that quite often, let's implement one clean version of it.
2017-06-22 20:52:23 +02:00
Lennart Poettering 54d8ef14d8 time-util: rename usec_sub() to usec_sub_signed() and add usec_sub_unsigned()
Quite often we just want to subtract two normal usec_t values, hence
provide an implementation for that.
2017-06-22 20:51:06 +02:00
Lennart Poettering 7be1420f44 dissect: when dissecting block devices, ignore weird MMC RPMB partitions (#6165)
For now, let's just special-case this in the sources. If more partition
types like this show up we should probably find some other solution.

Fixes: #5806
2017-06-22 17:40:50 +02:00
Lennart Poettering cf2d0085ba Merge pull request #6170 from whot/master
Extend the joystick detection
2017-06-22 15:14:18 +02:00
Evgeny Vereshchagin 1741b25c72 log: pass the correct length to vsnprintf (#6168)
This prevents log_object_internalv from corrupting the stack.
Closes #6147.

Many thanks to Walter Doekes for the code review.
2017-06-21 21:10:29 -04:00
Peter Hutterer 2e856c63d4 udev: always consider devices with joystick axes/buttons as joystick
Even when they don't have an x/y axis.

https://github.com/systemd/systemd/issues/6137

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-22 09:19:53 +10:00
Peter Hutterer c874fed348 udev: consider a device with BTN_TRIGGER_HAPPY as joystick
These buttons were added specifically for joysticks with lots of buttons, no
other device should be using them. See kernel commit
cf2f765f18960 "HID: handle joysticks with large number of buttons"

We only test for BTN_TRIGGER_HAPPY (an alias for BTN_TRIGGER_HAPPY1) here, a
device that sets buttons 2 and above but doesn't set 1 is considered buggy.

https://github.com/systemd/systemd/issues/6137

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-22 09:19:25 +10:00
Lennart Poettering f2bfc6ba45 sd-bus: make sure propagate all errors with vtable callbacks back to clients
Previously we'd propagate errors returned by user callbacks configured
in vtables back to the users only for method handlers and property
get/set handlers. This does the same for child enumeration and when we
check whether a fallback unit exists.

Without this the failure will be treated as a non-recoverable connection
error and result in connection termination.

Fixes: #6059
2017-06-21 20:42:28 +02:00
tblume c9fb8c7c4a only check signature job error if signature job exists (#6118)
otherwise it will segfault when accessing signature jobs error status
2017-06-21 19:29:58 +02:00
Zbigniew Jędrzejewski-Szmek 4b57a27200 meson: add -pthreads and more libs when -Dlink-udev-shared=false (#6159)
Three binaries would fail to link when ld.bfd was used and link-udev-shared was
false. Add -pthreads (again) to the failing binaries and synchronize the
dependency list between libsystemd-shared .a and .so versions.
Apart from allowing the build to succeed, this shouldn't have much effect becuase
systemd-networkd was already using pthreads.

Fixes #5828.
2017-06-21 12:05:15 +02:00
Lennart Poettering 6c223c6719 Merge pull request #6113 from keszybz/shell-quoting
Use "dollar-single-quotes" to escape shell-sensitive strings
2017-06-20 20:17:03 +02:00
Zbigniew Jędrzejewski-Szmek 804ee07c13 Use "dollar-single-quotes" to escape shell-sensitive strings
Also called "ANSI-C Quoting" in info:(bash) ANSI-C Quoting.

The escaping rules are a POSIX proposal, and are described in
http://austingroupbugs.net/view.php?id=249. There's a lot of back-and-forth on
the details of escaping of control characters, but we'll be only using a small
subset of the syntax that is common to all proposals and is widely supported.
Unfortunately dash and fish and maybe some other shells do not support it (see
the man page patch for a list).

This allows environment variables to be safely exported using show-environment
and imported into the shell. Shells which do not support this syntax will have
to do something like
    export $(systemctl show-environment|grep -v '=\$')
or whatever is appropriate in their case. I think csh and fish do not support
the A=B syntax anyway, so the change is moot for them.

Fixes #5536.

v2:
- also escape newlines (which currently disallowed in shell values, so this
  doesn't really matter), and tabs (as $'\t'), and ! (as $'!'). This way quoted
  output can be included directly in both interactive and noninteractive bash.
2017-06-19 19:39:43 -04:00
hecke bc652b81f6 accept LLDP messages containing padding 2017-06-20 01:12:30 +02:00
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
Richard Maw 45a9eac9a0 networkd: Allow DHCP servers to be re-configured on carrier gain
In normal operation this would trigger an assertion
when a DHCP server is configured every time the link goes up.

This change makes sd_dhcp_server_configure_pool idempotent
and stops the DHCP server when the link loses carrier.

In addition to this stopping the assertion being triggered,
this has the useful side-effect of allowing the link to be taken down
and then brought back up as a way to have it use DNS from an "upstream"
interface that got its DNS configuration via DHCP
after the downstream link was configured.
2017-06-12 16:54:42 +01:00
Richard Maw c1835a427f networkd: Wait for link to get carrier before setting addresses
For containers the link is effectively always up,
but for virtual and physical machines networkd may have started
before the link has gained carrier.

Networkd will configure addresses when carrier is gained,
but should also configure addresses if the link is already up.
Without this patch the addresses are set unconditionally.

Normally this isn't a problem since addresses are either fixed,
set over DHCP, or is never without carrier.
But for machines that gain carrier and are configured to select
an address from the unallocated local address pool
this causes them to pick an address from the pool twice.

This change to skip address configuration when a link is added
before it has a carrier fixes having multiple addresses assigned
if the machine starts networkd before it has gained carrier
and is configured with an address from the pool.
2017-06-12 16:39:24 +01:00
Richard Maw 410a7f15f0 networkd: Clean up pool addresses on link down
When the link comes up it assigns addresses
by checking whether the address is 0.0.0.0,
and if so pulling a new address range out of the pool.

If the addresses aren't removed from the pool when the link goes down
then the set of addresses allocated will grow
until all the local address ranges are exhausted,
while it gets a different IP address every time.

This patch frees the addresses when link config is dropped
to fix the address leak,
and on systems which can expect all interfaces to be brought up or down
in a deterministic order this conveniently makes use the same address each time.
2017-06-12 16:20:49 +01:00
Franck Bui aed24c4cd7 logind: save/restore session devices and their respective file descriptors
This patch ensures that session devices are saved for each session.

In order to make the revokation logic work when logind is restarted, the
session devices are now saved in the session state files and their respective
file descriptors sent to PID1's fdstore in order to keep them open accross
restart.

This is mandatory in order to keep the revokation logic working. Indeed in case
of input-devices, the same file descriptors must be shared by logind and a
given session controller in order EVIOCREVOKE to work otherwise multiple
sessions can have device access in parallel.

This should be the only remaining and missing piece for making logind fully
restartable.

Fixes: #1163
2017-06-08 16:21:36 +02:00
Franck Bui dc6284e9ef logind: when setting a new controller, don't prepare the VT if logind is restarted
When assigning a new session controller to a session, the VT is prepared so the
controller can expect the VT to be in a good default state.

However when logind is restarted and a session controller already took control
of a session, there's no need to prepare th VT otherwise logind may screw up
the VT state set by the controller.

This patch prevents the preparation of the VT in this case.
2017-06-08 16:21:36 +02:00
Franck Bui 4c47affcf1 core: remove the redundancy of 'n_fds' and 'n_storage_fds' in ExecParameters struct
'n_fds' field in the ExecParameters structure was counting the total number of
file descriptors to be passed to a unit.

This counter also includes the number of passed socket fds which is counted by
'n_socket_fds' already.

This patch removes that redundancy by replacing 'n_fds' with
'n_storage_fds'. The new field only counts the fds passed via the storage store
mechanism.  That way each fd is counted at one place only.

Subsequently the patch makes sure to fix code that used 'n_fds' and also wanted
to iterate through all of them by explicitly adding 'n_socket_fds' + 'n_storage_fds'.

Suggested by Lennart.
2017-06-08 16:21:35 +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
Franck Bui 9b1419111a core: only apply NonBlocking= to fds passed via socket activation
Make sure to only apply the O_NONBLOCK flag to the fds passed via socket
activation.

Previously the flag was also applied to the fds which came from the fd store
but this was incorrect since services, after being restarted, expect that these
passed fds have their flags unchanged and can be reused as before.

The documentation was a bit unclear about this so clarify it.
2017-06-06 22:42:50 +02:00
Franck Bui fbcc7f4168 parse-util: introduce parse_dev() helper 2017-06-06 22:42:35 +02: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
Zbigniew Jędrzejewski-Szmek 93c9a9d235 vconsole-setup: skip setting fonts when setfont returns EX_OSERR
On a machine without a VGA console, /dev/tty{0,1,…} exist, so
systemd-vconsole-setup is started, but all setfont operations fail.

setfont has a bunch of return codes for different failure modes. It uses
EX_OSERR when the communication with the kernel using ioctls fails. This isn't
too specific, but at least it's only used this general class of errors. Let's
swallow the error in this case to avoid systemd-vconsole-setup.service failing
on cloud vms.

On a machine from https://bugzilla.redhat.com/show_bug.cgi?id=1272686#c4:
$ build/systemd-vconsole-setup
setfont: putfont: 512,8x16:  failed: -1
putfont: PIO_FONT: Invalid argument
/usr/bin/setfont failed with error code 71.
Setting fonts failed with a "system error", ignoring.

$ SYSTEMD_LOG_LEVEL=debug build/systemd-vconsole-setup
Found container virtualization none.
Sysfs UTF-8 flag enabled
UTF-8 kbdmode enabled on /dev/tty0
Executing "/usr/bin/setfont -C /dev/tty0 eurlatgr"...
setfont: putfont: 512,8x16:  failed: -1
putfont: PIO_FONT: Invalid argument
/usr/bin/setfont failed with error code 71.
Executing "/usr/bin/loadkeys -q -C /dev/tty0 -u us"...
/usr/bin/loadkeys succeeded.
Setting fonts failed with a "system error", ignoring.

$ lspci | grep -i vga

$ ls /dev/tty?
/dev/tty0  /dev/tty2  /dev/tty4  /dev/tty6  /dev/tty8
/dev/tty1  /dev/tty3  /dev/tty5  /dev/tty7  /dev/tty9

If we have a better test for /dev/tty? being connected to something that has a
font, we could avoid running setfont at all… ATM, I'm not aware of a simple
test like that.
2017-05-24 23:25:44 -04:00
Zbigniew Jędrzejewski-Szmek 3d62378088 vconsole-setup: add more log messages
This makes it quite a bit easier to see what failed.

strv_join is called inline in log_debug so that it is under the conditional
that kills the whole thing if debugging is disabled.
2017-05-24 23:25:10 -04:00
Michael Biebl 3745770ae4 timesyncd: don't use compiled-in list if FallbackNTP has been configured explicitly
Parse the config files first and only apply the compiled-in list of
fallback servers if no NTP server was configured via FallbackNTP.

Closes: #5091
2017-05-24 17:45:46 +02:00
Daniel Wang b23aec0d6b DHCP: Fail link_dhcp_set_routes promotely if no address is assigned from lease (#6009)
Currently the local variable `address` is unintialized if the DHCP lease
doesn't provide a router address (when r == -ENODATA). Thus the
subsequent call to route_scope_from_address will result in accessing an
unintialized variable.

As a matter of fact, sd-dhcp-client ignores DHCP leases without an
address so link_dhcp_set_routes probably will never be called without a
valid address.
2017-05-24 14:05:49 +02:00
Evgeny Vereshchagin a924f43f30 resolved: bugfix of null pointer p->question dereferencing (#6020)
See https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1621396
2017-05-24 08:56:48 +03:00
NeilBrown 2d79a0bbb9 Allow TimeoutSec=0 to work as documented in mount units and elsewhere (#6013)
Since commit 36c16a7cdd ("core: rework unit timeout handling, and add
new setting RuntimeMaxSec=") TimeoutSec=0 in mount units has
cause the mount to timeout immediately instead of never as documented.

There is a similar problem with Socket.TimeoutSec and Swap.TimeoutSec.

These are easily fixed using config_parse_sec_fix_0().

Automount.TimeoutIdleSec looks like it could have the same problem,
but doesn't because the kernel treats '0' as 'no timeout'.
It handle USEC_INFINITY correctly only because that constant has
the value '-1', and when round up, it becomes zero.
To avoid possible confusion, use config_parse_sec_fix_0() as well, and
explicitly handle USEC_INFINITY.
2017-05-23 09:42:26 +02:00
tomty89 e8a94ce83e nspawn: add nosuid and nodev to /tmp mount (#6004)
When automatic /tmp mount was introduced to nspawn in v219, it was done without having the nosuid and nodev mount options, which was the same case as systemd's default tmp.mount unit back then.

nosuid and nodev was added to tmp.mount(.m4) in v231 for security reasons. matching the nspawn /tmp mount entry against that.

Ref.:
2f9df7c96a
bbb99c30d0
2017-05-23 09:41:36 +02:00
sjoerd-ccu 764febc23e networkd-link: Receive LLDP on Bridge slaves not master (#5995)
LLDP should be received on bridge slaves as they're the entities
directly connected to a peer. Receiving LLDP on the bridge device makes
little sense, Linux by default even filters out LLDP going onto the
bridge device.

Flip the current logic, receive LLDP on bridge slaves don't listen for
them on the bridge itself.
2017-05-23 09:10:59 +02:00
Lennart Poettering 45f4238a1f load-dropin: propagate errors properly from unit_name_compatible() (#6002)
Let's log about this in the caller.

Doesn't really matter, but let's do something about my OCD, and
propagate errors properly, so that the caller can log about them.
2017-05-22 09:18:00 -04:00
Lennart Poettering 4dd53da97d sd-dhcp: library code shouldn't log above LOG_DEBUG (#6001)
Let's downgrade the warning introduced by
955d99edc7 to debug, as we really
shouldn't log at more than debug level from library code.

(And while we are at it, print the MTU as the right (unsigned) type in
the format string.)
2017-05-22 08:38:01 -04:00
Lennart Poettering 401a38e770 Merge pull request #5958 from keszybz/explicit-log-errno
Use explicit errno in log calls
2017-05-22 10:12:18 +02:00
Matthias Greiner 955d99edc7 Allow bad MTU values with warning to be able to connect to the machine. (#5954)
Ensure the MTU value is valid. Emit a warning and ignore otherwise.
2017-05-21 21:11:25 -04:00
Djalal Harouni 7a093ea246 Merge pull request #5990 from keszybz/logind
A bunch of sd-login improvements
2017-05-21 07:14:21 +02:00
Zbigniew Jędrzejewski-Szmek e450032f09 core/load-droping: avoid oom warning when the unit symlink is not a template
unit_name_template returns -EINVAL if the unit name is not a template, but
the code assumed that OOM is the only failure mode. Fix that to emit the warning
if a non-template unit is encountered (because in this case we expect the name
to match exactly), and just skip the warning on other errors (presumably oom).

Fixes #5543.
2017-05-20 19:34:50 -04:00
Evgeny Vereshchagin 4417e1a33d Merge pull request #5960 from keszybz/journald-memleak
Journald and journal-remote memleak fixes
2017-05-21 01:41:48 +03:00
Daniel Wang d6eac9bd06 DHCP: when adding static routes set scopes properly (#5982)
DHCP responses could include static routes, but unfortunately not an
option to tell what scope to use. So it's important that the client sets
it properly.

This mimics what the `ip route add` command does when adding a static
route without an explicit scope:

* If the destination IP is on the local host, use scope `host`
* Otherwise if the gateway IP is null (direct route), use scope `link`
* If anything else, use the current default `global`.

Fixes #5979.
2017-05-20 07:05:18 -04:00
Zbigniew Jędrzejewski-Szmek c6e9e16f77 journald: fix trivial memleak
Fixes #5516.
2017-05-19 19:15:26 -04:00
Zbigniew Jędrzejewski-Szmek 2da03cbf9d udev-rules: add helper function for logging
Avoid repeating the same conditional four times. Error messages are
capitalized.
2017-05-19 15:03:14 -04:00
Zbigniew Jędrzejewski-Szmek 9c0565b2c3 basic/time-util: make parsing of dual_timestamp more strict
*scanf functions set errno on i/o error. For sscanf, this doesn't really apply,
so (based on the man page), it seems that errno is unlikely to be ever set to a
useful value. So just ignore errno. The error message includes the string that
was parsed, so it should be always pretty clear why parsing failed.

On the other hand, detect trailing characters and minus prefix that weren't
converted properly. This matches what our safe_ato* functions do. Add tests to
elucidate various edge cases.
2017-05-19 15:01:20 -04:00
Zbigniew Jędrzejewski-Szmek bf32e38576 test-parse-util: verify that ato[ui] actually rejects trailing garbage 2017-05-19 14:37:48 -04:00
Zbigniew Jędrzejewski-Szmek 25f027c5ef tree-wide: when %m is used in log_*, always specify errno explicitly
All those uses were correct, but I think it's better to be explicit.
Using implicit errno is too error prone, and with this change we can require
(in the sense of a style guideline) that the code is always specified.

Helpful query: git grep -n -P 'log_[^s][a-z]+\(.*%m'
2017-05-19 14:24:03 -04:00
Lennart Poettering 07755554ab Merge pull request #5624 from glaubitz/x32
Fix multiple issues with incorrect usage of format specifiers
2017-05-19 19:17:57 +02:00
Zbigniew Jędrzejewski-Szmek 4b29a7f41f journald: process "binary" fields the same as text fields
MESSAGE=data\n and MESSAGE\n40000000data\n are both valid serializations, so
they should be stored in the journal. Before, MESSAGE, SYSLOG_FACILITY,
SYSLOG_IDENTIFIER, PRIORITY, and OBJECT_PID would be only honoured if they were
given in the first form.

Fixed #5973.
2017-05-19 13:02:57 -04:00
Zbigniew Jędrzejewski-Szmek 68944f196b journald: properly process multiple entries in the same native packet
For all except the last entry in a single packet, we would dispatch the
message to the journal, but not forward it, nor perform proper cleanup.
Rewrite the code to process each entry in a helper function, and make
server_process_native_message() just call this function in a loop.

Fixes #5643.

v2:
- properly decrement *remaining when processing entry separator
2017-05-19 13:02:17 -04:00
Zbigniew Jędrzejewski-Szmek 8924973ae2 shared/logs-show: avoid printing "(null)" when timestamp is not specified
$ perl -e 'print("MESSAGE\n", pack("q<", 1), "A\n\nMESSAGE=test2\n")' > message.bin
$ systemd-journal-remote -o /tmp/out.journal message.bin
$ journalctl -o export --file /tmp/out.journal
__CURSOR=s=b16c464c2db44384b29e75a564d8388e;i=1;b=6b0be47627bd4932913dc126012c21c0;m=0;t=0;x=b04263a253e357a
__REALTIME_TIMESTAMP=0
__MONOTONIC_TIMESTAMP=0
_BOOT_ID=6b0be47627bd4932913dc126012c21c0
MESSAGE=A

$ journalctl -o verbose --file /tmp/out.journal
(null) [s=b16c464c2db44384b29e75a564d8388e;i=1;b=6b0be47627bd4932913dc126012c21c0;m=0;t=0;x=b04263a253e357a]
    MESSAGE=A

This is changed to
$ build/journalctl -o verbose --file /tmp/out.journal
(no timestamp) [s=b16c464c2db44384b29e75a564d8388e;i=1;b=6b0be47627bd4932913dc126012c21c0;m=0;t=0;x=b04263a253e357a]
    MESSAGE=A

We should deal gracefully with unexpected input.
2017-05-19 11:40:56 -04:00
Zbigniew Jędrzejewski-Szmek 2ddb70d26f journal-remote: fix memleak of the name of the remote source 2017-05-19 11:40:56 -04:00
Zbigniew Jędrzejewski-Szmek 731e10f3c5 journald: use unaligned_read instead of memcpy 2017-05-19 11:40:53 -04:00
Alexey Brodkin 27b09f1f1e architecture: add Synopsys DesignWare ARC cores support (#5992)
DesignWare ARC Processors are a family of 32-bit CPUs from Synopsys
used extensively in SoCs of different vendors.
2017-05-19 10:55:24 -04:00
Matija Skala fe9938888b Fix includes (#5980)
Needed on musl.
2017-05-19 10:01:35 -04:00
Matija Skala 0060bb8f5b timesync/timesyncd-manager: fix format-specifier issue
timex::time::tv_sec can have different sizes depending on the
host architecture. On x32 in particular, it is 8 bytes
long while the long int type is only 4 bytes  long. Hence,
using li as a format specifier will trigger a format
error. Thus, better use PRI_TIME instead of li which is
actually the right format specifier to use for time_t.
2017-05-19 14:40:07 +02:00
Timothée Ravier ac9de0b379 core: open /proc/self/mountinfo early to allow mounts over /proc (#5985)
Enable masking the /proc folder using the 'InaccessiblePaths' unit
option.

This also slightly simplify mounts setup as the bind_remount_recursive
function will only open /proc/self/mountinfo once.

This is based on the suggestion at:
https://lists.freedesktop.org/archives/systemd-devel/2017-April/038634.html
2017-05-19 14:38:40 +02:00
Matija Skala 3bd7ef833c timesync/timesyncd-manager: fix format-specifier issues
timex::time::tv_usec and timex::freq can have different sizes
depending on the host architecture. On x32 in particular,
it is 8 bytes long while the long int type is only 4 bytes
long. Hence, using li as a format specifier will trigger
a format error. Thus, introduce a new format specifier
PRI_TIMEX which is defined as PRIi64 on x32 and li
everywhere else.
2017-05-19 14:38:25 +02:00
John Paul Adrian Glaubitz cc9211b030 udev/udevadm-monitor: fix format-specifier issue
timespec::tv_nsec can have different sizes depending on the
host architecture. On x32 in particular, it is 8 bytes long
while the long int type is only 4 bytes long. Hence, using
ld as a format specifier will trigger a format error. Thus,
explicitly cast timespec::tv_nsec to nsec_t and use PRI_NSEC
as the format specifier to make sure the sizes for both match.
2017-05-19 14:23:32 +02:00
John Paul Adrian Glaubitz b123d975ca journal/journald-console: fix format-specifier issue
timespec::tv_nsec can have different sizes depending on the
host architecture. On x32 in particular, it is 8 bytes long
while the long int type is only 4 bytes long. Hence, using
ld as a format specifier will trigger a format error. Thus,
explicitly cast timespec::tv_nsec to nsec_t and use PRI_NSEC
as the format specifier to make sure the sizes for both match.
2017-05-19 14:23:22 +02:00
Zbigniew Jędrzejewski-Szmek 0543105b0f sd-login: fix querying machines when machined is not running
We should not leak the internal error from missing directory and treat
that case the same as no machines.
2017-05-19 07:52:00 -04:00
Lennart Poettering b2d0c14214 Merge pull request #5598 from pfl/ndisc_prefix_delegation
Initial Router Advertisment implementation
2017-05-19 11:17:07 +02:00
Peter Hutterer 855cf359b2 udev: skip EVDEV_ABS override on devices without EV_ABS (#5984)
When we first handle a device with an EVDEV_ABS override, check if it has
EV_ABS bits. If not, print a warning and continue. This is required on devices
where the match string applies to multiple device nodes, not all of which may
have absolute axes.

Fixes https://github.com/systemd/systemd/issues/5079
2017-05-19 10:56:29 +02:00
Zbigniew Jędrzejewski-Szmek 171f8f591f sd-login,test-login: return -ENODATA from sd_pid_get_unit too
After all, we might be running on a non-systemd system.
2017-05-18 22:32:19 -04:00
Lennart Poettering 86a48fb6f7 udev: turn off -Wformat-nonliteral for one safe case
c20e6de897 introduced a format string as
variable, but didn't turn off -Wformat-nonliteral warnings on it, thus
breaking the build. Let's fix that, by simply turning off the warning in
this case, as we know it's safe.
2017-05-18 22:26:12 -04:00
Zbigniew Jędrzejewski-Szmek ce737f46cd test-login: make the test non-manual
test-login.c is largely rewritten to use _cleanup_ and give more meaningful
messages (function names are used instead of creative terms like "active
session", so that when something unexpected is returned, it's much easier to
see what function is responsible).

The monitoring part is only activated if '-m' is passed on the command line.

It runs against the information from /run/systemd/ in the live system, but that
should be OK: logind/sd-login interface is supposed to be stable and both
backwards and forwards compatible.

If not running in a login session, some tests are skipped.

Those two changes together mean that it's possible to run test-login in the
test suite.

Tests for sd_pid_get_{unit,user_unit,slice} are added.
2017-05-18 22:11:58 -04:00
Zbigniew Jędrzejewski-Szmek d440fb97ba sd-login: fix return value of sd_pid_get_user_unit
E.g. "/user.slice/user-1000.slice/session-15.scope" would cause -ENXIO to be
returned.
2017-05-18 22:11:58 -04:00
Zbigniew Jędrzejewski-Szmek 19d64d10c0 sd-login: fix return value of sd_pid_get_session
We'd return -ENXIO, even thoug -ENODATA is documented.
2017-05-18 21:59:59 -04:00
Zbigniew Jędrzejewski-Szmek cc6182e854 sd-login: always return two arrays of same length from sd_seat_get_sessions
sd_seat_get_sessions returns two arrays, that in principle should always match:
the session names and corresponding uids. The second array could be shorter only
if parsing or uid conversion fails. But in that case there is no way to tell
*which* uid is wrong, so they are *all* useless. It's better to simplify things and
just return an error if parsing fails.
2017-05-18 21:59:09 -04:00
Zbigniew Jędrzejewski-Szmek d3cfab3148 sd-login: read list of uids of sessions from UIDS not ACTIVE_SESSIONS
As described by Luke Shumaker:

  sd_seat_get_sessions looks at /run/systemd/seats/${seat_name}:SESSIONS to get
  the list of sessions (which I believe is correct), and at
  /run/systemd/seats/${seat_name}:ACTIVE_SESSIONS for the list of users (which
  I believe is incorrect); I believe that it should look at the UIDS field for
  the list of users. As far as I can tell, the ACTIVE_SESSIONS field is never
  even present in the seats file. I also believe that this has been broken
  since the function was first committed almost 6 years ago.

Fixes #5743.
2017-05-18 21:37:41 -04:00
Susant Sahani cb4d8b2d05 sd-netlink: Make use of IN_SET (#5977) 2017-05-18 12:56:36 +02:00
Lennart Poettering f731ad4456 Merge pull request #5957 from keszybz/test-c++
Test compilation under C++
2017-05-17 17:02:55 +02:00
Dimitri John Ledkov c20e6de897 udev: net_id add support for platform bus (ACPI, mostly arm64) devices (#5933)
Fixes: #5894
2017-05-17 15:28:35 +02:00
Zbigniew Jędrzejewski-Szmek d80e5b74e8 calendarspec: parse unix timestamps (@...) (#5947)
Fixes #5810.
2017-05-17 11:40:49 +02:00
Lennart Poettering a8b7e8a742 Merge pull request #5883 from garyttierney/fix-selinux
selinux: enable labeling and access checks for unprivileged users
2017-05-17 11:39:44 +02:00
Yu Watanabe 8ff213fd65 meson: do not use generate_gperfs.py for keyboard-keys-from-name.gperf (#5968)
Fixes #5967.
2017-05-15 20:51:22 -04:00
Zbigniew Jędrzejewski-Szmek 4a24ba71a3 meson: add rules for RA sources 2017-05-15 14:49:50 +03:00
Patrik Flykt 24852172b9 test-ndisc-ra: Add Router Advertisement test cases
Add tests for prefix creation, router variable setting and finally
verify that a Router Advertisement is properly formatted when sending.
Also check that there is a Router Advertisment with zero lifetime
when Router Advertisement sending is stopped.
2017-05-15 14:49:50 +03:00
Patrik Flykt 88d5a3db55 sd-radv: Receive Router Solicitations
Receive Router Solicitations and send a unicast Router Advertisment
in response. Refactor ICMPv6 packet handling code so that the common
ICMPv6 validation parts are reused between the existing router
discovery and the new functionality adding reception of Router
Solicitation messages.
2017-05-15 14:49:50 +03:00
Patrik Flykt 77baf5aee6 sd-radv: Send Router Advertisments
Create and remove the ICMPv6 Router Advertisement socket file
descriptor and implement Router Advertisment sending. As not
all options are mandatory, use IO vectors to point to the included
options and the prefix information.
2017-05-15 14:49:50 +03:00
Patrik Flykt e2e8122838 icmp6-util: Move multicast address definitions
As the Router Advertisment sending code needs these multicast
address definitions, move them to the header file.
2017-05-15 14:49:50 +03:00
Patrik Flykt 6142bb37a5 icmp6-util: Bind Router Advertisement socket
Reuse and refactor the functionality already present for Router
Solicitations in order to create a socket for sending Router
Advertisements. Anticipate reception of incoming Router
Solicitations by setting the ICMPv6 filter accordingly. Also set
the unicast hop limit to 255 for ICMPv6 sockets as unicast Router
Advertisments are to be sent in response to Router Solicitations.

Update the Router Solicitation test case code with a function
definition in order to keep the test case working.
2017-05-15 14:49:50 +03:00
Patrik Flykt 204fb681f6 sd-radv: Implement Router Advertisement timeout handling
Router Advertisements are sent uniformly distributed between a
minimum and maximum time according to RFC 4861, Section 6.2.4.
Default values from RFC 4861 are for now used as minimum and
maximum Router Advertisement timeouts.

When stopping, a Router Advertisement with a router lifetime set
to zero is sent in order to inform any nodes that the interface
on this host no longer is a router.
2017-05-15 14:49:50 +03:00
Patrik Flykt 7465dd22ad networkd-link.c: Add Router Advertisement starting and stopping
Start and stop Router Advertisement sending once the link has acquired
a link-local IPv6 address.
2017-05-15 14:49:50 +03:00
Patrik Flykt 091214b636 networkd-radv: Helper function for Router Advertisement initialization
Add a helper function for configuring Router Advertisement on a
specific network link. Add the prefixes that are going to be advertised.
2017-05-15 14:49:50 +03:00
Patrik Flykt 204f99d21e sd-radv: Add Router Advertisement functionality
Add Router Advertisement header files, data structures and core
functionality that is quite similar to other parts of networkd.
2017-05-15 14:49:50 +03:00
Patrik Flykt 7d5cac19b5 networkd: Add Router Advertisement variables
Add variables for enabling Router Advertisements, router lifetime as
well as managed and other information flags indicating use of DHCPv6.
Add configuration of default router preferences as defined in RFC 4191.

IPv6PrefixDelegation in the [Network] section has to be set in order
to enable prefix delegation. The rest of the prefix delegation values
are stored in the [IPv6PrefixDelegation] section. The host will act as
a default router if it is given a non-zero lifetime with
RouterLifetimeSec. Managed and OtherInformation booleans set the level
of DHCPv6 support, and the RouterPreference configures the router's
preference between low, medium and high. Words 'normal' and 'default'
are added as synonyms for 'medium' just to make configuration simpler.

This adds a section like the following to .network configuration files:
[Network]
IPv6PrefixDelegation=true

[IPv6PrefixDelegation]
RouterLifetimeSec=2000
Managed=false
OtherInformation=true
RouterPreference=medium
2017-05-15 14:49:50 +03:00
Patrik Flykt 9d5d0090ca networkd: Add IPv6Prefix sections to the network configuration files
Support zero or more [IPv6Prefix] sections in the network configuration
files. Each section can have one Prefix=<subnet>[/<prefixlength>]
option, with the preferred and valid lifetimes specified by
ValidLifetimeSec and PreferredLifetimeSec measured in seconds, and
with onlink and address autoconfiguration booleans specified by
OnLink and AddressAutoconfiguration variables.

This adds a section like the following to .network configuration files:
[IPv6Prefix]
Prefix=2001:db8:dead:beef::/64
OnLink=true
AddressAutoconfiguration=true
ValidLifetimeSec=1500
PreferredLifetimeSec=1000
2017-05-15 14:49:50 +03:00
Patrik Flykt 057abfd88a networkd: Add initial prefix handling for network configuration
Add initial code for handling prefixes in network configuration files.
Add hash map and list storing the information in systemd-networkd.
2017-05-15 14:49:50 +03:00
Patrik Flykt 04473969ef sd-radv: Add Router Advertisement prefix handling
Define Router Advertisement prefix structure. Add the Prefix
Information ICMPv6 option defined in RFC 4861 to the prefix
information structure, as it will simplify sending a Prefix
Information option later on. In order to handle endianness
correctly, the structure is redefined here instead of using
the one in netinet/icmp6.h.

Add functions to create and modify prefix information and set
default values as defined in RFC 4861, Section 6.2.1.
2017-05-15 14:49:50 +03:00
Zbigniew Jędrzejewski-Szmek 0f771be9ca test-bus-vtable: add SD_BUS_PROPERTY
Without cc9daff228, this results in:

src/libsystemd/sd-bus/test-bus-vtable-cc.cc:56:1: sorry, unimplemented: non-trivial designated initializers not supported
 };
 ^
2017-05-14 15:10:44 -04:00
Zbigniew Jędrzejewski-Szmek 5502d46f73 Merge pull request #5961 from ronnychevalier/rc/conf-parser-strv-typo
conf-parser: fix wrong argument given to log_syntax_invalid_utf8
2017-05-14 10:31:12 -04:00
Ronny Chevalier 16eefcafed env-util: fix memory leak (#5962)
If cunescape succeeds, but the assignment is not valid, uce is not freed.
2017-05-14 10:30:40 -04:00
Ronny Chevalier d5ade2d602 test-conf-parser: add valid and invalid utf8 test for config_parse_path 2017-05-14 13:19:11 +02:00
Ronny Chevalier b4958f42af conf-parser: fix wrong argument given to log_syntax_invalid_utf8
The condition is on "word", hence we give word instead of rvalue.

An assert would be triggered if !utf8_is_valid(word) is true and
rvalue == NULL, since log_syntax_invalid_utf8 calls utf8_escape_invalid
which calls assert(str).

A test case has been added to test with valid and invalid utf8.
2017-05-14 13:19:11 +02:00
Zbigniew Jędrzejewski-Szmek 94e2523b70 tests,meson: add test-bus-vtable, compiled as C and C++
This test is mostly a compilation test that checks that various defines in
sd-bus-vtable.h are valid C++. The code is executed, but the results are not
checked (apart from sd-bus functions not returning an error). test-bus-objects
contains pretty extensive tests for this functionality.

The C++ version is only added to meson, since it's simpler there.
Because of the .cc extension, meson will compile the executable with c++.

This test is necessary to properly check the macros in sd-bus-vtable.h. Just
running the headers through g++ is not enough, because the macros are not
exercised.

Follow-up for #5941.
2017-05-13 15:50:44 -04:00
Zbigniew Jędrzejewski-Szmek 3bf47e7392 test-ipv4ll: use assert_se consistently
We use assert_se in tests so that the asserts get evaluated even if compiled with NDEBUG.
2017-05-13 15:45:29 -04:00
Zbigniew Jędrzejewski-Szmek afc5fc1ffa tree-wide: drop assert.h includes
We provide an independent reimplementation in macro.h, and that's the one
we want to use. Including the system header is unnecessary and confusing.
2017-05-13 15:44:30 -04:00
Zbigniew Jędrzejewski-Szmek d7f149c1aa tests: make sure that our headers are valid c++
This adds a meson test because it fits nicely into the existing framework.
It should be enough to run this test once in a while, so I don't think it's
crucial to also have it under autotools.
2017-05-13 15:43:39 -04:00
Zbigniew Jędrzejewski-Szmek 35bca925f9 tree-wide: fix incorrect uses of %m
In those cases errno was not set, so we would be logging some unrelated error
or "Success".
2017-05-13 15:42:26 -04:00
Daniel Wang b85bc551c3 network: Implement DHCP Option 119 (Domain Search List) (#5932)
This adds a modified version of dhcp6_option_parse_domainname() that is
able to parse compressed domain names, borrowing the idea from
dns_packet_read_name(). It also adds pieces in networkd-link and
networkd-manager to properly save/load the added option field.

Resolves #2710.
2017-05-13 10:19:32 -04:00
Gary Tierney b3fb3c01ee audit-fd: check for CAP_AUDIT_WRITE before opening an audit socket
Adds a check to audit-fd.c to ensure that CAP_AUDIT_WRITE is present in
the set of effective capabilities before opening an audit netlink
socket.  This ensures that unprivileged systemd instances (MANAGER_USER)
don't try to log AVC permission checks with the audit subsystem when
CAP_AUDIT_WRITE is not present.
2017-05-12 14:43:39 +01:00
Gary Tierney 6d395665e5 Revert "selinux: split up mac_selinux_have() from mac_selinux_use()"
This reverts commit 6355e75610.

The previously mentioned commit inadvertently broke a lot of SELinux related
functionality for both unprivileged users and systemd instances running as
MANAGER_USER.  In particular, setting the correct SELinux context after a User=
directive is used would fail to work since we attempt to set the security
context after changing UID.  Additionally, it causes activated socket units to
be mislabeled for systemd --user processes since setsockcreatecon() would never
be called.

Reverting this fixes the issues with labeling outlined above, and reinstates
SELinux access checks on unprivileged user services.
2017-05-12 14:43:39 +01:00
Lennart Poettering 6e4177315f Merge pull request #5432 from keszybz/udev-logging
udev logging separation
2017-05-12 15:22:46 +02:00
Zbigniew Jędrzejewski-Szmek 5486a31d28 nss-resolve: drop the internal fallback to libnss_dns (#5945)
If we could not communicate with systemd-resolved, we would call into
libnss_dns. libnss_dns would return NOTFOUND for stuff like "localhost" and
other names resolved by nss-myhostname, which we would fall under the !UNAVAIL=
condition and cause resolution to fail. So the following recommended
configuration in nsswitch.conf would not work:

   hosts: resolve [!UNAVAIL=return] dns myhostname

Remove the internal fallback code completely so that the fallback logic
can be configured in nsswitch.conf.

Tested with
   hosts: resolve [!UNAVAIL=return] myhostname
and
   hosts: resolve [!UNAVAIL=return] dns myhostname

Fixes #5742.
2017-05-12 14:31:46 +02:00
Lennart Poettering 3823da25cf Merge pull request #5928 from keszybz/libidn2
Use idn2 instead of idn
2017-05-12 12:01:40 +02:00
Lennart Poettering 2cfafe4d03 Merge pull request #5942 from keszybz/timestamp-writing
Allow timestamp to be set by the file writing utility functions
2017-05-12 12:00:24 +02:00
Lennart Poettering 77f0f0a5c7 Merge pull request #5946 from evverx/test-sigbus-fixes
test-sigbus: use posix_fallocate rather than fallocate
2017-05-12 11:58:13 +02:00
Zbigniew Jędrzejewski-Szmek ca3bad6504 networkd: remove unused variables (#5948)
Fixup for 36423ff433.
2017-05-12 04:53:12 +03:00
Matthijs van Duin cc9daff228 sd-bus: fix c++ compatibility (#5941)
g++ annoyingly requires a non-empty struct-initializer to initialize all
struct members, in order of declaration.

Signed-off-by: Matthijs van Duin <matthijsvanduin@gmail.com>
2017-05-11 18:55:26 -04:00
Zbigniew Jędrzejewski-Szmek fc1b2dc395 Merge pull request #5936 from ssahani/net-route
networkd: route replace parse prefix with generic in_addr_prefix_from_string
2017-05-11 18:53:35 -04:00
Lars Karlitski 5f42943c35 journalctl: honor --show-cursor in more sitatuations
Try to honor --show-cursor in more situations by never terminating early
when we didn't read any logs.

In particular, sd_journal_previous_skip() now returns 0 when it didn't
actually skip anything (for example with --lines=0), which resulted in
--show-cursor not working anymore.
2017-05-11 22:49:20 +02:00
Lars Karlitski 0488435496 journal: return 0 from _skip() when it didn't skip
Seeking to the tail and calling `sd_journal_previous_skip(journal, 0)`
was equivalent to calling it with skip == 1 (same for head and next()).
2017-05-11 22:49:20 +02:00
Zbigniew Jędrzejewski-Szmek 87057e244b resolved: support libidn2 in addition to libidn
libidn2 2.0.0 supports IDNA2008, in contrast to libidn which supports IDNA2003.

https://bugzilla.redhat.com/show_bug.cgi?id=1449145
From that bug report:

Internationalized domain names exist for quite some time (IDNA2003), although
the protocols describing them have evolved in an incompatible way (IDNA2008).
These incompatibilities will prevent applications written for IDNA2003 to
access certain problematic domain names defined with IDNA2008, e.g., faß.de is
translated to domain xn--fa-hia.de with IDNA2008, while in IDNA2003 it is
translated to fass.de domain. That not only causes incompatibility problems,
but may be used as an attack vector to redirect users to different web sites.

v2:
- keep libidn support
- require libidn2 >= 2.0.0
v3:
- keep dns_name_apply_idna caller dumb, and keep the #ifdefs inside of the
  function.
- use both ±IDN and ±IDN2 in the version string
2017-05-11 14:25:01 -04:00
Zbigniew Jędrzejewski-Szmek d84ed2bd13 networkd: pretiffy message about invalid prefix
We know how the field we are parsing is called, let's put this information in
the error message:
"Route Source= prefix is invalid, ignoring assignment: ..."
"Route Destination= prefix is invalid, ignoring assignment: ..."
2017-05-11 14:01:14 -04:00
Zbigniew Jędrzejewski-Szmek 872c403963 update-done: use newly added library function to write the file
Fixes #5861.
2017-05-11 13:43:53 -04:00
Lennart Poettering 271312e37b Merge pull request #5893 from keszybz/memorydenywriteexecute
Add support for more arches for MemoryDenyWriteExecute
2017-05-11 19:42:42 +02:00
Zbigniew Jędrzejewski-Szmek c826cd3f7c pid1: improve logging when failing to remount / ro (#5940)
https://bugzilla.redhat.com/show_bug.cgi?id=1227736#c49

We counted how many filesystems could not be unmounted, but only for those
filesystems which we tried to unmount. Since we only remount / ro, without
attempting to unmount, we would emit a confusing error message:

Remounting '/' read-only with options 'seclabel,space_cache,subvolid=5,subvol=/'.
Remounting '/' read-only with options 'seclabel,space_cache,subvolid=5,subvol=/'.
Remounting '/' read-only with options 'seclabel,space_cache,subvolid=5,subvol=/'.
All filesystems unmounted.

Warn when remount-ro fails, and for filesystems which we won't try to unmount,
include the failure to remount-ro in n_failed.

A few minor cleanups:
- remove unecessary goto which jumps to the next line anyway
- always calculate n_failed, even if log_error is false. This causes no change
  in behaviour, but I think the code is easier to follow, since the log setting
  cannot influence other logic.
2017-05-11 18:12:41 +02:00
Zbigniew Jędrzejewski-Szmek 39c38d773f basic/fileio: extend atomic file writing with timestamp setting
There should be no functional change.
2017-05-11 10:23:36 -04:00
Tom Gundersen f5938e8ff3 busctl: monitor - only start printing messages once we have become a monitor (#5931)
A connection becomes a monitor the moment it loses its unique name, so any
messages received before that should not be dumped to the console.

Currently, we print NameAcquired and NameLost for the unique name of the
peer that becomes the monitor, simply discard all messages until we
receive our NameLost signal.
2017-05-11 15:56:55 +02:00
Zbigniew Jędrzejewski-Szmek 52511fae7b core: fix warning about unsigned variable (#5935)
Fixup for d8c92e8bc7.
2017-05-11 08:15:28 +02:00
Susant Sahani 36423ff433 networkd: route replace parse prefix with generic in_addr_prefix_from_string 2017-05-11 10:12:54 +05:30
Peter Hutterer 61b2f1976c udev: don't allow pointing stick sensitivities greater than 255 (#5927)
It gets truncated, so the result is that people mess with the const accel
because the sensitivity isn't the expected 300 but the too-low 45.

One example: https://bugs.freedesktop.org/show_bug.cgi?id=100965
2017-05-10 21:22:00 +02:00
Lennart Poettering 554a080674 Merge pull request #5920 from fbuihuu/sysusers-disable-gshadow
Sysusers disable group shadow support
2017-05-10 19:46:13 +02:00
Zbigniew Jędrzejewski-Szmek da1921a5c3 seccomp: enable RestrictAddressFamilies on ppc64, autodetect SECCOMP_RESTRICT_ADDRESS_FAMILIES_BROKEN
We expect that if socket() syscall is available, seccomp works for that
architecture.  So instead of explicitly listing all architectures where we know
it is not available, just assume it is broken if the number is not defined.
This should have the same effect, except that other architectures where it is
also broken will pass tests without further changes. (Architectures where the
filter should work, but does not work because of missing entries in
seccomp-util.c, will still fail.)

i386, s390, s390x are the exception — setting the filter fails, even though
socket() is available, so it needs to be special-cased
(https://github.com/systemd/systemd/issues/5215#issuecomment-277241488).

This remove the last define in seccomp-util.h that was only used in test-seccomp.c. Porting
the seccomp filter to new architectures should be simpler because now only two places need
to be modified.

RestrictAddressFamilies seems to work on ppc64[bl]e, so enable it (the tests pass).
2017-05-10 09:21:16 -04:00
Franck Bui 1dd98a71e5 sysusers: make use of cleanup(unlink_and_freep) in write_files() and its auxiliary helpers
No functional changes.
2017-05-10 14:29:21 +02:00
Anchor Cat e7d54bf587 automount: ack automount requests even when already mounted (#5916)
If a process accesses an autofs filesystem while systemd is in the
middle of starting the mount unit on top of it, it is possible for the
autofs_ptype_missing_direct request from the kernel to be received after
the mount unit has been fully started:

  systemd forks and execs mount             ...
            ...                     access autofs, blocks
  mount exits                               ...
  systemd receives SIGCHLD                  ...
            ...                     kernel sends request
  systemd receives request                  ...

systemd needs to respond to this request, otherwise the kernel will
continue to block access to the mount point.
2017-05-10 13:23:58 +02:00
Evgeny Vereshchagin af02b15a9d test-sigbus: skip the test under valgrind 2017-05-10 11:05:57 +00:00
Evgeny Vereshchagin aab7037de4 test-sigbus: use posix_fallocate rather than fallocate
Some filesystems do not support fallocate, so we need to fall back on
something like posix_fallocate.

Closes #5833
2017-05-10 08:47:39 +00:00
Franck Bui b14e1b4394 sysusers: make group shadow support configurable
Some distros (openSUSE) don't have group shadow support enabled. This can lead
to the following error:

  # systemd-sysusers
  Creating group foofoo with gid 478.
  # systemd-sysusers
  # groupdel foofoo
  # systemd-sysusers
  Creating group foofoo with gid 478.
  Failed to write files: File exists

This patch adds --disable-gshadow option to configure. If used,
systemd-sysvusers won't consider /etc/gshadow.
2017-05-10 10:19:37 +02:00
Franck Bui b20b0b6606 sysusers: split make_files()
This patch extracts the code which is in charge to write the new users or
groups into temporary files and move it into 4 dedicated functions.

This part was previously inlined in makes_files() making this function quite
big and hard to read and maintain.

There should be no functional change.
2017-05-10 10:06:20 +02:00
Max Resch b2bb40ce9a sd-boot: added shim signature/MOK validation (#5702)
Adds support for booting in a SecureBoot environment with shim as a
preloader. Install an appropriate UEFI security policy to check PE
signature of a chained kernel or UEFI application (using LoadImage())
against the MOK database maintained by shim, using shim's installed
BootServices.

Implementation details for installing the security policy are based on
code from the LinuxFoundation's SecureBoot PreLoader, part of efitools
licensed under LGPL 2.1

Current signed (by Microsoft) versions of shim (Versions 0.8 & 0.9)
so not install a security policy by themselves, future Versions of
shim might (a compile time switch exists in rectent git versions),
so in the future this PR might become unnecessary.
2017-05-09 20:57:40 +02:00
Lennart Poettering 7ce63d7c9b Merge pull request #5619 from fbuihuu/fully-restore-unit-cgroup-state
core: when deserializing a unit, fully restore its cgroup state
2017-05-09 20:49:17 +02:00
Lennart Poettering 4e168f4606 Merge pull request #5420 from OpenDZ/tixxdz/namespace-fixes-v2
Namespace: RootImage= RootDirectory= and MountAPIVFS fixes
2017-05-09 20:42:32 +02:00
Susant Sahani 6c1ff21b00 network: add support for vlan confs(MVRP, reorder header, loose binding) (#5834) 2017-05-09 20:25:11 +02:00
Hristo Venev 465dfe59fc networkd: add IPv6ProxyNDP (#5913)
This allows enabling proxy_ndp even if no addresses are configured in
networkd, as well as disabling proxy_ndp from a drop-in.
2017-05-09 20:04:55 +02:00
Susant Sahani c83ecc04d9 networkd: add support to configure route protocol. (#5890)
Closes: #5889
2017-05-09 20:01:25 +02:00
John Paul Adrian Glaubitz eb8124f6d5 meson: Add missing dependency on libkmod for libudev_core 2017-05-09 13:13:49 +02:00
John Paul Adrian Glaubitz 849c09c4dd meson: Add missing dependency on libseccomp for libcore 2017-05-09 13:13:43 +02:00
Aggelos Avgerinos 488ab41cb8 execute: Properly log errors considering socket fds (#5910)
Till now if the params->n_fds was 0, systemd was logging that there were
more than one sockets.

Thanks @gregoryp and @VFXcode who did the most work debugging this.
2017-05-08 19:09:22 -04:00
Zbigniew Jędrzejewski-Szmek 3cf3392364 udev/collect: remove now-unused struct udev 2017-05-07 22:49:12 -04:00
Zbigniew Jędrzejewski-Szmek b237a168df Rip out setting of the log level from udev_new and put it in a new function
This function is internal to systemd code, so external users of libudev
will not see those log messages. I think this is better. If we want to
allow that, the function could be put in libudev and exported.

v2: check that the string is more than one char before stripping quotes
2017-05-07 22:49:12 -04:00
Zbigniew Jędrzejewski-Szmek 5c72049f91 udev: use LOG_REALM_UDEV in all udev code
Any call to set/query/use the log level in the code with LOG_REALM=LOG_REALM_UDEV
refers to log_max_level[1]. In particular this means that systemd code using
the libudev library uses does not set the log level for log calls done in libudev.

Fixes #4525.

v2:
- also update meson's meson.build
2017-05-07 22:49:12 -04:00
Zbigniew Jędrzejewski-Szmek ff524019ef basic/log: split max log level into multiple "realms"
The single log level is split into an array of log levels. Which index in the
array is used can be determined for each compilation unit separately by setting
a macro before including log.h. All compilation units use the same index
(LOG_REALM_SYSTEMD), so there should be no functional change.

v2:
- the "realm" is squished into the level (upper bits that are not used by
  priority or facility), and unsquished later in functions in log.c.

v3:
- rename REALM_PLUS_LEVEL to LOG_REALM_PLUS_LEVEL and REALM to LOG_REALM_REMOVE_LEVEL.
2017-05-07 22:48:24 -04:00