Commit Graph

33876 Commits

Author SHA1 Message Date
Lennart Poettering 4055a62faf
Merge pull request #9176 from keszybz/flags-set
Macro to check if flags are set
2018-06-04 13:45:29 +02:00
Lennart Poettering b5b74e4b12
Merge pull request #9167 from keszybz/ellipsization
Ellipsization fixes based on unit-testing and fuzzing
2018-06-04 13:45:03 +02:00
Lennart Poettering 0be9b12be2
Merge pull request #9147 from keszybz/runtime-enablement
Runtime enablement
2018-06-04 11:58:21 +02:00
Zbigniew Jędrzejewski-Szmek 5c270a18da basic/path-util: use FLAGS_SET in one more place 2018-06-04 11:50:44 +02:00
Zbigniew Jędrzejewski-Szmek d94a24ca2e Add macro for checking if some flags are set
This way we don't need to repeat the argument twice.
I didn't replace all instances. I think it's better to leave out:
- asserts
- comparisons like x & y == x, which are mathematically equivalent, but
  here we aren't checking if flags are set, but if the argument fits in the
  flags.
2018-06-04 11:50:44 +02:00
Zbigniew Jędrzejewski-Szmek 00bfe67f6b coccinelle: add option to make changes in place 2018-06-04 11:48:52 +02:00
Zbigniew Jędrzejewski-Szmek 31d31f2021 coccinelle: run spatch just on version-controlled files
Also, allow run-cocinnelle.sh to be started from any directory.

Unfortunately set -x does not work nicely anymore, because the list is
too verbose. Replace it by an echo line.
2018-06-04 11:48:50 +02:00
Lennart Poettering ec5b1452ac core: go to failure state if the main service process fails and RemainAfterExit=yes (#9159)
Previously, we'd not care about failures that were seen earlier and
remain in "exited" state. This could be triggered if the main process of
a service failed while ExecStartPost= was still running, as in that case
we'd not immediately act on the main process failure because we needed
to wait for ExecStartPost= to finish, before acting on it.

Fixes: #8929
2018-06-04 11:35:25 +02:00
Alan Jenkins 8150acb160 login: log session state "closing" (as well as New/Removed)
Let's show a message at the time of logout i.e. entering the "closing"
state, not just e.g. once the user closes `tmux` and the session can be
removed completely.  (At least when KillUserProcesses=no applies.  My
thinking was we can spare the log noise if we're killing the processes
anyway).

These are two independent events.  I think the logout event is quite
significant in the session lifecycle.  It will be easier for a user who
does not know logind details to understand why "Removed session" doesn't
appear at logout time, if we have a specific message we can show at this
time :).

Tested using tmux and KillUserProcesses=no.  I can also confirm the extra
message doesn't show when using KillUserProcesses=yes.  Maybe it looks a
bit mysterious when you use KillOnlyUsers= / KillExcludeUsers=, but
hopefully not alarmingly so.


I was looking at systemd-logind messages on my system, because I can
reproduce two separate problems with Gnome on Fedora 28 where
sessions are unexpectedly in state "closing".  (One where a GUI session
limps along in a degraded state[1], and another where spice-vdagent is left
alive after logout, keeping the session around[2]).  It logged when
sessions were created and removed, but it didn't log when the session
entered the "closing" state.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1583240#c1
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1583261

