]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agojournal: Rename JournaldFile to ManagedJournalFile 22373/head
Daan De Meyer [Wed, 2 Feb 2022 14:30:50 +0000 (14:30 +0000)] 
journal: Rename JournaldFile to ManagedJournalFile

JournalFile and JournaldFile are hard to distinguish from each other.
Let's use ManagedJournalFile instead to make the distinction more clear.

3 years agonetwork: update operational state when we remove an address
Yu Watanabe [Wed, 2 Feb 2022 07:39:38 +0000 (16:39 +0900)] 
network: update operational state when we remove an address

3 years agodhcp-identifier: always use a fixed machine-id while fuzzing
Evgeny Vereshchagin [Wed, 2 Feb 2022 08:30:19 +0000 (08:30 +0000)] 
dhcp-identifier: always use a fixed machine-id while fuzzing

It's a follow-up to https://github.com/systemd/systemd/pull/10200 where
that fuzzer was introduced. At the time it was run regularly on machines
where machine-id wasn't present so it was kind of reproducible. Now
it's run on CIFuzz and CFLite using GHActions with the public OSS-Fuzz
corpora (based on that particular machine-id) so to fully utilize
those corpora it's necessary to use it always. Other than that
it makes it possible for fuzzers targeting outgoing packets
based on incoming packets like https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1795921
to get past client_parse_message on my machine :-)

3 years agotest: allow to set NULL to intro or outro
Yu Watanabe [Wed, 2 Feb 2022 02:06:41 +0000 (11:06 +0900)] 
test: allow to set NULL to intro or outro

Addresses https://github.com/systemd/systemd/pull/22338#discussion_r796741033.

3 years agoMerge pull request #22359 from yuwata/mkdir-fix
Luca Boccassi [Wed, 2 Feb 2022 11:03:04 +0000 (11:03 +0000)] 
Merge pull request #22359 from yuwata/mkdir-fix

mkdir: allow to create directory whose path contains symlink

3 years agotest: add a test for mkdir_p() 22359/head
Yu Watanabe [Wed, 2 Feb 2022 06:08:18 +0000 (15:08 +0900)] 
test: add a test for mkdir_p()

3 years agomkdir: allow to create directory whose path contains symlink
Yu Watanabe [Wed, 2 Feb 2022 05:20:48 +0000 (14:20 +0900)] 
mkdir: allow to create directory whose path contains symlink

Fixes a regression caused by 3008a6f21c1c42efe852d69798a2fdd63fe657ec.

Before the commit, when `mkdir_parents_internal()` is called from `mkdir_p()`,
it uses `_mkdir()` as `flag` is zero. But after the commit, `mkdir_safe_internal()`
is always used. Hence, if the path contains a symlink, it fails with -ENOTDIR.

To fix the issue, this makes `mkdir_p()` calls `mkdir_parents_internal()` with
MKDIR_FOLLOW_SYMLINK flag.

Fixes #22334.

3 years agomkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()
Yu Watanabe [Wed, 2 Feb 2022 06:06:27 +0000 (15:06 +0900)] 
mkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()

3 years agocore/mount: fail early if directory cannot be created
Yu Watanabe [Wed, 2 Feb 2022 05:05:45 +0000 (14:05 +0900)] 
core/mount: fail early if directory cannot be created

Prompted by #22334.

3 years agoMerge pull request #22350 from poettering/journal-read-object-fix
Yu Watanabe [Wed, 2 Feb 2022 04:47:32 +0000 (13:47 +0900)] 
Merge pull request #22350 from poettering/journal-read-object-fix

journal: various fixes to journal_file_read_object()

3 years agosystemctl: strings returned by sd_bus_message_read_basic() are immutable
Lennart Poettering [Tue, 1 Feb 2022 16:38:23 +0000 (17:38 +0100)] 
systemctl: strings returned by sd_bus_message_read_basic() are immutable

It's totally not OK to write to the strings returned by it, the data is
shared by all code that references the message.

While we are at it, simplify the code via
json_variant_set_field_string().

Follow-up for: 5ef599b324efbcb7af317c102b59c662df068500

3 years agojournal-file: don't use pread() when determining where to append, use mmap as before 22350/head
Lennart Poettering [Tue, 1 Feb 2022 17:45:35 +0000 (18:45 +0100)] 
journal-file: don't use pread() when determining where to append, use mmap as before

This partially undoes the effect of
ab6e257b3e4e5b95f3750ed019bed6e89989e41b.

Originally, we always used the mmap logic to determine the current end
of the file. ab6e257b3e4e5b95f3750ed019bed6e89989e41b changed this so
that we always used pread().

