Commit Graph

31341 Commits

Author SHA1 Message Date
Yu Watanabe d03cb6b85d link-config: make MACAddressPolicy= accept an empty string 2020-11-20 22:59:12 +09:00
Lennart Poettering eebd1c3ad2
Merge pull request #17649 from yuwata/resolve-dnssd-template-name
resolve: ignore invalid service template name
2020-11-20 14:56:59 +01:00
Yu Watanabe e23baae0da systemctl: fix potential pointer overflow 2020-11-20 21:58:47 +09:00
Yu Watanabe 48b11b09ab ask-passwd: drop a condition which is always false 2020-11-20 19:42:38 +09:00
Yu Watanabe 283ec78963 resolvectl: drop a condition which is always true 2020-11-20 19:39:49 +09:00
Yu Watanabe 1058390d20 pstore: use log_oom() 2020-11-20 02:59:02 +09:00
Yu Watanabe fed66db05d tree-wide: use return value of log_xxx_errno() 2020-11-20 02:58:27 +09:00
Lennart Poettering 5abede3247 seccomp: move brk+mmap+mmap2 into @default syscall filter set
These three syscalls are internally used by libc's memory allocation
logic, i.e. ultimately back malloc(). Allocating a bit of memory is so
basic, it should just be in the default set.

This fixes a couple of issues with asan/msan and the seccomp tests: when
asan/msan is used some additional, large memory allocations take place
in the background, and unless mmap/mmap2/brk are allowlisted these will
fail, aborting the test prematurely.
2020-11-19 16:44:50 +01:00
Yu Watanabe f56a9cbf9c khash: fix structured initializer
Fixes #17646.
2020-11-18 11:15:05 +01:00
Yu Watanabe 273d76f4f8 tree-wide: update "that that" 2020-11-18 17:23:00 +09:00
Yu Watanabe b9cbb08e0a sd-device: drop unwanted newline in netlink message 2020-11-18 05:32:44 +09:00
Yu Watanabe dd2e9e1d0e resolve: ignore invalid service template name
Let's fiest test the template name, and then assign it.
2020-11-18 03:32:40 +09:00
Yu Watanabe 0c949643b8 resolve: make config_parse_dnssd_service_name() accepts an empty string 2020-11-18 03:23:32 +09:00
Yu Watanabe a37eb63ffa resolve: add a short comment about difference between dnssd_render_instance_name() and config_parse_dnssd_service_name() 2020-11-18 03:22:56 +09:00
Yu Watanabe d63542bc02 resolve: wrap long line 2020-11-18 03:20:30 +09:00
Roman Beranek 07e4a8dc23 Revert "resolve: check DNSSD service name template before assigning it"
This reverts commit 34136e1503.

Having the "%H" host name specifier in a DNSSD service name template
triggers a failed assertion during name template instantiation as
specifier_dnssd_host_name expects DnssdService in its userdata
pointer but finds NULL instead.
2020-11-18 03:16:57 +09:00
Zbigniew Jędrzejewski-Szmek 1598b07da3
Merge pull request #17640 from keszybz/meson-test-c++20
Also test headers against c++20
2020-11-17 17:14:49 +01:00
Zbigniew Jędrzejewski-Szmek 485a9202ba
Merge pull request #17643 from keszybz/man-news-independent
NEWS and man page tweaks
2020-11-17 17:14:14 +01:00
Zbigniew Jędrzejewski-Szmek dbc29e9175 network: use the common "cannot" form
Just for consistency.
2020-11-17 10:55:36 +01:00
Zbigniew Jędrzejewski-Szmek 7ad41997d1 man/systemd.netdev: remove bogus markup
There is no "Multicast" constant, and NULL doesn't make sense in the
context of addresses.
2020-11-17 10:55:12 +01:00
Anita Zhang 6ace20b971 test-oomd-util: remove memory_pressure == 0 checks
test_oomd_cgroup_context_acquire_and_insert reads the live cgroup data used
by the unit test. Under certain conditions, the memory pressure for the cgroup
can be non-zero (although most of the time it is 0 since these tests don't
generate much pressure).

Since these values are too dependent on the state of the system, remove the
checks. The type used is always >= 0 and test-psi-util already unit tests that
PSI values are parsed correctly from files so this test is redundant anyways.
2020-11-17 10:08:32 +01:00
Zbigniew Jędrzejewski-Szmek 40ebe49259
Merge pull request #17597 from yuwata/fix-typo
tree-wide: Fix typo
2020-11-17 10:06:58 +01:00
Zbigniew Jędrzejewski-Szmek 2e5811521d test: let's start getting ready for 2020
It'll be a wonderful year, I'm sure.
2020-11-17 10:03:15 +01:00
Zbigniew Jędrzejewski-Szmek e318c2a444 meson: use proper variable for libudev.h path 2020-11-17 10:01:05 +01:00
Yu Watanabe a614a6e2f8 meson: fix build tests for c++14 and c++17 2020-11-17 09:55:08 +01:00
Zbigniew Jędrzejewski-Szmek 88e574e7c1
Merge pull request #17603 from yuwata/systemctl-fix-underline
systemctl: always show underline even if unit has no job ID
2020-11-17 09:49:05 +01:00
Yu Watanabe 5b90b906c7 udev: use FOREACH_DEVICE_TAG() macro at one more place 2020-11-17 09:47:14 +01:00
Yu Watanabe e5b88e8d73
Merge pull request #17619 from yuwata/network-ndisc-dhcp6-client-always
network: honor M or O flag in RA even if IPv6AcceptRA.DHCPv6Cleint=always
2020-11-17 01:20:56 +09:00
Yu Watanabe d448888924 meson: use "_" as separator in test names
Follow-up for ca121e20c4.

Fixes #17568.
2020-11-16 21:28:05 +09:00
Yu Watanabe 787dd704e1 sd-dhcp6-client: insert spaces around ternary operator 2020-11-16 18:59:28 +09:00
Yu Watanabe 0e686feaff network: honor M or O flag in RA even if IPv6AcceptRA.DHCPv6Cleint=always
Follow-up for ac24e418d9.

The original motivation of the commit and RFE #15339 is to start dhcpv6
client in managed mode when neither M nor O flag is set in the RA.
But, previously, if the setting is set to "always", then the DHCPv6
client is always started in managed mode even if O flag is set in the
RA. Such the behavior breaks RFC 7084.
2020-11-16 18:59:24 +09:00
Yu Watanabe 77419ba463 missing: define several syscall numbers for MIPS arch
Fixes #17591.
2020-11-16 17:04:20 +09:00
Yu Watanabe b96f2f28da
Merge pull request #17600 from yuwata/drop-log-oom
util: drop log_oom() from several library functions
2020-11-16 17:03:46 +09:00
Michael Biebl 85ddb8dc42 test: bump timeout for test-libcrypt-util
Apparently this test is prone to time out on slower architectures, so
bump it from 30s to 120s.

