platform/upstream/systemd.git
6 years agoCODING_STYLE: document why O_NONBLOCK makes sense when opening regular files, too
Lennart Poettering [Fri, 9 Mar 2018 20:35:48 +0000 (21:35 +0100)]
CODING_STYLE: document why O_NONBLOCK makes sense when opening regular files, too

6 years agosystemd-inhibit: ignore signal interrupt from keyboard (#8569)
Christian Hesse [Wed, 28 Mar 2018 19:58:10 +0000 (21:58 +0200)]
systemd-inhibit: ignore signal interrupt from keyboard (#8569)

By default both processes, systemd-inhibit and the forked one, receive
the signals. Pressing Ctrl+C on the keyboard results in SIGINT being
sent to the processes, followed by SIGTERM being sent to the forked
process when systemd-inhibit exits. This can cause trouble when the
forked process does not clean up properly but exit immediately.

Instead make systemd-inhibit ignore SIGINT, leaving it to the forked
process to clean up and exit.

6 years agodoc: merge docs/ dir → doc/
Lennart Poettering [Wed, 28 Mar 2018 14:58:37 +0000 (16:58 +0200)]
doc: merge docs/ dir → doc/

It's weird having two subdirs for documentation, let's unify this in
one.

6 years agosystemctl: refuse to edit masked units (#8602)
Zbigniew Jędrzejewski-Szmek [Wed, 28 Mar 2018 15:25:04 +0000 (17:25 +0200)]
systemctl: refuse to edit masked units (#8602)

Note: in check_triggering_units 'path' will be allocated twice. This is a
conscious choice, this way the implementation is simpler and not worth
optimizing.

Fixes #8519.

6 years agobus-util: add flags for bus_map_all_properties() (#8546)
Yu Watanabe [Wed, 28 Mar 2018 11:37:27 +0000 (20:37 +0900)]
bus-util: add flags for bus_map_all_properties() (#8546)

This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL.
If BUS_MAP_STRDUP is set, then each "s" message is duplicated.
If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is
written to a bool pointer.

Follow-up for #8488.
See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.

6 years agocore: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)
Krzysztof Nowicki [Wed, 28 Mar 2018 11:36:33 +0000 (13:36 +0200)]
core: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)

The initial fix for relabelling the cgroup filesystem for
SELinux delivered in commit 8739f23e3 was based on the assumption that
the cgroup filesystem is already populated once mount_setup() is
executed, which was true for my system. What I wasn't aware is that this
is the case only when another instance of systemd was running before
this one, which can happen if systemd is used in the initrd (for ex. by
dracut).

In case of a clean systemd start-up the cgroup filesystem is actually
being populated after mount_setup() and does not need relabelling as at
that moment the SELinux policy is already loaded. Since however the root
cgroup filesystem was remounted read-only in the meantime this operation
will now fail.

To fix this check for the filesystem mount flags before relabelling and
only remount ro->rw->ro if necessary and leave the filesystem read-write
otherwise.

Fixes #7901.

6 years agoMerge pull request #8140 from stuarthayes/new
Lennart Poettering [Wed, 28 Mar 2018 11:33:06 +0000 (13:33 +0200)]
Merge pull request #8140 from stuarthayes/new

udev: network device naming improvements (sr-iov, npar, slots)

6 years agobacklight: use current brightness if no saved value to trigger clamping (#8526)
Sebastian Reichel [Wed, 28 Mar 2018 11:32:27 +0000 (13:32 +0200)]
backlight: use current brightness if no saved value to trigger clamping (#8526)

This reads current brightness value in case it has not yet been
saved. This results in the brightness properly being clamped.

6 years agoMerge pull request #8600 from keszybz/oss-fuzz-again
Lennart Poettering [Wed, 28 Mar 2018 11:01:37 +0000 (13:01 +0200)]
Merge pull request #8600 from keszybz/oss-fuzz-again

Fuzzing- and test-related fixes

6 years agonspawn: do not insist on locking read-only container on readonly fs (#8589)
Lauri Tirkkonen [Wed, 28 Mar 2018 10:57:21 +0000 (13:57 +0300)]
nspawn: do not insist on locking read-only container on readonly fs (#8589)

6 years agoFix compilation w/o smack (#8593)
Zbigniew Jędrzejewski-Szmek [Wed, 28 Mar 2018 10:54:26 +0000 (12:54 +0200)]
Fix compilation w/o smack (#8593)

6 years agoshared/specifier: use realloc to free some memory after specifier expansion
Zbigniew Jędrzejewski-Szmek [Wed, 28 Mar 2018 08:33:40 +0000 (10:33 +0200)]
shared/specifier: use realloc to free some memory after specifier expansion

This is a separate commit only because it actually *increases* memory allocations:
==3256==   total heap usage: 100,120 allocs, 100,120 frees, 13,097,140 bytes allocated
to
==4690==   total heap usage: 100,121 allocs, 100,121 frees, 14,198,329 bytes allocated

Essentially, we do a little more work to reduce the memory footprint a bit. For a
test where we just allocate the memory and drop it soon afterwards, this is not
beneficial, but it should still be useful for a long running program.

6 years agoshared/specifier: be less extravagant with memory allocations
Zbigniew Jędrzejewski-Szmek [Wed, 28 Mar 2018 08:15:44 +0000 (10:15 +0200)]
shared/specifier: be less extravagant with memory allocations

ubsan times out because we do too many allocations:

$ valgrind build/fuzz-unit-file test/fuzz-regressions/fuzz-unit-file/oss-fuzz-6977-full
...
test/fuzz-regressions/fuzz-unit-file/oss-fuzz-6977-full... ok
==1757==
==1757== HEAP SUMMARY:
==1757==     in use at exit: 0 bytes in 0 blocks
==1757==   total heap usage: 199,997 allocs, 199,997 frees, 90,045,318,585 bytes allocated

...
==3256==   total heap usage: 100,120 allocs, 100,120 frees, 13,097,140 bytes allocated

https://oss-fuzz.com/v2/issue/4651449704251392/6977 should now be really fixed.

e3c3d6761b3e7d was the first attempt, but even with this change, e3c3d6761b3e7d
still makes sense.

6 years agocore/main: preserve return value under valgrind
Zbigniew Jędrzejewski-Szmek [Tue, 27 Mar 2018 20:09:25 +0000 (22:09 +0200)]
core/main: preserve return value under valgrind

6 years agocore/socket: use chase_symlinks to find binary inside chroot when looking for SELinux...
Filipe Brandenburger [Wed, 28 Mar 2018 07:00:42 +0000 (00:00 -0700)]
core/socket: use chase_symlinks to find binary inside chroot when looking for SELinux label (#8591)

This is a follow up for this comment from @poettering:
https://github.com/systemd/systemd/pull/8405#discussion_r175719214

This updates PR #8405.

Tested manually using the same commands in
https://lists.freedesktop.org/archives/systemd-devel/2018-March/040478.html.

6 years agoMerge pull request #8576 from keszybz/oss-fuzz
Evgeny Vereshchagin [Tue, 27 Mar 2018 17:30:02 +0000 (20:30 +0300)]
Merge pull request #8576 from keszybz/oss-fuzz

oss-fuzz adjustments and other cleanups

6 years agocore: use setreuid/setregid trick to create session keyring with right ownership...
Dimitri John Ledkov [Tue, 27 Mar 2018 10:58:10 +0000 (11:58 +0100)]
core: use setreuid/setregid trick to create session keyring with right ownership (#8447)

Re-use the hacks used to link user keyring, when creating the session
keyring. This way changing ownership of the keyring is not required, and thus
incovation_id can be correctly created in restricted environments.

Creating invocation_id with root permissions works and linking it into session
keyring works, as at that point session keyring is possessed.

Simple way to validate this is with following commands:

$ journalctl -f &
$ sudo systemd-run --uid 1000 /bin/sh -c 'keyctl describe @s; keyctl list @s; keyctl read `keyctl search @s user invocation_id`'

which now works in LXD containers as well as on the host.

Fixes: https://github.com/systemd/systemd/issues/7655

6 years agojournal-file: we can't use a chain cache entry if we don't know where it starts ...
Lennart Poettering [Tue, 27 Mar 2018 07:36:49 +0000 (09:36 +0200)]
journal-file: we can't use a chain cache entry if we don't know where it starts (#8542)

It might happen that we try to bisect through a chain of offset arrays in the
journal whose last element was just allocated but no item yet written
to. In that case that array will be all NUL, but it might still end up
in our array chain cache. If it does, we cannot use it for bisection,
since for bisection we need to know the value of the first entry in that
array, but if it's uninitialized it does not have a first value. Hence,
as a simple fix, in this unlikely case, simply ignore the chain cache.

This is supposed to fix the issue pointed out in #8432, but in a more
permissive way, as this case isn't strictly a badly formatted journal
but actually a valid state (though one within a very short time window),
and we should make the best of it, and handle it gracefully.

Background: in each journal file entries are linked up in large arrays
of offsets. In each array the entries are strictly ordered by the
offsets of the entries, which permits search by bisection. These arrays
are allocated with a fixed size and then filled up as entries are added
to the journal file. If an array is fully filled up, a new array
(double in size as the old one) is appended to the journal file, and
linked up. This means, the journal file will contain a series of chained
up arrays, each time doubling in size, and strictly ordered. When
looking for an entry we maintain a "chain cache", which allows us to
bypass traversing the chain in full if we look for entries close to each
other in a short time. With the fix above we make sure we don't
erroneously use a chain cache item that doesn't carry enough information
for this bisection to work.

Original issue identified (with patch) by @Kxuan.

Replaces: #8432

6 years agolabel: rework label_fix() implementations (#8583)
Lennart Poettering [Tue, 27 Mar 2018 05:38:26 +0000 (07:38 +0200)]
label: rework label_fix() implementations (#8583)

This reworks the SELinux and SMACK label fixing calls in a number of
ways:

1. The two separate boolean arguments of these functions are converted
   into a flags type LabelFixFlags.

2. The operations are now implemented based on O_PATH. This should
   resolve TTOCTTOU races between determining the label for the file
   system object and applying it, as it it allows to pin the object
   while we are operating on it.

3. When changing a label fails we'll query the label previously set, and
   if matches what we want to set anyway we'll suppress the error.

Also, all calls to label_fix() are now (void)ified, when we ignore the
return values.

Fixes: #8566

6 years agoNEWS: Warn about predictable network naming changes
Stuart Hayes [Wed, 14 Feb 2018 20:44:47 +0000 (15:44 -0500)]
NEWS: Warn about predictable network naming changes

6 years agoudev: net_id: Improve predictable names for NPAR devices
Stuart Hayes [Thu, 18 Jan 2018 20:14:56 +0000 (15:14 -0500)]
udev: net_id: Improve predictable names for NPAR devices

NPAR is a technology that allows a single network interface to
be divided into number of partitions. The partitions show up
as functions on the same PCI device... when there are more than
8 functions, ARI (alternative routing-ID interpretation) is
used. With ARI is enabled, the 8 bit field that normally has 5
bits for the PCI device and 3 bits for the PCI function is instead
interpreted as (implicit) device 0, with 8 bits for the function
number.

Because the linux kernel exposes the PCI device/function numbers
to userspace the same regardless of whether ARI is enabled,
systemd predictable device naming can generate unpredictable
names in this case, because network names using the PCI slot use
the function number, but not the device number, causing systemd
to generate the same name for mulitple network devices (so some
will revert to the "ethX" names).

With this patch, device naming code checks if ARI is enabled for
a PCI network device, and uses the full 8-bit function number
for naming to avoid this situation. This should improve
readability and predictability of device names.

Here is an example of how this change would affect naming:

before patch  |  after patch
-----------------------------
ens2f0        |  ens2f0        NPAR partition 0 (in PCI slot 2)
ens2f1        |  ens2f1        NPAR partition 1
...
ens2f7        |  ens2f7        NPAR partition 7
eth1          |  ens2f8        NPAR partition 8
eth2          |  ens2f9        NPAR partition 9

6 years agoudev: net_id: Improve predictable names for SR-IOV virtual devices
Stuart Hayes [Wed, 17 Jan 2018 19:31:55 +0000 (14:31 -0500)]
udev: net_id: Improve predictable names for SR-IOV virtual devices

With PCI SR-IOV, a number of virtual network devices can be enabled,
all of which share the same physical network device.  Currently,
udev generates names for SR-IOV virtual functions as if they were
independent network devices.

With this change, the predictable network device naming code will
check if a network device is an SR-IOV virtual device, and will
generate a name based on the physical PCI device plus a "v%u"
suffix.  This should improve readability and predictability of
device names.

Here is an example of how this change would affect naming:

before patch  |  after patch
-----------------------------
eno1          |  eno1          onboard NIC, physical function
enp101s0f0    |  eno1v0        onboard NIC, SR-IOV virtual func 0
enp101s0f1    |  eno1v1        onboard NIC, SR-IOV virtual func 1

6 years agoudev: net_id: search parent devices for PCI slot number
Stuart Hayes [Tue, 16 Jan 2018 21:08:10 +0000 (16:08 -0500)]
udev: net_id: search parent devices for PCI slot number

To generate predictable network device names, the code in
udev-builting-net_id.c tries to match the PCI device address
of the network device to the entries in /sys/bus/pci/slots.
However, sometimes the slot number is not associated the
network controller PCI device itself, but rather with one of
its parents.

This change will try to find a match in /sys/bus/pci/slots for
the parents of the PCI network device, if it doesn't find a
match for the device itself.

6 years agoMerge pull request #8554 from poettering/chase-trail-slash
Zbigniew Jędrzejewski-Szmek [Mon, 26 Mar 2018 16:00:08 +0000 (18:00 +0200)]
Merge pull request #8554 from poettering/chase-trail-slash

 fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()

6 years agoFix for alphabetical ordering (#8581)
mourikwa [Mon, 26 Mar 2018 15:50:35 +0000 (17:50 +0200)]
Fix for alphabetical ordering (#8581)

I read the addition of the purism laptop keyboard and noticed
that the 60-keyboard.hwdb file could/should have an alphabetical ordering.
I scratched that itch with this commit.

6 years agocore: don't include libmount.h in a header file (#8580)
Michael Olbrich [Mon, 26 Mar 2018 15:34:53 +0000 (17:34 +0200)]
core: don't include libmount.h in a header file (#8580)

linux/fs.h sys/mount.h, libmount.h and missing.h all include MS_*
definitions.

To avoid problems, only one of linux/fs.h, sys/mount.h and libmount.h
should be included. And missing.h must be included last.

Without this, building systemd may fail with:

In file included from [...]/libmount/libmount.h:31:0,
                 from ../systemd-238/src/core/manager.h:23,
                 from ../systemd-238/src/core/emergency-action.h:37,
                 from ../systemd-238/src/core/unit.h:34,
                 from ../systemd-238/src/core/dbus-timer.h:25,
                 from ../systemd-238/src/core/timer.c:26:
[...]/sys/mount.h:57:2: error: expected identifier before numeric constant

6 years agoMerge pull request #8562 from keszybz/docs
Lennart Poettering [Mon, 26 Mar 2018 13:34:39 +0000 (15:34 +0200)]
Merge pull request #8562 from keszybz/docs

Man page and log message fixes

6 years agoREADME: mention systemd-stable
Zbigniew Jędrzejewski-Szmek [Mon, 26 Mar 2018 08:40:45 +0000 (10:40 +0200)]
README: mention systemd-stable

Fixes #8564.

https://www.freedesktop.org/wiki/Software/systemd/Backports/ has already been
adjusted.

6 years agobasic/strbuf: include empty strings in count
Zbigniew Jędrzejewski-Szmek [Mon, 26 Mar 2018 08:32:42 +0000 (10:32 +0200)]
basic/strbuf: include empty strings in count

Not that it matters much, but it seems cleaner to also count those
inputs, even if they do not consume extra storage space.

The test is extended to include an empty input and counts in the test are
adjusted to include it.

6 years agobasic/strbuf: use structured initalizers to shorten code
Zbigniew Jędrzejewski-Szmek [Mon, 26 Mar 2018 08:26:39 +0000 (10:26 +0200)]
basic/strbuf: use structured initalizers to shorten code

6 years agojournal: use structured initalizer
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 20:44:05 +0000 (22:44 +0200)]
journal: use structured initalizer

6 years agotree-wide: add bsearch_safe and use where appropriate
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 20:43:43 +0000 (22:43 +0200)]
tree-wide: add bsearch_safe and use where appropriate

Should fix #8557.

6 years agofuzz-unit-file: add __has_feature(memory_sanitizer) when skipping ListenNetlink=
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 20:26:13 +0000 (22:26 +0200)]
fuzz-unit-file: add __has_feature(memory_sanitizer) when skipping ListenNetlink=

https://clang.llvm.org/docs/MemorySanitizer.html#id5 documents this
check as the way to detect MemorySanitizer at compilation time. We
only need to skip the test if MemorySanitizer is used.

Also, use this condition in cg_slice_to_path(). There, the code that is
conditionalized is not harmful in any way (it's just unnecessary), so remove
the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION condition.

Fixes #8482.

6 years agoMerge pull request #8578 from yuwata/resolve-tool-cleanup
Zbigniew Jędrzejewski-Szmek [Mon, 26 Mar 2018 12:54:30 +0000 (14:54 +0200)]
Merge pull request #8578 from yuwata/resolve-tool-cleanup

resolve-tool: small cleanups

6 years agofuzz-unit-file: adjust check for ListenNetlink yet again
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 20:11:44 +0000 (22:11 +0200)]
fuzz-unit-file: adjust check for ListenNetlink yet again

The test for ListenNetlink would abort the loop if a line longer then LINE_MAX
was encountered (read_line() returns -ENOBUFS in that case). Let's use the
the line length limit that the unit file parses uses.

https://oss-fuzz.com/v2/issue/5546208027213824/7094.

6 years agoresolve: always shows global settings
Yu Watanabe [Sun, 25 Mar 2018 09:57:19 +0000 (18:57 +0900)]
resolve: always shows global settings

6 years agocore/service: rework the hold-off time over message
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 13:43:52 +0000 (14:43 +0100)]
core/service: rework the hold-off time over message

"hold-off" is apparently confusing, because we also have HoldoffTimeoutSec=.
Let's use RestartSec= directly in the message.

Fixes #5472.

6 years agoman: add an additional note about journalctl -u
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 13:27:48 +0000 (14:27 +0100)]
man: add an additional note about journalctl -u

Fixes #5387.

I kept the _SYSTEMD_UNIT= example because it is easy to understand and
not very verbose. _SYSTEMD_CGROUP has much longer entries which do not
fit well in the narrow man page. Instead, I added an explanation of what
-u is translated into.

6 years agoman: mention that oldest journal files are removed
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 13:04:13 +0000 (14:04 +0100)]
man: mention that oldest journal files are removed

Fixes #7225.

6 years agoman: add a note about "archived" journal files and when files can be copied
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 12:54:20 +0000 (13:54 +0100)]
man: add a note about "archived" journal files and when files can be copied

Issue #6673 requests advice on backup strategy. But the right backup strategy
depends on many factors, too many to describe in a man page. So let's just
provide some general information which files are mutable and that it is always
safe to use/copy files.

Closes #6673.

6 years agoman: add a note about $XDG_SEAT and $XDG_VTNR to pam_systemd(8)
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 12:15:19 +0000 (13:15 +0100)]
man: add a note about $XDG_SEAT and $XDG_VTNR to pam_systemd(8)

Issue #6499 requests that a mention that those varibles can be set in the
environment is added. But the man page already says that. There isn't much
detail, but a man page does not need to and in this case should not include
all the details. Instead a note is added that those vars can be derived from
$DISPLAY.

Closes #6499.

6 years agoman: add link and list of known attrs to systemd-gpt-auto-generator(8)
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 11:59:09 +0000 (12:59 +0100)]
man: add link and list of known attrs to systemd-gpt-auto-generator(8)

Fixes #7859.

6 years agoman: add missing headers to glib-event-glue.c
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 15:38:51 +0000 (16:38 +0100)]
man: add missing headers to glib-event-glue.c

6 years agoman: fix compilation of journal-iterate-poll.c
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 15:35:02 +0000 (16:35 +0100)]
man: fix compilation of journal-iterate-poll.c

Our examples should compile...

6 years agoman: drop license header in glib-event-glue.c
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 19:02:49 +0000 (20:02 +0100)]
man: drop license header in glib-event-glue.c

We're moving towards just SPDX license identifiers, and the boilerplate
is especially annoying in a man page. Also adjust to the smaller indentation
to make the code fit better on a page.

6 years agoman: move examples out of sd_journal_get_fd into separate files
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 15:32:17 +0000 (16:32 +0100)]
man: move examples out of sd_journal_get_fd into separate files

man/.dir-locals is to keep indentation under control.

This makes it much easier to compile and run those examples, c.f. #7578.

v2:
- copy more of .dir-locals.el from the root to man/.dir-locals.el
  (I though emacs would inherit from the one in the parent dir, but
   it seems it just uses its own broken defaults, including
   indent-tabs-mode by default.)

6 years agoresolve: actually shows information about all specified interfaces
Yu Watanabe [Tue, 20 Mar 2018 09:11:39 +0000 (18:11 +0900)]
resolve: actually shows information about all specified interfaces

6 years agoMerge pull request #8565 from poettering/cocci-again
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 18:22:24 +0000 (19:22 +0100)]
Merge pull request #8565 from poettering/cocci-again

run all coccinelle again

6 years agoMerge pull request #8559 from poettering/integration-test-fixes
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 18:21:25 +0000 (19:21 +0100)]
Merge pull request #8559 from poettering/integration-test-fixes

make integration tests pass again

6 years agococcinelle: run no-if-assignments.cocci again
Lennart Poettering [Fri, 23 Mar 2018 15:33:38 +0000 (16:33 +0100)]
coccinelle: run no-if-assignments.cocci again

6 years agococcinelle: run safe_fclose.cocci again
Lennart Poettering [Fri, 23 Mar 2018 15:32:48 +0000 (16:32 +0100)]
coccinelle: run safe_fclose.cocci again

6 years agococcinelle: run while-true.cocci again
Lennart Poettering [Fri, 23 Mar 2018 15:32:26 +0000 (16:32 +0100)]
coccinelle: run while-true.cocci again

6 years agoPartially revert "seccomp: add mmap and address family restrictions for MIPS" (#8563)
James Cowgill [Fri, 23 Mar 2018 15:04:16 +0000 (15:04 +0000)]
Partially revert "seccomp: add mmap and address family restrictions for MIPS" (#8563)

This reverts the mmap parts of f5aeac1439d64905c7b1b57042c39589dd31e3a6,
but keeps the part which restricts address families which works
correctly.

Unfortunately the MIPS toolchains still do not implement PT_GNU_STACK.
This means that while the commit to restrict mmap on MIPS was "correct",
it had the side effect of causing pthread_create to fail because glibc tries
to allocate an executable stack for new threads in the absense of
PT_GNU_STACK. We should wait until PT_GNU_STACK is implemented in all
the relevant parts of the toolchain (at least gcc and glibc) before
enabling this again.

6 years agorun-coccinelle.sh: use set -x for showing command line of "spatch"
Lennart Poettering [Fri, 23 Mar 2018 14:44:10 +0000 (15:44 +0100)]
run-coccinelle.sh: use set -x for showing command line of "spatch"

Let's make sure run-coccinelle.sh generates similar output as
run-integration-tests.sh, hence use the same "set -x" logic.

6 years agococcinelle: run const-strlen.cocci again
Lennart Poettering [Fri, 23 Mar 2018 14:41:33 +0000 (15:41 +0100)]
coccinelle: run const-strlen.cocci again

6 years agorun-integration-tests: show number of tests run
Lennart Poettering [Fri, 23 Mar 2018 09:02:22 +0000 (10:02 +0100)]
run-integration-tests: show number of tests run

6 years agorun-integration-tests: show make command line executed
Lennart Poettering [Fri, 23 Mar 2018 08:51:02 +0000 (09:51 +0100)]
run-integration-tests: show make command line executed

That makes it much easier to figure out what to type to just run one
specific test for debugging.

6 years agotest: bypass selinux integration test if selinux policy devel package is not installed
Lennart Poettering [Fri, 23 Mar 2018 08:48:15 +0000 (09:48 +0100)]
test: bypass selinux integration test if selinux policy devel package is not installed

With this "sudo ./run-integration-tests.sh" should work fully without
exception, even on systems lacking SELinux (in which case that test will
just be skipped)

6 years agostat-util: fix fd_is_network_ns()
Lennart Poettering [Fri, 23 Mar 2018 08:47:04 +0000 (09:47 +0100)]
stat-util: fix fd_is_network_ns()

This was broken in 77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0. My fault.

Fixes: #8543

6 years agocore: delay adding target dependencies until all units are loaded and aliases resolve...
Michal Sekletar [Fri, 23 Mar 2018 14:28:06 +0000 (15:28 +0100)]
core: delay adding target dependencies until all units are loaded and aliases resolved (#8381)

Currently we add target dependencies while we are loading units. This
can create ordering loops even if configuration doesn't contain any
loop. Take for example following configuration,

$ systemctl get-default
multi-user.target

$ cat /etc/systemd/system/test.service
[Unit]
After=default.target

[Service]
ExecStart=/bin/true

[Install]
WantedBy=multi-user.target

If we encounter such unit file early during manager start-up (e.g. load
queue is dispatched while enumerating devices due to SYSTEMD_WANTS in
udev rules) we would add stub unit default.target and we order it Before
test.service. At the same time we add implicit Before to
multi-user.target. Later we merge two units and we create ordering cycle
in the process.

To fix the issue we will now never add any target dependencies until we
loaded all the unit files and resolved all the aliases.

6 years agoMerge pull request #8552 from keszybz/test-improvements
Lennart Poettering [Fri, 23 Mar 2018 14:26:54 +0000 (15:26 +0100)]
Merge pull request #8552 from keszybz/test-improvements

Test and diagnostics improvements

6 years agotree-wide: tabs suck (#8527)
Lennart Poettering [Fri, 23 Mar 2018 14:21:35 +0000 (15:21 +0100)]
tree-wide: tabs suck (#8527)

6 years agobacklight: minor modernizations (#8528)
Lennart Poettering [Fri, 23 Mar 2018 14:20:34 +0000 (15:20 +0100)]
backlight: minor modernizations (#8528)

Use strjoina() and STR_IN_SET()

6 years agoMerge pull request #8529 from poettering/logind-fixlets
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 14:19:32 +0000 (15:19 +0100)]
Merge pull request #8529 from poettering/logind-fixlets

three trivial logind improvements

6 years agoudev: don't label high-button mice as joysticks (#8493)
Peter Hutterer [Fri, 23 Mar 2018 14:15:41 +0000 (00:15 +1000)]
udev: don't label high-button mice as joysticks (#8493)

If a device exposes more than 16 mouse buttons, we run into the BTN_JOYSTICK
range, also labelling it as joystick. And since 774ff9b this results in only
ID_INPUT_JOYSTICK but no ID_INPUT_MOUSE.

Fixes #8460

6 years agoMerge pull request #8530 from poettering/include-is-obsolete
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 14:13:02 +0000 (15:13 +0100)]
Merge pull request #8530 from poettering/include-is-obsolete

actively say that .include is obsolete

6 years agoMerge pull request #8533 from poettering/bootup-shutdown-phase2
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 14:11:46 +0000 (15:11 +0100)]
Merge pull request #8533 from poettering/bootup-shutdown-phase2

extend docs on second phase of shutdown and watchdog handling

6 years agoMerge pull request #8534 from poettering/safe-atoi-full
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 11:30:12 +0000 (12:30 +0100)]
Merge pull request #8534 from poettering/safe-atoi-full

some improvements to safe_atou() to allow specification of arbitrary bases

6 years agotree-wide: warn when a directory path already exists but has bad mode/owner/type
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 12:03:41 +0000 (13:03 +0100)]
tree-wide: warn when a directory path already exists but has bad mode/owner/type

When we are attempting to create directory somewhere in the bowels of /var/lib
and get an error that it already exists, it can be quite hard to diagnose what
is wrong (especially for a user who is not aware that the directory must have
the specified owner, and permissions not looser than what was requested). Let's
print a warning in most cases. A warning is appropriate, because such state is
usually a sign of borked installation and needs to be resolved by the adminstrator.

$ build/test-fs-util

Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing.
   (or)
Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing.
   (or)
Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing.

Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting.

No functional change except for the new log lines.

6 years agoMerge pull request #8553 from poettering/take-take
Alan Jenkins [Thu, 22 Mar 2018 22:33:38 +0000 (22:33 +0000)]
Merge pull request #8553 from poettering/take-take

introduce TAKE_FD() and TAKE_PTR() macros

6 years agounits: document why systemd-time-wait-sync.service conditions on CAP_SYS_TIME (#8555)
Lennart Poettering [Thu, 22 Mar 2018 20:41:54 +0000 (21:41 +0100)]
units: document why systemd-time-wait-sync.service conditions on CAP_SYS_TIME (#8555)

As requested by @evverx in https://github.com/systemd/systemd/pull/8537#issuecomment-375122615

6 years agovconsole: minor modernizations
Lennart Poettering [Thu, 22 Mar 2018 16:12:23 +0000 (17:12 +0100)]
vconsole: minor modernizations

6 years agovconsole-setup: don't concat strv if we don't need to (i.e. not in debug log mode)
Lennart Poettering [Thu, 22 Mar 2018 16:07:18 +0000 (17:07 +0100)]
vconsole-setup: don't concat strv if we don't need to (i.e. not in debug log mode)

6 years agomacro: introduce new TAKE_FD() macro
Lennart Poettering [Thu, 22 Mar 2018 16:04:29 +0000 (17:04 +0100)]
macro: introduce new TAKE_FD() macro

This is similar to TAKE_PTR() but operates on file descriptors, and thus
assigns -1 to the fd parameter after returning it.

Removes 60 lines from our codebase. Pretty good too I think.

6 years agosleep-config: replace USE() macro with TAKE_PTR() usage
Lennart Poettering [Thu, 22 Mar 2018 15:59:46 +0000 (16:59 +0100)]
sleep-config: replace USE() macro with TAKE_PTR() usage

let's use the new generic macor instead of the locally defined, specific
one.

6 years agomacro: introduce TAKE_PTR() macro
Lennart Poettering [Thu, 22 Mar 2018 15:53:26 +0000 (16:53 +0100)]
macro: introduce TAKE_PTR() macro

This macro will read a pointer of any type, return it, and set the
pointer to NULL. This is useful as an explicit concept of passing
ownership of a memory area between pointers.

This takes inspiration from Rust:

https://doc.rust-lang.org/std/option/enum.Option.html#method.take

and was suggested by Alan Jenkins (@sourcejedi).

It drops ~160 lines of code from our codebase, which makes me like it.
Also, I think it clarifies passing of ownership, and thus helps
readability a bit (at least for the initiated who know the new macro)

6 years agosd-device: make use of the fact that log_debug_errno() returns the error passed in
Lennart Poettering [Thu, 22 Mar 2018 18:59:49 +0000 (19:59 +0100)]
sd-device: make use of the fact that log_debug_errno() returns the error passed in

6 years agofs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()
Lennart Poettering [Thu, 22 Mar 2018 18:54:24 +0000 (19:54 +0100)]
fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()

This rearranges chase_symlinks() a bit: if no special flags are
specified it will now revert to behaviour before
b12d25a8d631af00b200e7aa9dbba6ba4a4a59ff. However, if the new
CHASE_TRAIL_SLASH flag is specified it will follow the behaviour
introduced by that commit.

I wasn't sure which one to make the beaviour that requires specification
of a flag to enable. I opted to make the "append trailing slash"
behaviour the one to enable by a flag, following the thinking that the
function should primarily be used to generate a normalized path, and I
am pretty sure a path without trailing slash is the more "normalized"
one, as the trailing slash is not really a part of it, but merely a
"decorator" that tells various system calls to generate ENOTDIR if the
path doesn't refer to a path.

Or to say this differently: if the slash was part of normalization then
we really should add it in all cases when the final path is a directory,
not just when the user originally specified it.

Fixes: #8544
Replaces: #8545

6 years agoman/udevadm: remove superfluous --version from subcommands (#8549)
Jan Synacek [Thu, 22 Mar 2018 18:24:37 +0000 (19:24 +0100)]
man/udevadm: remove superfluous --version from subcommands (#8549)

There's need to show the program specific --version for each subcommand.

6 years agoman: add a note that nspawn gives access to network by default
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 15:07:20 +0000 (16:07 +0100)]
man: add a note that nspawn gives access to network by default

Fixes #6546.

6 years agobasic/mkdir: convert bool flag to enum
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 11:38:01 +0000 (12:38 +0100)]
basic/mkdir: convert bool flag to enum

In preparation for subsequent changes...

6 years agotest-execute: skip exec-specifier-interpolation if perl is missing
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 08:24:14 +0000 (09:24 +0100)]
test-execute: skip exec-specifier-interpolation if perl is missing

6 years agotest-execute: allow sit0@ to exist in private network namespace
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 07:50:10 +0000 (08:50 +0100)]
test-execute: allow sit0@ to exist in private network namespace

It's always visible:

$ sudo modprobe sit
$ sudo unshare -n ip l
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    ...
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    ...

6 years agotest-execute: simplify checks if grep output is empty
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 07:42:02 +0000 (08:42 +0100)]
test-execute: simplify checks if grep output is empty

grep already indicates if it matched anything by return value.
Additional advantage is then that if the test fails, the unexpected
matching lines are visible in the log output.

6 years agotests: skip udev-test when perl is not installed
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 07:34:21 +0000 (08:34 +0100)]
tests: skip udev-test when perl is not installed

6 years agoseccomp: add mmap and address family restrictions for MIPS (#8547)
James Cowgill [Thu, 22 Mar 2018 14:40:44 +0000 (14:40 +0000)]
seccomp: add mmap and address family restrictions for MIPS (#8547)

6 years agoMerge pull request #8531 from poettering/dhcp-server-mini-fixes
Lennart Poettering [Thu, 22 Mar 2018 14:36:48 +0000 (15:36 +0100)]
Merge pull request #8531 from poettering/dhcp-server-mini-fixes

some minor tweaks to sd-dhcp-server

6 years agoHACKING: small umask tweak for the rootpw (#8541)
Lennart Poettering [Thu, 22 Mar 2018 14:36:01 +0000 (15:36 +0100)]
HACKING: small umask tweak for the rootpw (#8541)

6 years agounits: disable systemd-time-sync-wait inside containers (#8537)
Peter A. Bigot [Thu, 22 Mar 2018 02:27:27 +0000 (21:27 -0500)]
units: disable systemd-time-sync-wait inside containers (#8537)

Fixes #8535

6 years agodoc/HACKING: show command to set root password in image (#8540)
Peter A. Bigot [Wed, 21 Mar 2018 22:56:33 +0000 (17:56 -0500)]
doc/HACKING: show command to set root password in image (#8540)

Fixes #8538

6 years agomain: add NoNewPrivileges config option (#8475)
juergbi [Wed, 21 Mar 2018 22:41:19 +0000 (23:41 +0100)]
main: add NoNewPrivileges config option (#8475)

This makes it possible to disable new privileges for the whole system.

6 years agoparse-util: similar to safe_atou16_full() add safe_atou_full()
Lennart Poettering [Wed, 21 Mar 2018 21:31:40 +0000 (22:31 +0100)]
parse-util: similar to safe_atou16_full() add safe_atou_full()

What's good for uint16_t is also good for unsigned.

This is preparation for: #8140

6 years agoparse-util: introduce safe_atou16_full()
Lennart Poettering [Wed, 21 Mar 2018 21:27:19 +0000 (22:27 +0100)]
parse-util: introduce safe_atou16_full()

safe_atou16_full() is like safe_atou16() but also takes a base
parameter. safe_atou16() is then implemented as inline function on top
of it, passing 0 as base. Similar safe_atoux16() is reworked as inline
function too, with 16 as base.

6 years agoman: watchdog documentation improvements
Lennart Poettering [Wed, 21 Mar 2018 21:00:21 +0000 (22:00 +0100)]
man: watchdog documentation improvements

6 years agoman: document that there's a second phase of shutdown in bootup(7)
Lennart Poettering [Wed, 21 Mar 2018 19:57:06 +0000 (20:57 +0100)]
man: document that there's a second phase of shutdown in bootup(7)

6 years agodhcp-server: don't propagate erros up the event loop
Lennart Poettering [Wed, 21 Mar 2018 19:30:56 +0000 (20:30 +0100)]
dhcp-server: don't propagate erros up the event loop

If we can't send a message this is no reason to completely abort the
event handler.

Issue identified by Nandor Han <nandor.han@ge.com>, Sebastian Reichel
<sebastian.reichel@collabora.co.uk>.

Replaces: #8525

6 years agodhcp-sever: check properly for invalid fds
Lennart Poettering [Wed, 21 Mar 2018 19:30:29 +0000 (20:30 +0100)]
dhcp-sever: check properly for invalid fds

We generally just compare for negativity, not for equlity to -1, let's
do so here too.

6 years agodhcp_server_handle_message: don't pretend there was a difference between return code...
Lennart Poettering [Wed, 21 Mar 2018 19:29:43 +0000 (20:29 +0100)]
dhcp_server_handle_message: don't pretend there was a difference between return code 0 or 1

We ignore the difference anyway, hence let's systematically return 0.

6 years agodhcp-server: reduce level of indentation a bit
Lennart Poettering [Wed, 21 Mar 2018 19:29:07 +0000 (20:29 +0100)]
dhcp-server: reduce level of indentation a bit

Less indentation is good, let's do that where it's easy.

6 years agodhcp-server: introduce log_dhcp_server_errno()
Lennart Poettering [Wed, 21 Mar 2018 19:28:01 +0000 (20:28 +0100)]
dhcp-server: introduce log_dhcp_server_errno()

Sometimes we want to print the error number, hence do so properly, and
avoid to use strerror() which is not reentrant.