With this change we'll use pread() from the synchronization thread and
mmap otherwise.

3 years agotests: rework test macros to not take code as parameters
Lennart Poettering [Tue, 1 Feb 2022 11:06:59 +0000 (12:06 +0100)] 
tests: rework test macros to not take code as parameters

C macros are nasty. We use them, but we try to be conservative with
them. In particular passing literal, complex code blocks as argument is
icky, because of "," handling of C, and also because it's quite a
challange for most code highlighters and similar. Hence, let's avoid
that. Using macros for genreating functions is OK but if so, the
parameters should be simple words, not full code blocks.

hence, rework DEFINE_CUSTOM_TEST_MAIN() to take a function name instead
of code block as argument.

As side-effect this also fixes a bunch of cases where we might end up
returning a negative value from main().

Some uses of DEFINE_CUSTOM_TEST_MAIN() inserted local variables into the
main() functions, these are replaced by static variables, and their
destructors by the static destructor logic.

This doesn't fix any bugs or so, it's just supposed to make the code
easier to work with and improve it easthetically.

Or in other words: let's use macros where it really makes sense, but
let's not go overboard with it.

(And yes, FOREACH_DIRENT() is another one of those macros that take
code, and I dislike that too and regret I ever added that.)

3 years agonetwork: dhcp-server: make empty string to DNS= or friends clear previously specified...
Yu Watanabe [Tue, 1 Feb 2022 22:20:25 +0000 (07:20 +0900)] 
network: dhcp-server: make empty string to DNS= or friends clear previously specified servers

3 years agosd-dhcp-lease: store static routes and classless static routes in different arrays
Yu Watanabe [Tue, 1 Feb 2022 21:35:43 +0000 (06:35 +0900)] 
sd-dhcp-lease: store static routes and classless static routes in different arrays

When classless static routes option is provided, then static routes
option should not be used. Hence, let's not mix and store them in one
storage.

This introduce sd_dhcp_lease_get_static_routes() and
sd_dhcp_lease_get_classless_routes().

3 years agoMerge pull request #22351 from mrc0mmand/TEST-56-cgroupsv1
Yu Watanabe [Wed, 2 Feb 2022 01:02:26 +0000 (10:02 +0900)] 
Merge pull request #22351 from mrc0mmand/TEST-56-cgroupsv1

test: require unified cgroup hierarchy for TEST-56

3 years agoresolve: add missing OOM check
Lennart Poettering [Tue, 1 Feb 2022 16:38:12 +0000 (17:38 +0100)] 
resolve: add missing OOM check

3 years agocore: warn on ExitType=cgroup with legacy cgroup setup
Luca Boccassi [Tue, 1 Feb 2022 15:31:52 +0000 (15:31 +0000)] 
core: warn on ExitType=cgroup with legacy cgroup setup

'cgroup empty' notifications are not reliable on v1, so log a warning.

See: https://github.com/systemd/systemd/issues/22320

3 years agoMerge pull request #22332 from yuwata/network-dhcp-server-dns-server-address
Yu Watanabe [Tue, 1 Feb 2022 22:07:22 +0000 (07:07 +0900)] 
Merge pull request #22332 from yuwata/network-dhcp-server-dns-server-address

network: dhcp-server: allow to specify server address for DNS= or friends

3 years agoMerge pull request #22327 from joanbm/main_resolved_improvements
Yu Watanabe [Tue, 1 Feb 2022 22:06:56 +0000 (07:06 +0900)] 
Merge pull request #22327 from joanbm/main_resolved_improvements

resolved: misc. small DnsStream refactors and improvements

3 years agotest: require unified cgroup hierarchy for TEST-56 22351/head
Frantisek Sumsal [Tue, 1 Feb 2022 19:25:00 +0000 (20:25 +0100)] 
test: require unified cgroup hierarchy for TEST-56

since cgroup empty notifications are unreliable in legacy cgroups.

See: systemd/systemd#22320
Complements: systemd/systemd#22344

3 years agotest: introduce `get_cgroup_hierarchy() helper
Frantisek Sumsal [Tue, 1 Feb 2022 19:18:29 +0000 (20:18 +0100)] 
test: introduce `get_cgroup_hierarchy() helper

which returns the host's cgroup hierarchy (unified, hybrid, or legacy).

3 years agounits: we need systemd-journald.service from systemd-journal-flush.service
Lennart Poettering [Tue, 1 Feb 2022 17:11:04 +0000 (18:11 +0100)] 
units: we need systemd-journald.service from systemd-journal-flush.service