See
https://buildd.debian.org/status/fetch.php?pkg=systemd&arch=mipsel&ver=247%7Erc2-2&stamp=1605303506&raw=0
https://buildd.debian.org/status/fetch.php?pkg=systemd&arch=sparc64&ver=247%7Erc2-2&stamp=1605294845&raw=0
2020-11-16 17:03:02 +09:00
Christof Efkemann cabe57119f networkd: fix default value of DHCPv6Client
The configuration of networkd has a DHCPv6Client setting in its
[IPv6AcceptRA] section, which, according to the man page, can be
a boolean, or the special value "always". The man page states
that "true" is the default.

The default value is implemented in src/network/networkd-network.c
by setting field ipv6_accept_ra_start_dhcp6_client of network to
true. However, this field is not a boolean, but an enum type
IPv6AcceptRAStartDHCP6Client (src/network/networkd-ndisc.h).

Setting ipv6_accept_ra_start_dhcp6_client to true effectively
corresponds to the enum value IPV6_ACCEPT_RA_START_DHCP6_CLIENT_ALWAYS,
resulting in the DHCPv6Client setting having the default value
"always".

This patch changes the initialisation to the correct enum value
IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES.
2020-11-16 16:09:37 +09:00
Yu Watanabe 5ba97fc0a9 systemctl: fix minor coding style issue 2020-11-14 09:06:35 +09:00
Yu Watanabe ca7b9e1e0a systemctl: use unsigned for job_count
As, the number of units `c` is unsigned.
2020-11-14 09:05:32 +09:00
Yu Watanabe 810394481b systemctl: always show underline even if unit has no job ID 2020-11-14 09:19:01 +09:00
Yu Watanabe c4cce95731 io-util: do not call log_oom() in library functions 2020-11-13 19:35:01 +09:00
Yu Watanabe ca39a3cef9 bpf: do not call log_oom() in library function 2020-11-13 19:30:57 +09:00
Yu Watanabe d51c4fca29 tree-wide: fix "a the" or "the a" 2020-11-13 16:28:47 +09:00
Etienne Doms e2357b1c8a ratelimit: fix integer overflow
If StartLimitIntervalSec is huge, or more specifically, set to "infinity", we need to take care about overflows.
2020-11-12 14:35:06 +01:00
Jörg Thalheim d7aa78c32f meson: add option to skip installing to $sysconfdir
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to https://github.com/systemd/systemd/pull/17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
2020-11-12 11:21:46 +01:00
Yu Watanabe 9429ee6a89
Merge pull request #17567 from keszybz/various-small-cleanups
Various small cleanups
2020-11-12 16:30:06 +09:00
Zbigniew Jędrzejewski-Szmek ca121e20c4 meson: use "_" as separator in test names
":" is prettier, but meson 0.56+ doesn't like it:
src/systemd/meson.build:73: DEPRECATION: ":" is not allowed in test name "cc-sd-bus.h:c", it has been replaced with "_"
src/systemd/meson.build:73: DEPRECATION: ":" is not allowed in test name "cc-sd-bus.h:c-ansi", it has been replaced with "_"
...

Fixes #17568.
2020-11-11 16:58:05 +01:00
Lennart Poettering 23dce98e89
Merge pull request #16603 from benzea/benzea/special-app-slice
Use app.slice by default in user manager (and define special user slices)
2020-11-11 14:11:02 +01:00
Zbigniew Jędrzejewski-Szmek 5ee24fa0a0 user: move "extrinsic" units to their root slice
With the grandparent change to move most units to app.slice,
those units would be ordered After=app.slice which doesn't make any sense.
Actually they appear earlier, before the manager is even started, and
conceputally it doesn't seem useful to put them under any slice.
2020-11-10 17:33:32 +01:00
Zbigniew Jędrzejewski-Szmek 4d5f52e77e basic/fileio: constify struct timespec arguments 2020-11-10 15:52:32 +01:00
Zbigniew Jędrzejewski-Szmek b5c474f69b libsystemd-network: add comment explaining unusual memory access
Inspired by coverity CID#1435984. I'm confused by the union definion every time I look at it...
Let's at least add a comment to help future readers.
2020-11-10 15:52:32 +01:00
Zbigniew Jędrzejewski-Szmek 44ee03d111 tree-wide: unsetenv cannot fail
... when called with a valid environment variable name. This means that
any time we call it with a fixed string, it is guaranteed to return 0.
(Also when the variable is not present in the environment block.)
2020-11-10 15:52:32 +01:00
Zbigniew Jędrzejewski-Szmek 063f9f0da9 basic/env-util: add little helper to call setenv or unsetenv 2020-11-10 15:48:14 +01:00
Zbigniew Jędrzejewski-Szmek 39c79477ac pid1: expose "extrinsic" status of swaps and mounts
The only visible change from this is that we show Extrinsic: yes/no
in dumps for swap units (this was already done for mount units).
2020-11-10 14:42:42 +01:00
Zbigniew Jędrzejewski-Szmek 55c540d39f sd-event: minor modernization
With this change the pattern used for epoll_ctl() is the same in all calls in
this file. Consistency FTW!
2020-11-10 14:19:20 +01:00
Zbigniew Jędrzejewski-Szmek ac9f2640cb sd-event: increase n_enabled_child_sources just once
Neither source_child_pidfd_register() nor event_make_signal_data() look at
n_enabled_child_sources.
2020-11-10 14:19:20 +01:00
Zbigniew Jędrzejewski-Szmek d2eafe61ca sd-event: update state at the end in event_source_enable
Coverity in CID#1435966 was complaining that s->enabled is not "restored" in
all cases. But the code was actually correct, since it should only be
"restored" in the error paths. But let's still make this prettier by not setting
the state before all operations that may fail are done.

We need to set .enabled for the prioq reshuffling operations, so move those down.

