platform/upstream/systemd.git
6 years agostring-util: tweak ellipsation a bit
Lennart Poettering [Wed, 11 Apr 2018 17:52:25 +0000 (19:52 +0200)]
string-util: tweak ellipsation a bit

This primarily changes to things:

1. Ellipsation to 0, 1 or 2 characters is now supported. Previously we'd
   hit an assert if the new lengths was < 3, this is now permitted. The
   result strings won't show too much info still of course, but the code
   becomes a bit more generic and robust to use.

2. If a UTF-8 mode is disabled and the input string is pure ASCII, then
   "..." is used for ellipsation, otherwise (as before) "…". This means
   on a pure-ASCII system we should remain pure-ASCII, matching
   behaviour otherwise exposed with special_glyph() and friends. Note
   that we'll use "…" for ellipsiation as soon as either the locale
   settings indicate an UTF-8 mode or the input string already contains
   non-ASCII unicode characters.

Testing for these special cases is improved.

6 years agoutil: add qsort_r_safe(), similar to qsort_safe()
Lennart Poettering [Wed, 11 Apr 2018 17:51:39 +0000 (19:51 +0200)]
util: add qsort_r_safe(), similar to qsort_safe()

6 years agoutf8: add helper call for counting display width of strings
Lennart Poettering [Wed, 11 Apr 2018 17:50:53 +0000 (19:50 +0200)]
utf8: add helper call for counting display width of strings

6 years agolocale: add ellipsis as special glyph
Lennart Poettering [Wed, 11 Apr 2018 17:49:50 +0000 (19:49 +0200)]
locale: add ellipsis as special glyph

6 years agoMerge pull request #8417 from brauner/2018-03-09/add_bind_mount_fallback_to_private_d...
Lennart Poettering [Wed, 18 Apr 2018 09:56:56 +0000 (11:56 +0200)]
Merge pull request #8417 from brauner/2018-03-09/add_bind_mount_fallback_to_private_devices

core: fall back to bind-mounts for PrivateDevices= execution environments

6 years agoMerge pull request #8735 from keszybz/small-docs-updates
Lennart Poettering [Wed, 18 Apr 2018 09:50:56 +0000 (11:50 +0200)]
Merge pull request #8735 from keszybz/small-docs-updates

Small docs updates

6 years agoMerge pull request #8741 from poettering/assorted-stuff2
Zbigniew Jędrzejewski-Szmek [Wed, 18 Apr 2018 08:31:58 +0000 (10:31 +0200)]
Merge pull request #8741 from poettering/assorted-stuff2

four smaller machinectl/nspawn/machined clean-ups/improvements

6 years agoman: merge two sections into two subsections of one section
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 16:00:33 +0000 (18:00 +0200)]
man: merge two sections into two subsections of one section

Those are very close subjects that are a good fit for one section.

6 years agoman: describe unit templating explicitly
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 15:57:37 +0000 (17:57 +0200)]
man: describe unit templating explicitly

This patch is heavily based on the text suggested by
archenemies in #3791.

Fixes #3791.

6 years agoman: briefly document Following=
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 15:42:10 +0000 (17:42 +0200)]
man: briefly document Following=

Fixes #1914.

6 years agoman: use --option= in more places
Zbigniew Jędrzejewski-Szmek [Wed, 18 Apr 2018 07:15:28 +0000 (09:15 +0200)]
man: use --option= in more places

6 years agoman: be more explicit about sd-journal-upload input format
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 15:20:23 +0000 (17:20 +0200)]
man: be more explicit about sd-journal-upload input format

Fixes #3857.

6 years agoman: add a new page with a general description of common syntax
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 15:09:58 +0000 (17:09 +0200)]
man: add a new page with a general description of common syntax

We have a common parser, but for the user it might be
completely unobvious that the same general rules apply
to all those files. Let's add a page about the basic syntax
so that the more specific pages don't have to repeat those
details.

6 years agomeson: fix indentation for systemd-time-sync-wait(5) entries
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 15:08:21 +0000 (17:08 +0200)]
meson: fix indentation for systemd-time-sync-wait(5) entries

Those files should not be updated manually, because then automatic updates
contain spurious "changes".