This is a follow-up for d5ee050ffc9d413253932d9340ade8c8fb111092, and
reintroduces a requirement dep from systemd-journal-flush.service onto
systemd-journald.service, but a weaker one than originally: a Wants= one
instead of a Requires= one.

Why? Simply because the service issues an IPC call to the journald,
hence it should pull it in. (Note that socket activation doesn't happen
for the Varlink socket it uses, hence we should pull in the service
itself.)

3 years agotest-network: add tests for DNS=_server_address in [DHCPServer] 22332/head
Yu Watanabe [Tue, 1 Feb 2022 07:30:45 +0000 (16:30 +0900)] 
test-network: add tests for DNS=_server_address in [DHCPServer]

3 years agonetwork: dhcp-server: introduce special value DNS=_server_address
Yu Watanabe [Tue, 1 Feb 2022 07:20:33 +0000 (16:20 +0900)] 
network: dhcp-server: introduce special value DNS=_server_address

Closes #15026.

3 years agoMerge pull request #22310 from yuwata/sd-dhcp-lease-fixes
Yu Watanabe [Tue, 1 Feb 2022 19:55:07 +0000 (04:55 +0900)] 
Merge pull request #22310 from yuwata/sd-dhcp-lease-fixes

sd-dhcp-lease: two fixes

3 years agoMerge pull request #22343 from poettering/assert-se-efi
Luca Boccassi [Tue, 1 Feb 2022 19:26:57 +0000 (19:26 +0000)] 
Merge pull request #22343 from poettering/assert-se-efi

efi: add/user assert_se()/ASSERT_SE_PTR() for OOM handling

3 years agoanalyze: correctly mention that --json= is also understood by inspect-elf
Lennart Poettering [Tue, 1 Feb 2022 16:37:19 +0000 (17:37 +0100)] 
analyze: correctly mention that --json= is also understood by inspect-elf

3 years agoresolved: Allow test-resolved-stream to run concurrently 22327/head
Joan Bruguera [Sun, 30 Jan 2022 16:56:32 +0000 (17:56 +0100)] 
resolved: Allow test-resolved-stream to run concurrently

Since test-resolved-stream brings up a simple DNS server on 127.0.0.1:12345,
only one instance could run at a time, so it would fail when run like
`meson test -C build test-resolved-stream --repeat=1000`.
Similarly, if by chance something is up on port 12345, the test would fail.

To make the test more reliable, run it in an isolated user + network namespace.
If this fails (some distributions disable user namespaces), just run as before.

3 years agoresolved: Read as much as possible per stream EPOLLIN event
Joan Bruguera [Sun, 30 Jan 2022 11:51:10 +0000 (12:51 +0100)] 
resolved: Read as much as possible per stream EPOLLIN event

In commit 2aaf6bb6e99b0f2bd73e0c49bef9e11a2844bf1a, an issue was fixed where
systemd-resolved could get stuck for multiple seconds waiting for incoming data,
since GnuTLS/OpenSSL can buffer a TLS record, so data could be available, but
no EPOLLIN event would be generated.

To fix this, a somewhat elaborate logic consisting on asking the TLS library
whether it had buffered data, then "faking" an EPOLLIN event was implemented.

However, there is a much simpler solution: Always read as much data as available
(i.e. until we get an event like EAGAIN when trying to read) from the stream
when we get an EPOLLIN event, instead of at most a single packet per event.
This approach does not require asking the TLS library whether it has buffered
data, and the logic is exactly the same for both the TCP and TLS case.

test-resolved-stream is fixed to avoid a latent double free bug.

3 years agoresolved: Avoid multiple SSL writes per DoT packet
Joan Bruguera [Mon, 31 Jan 2022 20:28:32 +0000 (21:28 +0100)] 
resolved: Avoid multiple SSL writes per DoT packet

In the DoT case, dns_stream_writev decomposed an iovec into multiple
dnstls_stream_write calls, which resulted in multiple SSL writes and multiple
TLS records. This can be checked from a network capture, e.g. using socat:
socat -v -x openssl-listen:853,reuseaddr,fork,cert=my.cert,key=my.key,verify=0 openssl:8.8.8.8:853

Instead, propagate the iovec as-is into the DoT handling code. For GnuTLS, the
library provides support for buffering ('corking') a record. OpenSSL has no
such facility, so we join the iovec into a single buffer then call SSL_write.

socat capture of `resolvectl -4 query --cache=no example.com` before the commit:

> 2022/01/30 13:35:52.194200  length=2 from=0 to=1
 00 28                                            .(
--
> 2022/01/30 13:35:52.194253  length=40 from=2 to=41
 1e b2 01 00 00 01 00 00 00 00 00 01 07 65 78 61  .............exa
 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 00 00 29  mple.com.......)
 ff e4 00 00 00 00 00 00                          ........
--
< 2022/01/30 13:35:52.232798  length=58 from=0 to=57
 00 38 1e b2 81 80 00 01 00 01 00 00 00 01 07 65  .8.............e
 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 c0  xample.com......
 0c 00 01 00 01 00 00 53 6f 00 04 5d b8 d8 22 00  .......So..]..".
 00 29 02 00 00 00 00 00 00 00                    .)........

socat capture of `resolvectl -4 query --cache=no example.com` after the commit:

> 2022/01/30 13:34:47.598099  length=42 from=504 to=545
 00 28 37 86 01 00 00 01 00 00 00 00 00 01 07 65  .(7............e
 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 00  xample.com......
 00 29 ff e4 00 00 00 00 00 00                    .)........
--
< 2022/01/30 13:34:47.613203  length=58 from=756 to=813
 00 38 37 86 81 80 00 01 00 01 00 00 00 01 07 65  .87............e
 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 c0  xample.com......
 0c 00 01 00 01 00 00 52 5e 00 04 5d b8 d8 22 00  .......R^..]..".
 00 29 02 00 00 00 00 00 00 00                    .)........

3 years agoresolved: Make event flags logic robust for DoT
Joan Bruguera [Mon, 31 Jan 2022 20:28:21 +0000 (21:28 +0100)] 
resolved: Make event flags logic robust for DoT

Since when handling a DNS over TLS stream, the TLS library can override the
requested events through dnstls_events for handshake/shutdown purposes,
obtaining the event flags through sd_event_source_get_io_events and checking
for EPOLLIN or EPOLLOUT does not really tell us whether we want to read/write
a packet. Instead, it could just be OpenSSL/GnuTLS doing something else.

To make the logic more robust (and simpler), save the flags that tell us
whether we want to read/write a packet, and check them instead of the IO flags.

(& use uint32_t for the flags like in sd_event_source_set_io_events prototype)

3 years agojournal: various fixes to journal_file_read_object()
Lennart Poettering [Tue, 1 Feb 2022 17:31:12 +0000 (18:31 +0100)] 
journal: various fixes to journal_file_read_object()

This fixes a bunch of issues:

pread() returns ssize_t, and returns errors in 'errno', handle that
correctly.

More importantly: it might incompletely read data in case we hit
EOF. Check for that, and handle it.

Finally, rename the function to journal_file_read_object_header(), since
it really doesn't read full objects, but only their headers.

Follow-up for: 117e21121e857b4b7d81949542e8dd257265970a

3 years agoNEWS: minor formatting tweaks
Lennart Poettering [Tue, 1 Feb 2022 16:37:08 +0000 (17:37 +0100)] 
NEWS: minor formatting tweaks

3 years agoMerge pull request #22341 from poettering/pam-end-fix
Luca Boccassi [Tue, 1 Feb 2022 16:34:00 +0000 (16:34 +0000)] 
Merge pull request #22341 from poettering/pam-end-fix

pid1: pam_end() PAM_DATA_SILENT fix

3 years agoutil: another set of CVE-2021-4034 assert()s
Lennart Poettering [Tue, 1 Feb 2022 11:06:21 +0000 (12:06 +0100)] 
util: another set of CVE-2021-4034 assert()s

It's a good idea that we validate argc/argv when we are supposed to
store them away.

3 years agoefi: use assert_se() instead of assert() to guard for OOM issues in EFI code 22343/head
Lennart Poettering [Tue, 1 Feb 2022 14:28:33 +0000 (15:28 +0100)] 
efi: use assert_se() instead of assert() to guard for OOM issues in EFI code

3 years agomacro: add ASSERT_SE_PTR() macro
Lennart Poettering [Tue, 1 Feb 2022 13:43:04 +0000 (14:43 +0100)] 
macro: add ASSERT_SE_PTR() macro

ASSERT_SE_PTR() is like ASSERT_PTR() but uses assert_se() instead of
assert() internally.

Code should use ASSERT_SE_PTR() where the check should never be
optimized away, even if NDEBUG is set.

Rationale: assert() is the right choice for validating assumptions about
our own code, i.e. checking conditions that are "impossible" to not
hold, because we ourselves hacked things up the "right" way of course.
assert_se() is the right choice for tests that come with a weaker
guarantee, they encode assumptions over other's API behaviour, i.e.
whether something can fail there or not.