No functional change intended.
2020-11-10 14:18:47 +01:00
Lennart Poettering 394131d5be
Merge pull request #17497 from anitazha/randomizeonce
timer: add new feature FixedRandomDelay=
2020-11-10 13:29:04 +01:00
Lennart Poettering 4165a0590d
Merge pull request #17555 from yuwata/ethtool-get-driver
ethtool: make ethtool_get_driver() return -ENODATA if driver is an empty string.
2020-11-10 13:15:10 +01:00
Yu Watanabe 41d544a1c1 journal: refuse skip parameter for sd_journal_next_skip() larger than INT_MAX
Fixes #17502.
2020-11-10 13:14:42 +01:00
Zbigniew Jędrzejewski-Szmek b8aac5014c
Merge pull request #17431 from msekletar/udev-link-update-race
udev: make algorithm that selects highest priority devlink less susceptible to race conditions
2020-11-10 09:41:57 +01:00
Yu Watanabe 6272aef5ff sd-bus: drop redundant abs()
strerror_safe() internally applies abs().
2020-11-10 09:24:34 +01:00
Yu Watanabe 72585a584d core: add missing oom check
Fixes #17552.
2020-11-10 09:22:43 +01:00
Zbigniew Jędrzejewski-Szmek d61db498bf udev: log when we fail to query ID_NET_DRIVER
Inspired by #17532.
2020-11-10 09:18:53 +01:00
Zbigniew Jędrzejewski-Szmek a1b24ee147
Merge pull request #17551 from yuwata/radv-router-lifetime
network: about router lifetime
2020-11-09 21:07:16 +01:00
Yu Watanabe 861de64e68 ethtool: make ethtool_get_driver() return -ENODATA if ioctl succeeds but driver name is empty
Inspired by #17532.
2020-11-10 01:14:42 +09:00
Yu Watanabe a93187ced5 ethtool: add several assertions 2020-11-10 01:04:39 +09:00
Yu Watanabe 2075e596cf network: convert router lifetime from usec_t to uint16_t 2020-11-10 00:04:52 +09:00
Yu Watanabe dd1b187075 sd-radv: refuse to set preference except medium when router lifetime is zero 2020-11-10 00:04:52 +09:00
Yu Watanabe ac138551ce sd-radv: router lifetime is uint16_t 2020-11-10 00:04:52 +09:00
Yu Watanabe 71a5db49fd network: make default router lifetime to 30min
Closes #17527.
2020-11-10 00:04:42 +09:00
Lennart Poettering df80c98cde
Merge pull request #17549 from yuwata/tiny-fixes
tiny fixes
2020-11-09 16:04:01 +01:00
Yu Watanabe 601844b71d core: reduce scope of variants
Fixes #17543.
2020-11-09 14:40:05 +09:00
Yu Watanabe 291bb0b01c sd-bus: fix possible division by 0
Fixes #17541.
2020-11-09 14:33:19 +09:00
Yu Watanabe 755b35b1aa home: fix copy-and-paste mistake
Fixes #17542.
2020-11-09 14:00:16 +09:00
Yu Watanabe f13467ec23 license: GPL-2.0+ -> GPL-2.0-or-later 2020-11-09 13:25:50 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering eaa269484b resolved: fix non-initialized memory access
Fix for bug introduced in 1ed314087f.
2020-11-06 13:58:20 -08:00
Zbigniew Jędrzejewski-Szmek ceedbf8185 meson: add option for fexecve use
There are downsides to using fexecve:

when fexecve is used (for normal executables), /proc/pid/status shows Name: 3,
which means that ps -C foobar doesn't work. pidof works, because it checks
/proc/self/cmdline. /proc/self/exe also shows the correct link, but requires
privileges to read. /proc/self/comm also shows "3".

I think this can be considered a kernel deficiency: when O_CLOEXEC is used, this
"3" is completely meaningless. It could be any number. The kernel should use
argv[0] instead, which at least has *some* meaning.

I think the approach with fexecve/execveat is instersting, so let's provide it
as opt-in.
2020-11-06 15:20:34 +01:00
Zbigniew Jędrzejewski-Szmek 3f51bbff55 shared/exec-util: fall back to execve() also on permission errors 2020-11-06 15:20:34 +01:00
Zbigniew Jędrzejewski-Szmek 8939eeae52 shared/exec-util: use our own execveat() wrapper instead of fexecve()
For scripts, when we call fexecve(), on new kernels glibc calls execveat(),
which fails with ENOENT, and then we fall back to execve() which succeeds:
[pid 63039] execveat(3, "", ["/home/zbyszek/src/systemd/test/test-path-util/script.sh", "--version"], 0x7ffefa3633f0 /* 0 vars */, AT_EMPTY_PATH) = -1 ENOENT (No such file or directory)
[pid 63039] execve("/home/zbyszek/src/systemd/test/test-path-util/script.sh", ["/home/zbyszek/src/systemd/test/test-path-util/script.sh", "--version"], 0x7ffefa3633f0 /* 0 vars */) = 0

But on older kernels glibc (some versions?) implement a fallback which falls
into the same trap with bash $0:
[pid 13534] execve("/proc/self/fd/3", ["/home/test/systemd/test/test-path-util/script.sh", "--version"], 0x7fff84995870 /* 0 vars */) = 0

We don't want that, so let's call execveat() ourselves. Then we can do the
execve() fallback as we want.
2020-11-06 15:20:34 +01:00
Zbigniew Jędrzejewski-Szmek a6d9111c67 core/execute: fall back to execve() for scripts
fexecve() fails with ENOENT and we need a fallback. Add appropriate test.
2020-11-06 15:14:13 +01:00
Zbigniew Jędrzejewski-Szmek b83d505087 core: use fexecve() to spawn children
We base the smack/selinux setup on the executable. Let's open the file
once and use the same fd for that setup and the subsequent execve.
2020-11-06 15:13:01 +01:00
Zbigniew Jędrzejewski-Szmek 5ca9139ace basic/path-util: let find_executable_full() optionally return an fd 2020-11-06 15:12:54 +01:00
Lennart Poettering 76f772298e resolved: slightly extend debug log output about outgoing messages 2020-11-06 14:43:05 +01:00
Lennart Poettering 088648d081 resolved: don't resolve "local." via LLMNR
It's the mDNS top-level domain, hence don't consider it for LLMNR, ever.

Fixes: #16233
2020-11-06 14:43:01 +01:00
Lennart Poettering dc194dce80 resolved: add comments for various query flags 2020-11-06 14:42:56 +01:00
Lennart Poettering 5cdcac6cf6 resolved: show all answer flags when dumping answer 2020-11-06 14:42:53 +01:00
Lennart Poettering 032b398224 resolved: add minor optimization path to dns_answer_merge() 2020-11-06 14:42:49 +01:00
Lennart Poettering 02c205359b resolved: suppress misleading debug message about ignored resolv.conf line 2020-11-06 14:42:45 +01:00
Lennart Poettering 8d50c14252 errno: ETIMEDOUT is also a connection error 2020-11-06 14:42:18 +01:00
Michal Sekletár 30f6dce62c udev: make algorithm that selects highest priority devlink less susceptible to race conditions
Previously it was very likely, when multiple contenders for the symlink
appear in parallel, that algorithm would select wrong symlink (i.e. one
with lower-priority).

Now the algorithm is much more defensive and when we detect change in
set of contenders for the symlink we reevaluate the selection. Same
happens when new symlink replaces already existing symlink that points
to different device node.
2020-11-06 13:35:05 +01:00
Michal Sekletár a59b0a9f76 basic/stat-util: make mtime check stricter and use entire timestamp
Note that st_mtime member of struct stat is defined as follows,

 #define st_mtime st_mtim.tv_sec

Hence we omitted checking nanosecond part of the timestamp (struct
timespec) and possibly would miss modifications that happened within the
same second.
2020-11-06 12:28:40 +01:00
Ronan Pigott ea394d48cc journalctl: show boot id in the reboot context separator 2020-11-06 12:17:03 +01:00
Lennart Poettering ce8f6d478e seccomp: allow turning off of seccomp filtering via env var
Fixes: #17504