6 years agopath-util: Finish DEFAULT_PATH_NULSTR with an extra NUL (#8745)
Filipe Brandenburger [Wed, 18 Apr 2018 05:46:03 +0000 (22:46 -0700)]
path-util: Finish DEFAULT_PATH_NULSTR with an extra NUL (#8745)

The NULSTR_FOREACH iterator needs to see an empty string at the end, so
we need to insert an extra NUL explicitly.

Also update PATH0_BIN_SBIN(x) to include an extra NUL terminator, rename
it to PATH_BIN_SBIN_NULSTR(x), which is more consistent with the similar
CONF_PATHS_NULSTR(x) macro.

Fixes: 5008da1ec1cf2cf8c15b702c4052e3a49583095d

6 years agotimesync: establish connection when network become online and the manager is not...
Yu Watanabe [Tue, 17 Apr 2018 18:56:12 +0000 (03:56 +0900)]
timesync: establish connection when network become online and the manager is not connected yet (#8727)

This also introduces `manager_is_connected()` helper function, which
returns true when the manager is sending a request, resolving a server
name, or in a poll interval.

Follow-up for 3e85ec072180b6fbec82d715186985536859a29d.
Fixes #8719.

6 years agoMerge pull request #8739 from yuwata/add-description
Lennart Poettering [Tue, 17 Apr 2018 18:33:50 +0000 (20:33 +0200)]
Merge pull request #8739 from yuwata/add-description

bus-util: introduce bus_open_system_watch_bind_with_description()

6 years agomeson: install nspawn tmpfiles snippet only when machined is turned on
Lennart Poettering [Mon, 16 Apr 2018 19:40:26 +0000 (21:40 +0200)]
meson: install nspawn tmpfiles snippet only when machined is turned on

6 years agopolkit: normalize exit values of polkit_agent_open_if_enabled()
Lennart Poettering [Mon, 16 Apr 2018 19:37:12 +0000 (21:37 +0200)]
polkit: normalize exit values of polkit_agent_open_if_enabled()

It's strange eating up the errors here, hence don't. Let's leave this
to the caller.

6 years agoman: minor machinectl updates
Lennart Poettering [Tue, 17 Apr 2018 15:40:10 +0000 (17:40 +0200)]
man: minor machinectl updates

6 years agomachined: some modernizations
Lennart Poettering [Thu, 5 Apr 2018 10:38:25 +0000 (12:38 +0200)]
machined: some modernizations

A couple of minor modernizations:

1. Don't unnecessarily export functions we don't call outside of
   machined.c

2. Use cleanup logic for the manager object.

3. Propagate errors properly from manager_new(). So far if
   sd_event_new() returns EMFILE/ENFILE for some reason we would have
   logged that as log_oom(), which isn#t right, really.

4. Handle SIGTERM/SIGINT cleanly. It's easy, and prettier then letting
   the kernel just abort us. It also makes it possible to valgrind
   machined properly.

6 years agounit,meson: drop .in suffix if no substitution is required (#8740)
Yu Watanabe [Tue, 17 Apr 2018 17:49:10 +0000 (02:49 +0900)]
unit,meson: drop .in suffix if no substitution is required (#8740)

6 years agoMerge pull request #8716 from keszybz/two-nitpicks
Lennart Poettering [Tue, 17 Apr 2018 17:34:27 +0000 (19:34 +0200)]
Merge pull request #8716 from keszybz/two-nitpicks

Two nitpicks

6 years agonetworkd: fix dhcp4 link without routes not being considered ready (#8728)
Anssi Hannula [Tue, 17 Apr 2018 15:12:00 +0000 (18:12 +0300)]
networkd: fix dhcp4 link without routes not being considered ready (#8728)

The dhcp4 code sets link->dhcp4_configured when dhcp4_route_handler()
has processed the last message.

However, in case UseRoutes=no has been set in the [DHCP] section, or
in case the DHCP server simply sends no routes, link_set_dhcp_routes()
will not send any netlink messages and dhcp4_route_handler() will
therefore never be called.

This causes the link to never reach LINK_STATE_CONFIGURED, and e.g.
systemd-networkd-wait-online will not consider the link as ready.

Fix that by setting link->dhcp4_configured = true and calling
link_check_ready() in dhcp4_address_handler() in case
link_set_dhcp_routes() sent no netlink messages (dhcp4_messages is
zero).

6 years agobasic/copy: fix awkward sentence
Zbigniew Jędrzejewski-Szmek [Fri, 13 Apr 2018 10:40:11 +0000 (12:40 +0200)]
basic/copy: fix awkward sentence

6 years agobasic/unit-name: remove duplicate check
Zbigniew Jędrzejewski-Szmek [Fri, 13 Apr 2018 10:38:11 +0000 (12:38 +0200)]
basic/unit-name: remove duplicate check

The check that was right below already covers this case.

6 years agoresolve: set description to bus
Yu Watanabe [Tue, 17 Apr 2018 14:56:17 +0000 (23:56 +0900)]
resolve: set description to bus

6 years agonetwork: set description to bus
Yu Watanabe [Tue, 17 Apr 2018 14:55:27 +0000 (23:55 +0900)]
network: set description to bus

6 years agonetworkd: fix crash if fails to get network file (#8714)
Susant Sahani [Tue, 17 Apr 2018 14:55:04 +0000 (20:25 +0530)]
networkd: fix crash if fails to get network file (#8714)

In some situation if networkd fails to get the network file
then networkd crashes becasse the link->network is not initalized;

```
veth99: Failed to get network dhcp-client-ipv4-only: No such file or directory
Segmentation fault

gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/sus/tt/systemd/build/systemd-networkd
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
warning: Loadable section ".note.gnu.property" outside of ELF segments
warning: Loadable section ".note.gnu.property" outside of ELF segments
warning: Loadable section ".note.gnu.property" outside of ELF segments

Program received signal SIGSEGV, Segmentation fault.
link_load (link=0x55555582ccd0) at ../src/network/networkd-link.c:2973
2973                 r = sd_dhcp_client_new(&link->dhcp_client, link->network->dhcp_anonymize);
(gdb) bt
(gdb) p link->network
$1 = (Network *) 0x0
(gdb) list
2968                 if (r < 0) {
2969                         log_link_debug_errno(link, r, "Failed to parse DHCPv4 address %s: %m", dhcp4_address);
2970                         goto dhcp4_address_fail;
2971                 }
2972
2973                 r = sd_dhcp_client_new(&link->dhcp_client, link->network->dhcp_anonymize);
2974                 if (r < 0)
2975                         return log_link_error_errno(link, r, "Failed to create DHCPv4 client: %m");
2976
2977                 r = sd_dhcp_client_set_request_address(link->dhcp_client, &address.in);
(gdb) r
```

6 years agohwdb: Add a 2nd accelerometer orientation quirk for the Lenovo Ideapad Miix 320 ...
Hans de Goede [Tue, 17 Apr 2018 14:51:33 +0000 (16:51 +0200)]
hwdb: Add a 2nd accelerometer orientation quirk for the Lenovo Ideapad Miix 320 (#8734)

Different batches of the Lenovo Ideapad Miix 320 use a different sensor
it seems. Add a quirk for the model which uses the SMO8840 (ST) sensor.

6 years agologind: enable limiting of user session scopes using pam context objects (#8397)
Jan Synacek [Tue, 17 Apr 2018 14:42:44 +0000 (16:42 +0200)]
logind: enable limiting of user session scopes using pam context objects (#8397)

6 years agobus-util: introduce bus_open_system_watch_bind_with_description()
Yu Watanabe [Tue, 17 Apr 2018 14:37:52 +0000 (23:37 +0900)]
bus-util: introduce bus_open_system_watch_bind_with_description()

Similar to 56fbd7187a5af44a90c258fbeb1f17114f226bb3, this adds
bus_open_system_watch_bind_with_description() to set description
for busses.

6 years agoMerge pull request #8575 from keszybz/non-absolute-paths
Lennart Poettering [Tue, 17 Apr 2018 13:54:10 +0000 (15:54 +0200)]
Merge pull request #8575 from keszybz/non-absolute-paths

Do not require absolute paths in ExecStart and friends

6 years agonetwork,resolve: remove unused variables (#8738)
Yu Watanabe [Tue, 17 Apr 2018 10:40:45 +0000 (19:40 +0900)]
network,resolve: remove unused variables (#8738)

Follow-up for d7afd945b5aad5b262a3de97614f486d63d94612.

6 years agoMerge pull request #8696 from pabigot/issue/8683
Zbigniew Jędrzejewski-Szmek [Tue, 17 Apr 2018 09:55:12 +0000 (11:55 +0200)]
Merge pull request #8696 from pabigot/issue/8683

Use /run/clock/synchronized to notify when clock has been synchronized

6 years agotest-execute: make find invocation a bit more efficent, increase timeout
Zbigniew Jędrzejewski-Szmek [Wed, 11 Apr 2018 14:50:48 +0000 (16:50 +0200)]
test-execute: make find invocation a bit more efficent, increase timeout

We go through the whole file system, so this test can take arbitrary time.  But
this test is still quite useful, so let's at least try to make it more efficent
by not descending at all into the directories we would filter out later on
anyway.

Also increase the timeout, in case the previous step doesn't help enough.

6 years agosystemd-path: allow the default search path to be queried
Zbigniew Jędrzejewski-Szmek [Mon, 26 Mar 2018 07:51:12 +0000 (09:51 +0200)]
systemd-path: allow the default search path to be queried

6 years agotest: drop the use of /bin/sh in various test services
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 19:10:50 +0000 (21:10 +0200)]
test: drop the use of /bin/sh in various test services

This is not meant to be comprehensive, just the few cases where the /bin/sh -c wrapper
is obviously superfluous.

6 years agosystemd: do not require absolute paths in ExecStart
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 18:50:15 +0000 (20:50 +0200)]
systemd: do not require absolute paths in ExecStart

Absolute paths make everything simple and quick, but sometimes this requirement
can be annoying. A good example is calling 'test', which will be located in
/usr/bin/ or /bin depending on the distro. The need the provide the full path
makes it harder a portable unit file in such cases.

This patch uses a fixed search path (DEFAULT_PATH which was already used as the
default value of $PATH), and if a non-absolute file name is found, it is
immediately resolved to a full path using this search path when the unit is
loaded. After that, everything behaves as if an absolute path was specified. In
particular, the executable must exist when the unit is loaded.

6 years agoverify: use manager_load_startable_unit_or_warn() to load units for verification
Zbigniew Jędrzejewski-Szmek [Thu, 12 Apr 2018 13:58:45 +0000 (15:58 +0200)]
verify: use manager_load_startable_unit_or_warn() to load units for verification

This doesn't change the outcome:
(before)
/home/zbyszek/src/systemd/test/test-execute/exec-basic.service:6: Executable path specifies a directory: /usr/bin/test/
exec-basic.service: Failed to create exec-basic.service/start: Unit exec-basic.service is not loaded properly: Exec format error.
(after)
/home/zbyszek/src/systemd/test/test-execute/exec-basic.service:6: Executable path specifies a directory: /usr/bin/test/
Failed to load file /home/zbyszek/src/systemd/test/test-execute/exec-basic.service: Exec format error

(before)
masked.service: Failed to create masked.service/start: Unit masked.service is masked.
(after)
File /home/zbyszek/src/systemd/test/test-execute/masked.service is masked.

but the failure is immediate and the error messages are more direct.

6 years agotests: use manager_load_startable_unit_or_warn() to load units
Zbigniew Jędrzejewski-Szmek [Thu, 12 Apr 2018 13:51:39 +0000 (15:51 +0200)]
tests: use manager_load_startable_unit_or_warn() to load units

Doing manager_load_unit() followed by UNIT_VTABLE(unit)->start(unit) would
result in an assertion failure in ->start() if the unit failed to load
properly. Something like this is okey-ish is tests, since the test units are
not expected to fail to load, but the reason for failure is clearer if we
fail immediately.

6 years agocore/manager: split out function to verify that unit is loaded and not masked
Zbigniew Jędrzejewski-Szmek [Thu, 12 Apr 2018 13:13:14 +0000 (15:13 +0200)]
core/manager: split out function to verify that unit is loaded and not masked

No functional change.

6 years agofuzz-unit-file: skip BOM (#8723)
Zbigniew Jędrzejewski-Szmek [Mon, 16 Apr 2018 08:59:41 +0000 (10:59 +0200)]
fuzz-unit-file: skip BOM (#8723)

Yet another false positive from ListenNetlink,
https://oss-fuzz.com/v2/testcase-detail/4908210742886400/7694.

6 years agoSupport for Dell Inspiron 5378/5379 WLAN key (#8715)
dmig [Sun, 15 Apr 2018 08:43:58 +0000 (15:43 +0700)]
Support for Dell Inspiron 5378/5379 WLAN key (#8715)

6 years agotime-wait-sync: use watchfile to coordinate with timesyncd
Peter A. Bigot [Mon, 9 Apr 2018 18:39:16 +0000 (13:39 -0500)]
time-wait-sync: use watchfile to coordinate with timesyncd

Systems that have an accurate real-time clock may have an initial
unsynchronized time that is close enough to the synchronized time that
the final adjustment doesn't trigger a waking "clock set" event.  Have
timesyncd touch a file in its runtime directory as a secondary signal
for synchronization.  Continue to support the timerfd-based trigger as a
sufficient condition when the watchfile is not present.

Closes issue #8683

6 years agounits: leave systemd-time-wait-sync disabled by default
Peter A. Bigot [Tue, 10 Apr 2018 16:05:25 +0000 (11:05 -0500)]
units: leave systemd-time-wait-sync disabled by default

Also mark its presence conditional on ENABLE_TIMESYNCD.

6 years agofix url for binfmt documentation (#8720)
guixxx [Sat, 14 Apr 2018 13:15:19 +0000 (10:15 -0300)]
fix url for binfmt documentation (#8720)

this file went unnoticed in PR #6223

6 years agosrc/core/dbus-cgroup.c: fix typo contoller -> controller (#8717)
Giuseppe Scrivano [Sat, 14 Apr 2018 09:06:11 +0000 (11:06 +0200)]
src/core/dbus-cgroup.c: fix typo contoller -> controller (#8717)

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
6 years agoMerge pull request #8271 from poettering/unit-prefix-search
Zbigniew Jędrzejewski-Szmek [Fri, 13 Apr 2018 12:45:51 +0000 (14:45 +0200)]
Merge pull request #8271 from poettering/unit-prefix-search

Search unit .d/ drop-in files also in all "dash prefixes" of a unit

6 years agoMerge pull request #8707 from poettering/copy-tweaks
Zbigniew Jędrzejewski-Szmek [Fri, 13 Apr 2018 10:10:17 +0000 (12:10 +0200)]
Merge pull request #8707 from poettering/copy-tweaks

tweaks to fd copying code

6 years agoman: document the new dash truncation drop-in directories
Lennart Poettering [Fri, 23 Feb 2018 19:42:57 +0000 (20:42 +0100)]
man: document the new dash truncation drop-in directories

6 years agotest: add test for prefix unit loading
Lennart Poettering [Wed, 21 Mar 2018 18:55:54 +0000 (19:55 +0100)]
test: add test for prefix unit loading

6 years agodropin: when looking for dropins for a unit, also look within "-" prefix unit dirs
Lennart Poettering [Fri, 23 Feb 2018 11:32:23 +0000 (12:32 +0100)]
dropin: when looking for dropins for a unit, also look within "-" prefix unit dirs

This extends the logic by which we look for drop-ins for unit files when
loading them. Previously for a unit "foo-quux-bar.service" we'd look in
a directory "foo-quux-bar.service.d" accompanying it for extension
dropins. With this change we'll additionally look in:
"foo-quux-.service.d" and "foo-.service.d", i.e. we'll truncate the unit
name after every dash.

This is an alternative to templating for many services, as it permits
configuring defaults for sets of units that all use the same prefix in
the unit name. This is particularly useful in slice, mount and
automount units which reflect a hierarchy of concepts, as it permits
setting defaults for specific subsets of the tree. For example, in order
to provide every user with a memory of 1G it's now possible to do:

    # mkdir -p /etc/systemd/system/user-.slice.d
    # cat > /etc/systemd/system/user-.slice.d/50-memory.conf << EOF
    [Slice]
    MemoryMax=1G
    EOF
    # systemctl daemon-reload

This makes use of the fact that every user gets his own slice unit when
logging in, named "user-$UID.slice".

This doesn't precisely provide what is requested in #2556, but it does
provide equivalent functionality.

Fixes: #2556
See: #3504 #7599

6 years agosystemctl: fix indentation in output of "systemcl status" if there are multiple drop...
Lennart Poettering [Fri, 23 Feb 2018 11:31:30 +0000 (12:31 +0100)]
systemctl: fix indentation in output of "systemcl status" if there are multiple drop-in dirs

We were a few whitespace off. Let's fix that.

6 years agocore: minor coding style changes
Lennart Poettering [Fri, 23 Feb 2018 11:30:14 +0000 (12:30 +0100)]
core: minor coding style changes

6 years agodropin: don't fully suppress logging about ENAMETOOLONG. Just downgrade to LOG_DEBUG
Lennart Poettering [Wed, 21 Mar 2018 18:08:46 +0000 (19:08 +0100)]
dropin: don't fully suppress logging about ENAMETOOLONG. Just downgrade to LOG_DEBUG

6 years agoload-dropin: rename variable
Lennart Poettering [Fri, 23 Feb 2018 11:20:14 +0000 (12:20 +0100)]
load-dropin: rename variable

We are converting the unit name into its template, hence name the
variable that way, instead of the misleading 'prefix'.

6 years agounit-name: add new unit_name_build_from_type() helper
Lennart Poettering [Thu, 22 Feb 2018 17:24:57 +0000 (18:24 +0100)]
unit-name: add new unit_name_build_from_type() helper

The new helper is much like unit_name_build() but expects a UnitType
value instead of a suffix.

6 years agocopy: rearrange flags field definition
Lennart Poettering [Fri, 23 Mar 2018 17:27:31 +0000 (18:27 +0100)]
copy: rearrange flags field definition

Let's use the usual 1U << 0,1,2,3,4 spelling for definiting flags enums.

6 years agocopy: reduce number of checks
Lennart Poettering [Fri, 23 Mar 2018 17:26:58 +0000 (18:26 +0100)]
copy: reduce number of checks

We check max_bytes twice here, let's simplify that, and reduce one level
of indentation.

6 years agocopy: drop _unlikely_() that isn't obviously the case
Lennart Poettering [Fri, 23 Mar 2018 17:24:07 +0000 (18:24 +0100)]
copy: drop _unlikely_() that isn't obviously the case

If a tool only invokes copy_bytes() a single time the _unlikely_() will always be
wrong, and is hence not useful. Let's drop it and let the compiler
figure our what to do, instead of misleading it.

Also, some coding style imprvoements.

6 years agocopy: hide in copy_bytes() the strange way splice() handles O_NONBLOCK
Lennart Poettering [Fri, 23 Mar 2018 16:44:15 +0000 (17:44 +0100)]
copy: hide in copy_bytes() the strange way splice() handles O_NONBLOCK

splice() ignores O_NONBLOCK on pipes but not on other fds. Let's handle
that properly, and query O_ONBLOCK manually in that case, ensuring
systematic behaviour in either case.

6 years agocopy: extend copy_bytes() a bit
Lennart Poettering [Fri, 23 Mar 2018 15:41:42 +0000 (16:41 +0100)]
copy: extend copy_bytes() a bit

Optionally, when we copy between fds with simple read/write, let's
return any remaining data we already read into the buffer if write
fails. This is useful to allow callers to use the read data otherwise,
perhaps implementing a different fallback for copying.

6 years agocopy: tweak reflink logic in copy_bytes() a bit
Lennart Poettering [Fri, 23 Mar 2018 15:36:56 +0000 (16:36 +0100)]
copy: tweak reflink logic in copy_bytes() a bit

Let's use btrfs_clone_range() if partial copies are desired. And use
btrfs_reflink() only for full-file reflinks.

6 years agocopy: add brief comment to copy_bytes() explaining its return values
Lennart Poettering [Fri, 9 Mar 2018 21:44:47 +0000 (22:44 +0100)]
copy: add brief comment to copy_bytes() explaining its return values

6 years agoMerge pull request #8710 from poettering/triviailities-yeah-yeah
Zbigniew Jędrzejewski-Szmek [Thu, 12 Apr 2018 20:21:15 +0000 (22:21 +0200)]
Merge pull request #8710 from poettering/triviailities-yeah-yeah

some trivial additions and fixes

6 years agoISO-C compatibility: Remove empty initializer (#8713)
Leonard [Thu, 12 Apr 2018 19:31:19 +0000 (21:31 +0200)]
ISO-C compatibility:  Remove empty initializer (#8713)

ISO-C doesn't allow empty initializers, so replace it by explicitly
initializing to zero.

Also add braces because x is a union and we initialize a subobject, so
a compiler might warn about suggesting braces.  Shut that up.

6 years agocore/namespace: rework the return semantics of clone_device_node yet again
Zbigniew Jędrzejewski-Szmek [Thu, 12 Apr 2018 15:48:22 +0000 (17:48 +0200)]
core/namespace: rework the return semantics of clone_device_node yet again

Returning 0 on not-found/wrong-type is confusing. Let's return -ENXIO in that
case instead, and explicitly ignore it in the call site where we want to do that.
I think this is clearer and less likely to be used errenously in case another
call site is added.

C.f. 152c475f95c7b9b20d293 and 98b1d2b8d9ea27087a598.

6 years agocore: fall back to bind-mounts for PrivateDevices= execution environments
Christian Brauner [Fri, 9 Mar 2018 13:49:15 +0000 (14:49 +0100)]
core: fall back to bind-mounts for PrivateDevices= execution environments

In environments where CAP_MKNOD is not available or inside
user namespaces it is still desirable to enable services to use
PrivateDevices= . So fall back to using bind-mounts on EPERM.

6 years agotest-execute/exec-specifier.service: fix quoting
Zbigniew Jędrzejewski-Szmek [Thu, 12 Apr 2018 14:16:19 +0000 (16:16 +0200)]
test-execute/exec-specifier.service: fix quoting

The lines would cause the whole service to fail to be loaded.

6 years agomacro: don't rely on C's downgrade-to-bool feature for numeric comparisons
Lennart Poettering [Wed, 11 Apr 2018 19:36:52 +0000 (21:36 +0200)]
macro: don't rely on C's downgrade-to-bool feature for numeric comparisons

6 years agoinstall: minor enum beautifications
Lennart Poettering [Mon, 9 Apr 2018 17:45:04 +0000 (19:45 +0200)]
install: minor enum beautifications

6 years agoupdate TODO
Lennart Poettering [Fri, 6 Apr 2018 16:57:48 +0000 (18:57 +0200)]
update TODO

6 years agoimportd: ensure we don't mishandle a NULL string
Lennart Poettering [Fri, 6 Apr 2018 16:57:36 +0000 (18:57 +0200)]
importd: ensure we don't mishandle a NULL string

6 years agopath-util: document a few other special cases for last_path_component()
Lennart Poettering [Thu, 5 Apr 2018 16:00:39 +0000 (18:00 +0200)]
path-util: document a few other special cases for last_path_component()

6 years agoprocess-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child process...
Lennart Poettering [Tue, 27 Mar 2018 13:01:02 +0000 (15:01 +0200)]
process-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child process PIDs

6 years agoutil: introduce typesafe_qsort(), a typesafe version of qsort()/qsort_safe()
Lennart Poettering [Tue, 27 Mar 2018 12:56:29 +0000 (14:56 +0200)]
util: introduce typesafe_qsort(), a typesafe version of qsort()/qsort_safe()

It does two things:

1. It derives the element size from the array argument type

2. It derives the right type for the function from the array argument
   type

Using this macro call should make the invocations of qsort() quite a bit
safer.

6 years agoMerge pull request #8700 from keszybz/hibernation
Lennart Poettering [Wed, 11 Apr 2018 08:26:27 +0000 (10:26 +0200)]
Merge pull request #8700 from keszybz/hibernation

Various improvements related to hibernation

6 years agoshared/sleep-config: rename misnamed function
Zbigniew Jędrzejewski-Szmek [Wed, 11 Apr 2018 07:27:32 +0000 (09:27 +0200)]
shared/sleep-config: rename misnamed function

6 years agoshared/sleep-config: return a custom message when not enough swap for hibernation
Zbigniew Jędrzejewski-Szmek [Wed, 11 Apr 2018 06:51:06 +0000 (08:51 +0200)]
shared/sleep-config: return a custom message when not enough swap for hibernation

$ sudo swapoff -av
swapoff /dev/vda4
$ sudo systemctl hibernate
Failed to hibernate system via logind: Not enough swap space for hibernation

Fixes #6729.

6 years agologind: refuse operations if the target unit is masked or unavailable
Zbigniew Jędrzejewski-Szmek [Tue, 10 Apr 2018 11:15:00 +0000 (13:15 +0200)]
logind: refuse operations if the target unit is masked or unavailable

If hibernate.target is masked, and systemctl hibernate is invoked, havoc ensues.
logind starts the hibernation operation, but then doesn't go through with it;
gnome-shell segfaults. Let's be nice to the user and refuse doing anything in
that case.

$ sudo systemctl mask hibernate.target
$ busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanHibernate
s "no"
$ sudo systemctl hibernate
Failed to hibernate system via logind: Access denied
Failed to start hibernate.target: Unit hibernate.target is masked.

https://bugzilla.redhat.com/show_bug.cgi?id=1468003#c4

6 years agoMove utility function to query unit state from systemctl to shared/
Zbigniew Jędrzejewski-Szmek [Tue, 10 Apr 2018 10:35:36 +0000 (12:35 +0200)]
Move utility function to query unit state from systemctl to shared/

6 years agoshared/sleep-fix: fix check if s-then-h is possible
Zbigniew Jędrzejewski-Szmek [Tue, 10 Apr 2018 09:39:14 +0000 (11:39 +0200)]
shared/sleep-fix: fix check if s-then-h is possible

can_sleep() returns 0 if the operation is impossible, but
the code assumed that negative is returned in that case,
in effect reporting s2h was possible even if hibernation or
suspend were not possible.

6 years agoshared/sleep-config: get rid of explicit allocation size calculation
Zbigniew Jędrzejewski-Szmek [Tue, 10 Apr 2018 09:23:46 +0000 (11:23 +0200)]
shared/sleep-config: get rid of explicit allocation size calculation

6 years agohwdb: drop a space (#8701)
Evgeny Vereshchagin [Tue, 10 Apr 2018 19:10:52 +0000 (22:10 +0300)]
hwdb: drop a space (#8701)

This should make `parse_hwdb.py` and the CI happy again.

6 years agoMerge pull request #8676 from keszybz/drop-license-boilerplate
Lennart Poettering [Tue, 10 Apr 2018 12:53:31 +0000 (14:53 +0200)]
Merge pull request #8676 from keszybz/drop-license-boilerplate

Drop license boilerplate

6 years agoMerge pull request #8406 from dell/hibernate-disk-offset
Zbigniew Jędrzejewski-Szmek [Tue, 10 Apr 2018 07:53:17 +0000 (09:53 +0200)]
Merge pull request #8406 from dell/hibernate-disk-offset

Add support for setting a disk offset when hibernating

6 years agoAdd override axis for Toshiba Satellite R830 (#8694)
emelenas [Mon, 9 Apr 2018 22:15:25 +0000 (00:15 +0200)]
Add override axis for Toshiba Satellite R830 (#8694)

Incorrect range and resolution for the touchpad at a Toshiba Satellite R830 reported by kernel. After running

$ sudo touchpad-edge-detector 85x50 /dev/input/event4

the new axis overrides are as follows

#Toshiba Satellite R830
evdev:name:SynPS/2 Synaptics TouchPad:dmi:svnTOSHIBA:pnSATELLITER830
EVDEV_ABS_00=1238:5785:53
EVDEV_ABS_01=1045:4826:76
EVDEV_ABS_35=1238:5785:53
EVDEV_ABS_36=1045:4826:76

Those overrides have been tested to work.

6 years agohwdb: add support for VMBUS guids (#8677)
Stephen Hemminger [Mon, 9 Apr 2018 20:25:08 +0000 (13:25 -0700)]
hwdb: add support for VMBUS guids (#8677)

This addresses missing feature on #8677

Devices in Hyper-V/Azure exist on vmbus and are identified by
UUID value. This patch adds a hardware table so that udevadm
can report properties. I chose names are based on the values
reported in Window Device Manager (for consistency).
The table includes several devices that are not used by Linux
but are present and ignored.

For example:

$ udevadm info -q property /sys/bus/vmbus/devices/58f75a6d-d949-4320-99e1-a2a2576d581c
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0004:00/VMBUS:00/58f75a6d-d949-4320-99e1-a2a2576d581c
DRIVER=hid_hyperv
ID_MODEL_FROM_DATABASE=Microsoft Hyper-V Mouse
MODALIAS=vmbus:9eb6a8cf4a5bc04cb98b8ba1a1f3f95a
SUBSYSTEM=vmbus
USEC_INITIALIZED=11076966

Or with updated kernel the driverctl script.

$ driverctl -b vmbus -v list-devices
1eccfd72-4b41-45ef-b73a-4a6e44c12924 hv_balloon (Microsoft Hyper-V Dynamic Memory)
242ff919-07db-4180-9c2e-b86cb68c8c55 hv_util (Microsoft Hyper-V Data Exchange)
2450ee40-33bf-4fbd-892e-9fb06e9214cf hv_util (Microsoft Hyper-V Backup/Restore)
2dd1ce17-079e-403c-b352-a1921ee207ee hv_util (Microsoft Hyper-V Time Sync)
4487b255-b88c-403f-bb51-d1f69cf17f87 (none) (Microsoft Hyper-V Virtual Machine Activation)
53557f8e-057d-425b-9265-01c0fd7e273e hv_netvsc (Microsoft Hyper-V Network Adapter)
5620e0c7-8062-4dce-aeb7-520c7ef76171 hyperv_fb (Microsoft Hyper-V Video)
58f75a6d-d949-4320-99e1-a2a2576d581c hid_hyperv (Microsoft Hyper-V Mouse)
849a776e-8120-4e4a-9a36-7e3d95ac75b3 hv_netvsc (Microsoft Hyper-V Network Adapter)
99221fa0-24ad-11e2-be98-001aa01bbf6e (none) (Microsoft Hyper-V Remote Desktop Control)
b2f44faf-2a29-42ba-91b2-f13fd30a2d4b hv_storvsc (Microsoft Hyper-V SCSI Controller)
b6650ff7-33bc-4840-8048-e0676786f393 hv_util (Microsoft Hyper-V Guest Shutdown)
d34b2567-b9b6-42b9-8778-0a4ec0b955bf hyperv_keyboard (Microsoft Hyper-V Keyboard)
f5bee29c-1741-4aad-a4c2-8fdedb46dcc2 (none) (Microsoft Hyper-V Remote Desktop Virtualization)
fd149e91-82e0-4a7d-afa6-2a4166cbd7c0 hv_util (Microsoft Hyper-V Heartbeat)

6 years agosleep: Move the error level debugging for write_mode and write_state
Mario Limonciello [Thu, 29 Mar 2018 13:56:23 +0000 (08:56 -0500)]
sleep: Move the error level debugging for write_mode and write_state

This makes it more consistent with other code used in the file.

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
6 years agosleep: Add support for setting a disk offset when hibernating
Mario Limonciello [Thu, 8 Mar 2018 08:41:50 +0000 (02:41 -0600)]
sleep: Add support for setting a disk offset when hibernating

The Linux kernel is adding support for configuring the offset
into a disk.  This allows swapfiles to be more usable as users
will no longer need to set the offset on their kernel command
line.

Use this API in systemd when hibernating as well.

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
6 years agoMerge pull request #8681 from keszybz/assorted-style-fixes
Lennart Poettering [Mon, 9 Apr 2018 09:32:51 +0000 (11:32 +0200)]
Merge pull request #8681 from keszybz/assorted-style-fixes

Assorted style fixes

6 years agosystemctl: pass BUS_MAP_STRDUP when needed (#8682)
Zbigniew Jędrzejewski-Szmek [Sun, 8 Apr 2018 06:12:18 +0000 (08:12 +0200)]
systemctl: pass BUS_MAP_STRDUP when needed (#8682)

This fixes an assert in "systemctl list-dependencies".
Follow-up for a7e4861c7471bfe563078d11acbcecbf2d755462.

6 years agotime-sync-wait: trivial style fixes
Zbigniew Jędrzejewski-Szmek [Sat, 7 Apr 2018 17:19:49 +0000 (19:19 +0200)]
time-sync-wait: trivial style fixes

6 years agosd-event: use _cleanup_ to manage temporary references
Zbigniew Jędrzejewski-Szmek [Sat, 7 Apr 2018 17:14:37 +0000 (19:14 +0200)]
sd-event: use _cleanup_ to manage temporary references

6 years agoanalyze: give a hint what is it means that boot is still active
Zbigniew Jędrzejewski-Szmek [Sat, 7 Apr 2018 16:43:47 +0000 (18:43 +0200)]
analyze: give a hint what is it means that boot is still active

$ build/systemd-analyze time
Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=0).
Please try again later.
Hint: Use 'systemctl list-jobs' to see active jobs

6 years agocore: minor comment update
Zbigniew Jędrzejewski-Szmek [Wed, 4 Apr 2018 12:36:56 +0000 (14:36 +0200)]
core: minor comment update

6 years agodissect: drop unnecessary parenthesis
Zbigniew Jędrzejewski-Szmek [Wed, 4 Apr 2018 07:05:56 +0000 (09:05 +0200)]
dissect: drop unnecessary parenthesis

6 years agoanalyze: Do no require a full d-bus bus for the plot command (#8539)
Guillem Jover [Sat, 7 Apr 2018 18:02:20 +0000 (20:02 +0200)]
analyze: Do no require a full d-bus bus for the plot command (#8539)

The plot command requires a full d-bus bus to fetch the host
information, which seems rather optional, and having a running dbus
daemon is not always desirable. So instead, we try to acquire a full
bus, and if that fails we acquire the systemd bus, in which case we
omit the host information from the output.

We refactor acquire_bus() into two new functions which in addition
makes the call sites clearer.

6 years agosystemd-udevd: limit children-max by available memory (#8668)
Martin Wilck [Sat, 7 Apr 2018 15:33:48 +0000 (17:33 +0200)]
systemd-udevd: limit children-max by available memory (#8668)

Udev workers consume typically 50-100MiB virtual memory.
On systems with lots of CPUs and relatively low memory, that may
easily cause workers to be OOM-killed.

This patch limits the number of workers to 8 per GiB memory.
But don't let the limit drop below the smallest value we had
without this patch (8 + 1 * 2 = 10); on small systems, udev's
memory footprint is likely lower.