When developing tools that are not oom-safe assert_se() is the right
choice: we know that on Linux OOM doesn't really happen, even though
theoretically the API allows it to happen.

Usecase for ASSERT_SE_PTR() is mostly the fatal memory allocation logic
for EFI memory allocations. So far it used regular assert() i.e. OOM
failurs would be totally ignored if NDEBUG is set. We'd rather have our
EFI program to print an assert message and freeze instead though.

3 years agofundamental: support assert_se() in EFI mode too
Lennart Poettering [Tue, 1 Feb 2022 14:28:19 +0000 (15:28 +0100)] 
fundamental: support assert_se() in EFI mode too

3 years agoMerge pull request #22331 from yuwata/network-xfrm-interface-id
Luca Boccassi [Tue, 1 Feb 2022 13:25:38 +0000 (13:25 +0000)] 
Merge pull request #22331 from yuwata/network-xfrm-interface-id

network: xfrm: refuse zero interface ID

3 years agoexecute: document that the 'env' param is input *and* output 22341/head
Lennart Poettering [Tue, 1 Feb 2022 12:50:28 +0000 (13:50 +0100)] 
execute: document that the 'env' param is input *and* output

3 years agoexecute: line break comments a bit less aggressively
Lennart Poettering [Tue, 1 Feb 2022 12:50:13 +0000 (13:50 +0100)] 
execute: line break comments a bit less aggressively

3 years agoexecute: use _cleanup_ logic where appropriate
Lennart Poettering [Tue, 1 Feb 2022 12:49:56 +0000 (13:49 +0100)] 
execute: use _cleanup_ logic where appropriate

3 years agopid1: pass PAM_DATA_SILENT to pam_end() in child
Lennart Poettering [Tue, 1 Feb 2022 11:37:51 +0000 (12:37 +0100)] 
pid1: pass PAM_DATA_SILENT to pam_end() in child

Fixes: #22318
3 years agonetwork: dhcp-server: also refuse link local address to use as the server address
Yu Watanabe [Tue, 1 Feb 2022 07:39:43 +0000 (16:39 +0900)] 
network: dhcp-server: also refuse link local address to use as the server address

3 years agonetwork: use GREEDY_REALLOC() at one more place
Yu Watanabe [Tue, 1 Feb 2022 07:14:59 +0000 (16:14 +0900)] 
network: use GREEDY_REALLOC() at one more place

3 years agosd-dhcp-server: convert null address for e.g. DNS to server address
Yu Watanabe [Tue, 1 Feb 2022 07:09:17 +0000 (16:09 +0900)] 
sd-dhcp-server: convert null address for e.g. DNS to server address

3 years agosd-dhcp-server: use free_and_replace() at one more place
Yu Watanabe [Tue, 1 Feb 2022 06:49:52 +0000 (15:49 +0900)] 
sd-dhcp-server: use free_and_replace() at one more place

3 years agonetwork: drop outdated TODO comment
Yu Watanabe [Tue, 1 Feb 2022 06:38:39 +0000 (15:38 +0900)] 
network: drop outdated TODO comment

Follow-up for 59aa622013277cfe6349d0789a7a00ad2b884902.

3 years agoMerge pull request #22254 from yuwata/dhcp-server-fix-segfault
Yu Watanabe [Tue, 1 Feb 2022 05:10:11 +0000 (14:10 +0900)] 
Merge pull request #22254 from yuwata/dhcp-server-fix-segfault

sd-dhcp-server: remove lease with hashmap_remove_value()

3 years agoMerge pull request #22319 from yuwata/network-use-reconfigure
Yu Watanabe [Tue, 1 Feb 2022 05:09:32 +0000 (14:09 +0900)] 
Merge pull request #22319 from yuwata/network-use-reconfigure

network: also use link_reconfigure_impl() to initially assign .network file

3 years agotest-network: set xfrm interface ID 22331/head
Yu Watanabe [Tue, 1 Feb 2022 04:26:40 +0000 (13:26 +0900)] 
test-network: set xfrm interface ID

This also unifies two tests for xfrm, and checks the output of
'ip link' command.

Fixes #22329.

3 years agonetwork: xfrm: refuse zero interface ID
Yu Watanabe [Tue, 1 Feb 2022 04:00:51 +0000 (13:00 +0900)] 
network: xfrm: refuse zero interface ID

Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically,
https://github.com/torvalds/linux/commit/8dce43919566f06e865f7e8949f5c10d8c2493f5)
the kernel refuses to create an xfrm interface with zero ID.

3 years agomeson: use full argument names for bpftool gen commands
James Hilliard [Tue, 1 Feb 2022 01:20:53 +0000 (18:20 -0700)] 
meson: use full argument names for bpftool gen commands

