Commit Graph
54455 Commits
Author SHA1 Message Date
Lennart Poettering 979b0ff2c4 namespace-util: introduce userns_acquire() as helper for allocating new unbound userns
This returns a namespace fd, and takes a uidmap/gidmap as string. This
is split out out mount-util.c's remount_idmap() logic, so that we can
allocate a userns independently.
2021-10-22 16:34:30 +02:00
Lennart Poettering 8ddefb8eef basic: move freeze() from shared/exec-util.h to basic/process-util.h
That way we can use it in other code from basic/. It fits into both
headers equally well or badly, hence let's just move this one function.
2021-10-22 16:34:30 +02:00
Lennart Poettering 7cb791bcac homework: split home_unshare_and_mount() in two
Previously the call did two things, and the second thing was optional
(depending on first arg being NULL). Let's simplify this and just make
it two distinct functions, where one calls the other.

This should make things a bit more readable, given that we called a
function called "…and_mount()" which didn't actually mount...

No actual code changes, just some refactoring.
2021-10-22 16:09:50 +02:00
Lennart Poettering baa41cee77 homework: use bit fields where we deal with lots of separate boolean flags
No actual code changes, just making a structure a bit shorter.
2021-10-22 16:03:23 +02:00
Lennart Poettering 498abadb8c homework: add macro for "/run/systemd/user-home-mount"
We use this work dir a various places, and it's easy to mistype, hence
let the compiler detect this for us, and introduce a macro for it.

No code changes, just some search/replace.
2021-10-22 16:01:42 +02:00
Yu Watanabe 197aec7e79 network: dhcp6pd: fix the default value of subnet ID
The type of dhcp6_pd_subnet_id is int64_t.
2021-10-22 21:38:29 +09:00
Lennart Poettering 7c26a631ad varlink: disconnect varlink link in one more case
Previously we'd possibly see POLLHUP on a varlink link, and continue to
run epoll on it even though we have nothing to read nor write anymore.

Let's fix that, and once we know that there's nothing to write anymore
(or we saw a write error already) we'll disconnect after POLLHUP.

Fixes: #20062
2021-10-22 21:37:31 +09:00
Lennart Poettering 61fb966ccc test-fd-util: add test case for fd_reopen() 2021-10-22 14:06:08 +02:00
Lennart Poettering d6274e6b8f fd-util: tweak error handling in fd_reopen()
If we know that /proc/ works, then ENOENT when reopening an fd means the
fd didn't exist. Let's return the correct error code for that, i.e.
EBADF.
2021-10-22 14:06:08 +02:00
Lennart Poettering b4f73d1e17 fd-util: when re-opening a directory with fd_reopen() go via openat(…, ".", …)
This adds a tiny shortcut to fd_reopen(): if we are about to reopen the
fd via O_DIRECTORY then we know it#s a directory and we might as well
reopen it via opening "." using the fd as "at fd" in openat().