(While we are it, also move $SYSTEMD_SECCOMP_LOG= env var description
into the right document section)

Also suggested in: https://github.com/systemd/systemd/issues/17245#issuecomment-704773603
2020-11-05 20:22:19 +01:00
Kristijan Gjoshev acf24a1a84 timer: add new feature FixedRandomDelay=
FixedRandomDelay=yes will use
`siphash24(sd_id128_get_machine() || MANAGER_IS_SYSTEM(m) || getuid() || u->id)`,
where || is concatenation, instead of a random number to choose a value between
0 and RandomizedDelaySec= as the timer delay.
This essentially sets up a fixed, but seemingly random, offset for each timer
iteration rather than having a random offset recalculated each time it fires.

Closes #10355

Co-author: Anita Zhang <the.anitazha@gmail.com>
2020-11-05 10:59:33 -08:00
Zbigniew Jędrzejewski-Szmek 961b341e85 selinux: also try the netlink-based fallback and continue on permission error
Fedora Rawhide still has the old policy, so selinux prevents our selinux code
from checking if selinux is enabled. But it seems smart to fall back to the old
API anyway.

Follow-up for fd5e402fa9.

Both the reference policy [1] and Fedora selinux policy [2] needed to be
updated, so it's likely that this will impact other distros too.

[1] https://github.com/SELinuxProject/refpolicy/pull/308
[2] https://github.com/fedora-selinux/selinux-policy/pull/464
2020-11-04 09:49:53 +01:00
Topi Miettinen ae5e9bf46f shared/seccomp-util: move stime() to @obsolete
Quoting the manual page of stime(2): "Starting with glibc 2.31, this function
is no longer available to newly linked applications and is no longer declared
in <time.h>."
2020-11-04 09:48:33 +01:00
Zbigniew Jędrzejewski-Szmek 04bd604fb9 sd-login: fix parsing in sd_uid_is_on_seat
Bug introduced in 81823e6c12771721e9a729f6280a9de26fd70bad:
logind uses spaces not commas to separate items.
2020-11-04 09:46:59 +01:00
Zbigniew Jędrzejewski-Szmek 585d7a893e
Merge pull request #17521 from poettering/resolved-more-fixes
six fixes to resolved
2020-11-04 09:38:09 +01:00
Zbigniew Jędrzejewski-Szmek 24309e6683
Merge pull request #17493 from Villemoes/va-arg-simplifications
Some vararg simplifications
2020-11-04 09:22:15 +01:00
Lennart Poettering 2f4c2db20a resolved: handle RRs where we don't have a signer
If we encounter an RR that has no matching signature, then we don't know
whether it was expanded from a wildcard or not. We need to accept that
and not make the NSEC test fail, just skip over the RR.
2020-11-03 20:36:02 +01:00
Lennart Poettering de4a0138e7 resolved: drop unused family argument from manager_routable() 2020-11-03 20:35:09 +01:00
Lennart Poettering 014e8cc131 resolved: fix dumping of DnsAnswer objects 2020-11-03 20:35:09 +01:00
Lennart Poettering 398c611833 resolved: put size limit in DnsAnswer size to UINT16_MAX
The three answer sections can only carry up to UINT16_MAX entries, hence
put a hard upper limit on how far DnsAnswer can grow. The three count
fields in the DNS packet header are 16 bit only, hence the limit.

If code actually tries to add more than 64K RRs it will get ENOSPC with
this new checking.

And similar to DnsQuestion.
2020-11-03 20:35:04 +01:00
Lennart Poettering a63a1252b5 resolved: check return value of memdup() correctly for OOM 2020-11-03 20:05:46 +01:00
Rasmus Villemoes 3d2b1fa473 strv.c: simplify strv_new_ap
Instead of duplicating the code for x and the varargs, handle them all the same
way by using for loops.
2020-11-03 14:26:08 +01:00
Rasmus Villemoes bd8e699c27 signal-util: make sigaction_many_ap a little more concise
There's no reason to duplicate the stop condition sig < 0, nor the sigaction()
call.
2020-11-03 14:26:08 +01:00
Rasmus Villemoes 6ced0770c7 string-util: improve overflow checking
The current overflow checking is broken in the corner case of the strings'
combined length being exactly SIZE_MAX: After the loop, l would be SIZE_MAX,
but we're not testing whether the l+1 expression overflows.

Fix it by simply pre-accounting for the final '\0': initialize l to 1 instead
of 0.
2020-11-03 14:26:08 +01:00
Rasmus Villemoes 020003f235 string-util: simplify logic in strjoin_real()
The loops over (x, then all varargs, until a NULL is found) can be written much
simpler with an ordinary for loop. Just initialize the loop variable to x, test
that, and in the increment part, fetch the next va_arg(). That removes a level
of indentation, and avoids doing a separate strlen()/stpcpy() call for x.

While touching this code anyway, change (size_t)-1 to the more readable
SIZE_MAX.
2020-11-03 14:25:28 +01:00
Lennart Poettering d3dcf4e3b9 fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name
This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of
read_full_file_full() a bit: when used a sender socket name may be
specified. If specified as NULL behaviour is as before: the client
socket name is picked by the kernel. But if specified as non-NULL the
client can pick a socket name to use when connecting. This is useful to
communicate a minimal amount of metainformation from client to server,
outside of the transport payload.

Specifically, these beefs up the service credential logic to pass an
abstract AF_UNIX socket name as client socket name when connecting via
READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name
and the eventual credential name. This allows servers implementing the
trivial credential socket logic to distinguish clients: via a simple
getpeername() it can be determined which unit is requesting a
credential, and which credential specifically.

Example: with this patch in place, in a unit file "waldo.service" a
configuration line like the following:

    LoadCredential=foo:/run/quux/creds.sock

will result in a connection to the AF_UNIX socket /run/quux/creds.sock,
originating from an abstract namespace AF_UNIX socket:

    @$RANDOM/unit/waldo.service/foo

(The $RANDOM is replaced by some randomized string. This is included in
the socket name order to avoid namespace squatting issues: the abstract
socket namespace is open to unprivileged users after all, and care needs
to be taken not to use guessable names)

The services listening on the /run/quux/creds.sock socket may thus
easily retrieve the name of the unit the credential is requested for
plus the credential name, via a simpler getpeername(), discarding the
random preifx and the /unit/ string.

This logic uses "/" as separator between the fields, since both unit
names and credential names appear in the file system, and thus are
designed to use "/" as outer separators. Given that it's a good safe
choice to use as separators here, too avoid any conflicts.

This is a minimal patch only: the new logic is used only for the unit
file credential logic. For other places where we use
READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this
scheme too, but this should be done carefully in later patches, since
the socket names become API that way, and we should determine the right
amount of info to pass over.
2020-11-03 09:48:04 +01:00
Purushottam choudhary 92b555aaab network: selinux hook handling to enumerate nexthop
When selinux is enabled, the call of
manager_rtnl_enumerate_nexthop() fails.