This should be a purely cosmetic change.

3 years agosd-dhcp-lease: fix memleak 22310/head
Yu Watanabe [Sun, 30 Jan 2022 20:19:09 +0000 (05:19 +0900)] 
sd-dhcp-lease: fix memleak

Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811.

3 years agosd-dhcp-lease: fix reading unaligned memory
Yu Watanabe [Sun, 30 Jan 2022 20:04:52 +0000 (05:04 +0900)] 
sd-dhcp-lease: fix reading unaligned memory

The destination address was read twice, one is for prefixlen, and
other is for destination address itself. And for prefixlen, the address
might be read from unaligned buffer.

This also modernizes the code.

3 years agofuzz-dhcp-server: add static leases 22254/head
Yu Watanabe [Fri, 28 Jan 2022 01:12:00 +0000 (10:12 +0900)] 
fuzz-dhcp-server: add static leases

3 years agotest-dhcp-server: add tests for static lease
Yu Watanabe [Thu, 27 Jan 2022 18:07:28 +0000 (03:07 +0900)] 
test-dhcp-server: add tests for static lease

3 years agotest-dhcp-server: add tests for setting static DHCP lease
Yu Watanabe [Thu, 27 Jan 2022 07:04:20 +0000 (16:04 +0900)] 
test-dhcp-server: add tests for setting static DHCP lease

3 years agotest-dhcp-server: add usual headers
Yu Watanabe [Thu, 27 Jan 2022 06:40:40 +0000 (15:40 +0900)] 
test-dhcp-server: add usual headers

3 years agotest-dhcp-server: run a test earlier which does not require privilege
Yu Watanabe [Thu, 27 Jan 2022 07:07:48 +0000 (16:07 +0900)] 
test-dhcp-server: run a test earlier which does not require privilege

3 years agotest-dhcp-server: move sd-event allocation
Yu Watanabe [Thu, 27 Jan 2022 07:11:02 +0000 (16:11 +0900)] 
test-dhcp-server: move sd-event allocation

3 years agotest-dhcp-server: use log_tests_skipped_errno()
Yu Watanabe [Thu, 27 Jan 2022 07:06:13 +0000 (16:06 +0900)] 
test-dhcp-server: use log_tests_skipped_errno()

3 years agosd-dhcp-server: split out logic to ACK request
Yu Watanabe [Thu, 27 Jan 2022 17:44:10 +0000 (02:44 +0900)] 
sd-dhcp-server: split out logic to ACK request

3 years agosd-dhcp-server: do not assign address reserved for static leases to non-matching...
Yu Watanabe [Thu, 27 Jan 2022 17:25:37 +0000 (02:25 +0900)] 
sd-dhcp-server: do not assign address reserved for static leases to non-matching clients

This fix the root cause of the issue #22253.

3 years agosd-dhcp-server: explicitly refuse when conflicting address is requested
Yu Watanabe [Thu, 27 Jan 2022 18:50:57 +0000 (03:50 +0900)] 
sd-dhcp-server: explicitly refuse when conflicting address is requested

3 years agosd-dhcp-server: do not assign an address from pool when a static lease for the client...
Yu Watanabe [Thu, 27 Jan 2022 18:50:16 +0000 (03:50 +0900)] 
sd-dhcp-server: do not assign an address from pool when a static lease for the client ID exists

3 years agosd-dhcp-server: rename get_pool_offset() -> address_is_in_pool()
Yu Watanabe [Thu, 27 Jan 2022 17:10:23 +0000 (02:10 +0900)] 
sd-dhcp-server: rename get_pool_offset() -> address_is_in_pool()

As, the value of pool_offset is not used.

3 years agosd-dhcp-server: rename server_send_nak() -> server_send_nak_or_ignore()
Yu Watanabe [Thu, 27 Jan 2022 17:14:47 +0000 (02:14 +0900)] 
sd-dhcp-server: rename server_send_nak() -> server_send_nak_or_ignore()

And logs error in the function.

3 years agosd-dhcp-server: set DHCPLease::server before hashmap_put()
Yu Watanabe [Wed, 26 Jan 2022 15:17:23 +0000 (00:17 +0900)] 
sd-dhcp-server: set DHCPLease::server before hashmap_put()

Otherwise, if the second push is failed, then the first hashmap contains
dirty entry.

Also, this makes hashmap_remove_value() used when removing leases to
make not wrong lease is removed from the hashmap.

Note, this just hide the root cause of the issue #22253, which will be
fixed in later commit.

Fixes #22253.