Closes #9096
2018-06-04 11:31:11 +02:00
Zbigniew Jędrzejewski-Szmek 2a13fafd89
Merge pull request #9173 from jwrdegoede/hwdb-sensors3
Hwdb sensors3
2018-06-04 11:02:25 +02:00
Zbigniew Jędrzejewski-Szmek cb747347ac
Merge pull request #9149 from yuwata/fix-9107
path-util: introduce path_simplify()
2018-06-04 10:13:40 +02:00
Yu Watanabe a6dffbb7e7 test: fix function name 2018-06-04 09:33:45 +02:00
Yu Watanabe d3c8afd092 man: RuntimeDirectory= or friends accept dot contained paths 2018-06-04 01:44:04 +09:00
Yu Watanabe f106314c89 conf-parser: remove redundant utf8-validity check 2018-06-04 01:38:54 +09:00
Yu Watanabe 97b9c506cf conf-parse: use free_and_replace()
Also removes unnecessary empty lines.
2018-06-04 00:30:42 +09:00
Yu Watanabe 78d17fa099 conf-parser: reject utf8-invalid lines 2018-06-04 00:30:18 +09:00
Yu Watanabe 2b633119a0 test: add test for trailing dot in WorkingDirectory= and RuntimeDirectory= 2018-06-03 23:59:51 +09:00
Yu Watanabe 2f4d31c117 load-fragment: use path_simplify_and_warn() where applicable 2018-06-03 23:59:42 +09:00
Yu Watanabe cd4f53c5b5 conf-parse: use path_simplify_and_warn() in config_parse_path() 2018-06-03 23:57:30 +09:00
Yu Watanabe 58a53adde5 path-util: introduce path_simplify_and_warn() 2018-06-03 23:54:55 +09:00
Yu Watanabe 4805426279 path-util: make path_make_relative() support path including dots 2018-06-03 23:54:32 +09:00
Yu Watanabe 858d36c1ec path-util: introduce path_simplify()
The function is similar to path_kill_slashes() but also removes
initial './', trailing '/.', and '/./' in the path.
When the second argument of path_simplify() is false, then it
behaves as the same as path_kill_slashes(). Hence, this also
replaces path_kill_slashes() with path_simplify().
2018-06-03 23:39:26 +09:00
Susant Sahani e60dc5b441 Add SPDX license identifier. 2018-06-03 08:33:04 +05:30
Susant Sahani 56e7fb5088 networkd: introduce netdev "Netdevsim" Driver
This "netdevsim" as implied by the name is a tool for network developers and is a simulator.
This simulated networking device is used for testing various networking APIs and at this time
is particularly focused on testing hardware offloading related interfaces.
2018-06-03 08:16:11 +05:30
Zbigniew Jędrzejewski-Szmek aff4430136 network: avoid temporary variables for parsing, use TAKE_PTR (#9166)
We don't need a temporary variable when parsing just one number, because
our parsing functions do not touch the output variable on error.

TAKE_PTR is more expressive than 'n = NULL'.
2018-06-03 11:18:23 +09:00
Zbigniew Jędrzejewski-Szmek 9924aef690 test-ellipsize: add tests for ellipsize_mem, fix bugs
First, ellipsize() and ellipsize_mem() should not read past the input
buffer. Those functions take an explicit length for the input data, so they
should not assume that the buffer is terminated by a nul.

Second, ellipsization was off in various cases where wide on multi-byte
characters were used.

We had some basic test for ellipsize(), but apparently it wasn't enough to
catch more serious cases.

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8686.
2018-06-02 21:53:25 +02:00
Zbigniew Jędrzejewski-Szmek ae03775f56 basic/string-util: make ellipsize() inline
Once the redundant check is removed, it's a very simple wrapper around
ellipsize_mem().
2018-06-02 21:53:25 +02:00
Zbigniew Jędrzejewski-Szmek 4dae3ef6c0
Merge pull request #9156 from shr-project/jansa/gcc8
time-util: fix build with gcc8 -Werror=format-truncation=
2018-06-02 16:18:59 +02:00
Hans de Goede 3ecb1077be hwdb: Add accelerometer orientation quirk for the Onda V891w tablet
Add accelerometer orientation quirk for the Onda V891w tablet, this
does a partial match on the BIOS version because the other strings are
somewhat generic.

The BIOS match is done for both the W89* and D89* BIOS versions which are
for the Windows only and Dual boot versions respectively.
2018-06-02 15:48:48 +02:00
Hans de Goede fb5881bf17 hwdb: Add accelerometer orientation quirk for the Nuvision/TMAX TM800W560L
Add accelerometer orientation quirk for the Nuvision/TMAX TM800W560L
8" Windows signature edition tablet.
2018-06-02 12:10:33 +02:00
Yu Watanabe 40352cf0c1 netdev: fix parser for VRF.Table=
This effectively reverts f98dd1e707 (#6704).

Fixes #9150.
2018-06-02 11:15:37 +02:00
Hans de Goede b0488902dd hwdb: Add accelerometer orientation quirk for the Archos 80 Cesium tablet.
Add accelerometer orientation quirk for the Archos 80 Cesium 8" windows
tablet.
2018-06-02 10:57:19 +02:00
Hans de Goede b870058f6b hwdb: Extend Point of View TAB-P800W accelerometer quirk for another version
Extend the accelerometer quirk for the Point of View TAB-P800W to also
match the BIOS info on the Point of View TAB-P800W (v2.0).
2018-06-02 10:57:19 +02:00
Zbigniew Jędrzejewski-Szmek f1880a4b02 test-time-util: print names of test functions
This makes it easier to find the right spot in the long output.
2018-06-02 10:41:26 +02:00
Martin Jansa 5fd8d5be11 time-util: fix build with gcc8 -Werror=format-truncation=
* it fails with gcc8 when -O1 or -Os is used (and -ftree-vrp which is added by -O2 and higher isn't used)

../git/src/basic/time-util.c: In function 'format_timespan':
../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
                                              "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                              ^~~~
../git/src/basic/time-util.c:508:60: note: format string is defined here
                                              "%s"USEC_FMT".%0*"PRI_USEC"%s",
../git/src/basic/time-util.c:508:46: note: directive argument in the range [0, 18446744073709551614]
                                              "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                              ^~~~
../git/src/basic/time-util.c:507:37: note: 'snprintf' output 4 or more bytes (assuming 2147483651) into a destination of size 4294967295
                                 k = snprintf(p, l,
                                     ^~~~~~~~~~~~~~
                                              "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                              p > buf ? " " : "",
                                              ~~~~~~~~~~~~~~~~~~~
                                              a,
                                              ~~
                                              j,
                                              ~~
                                              b,
                                              ~~
                                              table[i].suffix);
                                              ~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

[zj: change 'char' to 'signed char']
2018-06-02 10:41:03 +02:00
Mike Gilbert 96f64eb574 basic: set errno in raw_clone() on sparc
sparc sets the carry bit when a syscall fails. Use this information to
set errno and return -1 as appropriate.

The added test case calls raw_clone() with flags known to be invalid
according to the clone(2) manpage.
2018-06-02 09:48:19 +02:00
Zbigniew Jędrzejewski-Szmek e0bd32c5cd
Merge pull request #9018 from poettering/get-process-comm-is-print
some extra safety checks for get_process_comm()
2018-06-01 23:34:53 +02:00
Lennart Poettering ce26882553 process-util: also filter non-printable characters in get_process_com()
We already do that in get_process_cmdline(), which is very similar in
behaviour otherwise. Hence, let's be safe and also filter them in
get_process_comm(). Let's try to retain as much information as we can
though and escape rather than suppress unprintable characters. Let's not
increase comm names beyond the kernel limit on such names however.

Also see discussion about this here:

https://marc.info/?l=linux-api&m=152649570404881&w=2
2018-06-01 21:53:13 +02:00
Lennart Poettering 61f6e27671 string-util: tweak cellescape() a bit
For short buffer sizes cellescape() was a bit wasteful, as it might
suffice to to drop a single character to find enough place for the full
four byte ellipsis, if that one character was a four character escape.
With this rework we'll guarantee to drop the minimum number of
characters from the end to fit in the ellipsis.

If the buffers we write to are large this doesn't matter much. However,
if they are short (as they are when talking about the process comm
field) then it starts to matter that we put as much information as we
can in the space we get.
2018-06-01 21:49:16 +02:00
Lennart Poettering 76a359736f escape: add an explanatory comment about buffer sizes 2018-06-01 21:49:16 +02:00
Lennart Poettering 92f14395cd missing: define kernel internal limit TASK_COMM_LEN in userspace too
We already use it at two places, and we are about to add one too.
Arbitrary literally hardcoded limits suck.
2018-06-01 21:49:16 +02:00
Lennart Poettering e225e5c3c6 process-util: mention that wait_for_terminate_with_timeout() should be called with SIGCHLD blocked 2018-06-01 21:49:16 +02:00
Lennart Poettering 1fc83d09c3 update NEWS to explain new OnFailure= behaviour 2018-06-01 19:13:38 +02:00
Lennart Poettering 2ad2e41a72 core: don't trigger OnFailure= deps when a unit is going to restart
This adds a flags parameter to unit_notify() which can be used to pass
additional notification information to the function. We the make the old
reload_failure boolean parameter one of these flags, and then add a new
flag that let's unit_notify() if we are configured to restart the
service.

Note that this adjusts behaviour of systemd to match what the docs say.

Fixes: #8398
2018-06-01 19:08:30 +02:00
Lennart Poettering 7f66b026bb core: when we can't enqueue OnFailure= job show full error message
Let's ask for the full error message and show it, there's really no
reason to just show the crappy errno error.
2018-06-01 19:04:37 +02:00
Susant Sahani 866e6b7a12 networkd: enable to set IFF_ALLMULTI to network device (#9146)
networkd: allow setting set IFF_ALLMULTI flag on network devices
2018-06-01 16:22:12 +02:00
Ian Miell be4bf266cb Minor spelling error - "Our of"->"Out of" 2018-06-01 15:15:31 +02:00
Zbigniew Jędrzejewski-Szmek 4910b35078 systemctl: when removing enablement or mask symlinks, cover both /run and /etc
'systemctl disable --runtime' would disable a unit, but only if it was enabled
with '--runtime', and silently do nothing if the unit was enabled persistently.
And similarly 'systemctl disable' would do nothing if the unit was enabled in
/run. This just doesn't seem useful.

This pathch changes enable/disable and mask/unmask to be asymmetrical. enable
and mask create symlinks in /etc or /run, depending on whether --runtime was
specified. disable and unmask remove symlinks from both locations. --runtime
cannot be specified for the disable and unmask verbs.

The advantage is that 'disable' now means that the unit is disabled, period.
And similarly for 'unmask', all masks are removed.

Similarly for preset and preset-all, they now cannot be called with --runtime,
and are asymmetrical: when they enable a unit, symlinks are created in /etc.
When they disable a unit, all symlinks are nuked.

$ systemctl --root=/ enable bluetooth
Created symlink /etc/systemd/system/dbus-org.bluez.service → /usr/lib/systemd/system/bluetooth.service.
Created symlink /etc/systemd/system/bluetooth.target.wants/bluetooth.service → /usr/lib/systemd/system/bluetooth.service.
$ systemctl --root=/ --runtime enable bluetooth
Created symlink /run/systemd/system/dbus-org.bluez.service → /usr/lib/systemd/system/bluetooth.service.
Created symlink /run/systemd/system/bluetooth.target.wants/bluetooth.service → /usr/lib/systemd/system/bluetooth.service.
$ systemctl --root=/ disable bluetooth
Removed /run/systemd/system/bluetooth.target.wants/bluetooth.service.
Removed /run/systemd/system/dbus-org.bluez.service.
Removed /etc/systemd/system/bluetooth.target.wants/bluetooth.service.
Removed /etc/systemd/system/dbus-org.bluez.service.
$ systemctl --root=/ disable --runtime bluetooth
--runtime cannot be used with disable

$ systemctl --root=/ mask --runtime bluetooth
Created symlink /run/systemd/system/bluetooth.service → /dev/null.
$ systemctl --root=/ mask bluetooth
Created symlink /etc/systemd/system/bluetooth.service → /dev/null.
$ systemctl --root=/ unmask bluetooth
Removed /run/systemd/system/bluetooth.service.
Removed /etc/systemd/system/bluetooth.service.
$ systemctl --root=/ unmask --runtime bluetooth
--runtime cannot be used with unmask

$ systemctl --root=/ --runtime enable bluetooth
Created symlink /run/systemd/system/dbus-org.bluez.service → /usr/lib/systemd/system/bluetooth.service.
Created symlink /run/systemd/system/bluetooth.target.wants/bluetooth.service → /usr/lib/systemd/system/bluetooth.service.
$ systemctl --root=/ enable bluetooth
Created symlink /etc/systemd/system/dbus-org.bluez.service → /usr/lib/systemd/system/bluetooth.service.
Created symlink /etc/systemd/system/bluetooth.target.wants/bluetooth.service → /usr/lib/systemd/system/bluetooth.service.
$ systemctl --root=/ preset bluetooth
Removed /run/systemd/system/bluetooth.target.wants/bluetooth.service.
Removed /run/systemd/system/dbus-org.bluez.service.
Removed /etc/systemd/system/bluetooth.target.wants/bluetooth.service.
Removed /etc/systemd/system/dbus-org.bluez.service.
$ systemctl --root=/ preset --runtime bluetooth
--runtime cannot be used with preset

$ systemctl preset-all --runtime
--runtime cannot be used with preset-all
2018-06-01 15:10:33 +02:00
Zbigniew Jędrzejewski-Szmek e2e6ca54c3 systemctl: remove newlines
This file is long enough already, we don't need extra vertical whitespace.
2018-05-31 20:42:07 +02:00
Zbigniew Jędrzejewski-Szmek bb2682bc04 Fix reporting of enabled-runtime units
We would always report them as "enabled", because path_is_config() includes
/run, despite the name.

Fixes #9122.
2018-05-31 20:42:07 +02:00