This fix is to facilitate selinux hook handling for enumerating
nexthop.

In manager_rtnl_enumerate_nexthop() there is a check
if "Not supported" is returned by the send_netlink() call.

This check expects that -EOPNOTSUPP is returned,
the selinux hook seems to return -EINVAL instead.

This happens in kernel older than 5.3
(more specificallytorvalds/linux@65ee00a) as it does not support
nexthop handling through netlink.

And if SELinux is enforced in the order kernel, callingRTM_GETNEXTHOP
returns -EINVAL.

Thus adding a call in the manager_rtnl_enumerate_nexthop for the
extra return -EINVAL.
2020-11-01 23:28:21 +09:00
Lennart Poettering acd156d197 automount: make user unmounting for automount units more debuggable
Let's add an explicit log message plus an error state for automount
units, if users explicitly unmounted our autofs mount.

Prompted by: #17448
2020-10-30 13:10:42 +01:00
Lennart Poettering bfeb927a55 pid1: various minor watchdog modernizations
Just some clean-ups.
2020-10-30 13:02:06 +01:00
Yu Watanabe 819a555bc5
Merge pull request #17399 from afq984/udev-escaped-string
Allow escaped string in udev rules
2020-10-30 09:52:45 +09:00
Zbigniew Jędrzejewski-Szmek 58f848148f
Merge pull request #17444 from BtbN/fix_ib_dhcp4
networkd: fix DHCP on InfiniBand interfaces
2020-10-29 19:27:29 +01:00
Zbigniew Jędrzejewski-Szmek e61f999755
Merge pull request #17472 from keszybz/spdx-license-headers
More SPDX license headers
2020-10-29 19:05:05 +01:00
Zbigniew Jędrzejewski-Szmek ae7e5d2037
Merge pull request #17476 from poettering/resolved-tweaks
three small resolved cleanups
2020-10-29 18:58:56 +01:00
Yu, Li-Yu c32d562da5 udev: add fuzzer for udev_rule_parse_value 2020-10-29 20:19:29 +08:00
Yu, Li-Yu 9abfd759d2 udev: test udev_rule_parse_value() 2020-10-29 20:19:29 +08:00
Yu, Li-Yu aea3253e71 udev: escaped string syntax e"..." in rule files
* Existing valid rule files written with KEY="value" are not affected
* Now, KEY=e"value\n" becomes valid. Where `\n` is a newline character
* Escape sequences supported by src/basic/escape.h:cunescape() is
  supported
2020-10-29 20:15:23 +08:00
Zbigniew Jędrzejewski-Szmek c062cd9dde headers: use custom LicenseRef- spdx tag for various "public domain" files
There is no spdx tag defined for those versions of "public domain", but we can
add a custom tag, see
https://spdx.github.io/spdx-spec/6-other-licensing-information-detected/.

crc32.h is updated to match crc32.c.
2020-10-29 11:41:27 +01:00
Zbigniew Jędrzejewski-Szmek 448e7440c2 headers: add spdx tags to imported files with a known license
I added the header in the cases where the license text is present and it is
easy to find the appropriate SPDX header.

For "public domain" stuff: SDPX treats each "public domain" license as unique [1],
but luckily the one in siphash24.c is one of the identified variants. There are
some other cases which specify "public domain" but there doesn't seem to be a
SPDX identifier.

[1] https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files

gunicode.[ch] are imported from glib, which is licensed as LGPL2.1+,
see https://gitlab.gnome.org/GNOME/glib/-/blob/master/glib/gunicode.h.
2020-10-29 11:32:24 +01:00
Zbigniew Jędrzejewski-Szmek 59a711c2cd time-wait-sync: drop gpl snail mail boilerplate
No idea why this chunk was left when we removed the other copies.
2020-10-29 10:47:28 +01:00
Zbigniew Jędrzejewski-Szmek 4368277c74 tree-wide: use the usual SPDX header for our own files 2020-10-29 10:47:20 +01:00
Yu Watanabe 7b6c92e6bb journalctl: drop format_journal_url() if gcrypt is not used
Follow-up for f1b823596f.
2020-10-29 00:28:28 -07:00
Yu Watanabe 5722fb89bc net-condition: introduce struct NetMatch 2020-10-29 15:04:52 +09:00
Yu Watanabe 26f4d32365 meson: drop libsystemd_network from several binaries
This reduces the size of udevadm:

Before:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1203800 Oct 29 01:36 udevadm
```

After:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1094384 Oct 29 01:38 udevadm
```
2020-10-29 14:23:49 +09:00
Yu Watanabe 01ab92af71 tree-wide: drop unnecessary inclusion of network-internal.h 2020-10-29 14:23:49 +09:00
Yu Watanabe dc7f6c9b94 sd-network: move net_get_unique_predictable_data() and net_get_name_persisten() 2020-10-29 14:23:49 +09:00
Yu Watanabe c2f781bc15 conf-parser: fix indentation 2020-10-29 14:23:49 +09:00
Yu Watanabe 7e19cc5462 net-condition: move net_match_config() and related conf parsers 2020-10-29 14:23:49 +09:00
Yu Watanabe 1929ed0e58 sd-network: move link_get_type_string() 2020-10-29 14:23:49 +09:00
Yu Watanabe 0ec2a7a125 libsystemd-network: move config_parse_hwaddr() and config_parse_hwaddrs() 2020-10-29 14:23:49 +09:00
Yu Watanabe fc27088ae7 udev: move config_parse_ifalias() 2020-10-29 14:23:49 +09:00
Yu Watanabe 796aa313b3 network: move config_parse_bridge_port_priority() 2020-10-29 14:23:49 +09:00
Yu Watanabe 6a74900002 libsystemd-network: make conf parsers accept an empty string 2020-10-29 14:23:49 +09:00
Yu Watanabe 7e7aa4e811 libsystemd-network: downgrade log level in conf parsers 2020-10-29 14:23:49 +09:00
Zbigniew Jędrzejewski-Szmek 23b13549fa
Merge pull request #17435 from poettering/event-shuffle-refactor
sd-event: split up sd_event_source_set_enable() function
2020-10-28 18:21:13 +01:00
Zbigniew Jędrzejewski-Szmek a1989bd84b
Merge pull request #17454 from keszybz/journal-dlopen-cleanup
Journal dlopen cleanup and qrcode printing test
2020-10-28 18:20:27 +01:00
Zbigniew Jędrzejewski-Szmek 32c3a623ce
Merge pull request #17467 from keszybz/unconditionally-pull-in-cryptsetup-remote
Unconditionally pull in cryptsetup-remote.target in the initramfs
2020-10-28 18:00:04 +01:00
Timo Rothenpieler f1f1714411 networkctl: use and print full hardware address
Intentionally not checking the iftype for the ieee_oui lookup to support
other ethernet-like devices.
2020-10-28 15:18:01 +01:00
Timo Rothenpieler 14b66dbc92 dhcp4: fix DHCP on InfiniBand interfaces
With these patches applied, networkd is successfully able to get an
address from a DHCP server on an IPoIB interface.