3 years agosd-dhcp-server: fix indentation
Yu Watanabe [Thu, 27 Jan 2022 16:24:35 +0000 (01:24 +0900)] 
sd-dhcp-server: fix indentation

3 years agosd-dhcp-server: rename argument and add one missing assertion
Yu Watanabe [Thu, 27 Jan 2022 16:24:20 +0000 (01:24 +0900)] 
sd-dhcp-server: rename argument and add one missing assertion

3 years agosd-dhcp-server: do not use implicit cast to boolean from integer
Yu Watanabe [Thu, 27 Jan 2022 16:23:39 +0000 (01:23 +0900)] 
sd-dhcp-server: do not use implicit cast to boolean from integer

3 years agosd-dhcp-server: refuse zero length client ID
Yu Watanabe [Thu, 27 Jan 2022 16:05:52 +0000 (01:05 +0900)] 
sd-dhcp-server: refuse zero length client ID

3 years agosd-dhcp-server: do not log "STOPPED" when already stopped
Yu Watanabe [Thu, 27 Jan 2022 07:19:10 +0000 (16:19 +0900)] 
sd-dhcp-server: do not log "STOPPED" when already stopped

3 years agonetwork: also use link_reconfigure_impl() to initially assign .network file 22319/head
Yu Watanabe [Mon, 31 Jan 2022 07:32:05 +0000 (16:32 +0900)] 
network: also use link_reconfigure_impl() to initially assign .network file

3 years agonetwork: drop tiny wrapper used only one place anymore
Yu Watanabe [Tue, 1 Feb 2022 02:37:45 +0000 (11:37 +0900)] 
network: drop tiny wrapper used only one place anymore

3 years agonetwork: do not free bound_by carrier map on reconfigure
Yu Watanabe [Mon, 31 Jan 2022 13:30:39 +0000 (22:30 +0900)] 
network: do not free bound_by carrier map on reconfigure

Otherwise, if a link enters unmanaged state, then its carrier state does
not propagated to other interfaces.

3 years agonetwork: do not remove localhost address
Yu Watanabe [Mon, 31 Jan 2022 10:26:51 +0000 (19:26 +0900)] 
network: do not remove localhost address

Managing loopback interfaces by networkd is not recommended, but supporeted.
Even such spurious situation, do not drop the localhost addresses.

3 years agonetwork: move ndisc_flush() to link_stop_engines()
Yu Watanabe [Mon, 31 Jan 2022 10:09:30 +0000 (19:09 +0900)] 
network: move ndisc_flush() to link_stop_engines()

As it is not related to any static configs.

3 years agonetwork: remove only managed configs on reconfigure or carrier lost
Yu Watanabe [Mon, 31 Jan 2022 10:08:27 +0000 (19:08 +0900)] 
network: remove only managed configs on reconfigure or carrier lost

Otherwise, if the carrir of the non-managed interface is lost, the
configs such as addresses or routes on the interface will be removed by
networkd.

3 years agoMerge pull request #22175 from keszybz/kernel-install-mkosi-initrd
Luca Boccassi [Mon, 31 Jan 2022 23:09:46 +0000 (23:09 +0000)] 
Merge pull request #22175 from keszybz/kernel-install-mkosi-initrd

kernel-install: add support for KERNEL_INSTALL_INITRD_GENERATOR and KERNEL_INSTALL_STAGING_AREA

3 years agonetwork: s/confiured/configured/
Frantisek Sumsal [Mon, 31 Jan 2022 21:17:48 +0000 (22:17 +0100)] 
network: s/confiured/configured/

A quick typo fix I noticed whilst debugging.

3 years agotree-wide: some additional checks to avoid CVE-2021-4034 style weaknesses
Lennart Poettering [Mon, 31 Jan 2022 16:58:18 +0000 (17:58 +0100)] 
tree-wide: some additional checks to avoid CVE-2021-4034 style weaknesses

3 years agorandom-seed: add missing %m in error message
Lennart Poettering [Mon, 31 Jan 2022 16:58:42 +0000 (17:58 +0100)] 
random-seed: add missing %m in error message

3 years agoMerge pull request #22323 from mrc0mmand/fix-TEST-69-on-C8S
Frantisek Sumsal [Mon, 31 Jan 2022 19:04:02 +0000 (19:04 +0000)] 
Merge pull request #22323 from mrc0mmand/fix-TEST-69-on-C8S

test: use ~/.bashrc instead of /etc/bash.bashrc

3 years agoupdate TODO
Lennart Poettering [Mon, 31 Jan 2022 16:58:25 +0000 (17:58 +0100)] 
update TODO