This has the benefit that we don't need /proc/self/fd/ around for this
special case: fewer sources of errors.
2021-10-22 14:05:12 +02:00
Lennart Poettering e0e914eaf8 test-networkd-address: fix clock type
The clock to use internally is clock_boottime_or_monotonic(), but the
test used CLOCK_MONOTONIC. After one system suspend the test thus likely
starts to fail.
2021-10-22 13:29:12 +02:00
Jan Janssen c496451216 sd-boot: Be more precise about secure boot modes
Fixes: #11559
2021-10-22 10:08:38 +02:00
Yu Watanabe b7f7c78793 network: dhcp6pd: check link state earlier before assigning prefixes to downstream
Also, narrow the acceptable range of the states.
2021-10-22 15:58:42 +09:00
Yu Watanabe a3ad6acf7b network: dhcp6pd: also call dhcp6_pd_prepare() and dhcp6_pd_finalize() for upstream interface
As now the subnet prefix may be assigned to the upstream interface.
2021-10-22 15:58:38 +09:00
Yu Watanabe aee21f7f8f Merge pull request #21081 from mrc0mmand/even-more-coverage-tweaks
test: collect even more coverage
2021-10-22 04:48:40 +09:00
Jonas Dreßler afa31f8c0f hwdb: Allow USB autosuspend for MS Surface Pro (2017) Type Cover
The Surface Type Covers are known to support USB autosuspend just fine
(and it's also enabled by default on Windows), so enable it in hwdb.
2021-10-21 18:59:06 +01:00
Yu Watanabe 796273775c network: dhcp6pd: not necessary to drop routes when Assign=yes 2021-10-22 02:00:46 +09:00
Yu Watanabe f45fb83996 Merge pull request #21072 from yuwata/network-address-lifetime
network: address: use usec_t for handling lifetime
2021-10-22 01:46:55 +09:00
Yu Watanabe a3e33adfb5 Merge pull request #21050 from yuwata/network-bpf-cleanups
libsystemd-network: cleanup BPF code
2021-10-22 01:46:15 +09:00
Frantisek Sumsal 7a6c5b6ab5 test: make the coverage check safer for non-compiled builds 2021-10-21 18:34:21 +02:00
Frantisek Sumsal 9bc10d3109 test: collect the coverage _before_ unmounting the rootfs
d'oh!
2021-10-21 18:12:06 +02:00
Frantisek Sumsal 02d7e73013 test: loosen sandbox restrictions for integration tests as well
Otherwise we miss quite a lot of coverage (mainly from logind,
hostnamed, networkd, and possibly others), since they can't write their
reports with `ProtectSystem=strict`.
2021-10-21 18:06:36 +02:00
Frantisek Sumsal 6c9efba677 test: loosen certain sandbox restrictions when collecting coverage
With `ProtectSystem=strict` gcov is unable to write the *.gcda files
with collected coverage. Let's add a yet another switch to make such
restriction less strict to make gcov happy.

This addresses following errors:
```
...
systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/binfmt-util.c.gcda:Cannot open
systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/base-filesystem.c.gcda:Cannot open
systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/barrier.c.gcda:Cannot open
systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/ask-password-api.c.gcda:Cannot open
systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/apparmor-util.c.gcda:Cannot open
systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/acpi-fpdt.c.gcda:Cannot open
...
```
2021-10-21 17:36:45 +02:00
Frantisek Sumsal dded88acb9 test: wait a bit for the given PID to die if it's still alive
When playing around with the coverage-enabled build I kept hitting
an issue where dnsmasq failed to start because the previous instance was
still shutting down. This should, hopefully, help to mitigate that.
2021-10-21 15:59:57 +02:00
Yu Watanabe 113e124f9b icmp6: shorten code a bit 2021-10-21 22:40:03 +09:00
Yu Watanabe ea51deb188 dhcp: shorten BPF code a bit
- replace `A = k` and `X = A` with `X = k`,
- replace `A ^= X` and `A == 0` with `A == X`.
- use UINT32_MAX when accept a packet
2021-10-21 22:39:53 +09:00
Yu Watanabe 155943b259 dhcp: rebreak function arguments 2021-10-21 22:39:43 +09:00
Yu Watanabe b8319d748f dhcp: fix assertions 2021-10-21 22:39:43 +09:00
Yu Watanabe d70c78131d dhcp: shorten code a bit 2021-10-21 22:39:43 +09:00
Yu Watanabe 36f1955da8 lldp: shorten code a bit 2021-10-21 22:39:43 +09:00
Yu Watanabe e2c7c38b74 arp-util: shorten BPF code a bit
- replace `A = k` and `X = A` with `X = k`,
- replace `A ^= X` and `A == 0` with `A == X`.
- use UINT32_MAX when accept a packet
2021-10-21 22:39:25 +09:00
Yu Watanabe 16bc8635d5 network: address: use usec_t for handling lifetime
This drops stuct ifa_cacheinfo from Address, and store lifetime with
usec_t.

Why? Now, all requests of address configurations are once stored in
the request queue, and will be processed when it is ready. So, the
timestamp value passed to the kernel must be evaluated on configure.

This also fixes the following two issues.
- Time values in struct ifa_cacheinfo are stored in uint32_t.
  So, the validity check of the address configured by NDisc may fail on
  long running systems.
- If a system uses DHCPv6PD, when an interface may appear or be
  reconfigured later, then the lifetime value may be inappropriate.
  We need to adjust the lifetime with the current time and the timestamp
  of the lease.
2021-10-21 20:58:15 +09:00
Yu Watanabe 03ccc4b423 network: ndisc: rename valid_until -> lifetime_usec 2021-10-21 20:58:15 +09:00
Yu Watanabe 09845af54b network: ndisc: add missing lifetime check 2021-10-21 20:58:15 +09:00
Yu Watanabe 91fc5135e6 network: route: rename lifetime -> lifetime_usec 2021-10-21 20:58:15 +09:00
Zbigniew Jędrzejewski-Szmek 97c373c7de Merge pull request #21065 from keszybz/efi-warnings
Clean up unused variables in efi code
2021-10-21 08:33:08 +02:00
Yu Watanabe 1c15c3653e network: drop unnecessary header inclusion 2021-10-21 08:32:04 +02:00
Luca Boccassi 0ad536c16a CI: disable code coverage in GH Action
It is now ran on the nightly CentOS build, so that it can cover
integration tests too, and not just unit tests. It's nightly as
it considerably increases the integration test runtime, so it's
not appropriate for all PRs.
2021-10-21 00:10:52 +01:00
Frantisek Sumsal 140557021a test: don't install test-network-generator-conversion.sh w/o networkd
otherwise TEST-02 will fail:

```
=== Failed test log ===
--- test-network-generator-conversion.sh begin ---
+ [[ -n '' ]]
+ [[ -x /usr/lib/systemd/systemd-network-generator ]]
+ [[ -x /lib/systemd/systemd-network-generator ]]
+ exit 1
--- test-network-generator-conversion.sh end ---
```

Before:
```
$ meson build -Dnetworkd=false -Dinstall-tests=true
$ ninja -C build
$ DESTDIR=$PWD/test-install ninja -C build install
$ find test-install/ -name test-network-generator-conversion.sh
test-install/usr/lib/systemd/tests/test-network-generator-conversion.sh
```

After:
```
$ find test-install/ -name test-network-generator-conversion.sh
<no output>
```
2021-10-20 22:04:45 +01:00
Frantisek Sumsal 0b5fe54ff5 test: collect coverage in a couple more codepaths
Otherwise we'd miss coverage from TEST-{02,24,61}, since they don't go
through the "standard" `check_result_common` hook.

Follow-up to 7bf20e48bd.
2021-10-20 16:46:58 +01:00
Yu Watanabe 21f2b19cc2 zsh-completion: nspawn: add --suppress-sync option
Follow-up for 4a4654e024.
2021-10-20 22:53:39 +09:00
Yu Watanabe 241167e68a Merge pull request #21051 from poettering/nspawn-no-sync
nspawn: add --suppress-sync=yes mode for turning sync() and friends i…
2021-10-20 22:42:43 +09:00
Luca Boccassi b78524f48d Merge pull request #21055 from yuwata/network-dhcp6-pd-route-lifetime-metric
network: dhcp6pd: set lifetime and route metric
2021-10-20 14:38:03 +01:00
Yu Watanabe 6417e8925c Merge pull request #21061 from poettering/direct-io-loopback-tweaks
tweaks to O_DIRECT loop work
2021-10-20 22:21:30 +09:00
Dimitri Papadopoulos ba669952b2 Typos found by codespell 2021-10-20 22:20:18 +09:00
Zbigniew Jędrzejewski-Szmek 2fffe2ed19 efi: check input parameter
clang complained about an unused variable. We cast the buffer to
struct boot_params, so let's check that it's at least this long.
2021-10-20 14:20:44 +02:00
Zbigniew Jędrzejewski-Szmek f3611cfb0b efi: drop two unused variables
It seems the code was added in 2553a5482c and
those two were never used for anything.
2021-10-20 13:58:03 +02:00
Lennart Poettering 4a4654e024 nspawn: add --suppress-sync=yes mode for turning sync() and friends into NOPs via seccomp
This is supposed to be used by package/image builders such as mkosi to
speed up building, since it allows us to suppress sync() inside a
container.

This does what Debian's eatmydata tool does, but for a container, and
via seccomp (instead of LD_PRELOAD).
2021-10-20 11:35:15 +02:00
Lennart Poettering 0193b93eb5 loop-util: call loop_device_make_internal() at the right place
The whole reason loop_device_make_internal() exists (as opposed to just
loop_device_make()) is to avoid mangling the loop flags value/call
getenv twice. Hence let's actually call it when we already mangled the
flags value.
2021-10-20 09:57:16 +02:00
Lennart Poettering aa4d3aa3ef loop-util: add debug logging about O_RDWR vs. O_RDONLY + O_DIRECT mode
Once we managed to open the file let's log what we wanted and what we
got.
2021-10-20 09:56:20 +02:00