1)
Makes networkd pass the actual interface type to the dhcp client,
instead of hardcoding it to Ethernet.

2)
Fixes some issues in handling the larger (20 Byte) IB MAC addresses in
the dhcp code.

3)
Add a new field to networkds Link struct, which holds the interface
broadcast address.

3.1)
Modify the DHCP code to also expect the broadcast address as parameter.
On an Ethernet-Interface the Broadcast address never changes and is always
all 6 bytes set to 0xFF.
On an IB one however it is not neccesarily always the same, thus
fetching the actual address from the interface is neccesary.

4)
Only the last 8 bytes of an IB MAC are stable, so when using an IB MAC to
generate a client ID, only pass those 8 bytes.
2020-10-28 14:44:43 +01:00
Timo Rothenpieler b8162cd200 network: store full hardware address in Link struct
This passes the legacy ethernet address to functions in a lot of places,
which all will need migrated to handle arbitrary size hardware addresses
eventually.
2020-10-28 14:44:43 +01:00
Timo Rothenpieler 4fc8a29a7e sd-netlink: introduce netlink_message_{read,append}_hw_addr
Hardware addresses come in various shapes and sizes, these new functions
and accomapying data structures account for that instead of hard-coding
a hardware address to the 6 bytes of an ethernet MAC.
2020-10-28 14:44:43 +01:00
Yu Watanabe 61eb77c4b6 network: drop link_load()
The link state file does not exist, as it is always removed on stop.
2020-10-28 18:16:01 +09:00
Yu Watanabe 6fdcef2174 network: do not serialize/deserialize routes
The same as the previous commit. These are not used.
2020-10-28 18:16:01 +09:00
Yu Watanabe 7b829a7b3b network: do not serialize/deserialize addresses
The link state file is always removed when networkd is stopping. So,
the deserialization logic does not work. Moreover, the ADDRESSES=
entry is not used by sd-network, so serialization is also not necessary.
2020-10-28 18:15:57 +09:00
Lennart Poettering b370adb593 resolved: advertise smaller UDP datagram size on extra stubs 2020-10-28 10:01:07 +01:00
Lennart Poettering 8facd1ce4f resolved: remove redundant conditionalization
If all protocols are listed there's no point in having the if check.

Follow-up for 8b4198373b
2020-10-28 10:01:03 +01:00
Lennart Poettering 1ed314087f resolved: use structured initialization everywhere 2020-10-28 10:00:28 +01:00
Yu Watanabe ca97e7cda0 network: do not serialize/deserialize ipv4ll address
The link state file is always removed on stop. So, we cannot deserialize
the address from the file. Moreover, currently the IPv4 link-local address
is always dropped by link_drop_foreign_addresses() on restart. Let's
drop the serialize/deserialize logic for IPv4 LL address.
2020-10-28 15:46:09 +09:00
Yu Watanabe 778c879533 network: use sysctl_read_ip_property() where applicable 2020-10-28 15:44:10 +09:00
Yu Watanabe 31a9a27d4c sysctl-util: truncate newline in read value 2020-10-28 15:44:10 +09:00
Yu Watanabe 62f12d757c network: downgrade log level in dhcp4_configure() 2020-10-28 15:44:10 +09:00
Yu Watanabe a41768533f network: always enable sysctl property promote_secondaries
systemd-sysctl already enables promote_secondaries for all interface.
So, networkd also enables it unconditionally.
2020-10-28 15:44:10 +09:00
Yu Watanabe e69642dccc network: mention that the error will be ignored 2020-10-28 15:44:10 +09:00
Yu Watanabe 5360b089e1 network: drop dhcp4_init()
It is now called by only dhcp4_configure(). Let's merge them.
2020-10-28 15:44:10 +09:00
Yu Watanabe 3def88503a network: set previous DHCP4 address in link->addresses_foreign
Previously, the address was taken from the state file, but DHCP4_ADDRESS=
entry was dropped by 46986251d6.
Moreover, the link state file is always removed when networkd is
stopping. Let's take the address from the list of enumerated addresses.
2020-10-28 15:44:05 +09:00
Zbigniew Jędrzejewski-Szmek a149d4a95e
Merge pull request #17455 from poettering/packet-auxdata
add Timestamping= to socket units and some other .socket unit tweaks
2020-10-27 20:20:57 +01:00
Zbigniew Jędrzejewski-Szmek 158b28313f test: add a simple test for the qr printing code
Ideally, we'd read back what we wrote, but that would have been
much more complicated. But just writing stuff is useful to test under
valgrind or manually.
2020-10-27 18:33:29 +01:00
Zbigniew Jędrzejewski-Szmek f1b823596f journal,homectl: unify implementations of libqrencode loading and fss key printing
We had two of each: both homectl and journalctl had the whole dlopen()
wrapper, and journalctl had two implementations (slightly different) of the
code to print the fss:// pattern.

print_qrcode() now returns -EOPNOTSUPP when compiled with qrcode support. Both
callers ignore the return value, so this changes nothing.

No functional change.
2020-10-27 18:33:29 +01:00
Timo Rothenpieler d0c4275c21 network: actually update radv mac 2020-10-27 18:01:22 +01:00
Lennart Poettering 9b1915256c core: add Timestamping= option for socket units
This adds a way to control SO_TIMESTAMP/SO_TIMESTAMPNS socket options
for sockets PID 1 binds to.

This is useful in journald so that we get proper timestamps even for
ingress log messages that are submitted before journald is running.

We recently turned on packet info metadata from PID 1 for these sockets,
but the timestamping info was still missing. Let's correct that.
2020-10-27 14:12:39 +01:00
Lennart Poettering a2b06dbe15 conf-parser: add a flavour of DEFINE_CONFIG_PARSE_ENUM() that allows specifiying the precie from_string() function to call 2020-10-27 14:12:31 +01:00
Lennart Poettering 3b719003c3 journald: remove pointless conditionalization
Let's not have #ifdeffery both in the consumers and the providers of the
selinux glue code. Unless the code is particularly complex, let's do the
ifdeffery only in the provider of the selinux glue code, and let's keep
the consumers simple and just invoke it.
2020-10-27 14:12:26 +01:00
Lennart Poettering 2d6d4136cd socket-util: make socket_set_recvpktinfo control PACKET_AUXDATA sockopt on AF_PACKET
Just for the sake of completness.
2020-10-27 14:12:10 +01:00
Lennart Poettering 74d6421da0 tree-wide: cast result of get_process_comm() to (void) where we ignore it 2020-10-27 14:06:49 +01:00
Lennart Poettering ddfde737b5 sd-event: split out enable and disable codepaths from sd_event_source_set_enabled()
So far half of sd_event_source_set_enabled() was doing enabling, the
other half was doing disabling. Let's split that into two separate
calls.

