Commit graph

31430 commits

Author SHA1 Message Date
Lennart Poettering ab27086387 link-config: make initialization to -1 less weird
memset() is weird anyway, since it expects an "int" as second parameter,
which it then uses as a byte, i.e. as uint8_t or something like that.
But by passing -1 to it, things get particularly weird, as that relies
on sign expansion to do the right thing.
2017-12-14 19:51:25 +01:00
Lennart Poettering 673192494c coccinelle: automatically rewrite memset() to zero() or memzero() where we can
We are pretty good at this already, hence only a single case is actually
found by this.
2017-12-14 19:47:46 +01:00
Lennart Poettering fbd0b64f44
tree-wide: make use of new STRLEN() macro everywhere (#7639)
Let's employ coccinelle to do this for us.

Follow-up for #7625.
2017-12-14 19:02:29 +01:00
Kyle Walker 73ad712fcf core: Implement sync_with_progress()
In similar fashion to the previous change, sync() operations can stall
endlessly if cache is unable to be written out. In order to avoid an
unbounded hang, the sync takes place within a child process. Every 10
seconds (SYNC_TIMEOUT_USEC), the value of /proc/meminfo "Dirty" is checked
to verify it is smaller than the last iteration. If the sync is not making
progress for 3 successive iterations (SYNC_PROGRESS_ATTEMPTS), a SIGKILL is
sent to the sync process and the shutdown continues.
2017-12-14 11:46:03 -05:00
Iago López Galeiras f3d33947ea test: add smoke tests for --network-namespace-path
We create net ns with `ip netns`, pass the created ns to nspawn and
check the loopback interface is DOWN.
2017-12-14 17:34:26 +01:00
Lennart Poettering ea2a3c9e50 NEWS: update NEWS again, and prepare for a release tomorrow 2017-12-14 17:29:30 +01:00
Lennart Poettering cbd73c69ba meson: increase version numbers 2017-12-14 17:29:30 +01:00
Lennart Poettering 1142cbd76a
Merge pull request #7610 from poettering/stdio-nolocking
use __fsetlocking() to turn off thread locking in STDIO where applicable
2017-12-14 16:56:36 +01:00
Zbigniew Jędrzejewski-Szmek 82267a45dd hwdb: update
The changes in pci.ids, usb.ids, and the .hwdb files are almost always
additions. 20-OUI.hwdb drops a few names and replaces them by
"IEEE Registration Authority". I'm not sure what to do about this.
Many other removals do not seem to be removals of real entries, but
rather placeholder or generic names.
2017-12-14 16:01:24 +01:00
Zbigniew Jędrzejewski-Szmek af49df623e hwdb/ids_parser: use replacement chars for invalid characters
We have some more non-utf8 characters. Let's just replace them, this doesn't
matter much.
2017-12-14 15:47:39 +01:00
Zbigniew Jędrzejewski-Szmek c6801f502c meson-hwdb-update: fix undefined variable access
I added the test if an optional parameter is not empty, but that doesn't work
with -u. Provide an empty "fallback" value to fix the issue.

Also group the update steps so that it's easier to see what is going on.
2017-12-14 15:45:21 +01:00
Kyle Walker d5641e0d7e core: Implement timeout based umount/remount limit
Remount, and subsequent umount, attempts can hang for inaccessible network
based mount points. This can leave a system in a hard hang state that
requires a hard reset in order to recover. This change moves the remount,
and umount attempts into separate child processes. The remount and umount
operations will block for up to 90 seconds (DEFAULT_TIMEOUT_USEC). Should
those waits fail, the parent will issue a SIGKILL to the child and continue
with the shutdown efforts.

In addition, instead of only reporting some additional errors on the final
attempt, failures are reported as they occur.
2017-12-14 08:58:56 -05:00
Cong Wang f581267a02 sd-bus: fix a memory leak in message_new_reply() (#7636)
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2017-12-14 13:07:04 +01:00
Lennart Poettering e18c15413d
Merge pull request #7606 from yuwata/run-timer
run: allow to specify multiple timer options
2017-12-14 13:04:30 +01:00
Daniel Black a327431bd1 core: add EXTEND_TIMEOUT_USEC={usec} - prevent timeouts in startup/runtime/shutdown (#7214)
With Type=notify services, EXTEND_TIMEOUT_USEC= messages will delay any startup/
runtime/shutdown timeouts.

A service that hasn't timed out, i.e, start time < TimeStartSec,
runtime < RuntimeMaxSec and stop time < TimeoutStopSec, may by sending
EXTEND_TIMEOUT_USEC=, allow the service to continue beyond the limit for
the execution phase (i.e TimeStartSec, RunTimeMaxSec and TimeoutStopSec).

EXTEND_TIMEOUT_USEC= must continue to be sent (in the same way as
WATCHDOG=1) within the time interval specified to continue to reprevent
the timeout from occuring.

Watchdog timeouts are also extended if a EXTEND_TIMEOUT_USEC is greater
than the remaining time on the watchdog counter.

Fixes #5868.
2017-12-14 12:17:43 +01:00
Lennart Poettering e51faad3d5 busctl: let's make use of the log_error_errno() calls 2017-12-14 10:46:19 +01:00
Lennart Poettering 8d3b9edc6b busctl: modernize code a bit
I am puzzled why coccinelle is unwilling to detect these cases...
2017-12-14 10:46:19 +01:00
Lennart Poettering 35bbbf85e0 basic: turn off stdio locking for a couple of helper calls
These helper calls are potentially called often, and allocate FILE*
objects internally for a very short period of time, let's turn off
locking for them too.
2017-12-14 10:46:19 +01:00
Lennart Poettering 0d53667334 tree-wide: use __fsetlocking() instead of fxyz_unlocked()
Let's replace usage of fputc_unlocked() and friends by __fsetlocking(f,
FSETLOCKING_BYCALLER). This turns off locking for the entire FILE*,
instead of doing individual per-call decision whether to use normal
calls or _unlocked() calls.

This has various benefits:

1. It's easier to read and easier not to forget

2. It's more comprehensive, as fprintf() and friends are covered too
   (as these functions have no _unlocked() counterpart)

3. Philosophically, it's a bit more correct, because it's more a
   property of the file handle really whether we ever pass it on to another
   thread, not of the operations we then apply to it.

This patch reworks all pieces of codes that so far used fxyz_unlocked()
calls to use __fsetlocking() instead. It also reworks all places that
use open_memstream(), i.e. use stdio FILE* for string manipulations.

Note that this in some way a revert of 4b61c87511.
2017-12-14 10:42:25 +01:00
Zbigniew Jędrzejewski-Szmek 966c04cf01
Merge pull request #7625 from thom311/th/const-strlen
Don't use strlen() to declare variable-length arrays
2017-12-14 09:41:09 +01:00
Saran Tunyasuvunakool 30cda194e8 networkd: RouteTable option in [IPv6AcceptRA] is now properly processed (#7633)
Fixes: #7632
2017-12-14 14:11:03 +09:00
Lennart Poettering 59f2725cc8 resolved: fix "in-between" logic when boundaries are equal (#7590)
This changes dns_name_between() to deal properly with checking whether B
is between A and C if A and C are equal. Previously we simply returned
-EINVAL in this case, refusing checking. With this change we correct
behaviour: if A and C are equal, then B is "between" both if it is
different from them. That's logical, since we do < and > comparisons, not
<= and >=, and that means that anything "right of A" and "left of C"
lies in between with wrap-around at the ends. And if A and C are equal
that means everything lies between, except for A itself.

This fixes handling of domains using NSEC3 "white lies", for example the
.it TLD.

Fixes: #7421
2017-12-14 14:08:21 +09:00
Yu Watanabe 1bb8d1fce8
Merge pull request #7618 from tiagosh/sysctl_use_read_line
Make systemd-sysctl use read_line() and LONG_LINE_MAX
2017-12-14 13:58:53 +09:00
Daniel Black afbc75e686 man: systemd.unit: move note about clearing lists (#7621)
This is mainly for drop-in files.
2017-12-14 13:51:23 +09:00
Yu Watanabe 314a6c0083
Merge pull request #7627 from poettering/lowercase-systemd
always spell out "systemd" in lowercase letters
2017-12-14 13:44:35 +09:00
Tiago Salem Herrmann 12ec9c3099 sysctl: disable buffer while writing to /proc
fputs() writes only first 2048 bytes and fails
to write to /proc when values are larger than that.
This patch adds a new flag to WriteStringFileFlags
that make it possible to disable the buffer under
specific cases.
2017-12-13 15:03:41 -02:00
Tiago Salem Herrmann a668bfe88a Use read_line() and LONG_LINE_MAX to read values configuration files. 2017-12-13 15:03:33 -02:00
Luca Bruno 2de2abad62 networkd/dhcp: shorten overlong hostname (#7616)
This commit updates networkd behavior to check if the hostname option
received via DHCP is too long for Linux limit, and in case shorten it.
An overlong hostname will be truncated to the first dot or to
`HOST_MAX_LEN`, whatever comes earlier.
2017-12-13 18:00:46 +01:00
Lennart Poettering c96528fae9 catalog: don't say "systemd" when we mean "system"
Yeah, it's hard to type "system", if all you ever type is "systemd", but
it's still a typo in this case.
2017-12-13 17:43:03 +01:00
Lennart Poettering f95b0be742 man: "systemd" is to be written in all lower-case, even at beginnings of sentences
This very important commit is very important.
2017-12-13 17:42:04 +01:00
Lennart Poettering 3ce5a5df2c
Merge pull request #7619 from msekletar/cryptsetup-image-name
cryptsetup: when unlocking always put path to the object into Id
2017-12-13 16:46:57 +01:00
Dongsu Park 25fd814316 test: add CLI smoke tests for --network-namespace-path of nspawn
Since the new option `--network-namespace-path=` of systemd-nspawn
cannot be used together with other network-related options, we need
to add more smoke tests for checking these conditions of options.
2017-12-13 10:21:06 +00:00
Dongsu Park d7bea6b629 nspawn: introduce an option for specifying network namespace path
Add a new option `--network-namespace-path` to systemd-nspawn to allow
users to specify an arbitrary network namespace, e.g. `/run/netns/foo`.
Then systemd-nspawn will open the netns file, pass the fd to
outer_child, and enter the namespace represented by the fd before
running inner_child.

```
$ sudo ip netns add foo
$ mount | grep /run/netns/foo
nsfs on /run/netns/foo type nsfs (rw)
...
$ sudo systemd-nspawn -D /srv/fc27 --network-namespace-path=/run/netns/foo \
  /bin/readlink -f /proc/self/ns/net
/proc/1/ns/net:[4026532009]
```

Note that the option `--network-namespace-path=` cannot be used together
with other network-related options such as `--private-network` so that
the options do not conflict with each other.

Fixes https://github.com/systemd/systemd/issues/7361
2017-12-13 10:21:06 +00:00
Thomas Haller dbcb4a900e tree-wide: use STRLEN() to allocate buffer of constant size
Using strlen() to declare a buffer results in a variable-length array,
even if the compiler likely optimizes it to be a compile time constant.

When building with -Wvla, certain versions of gcc complain about such
buffers. Compiling with -Wvla has the advantage of preventing variably
length array, which defeat static asserts that are implemented by
declaring an array of negative length.
2017-12-13 11:12:19 +01:00
Thomas Haller 6febe75da7 basic/macros: add STRLEN() to get length of string literal as constant expression
While the compiler likely optimizes strlen(x) for string literals,
it is not a constant expression.

Hence,

  char buffer[strlen("OPTION_000") + 1];

declares a variable-length array. STRLEN() can be used instead
when a constant espression is needed.

It's not entirely identical to strlen(), as STRLEN("a\0") counts 2.
Also, it only works with string literals and the macro enforces
that the argument is a literal.
2017-12-13 11:12:07 +01:00
Lennart Poettering 18a121f9b4 networkd: don't try to configure IPv6 proxy NDP if IPv6 is not available (#7613)
Fixes: #7612
2017-12-13 13:47:10 +09:00
Yu Watanabe ffbae6c978
Merge pull request #7588 from poettering/resolve-route-tweak
resolved domain routing tweaks and /etc/resolv.conf handling improvements
2017-12-13 13:43:55 +09:00
Yu Watanabe 74dc882153
Merge pull request #7569 from keszybz/doc-reverse-settings
Document reverse settings
2017-12-13 13:42:19 +09:00
Zbigniew Jędrzejewski-Szmek 404a048623
Merge pull request #7591 from poettering/retry-on-servfail
resolved: retry with a different server on SERVFAIL
2017-12-12 22:22:06 +01:00
Zbigniew Jędrzejewski-Szmek 4432ac91ee
Merge pull request #7611 from poettering/bootspec-fixes
minor fixes to bootctl.c/bootspec.c to make sure the tool works cleanly on my system
2017-12-12 22:16:34 +01:00
Zbigniew Jędrzejewski-Szmek bbaa8055ac Merge pull request #7608 from poettering/more-news-v236 2017-12-12 21:11:31 +01:00
Zbigniew Jędrzejewski-Szmek 5d0e48519b man: explain noauto/nofail more carefully in crypttab
https://bugzilla.redhat.com/show_bug.cgi?id=1524759
2017-12-12 20:51:24 +01:00
Michal Sekletar ea7e7c1e9c cryptsetup: use more descriptive name for the variable and drop redundant function
Let's rename escaped_name to disk_path since this is an actual content
that pointer refers to. It is either path to encrypted block device
or path to encrypted image file.

Also drop redundant function disk_major_minor(). src is always set, and
it always points to either encrypted block device path (or symlink to
such device) or to encrypted image. In case it is set to device path
there is no need to reset it to /dev/block/major:minor symlink since
those paths are equivalent.
2017-12-12 20:31:25 +01:00
Lennart Poettering b4b36f4405 meson: link NSS modules with -z nodelete (#7607)
We might end up allocating mempools, and when we are unloaded we might
orphan them, thus leaking them. Hence, let's just stick around for good,
so the mempools remain referenced continously and for good, and thus no
memory is leaked (though the memory isn't cleaned up either).

Fixes: #7596
2017-12-12 20:13:16 +01:00
Michal Sekletar 5a9f1b05ed cryptsetup: when unlocking always put path to the object into Id
Some ask-password agents (e.g. clevis-luks-askpass) use Id option from
/run/systemd/ask-password/ask* file in order to obtain the password for
the device.

Id option should be in the following format,
e.g. Id=subsystem:data. Where data part is supposed to identify object
that ask-password query is done for. Since
e51b9486d1 this field has format
Id=cryptsetup:/dev/block/major:minor when systemd-cryptsetup is
unlocking encrypted block device. However, crypttab also supports
encrypted image files in which case we usually set data part of Id to
"vol on mountpoint". This is unexpected and actually breaks network
based device encryption as implemented by clevis.

Example:
$ cat /etc/crypttab
clevis-unlocked /clevis-test-disk-image none luks,_netdev
$ systemctl start 'systemd-cryptsetup@clevis\x2dunlocked.service'
$ grep Id /run/systemd/ask-password/ask*

Before:
$ Id=cryptsetup:clevis-unlocked on /clevis-test-disk-image-mnt

After:
$ Id=cryptsetup:/clevis-test-disk-image
2017-12-12 18:28:08 +01:00
ott cb9eeb062c resolve: add support for RFC 8080 (#7600)
RFC 8080 describes how to use EdDSA keys and signatures in DNSSEC. It
uses the curves Ed25519 and Ed448. Libgcrypt 1.8.1 does not support
Ed448, so only the Ed25519 is supported at the moment. Once Libgcrypt
supports Ed448, support for it can be trivially added to resolve.
2017-12-12 16:30:12 +01:00
Saran Tunyasuvunakool 7715629e9a networkd: Fix race condition in [RoutingPolicyRule] handling (#7615)
The routing policy rule setup logic is moved to the routes setup phase (rather than the addresses setup phase as it is now). Additionally, a call to `link_check_ready` is added to the routing policy rules setup handler. This prevents a race condition with the routes setup handler.

Also give each async handler its own message counter to prevent race conditions when logging successes.

Fixes: #7614
2017-12-12 16:25:36 +01:00
Lennart Poettering e82b113257 resolved: try a different server if server is too dumb to do DNSSEC
If we are in strict DNSSEC mode it's worthy to try a different DNS
server before accepting that DNSSEC is not actually supported.

Fixes: #7040
2017-12-12 12:10:08 +01:00
Lennart Poettering 5cdb8930e0 resolved: cast dns_scope_get_dns_server() to NULL when we ignore it 2017-12-12 12:10:08 +01:00
Lennart Poettering 44db02d0ef resolved: when a server consistently returns SERVFAIL, try another one
Currently, we accept SERVFAIL after downgrading fully, cache it and move
on. Let's extend this a bit: after downgrading fully, if the SERVFAIL
logic continues to be an issue, then use a different DNS server if there
are any.

Fixes: #7147
2017-12-12 12:10:08 +01:00