3 years agotest: copy portable profiles into the image if they don't exist there
Frantisek Sumsal [Mon, 31 Jan 2022 13:19:09 +0000 (14:19 +0100)] 
test: copy portable profiles into the image if they don't exist there

If we're built with `-Dportable=false`, the portable profiles won't get
installed into the image. Since we need only the profile files and
nothing else, let's copy them into the image explicitly in such case.

3 years agotest: use ~/.bashrc instead of /etc/bash.bashrc 22323/head
Frantisek Sumsal [Mon, 31 Jan 2022 16:11:06 +0000 (17:11 +0100)] 
test: use ~/.bashrc instead of /etc/bash.bashrc

/etc/bash.bashrc appears to be Debian-specific[0] (or specific to bash
versions compiled with -DSYS_BASHRC), which doesn't seem to be the case
for C8S. Let's use ~/.bashrc instead to make the CIs happy again.

[0] https://sources.debian.org/src/bash/5.1-6/debian/README/#L50-L56

3 years agotest: make the code less error-prone
Frantisek Sumsal [Mon, 31 Jan 2022 15:48:15 +0000 (16:48 +0100)] 
test: make the code less error-prone

3 years agoMerge pull request #22316 from yuwata/network-mac-address-length
Luca Boccassi [Mon, 31 Jan 2022 14:21:28 +0000 (14:21 +0000)] 
Merge pull request #22316 from yuwata/network-mac-address-length

network: several cleanups related to MAC address length

3 years agoMerge pull request #22300 from yuwata/bus-fix-error-handling
Luca Boccassi [Mon, 31 Jan 2022 14:03:00 +0000 (14:03 +0000)] 
Merge pull request #22300 from yuwata/bus-fix-error-handling

tree-wide: fix bus method error handling

3 years agoboot: Don't require a machine ID to be available
Daan De Meyer [Fri, 28 Jan 2022 15:40:09 +0000 (15:40 +0000)] 
boot: Don't require a machine ID to be available

Regression introduced in https://github.com/systemd/systemd/pull/21807.

Fixes #22224

3 years agoMerge pull request #22274 from yuwata/resolve-comment
Luca Boccassi [Mon, 31 Jan 2022 13:56:04 +0000 (13:56 +0000)] 
Merge pull request #22274 from yuwata/resolve-comment

resolve: cleanups for on_stream_io()

3 years agocore: don't fail on EEXIST when creating mount point
Luca Boccassi [Fri, 28 Jan 2022 22:56:10 +0000 (22:56 +0000)] 
core: don't fail on EEXIST when creating mount point

systemd[1016]: Failed to mount /tmp/app1 (type n/a) on /run/systemd/unit-extensions/1 (MS_BIND ): No such file or directory
systemd[1016]: Failed to create destination mount point node '/run/systemd/unit-extensions/1': File exists

3 years agocore: check argc/argv uncoditionally
Frantisek Sumsal [Sun, 30 Jan 2022 14:49:27 +0000 (15:49 +0100)] 
core: check argc/argv uncoditionally

as `assert()` might be dropped with `-DNDEBUG`.

Follow-up to cf3095a and 1637e75.

3 years agoMerge pull request #21838 from lnussel/logind-refactor
Yu Watanabe [Mon, 31 Jan 2022 10:45:33 +0000 (19:45 +0900)] 
Merge pull request #21838 from lnussel/logind-refactor

Logind shutdown refactor

3 years agomeson: use bpftool based strip when available
James Hilliard [Mon, 31 Jan 2022 04:47:38 +0000 (21:47 -0700)] 
meson: use bpftool based strip when available

This should be useable in bpftool v5.13 or newer based on:
https://github.com/torvalds/linux/commit/d80b2fcbe0a023619e0fc73112f2a02c2662f6ab

3 years agomeson: set minimum clang/llvm versions for bpf support
James Hilliard [Mon, 31 Jan 2022 02:33:55 +0000 (19:33 -0700)] 
meson: set minimum clang/llvm versions for bpf support

The minimum clang/llvm-strip version needed for building libbpf based
programs is 10.0.0, this is documented here:
https://github.com/libbpf/libbpf/tree/v0.6.1#bpf-co-re-compile-once--run-everywhere

Using an older version such as 9.0.0 will generate objects that
bpftool will not be able to generate skeletons for.

3 years agonetwork: currently IPv4ACD requires MAC address whose length is ETH_ALEN 22316/head
Yu Watanabe [Mon, 31 Jan 2022 04:07:34 +0000 (13:07 +0900)] 
network: currently IPv4ACD requires MAC address whose length is ETH_ALEN