(This also adds a new shortcut to sd_event_source_set_enabled(): if the
caller toggles between "ON" and "ONESHOT" we'll now shortcut this, since
the event source is already enabled in that case and shall remain
enabled.)

This heavily borrows and is inspired from Michal Sekletár's #17284
refactoring.
2020-10-27 14:01:36 +01:00
Michal Sekletár e1951c16a8 sd-event: split out helper functions for reshuffling prioqs
We typically don't just reshuffle a single prioq at once, but always
two. Let's add two helper functions that do this, and reuse them
everywhere.

(Note that this drops one minor optimization:
sd_event_source_set_time_accuracy() previously only reshuffled the
"latest" prioq, since changing the accuracy has no effect on the
earliest time of an event source, just the latest time an event source
can run. This optimization is removed to simplify things, given that
it's not really worth the effort as prioq_reshuffle() on properly
ordered prioqs has practically zero cost O(1)).

(Slightly generalized, commented and split out of #17284 by Lennart)
2020-10-27 14:01:14 +01:00
Zbigniew Jędrzejewski-Szmek 6bdcb72086 Revert "units: add initrd-cryptsetup.target"
This reverts commit 6c5496c492.

sysinit.target is shared between the initrd and the host system. Pulling in
initrd-cryptsetup.target into sysinit.target causes the following warning at
boot:
Oct 27 10:42:30 workstation-uefi systemd[1]: initrd-cryptsetup.target: Starting requested but asserts failed.
Oct 27 10:42:30 workstation-uefi systemd[1]: Assertion failed for initrd-cryptsetup.target.
2020-10-27 13:36:22 +01:00
Anita Zhang e08dabfec7 core: clean up inactive/failed {service|scope}'s cgroups when the last process exits
If processes remain in the unit's cgroup after the final SIGKILL is
sent and the unit has exceeded stop timeout, don't release the unit's
cgroup information. Pid1 will have failed to `rmdir` the cgroup path due
to processes remaining in the cgroup and releasing would leave the cgroup
path on the file system with no tracking for pid1 to clean it up.

Instead, keep the information around until the last process exits and pid1
sends the cgroup empty notification. The service/scope can then prune
the cgroup if the unit is inactive/failed.
2020-10-27 13:20:40 +01:00
Zbigniew Jędrzejewski-Szmek 397cca2453 syscall-names: add process_madvise which is planned for 5.10
It was added in v5.9-11793-gecb8ac8b1f and is still present in v5.10-rc1, so it
seems likely that it'll be in 5.10 too.
2020-10-27 09:06:29 +01:00
Pat Coulthard 3045c416e1 tmpfiles: Handle filesystems without ACL support in more cases. 2020-10-26 10:20:10 +01:00
Zbigniew Jędrzejewski-Szmek a5258a0cb0
Merge pull request #17430 from yuwata/network-drop-foreign-routes-managed-by-manager
network: drop routes managed by Manager when they are not requested
2020-10-24 13:44:10 +02:00
Dan Streetman 352ab9d740 test: ignore ENOMEDIUM error from sd_pid_get_cgroup()
Ubuntu builds on the Launchpad infrastructure run inside a chroot that does
not have the sysfs cgroup dirs mounted, so this call will return ENOMEDIUM
from cg_unified_cached() during the build-time testing, for example when
building the package in a Launchpad PPA.
2020-10-24 13:34:01 +02:00
Yu Watanabe 377a9545e9 tree-wide: fix typos found by Fossies codespell report 2020-10-24 13:29:31 +02:00
Yu Watanabe 5a8775bb39 Revert "sd-dhcp-client: use asynchronous_close()"
This effectively reverts the commit 22fc2420b2.

The function `asynchronous_close()` confuses valgrind. Before this commit,
valgrind may report the following:

```
HEAP SUMMARY:
    in use at exit: 384 bytes in 1 blocks
  total heap usage: 4,787 allocs, 4,786 frees, 1,379,191 bytes allocated

384 bytes in 1 blocks are possibly lost in loss record 1 of 1
   at 0x483CAE9: calloc (vg_replace_malloc.c:760)
   by 0x401456A: _dl_allocate_tls (in /usr/lib64/ld-2.31.so)
   by 0x4BD212E: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.31.so)
   by 0x499B662: asynchronous_job (async.c:47)
   by 0x499B7DC: asynchronous_close (async.c:102)
   by 0x4CFA8B: client_initialize (sd-dhcp-client.c:696)
   by 0x4CFC5E: client_stop (sd-dhcp-client.c:725)
   by 0x4D4589: sd_dhcp_client_stop (sd-dhcp-client.c:2134)
   by 0x493C2F: link_stop_clients (networkd-link.c:620)
   by 0x4126DB: manager_free (networkd-manager.c:867)
   by 0x40D193: manager_freep (networkd-manager.h:97)
   by 0x40DAFC: run (networkd.c:20)

LEAK SUMMARY:
   definitely lost: 0 bytes in 0 blocks
   indirectly lost: 0 bytes in 0 blocks
     possibly lost: 384 bytes in 1 blocks
   still reachable: 0 bytes in 0 blocks
        suppressed: 0 bytes in 0 blocks

For lists of detected and suppressed errors, rerun with: -s
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
```
2020-10-24 13:27:37 +02:00
Zbigniew Jędrzejewski-Szmek c9e9a57fce shared/qrcode-util: reduce scope of iterator variables 2020-10-23 20:36:37 +02:00
Yu Watanabe 1132a714ec network: drop routes managed by Manager when link is removed
Also, foreign routes managed by Manager are dropped in
link_drop_foreign_routes().
2020-10-23 23:07:12 +09:00
Yu Watanabe 5f4d7aa458 network: specify route type in route_remove()
This factors out the common netlink message handling in route_remote()
and route_configure() to route_set_netlink_message().
2020-10-23 23:07:12 +09:00
Yu Watanabe bac319a795 network: link may be NULL 2020-10-23 23:07:12 +09:00
Yu Watanabe b1dc5946e2 network: ignore error in writing proxy_ndp
This partially reverts the commit fd773a11d8.

As, IPv6 may be disabled by kernel.
2020-10-23 23:07:12 +09:00
Yu Watanabe 9b3e49fc00 network: fix typo 2020-10-23 23:07:12 +09:00
Zbigniew Jędrzejewski-Szmek ff461576de Revert "basic/env-util: (mostly) follow POSIX for what variable names are allowed"
This reverts commit b45c068dd8.

I think the idea was generally sound, but didn't take into account the
limitations of show-environment and how it is used. People expect to be able to
eval systemctl show-environment output in bash, and no escaping syntax is
defined for environment *names* (we only do escaping for *values*). We could
skip such problematic variables in 'systemctl show-environment', and only allow
them to be inherited directly. But this would be confusing and ugly.

The original motivation for this change was that various import operations
would fail. a4ccce22d9 changed systemctl to filter
invalid variables in import-environment.
https://gitlab.gnome.org/GNOME/gnome-session/-/issues/71 does a similar change
in GNOME. So those problematic variables should not cause failures, but just
be silently ignored.

Finally, the environment block is becoming a dumping ground. In my gnome
session 'systemctl show-environment --user' includes stuff like PWD, FPATH
(from zsh), SHLVL=0 (no idea what that is). This is not directly related to
variable names (since all those are allowed under the stricter rules too), but
I think we should start pushing people away from running import-environment and
towards importing only select variables.

https://github.com/systemd/systemd/pull/17188#issuecomment-708676511
2020-10-23 15:07:07 +02:00
Zbigniew Jędrzejewski-Szmek 451ae5a11a basic/env-util: make function shorter 2020-10-23 13:49:05 +02:00
Lennart Poettering 17d99f95c2
Merge pull request #16859 from poettering/loop-eagain
loop: handle EAGAIN on LOOP_SET_STATUS64
2020-10-23 13:15:04 +02:00
Zbigniew Jędrzejewski-Szmek 15a6c4bf8b
Merge pull request #17417 from anitazha/more_systoomd
More systemd-oomd tweaks
2020-10-23 13:06:51 +02:00
Benjamin Berg 7f3b86a497 core: Move user units into app.slice by default
This changes the default from putting all units into the root slice to
placing them into the app slice in the user manager. The advantage is
that we get the right behaviour in most cases, and we'll need special
case handling in all other cases anyway.

Note that we have currently defined that applications *should* start
their unit names with app-, so we could also move only these by creating
a drop-in for app-.scope and app-.service.
However, that would not answer the question on how we should manage
session.slice. And we would end up placing anything that does not fit
the system (e.g. anything started by dbus-broker currently) into the
root slice.
2020-10-23 09:58:41 +02:00
Benjamin Berg 0b432bdc2e basic: Define macros for special user slices 2020-10-23 09:58:41 +02:00
Zbigniew Jędrzejewski-Szmek 943142a97d
Merge pull request #17185 from yuwata/ethtool-update
ethtool: add several link modes
2020-10-23 08:22:09 +02:00
Yu Watanabe 9c914c0401
Merge pull request #17357 from yuwata/network-dhcp6-pd-announce-17353
network: add an option to control announcement of delegated prefix
2020-10-23 12:57:58 +09:00
Dan Streetman e16e4b3bed network: move set-MAC and set-nomaster operations out of link_up()
These should not be bundled into the link_up() operation, as that is
not (currently) called during interface configuration if the interface
already is IFF_UP, which is unrelated to the need to change the mac
to a user-defined value, or set 'nomaster' on the interface.

Additionally, there is no need to re-set the mac or re-assert nomaster
every time the interface is brought up; those should be only part of
normal initial interface configuration.

Fixes: #17391
2020-10-23 12:09:31 +09:00
Anita Zhang 532855bead oomd: make start up swap check more robust 2020-10-22 17:04:26 -07:00
Lennart Poettering 3ec554ad17
Merge pull request #17418 from poettering/news-247-more
more v247 preps
2020-10-22 18:20:47 +02:00
Lennart Poettering f93ba37530 test: add heavy load loopback block device test 2020-10-22 15:10:03 +02:00
Lennart Poettering b202ec2068 loop-util: wait a random time before trying again
Let's try to make collisions when multiple clients want to use the same
device less likely, by sleeping a random time on collision.

The loop device allocation protocol is inherently collision prone:
first, a program asks which is the next free loop device, then it tries
to acquire it, in a separate, unsynchronized setp. If many peers do this
all at the same time, they'll likely all collide when trying to
acquire the device, so that they need to ask for a free device again and
again.

Let's make this a little less prone to collisions, reducing the number
of failing attempts: whenever we notice a collision we'll now wait
short and randomized time, making it more likely another peer succeeds.

(This also adds a similar logic when retrying LOOP_SET_STATUS64, but
with a slightly altered calculation, since there we definitely want to
wait a bit, under all cases)
2020-10-22 14:58:28 +02:00
Lennart Poettering 786e3a52a2 dissect: retrigger devices if we missed uevents
On systems that have a udev before
a7fdc6cbd3 uevents would sometimes be
eaten because of device node collisions that caused the ruleset to fail.
Let's add an (ugly) work-around for this, so that we can even work with
such an older udev.
2020-10-22 14:58:28 +02:00
Lennart Poettering 9e3d90671e udev-util: use absolute rather than relative timeout when waiting for devices
This makes it easier to accurately wait for a overall deadline.
2020-10-22 14:58:28 +02:00
Lennart Poettering 021bf17528 loop-util: if a loopback device we want to use still has partitions, do something about it
On current kernels (5.8 for example) under some conditions I don't fully
grok it might happen that a detached loopback block device still has
partition block devices around. Accessing these partition block devices
results in EIO errors (that also fill up dmesg). These devices cannot be
claned up with LOOP_CLR_FD (since the main device already is officially
detached), nor with LOOP_CTL_DELETE (returns EBUSY as long as the
partitions still exist). This is a kernel bug. But it appears to apply
to all recent kernels. I cannot really pin down what triggers this,
suffice to say our heavy-duty test can trigger it.

Either way, let's do something about it: when we notice this state we'll
attach an empty file to it, which is guaranteed to have to part table.
This makes the partitions go away. After closing/reoping the device we
hence are good to go again. ugly workaround, but I think OK enough to
use.

The net result is: with this commit, we'll guarantee that by the time we
attach a file to the loopback device we have zero kernel partitions
associated with it. Thus if we then wait for the kernel partitions we
need to appear we should have entirely reliable behaviour even if
loopback devices by the name are heavily recycled and udev events reach
us very late.

Fixes: #16858
2020-10-22 14:58:27 +02:00
Lennart Poettering 4ba86848c9 dissect-image: rework how we wait for partitions
Previously, we'd just wait for the first moment where the kernel exposes
the same numbre of partitions as libblkid tells us. After that point we
enumerate kernel partitions and look for matching libblkid partitions.

With this change we'll instead enumerate with libblkid only, and then
wait for each kernel partition to show up with the exact parameters we
expect them to show up. Once that happens we are happy.

Care is taken to use the udev device notification messages only as hint
to recheck what the kernel actually says. That's because we are
otherwise subject to a race: we might see udev events from an earlier
use of a loopback device. After all these devices are heavily recycled.
Under the assumption that we'll get udev events for *at least* all
partitions we care about (but possibly more) we can fix the race
entirely with one more fix coming in a later commit: if we make sure
that a loopback block device has zero kernel partitions when we take
possession of it, it doesn't matter anymore if we get spurious udev
events from a previous use. All we have to do is notice when the devices
we need all popped up.
2020-10-22 14:58:27 +02:00
Lennart Poettering 6c544d14d9 dissect-image: wait for udev device to be initialized early
If we allocate the sd_device early we can already use it as path when
looking at whole-device fs images.
2020-10-22 14:58:27 +02:00