]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agodns-domain: simplify code a bit 23687/head
Yu Watanabe [Fri, 10 Jun 2022 00:49:07 +0000 (09:49 +0900)] 
dns-domain: simplify code a bit

3 years agodns-domain: use dns_name_concat()
Yu Watanabe [Fri, 10 Jun 2022 00:42:24 +0000 (09:42 +0900)] 
dns-domain: use dns_name_concat()

`dns_name_normalize()` is an alias of `dns_name_concat()`.
For consistency with `dns_name_is_valid_ldh()`, let's use
`dns_name_concat()`.

3 years agofix: sd_id128_get_invocation now works for user services
i-do-cpp [Sat, 4 Jun 2022 20:18:05 +0000 (22:18 +0200)] 
fix: sd_id128_get_invocation now works for user services

3 years agotree-wide: fix typo
Yu Watanabe [Thu, 9 Jun 2022 23:26:08 +0000 (08:26 +0900)] 
tree-wide: fix typo

3 years agopo: Translated using Weblate (Estonian)
H A [Thu, 9 Jun 2022 21:18:44 +0000 (23:18 +0200)] 
po: Translated using Weblate (Estonian)

Currently translated at 18.5% (35 of 189 strings)

Co-authored-by: H A <contact+fedora@hen.ee>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/et/
Translation: systemd/main

3 years agotest: account for ADDR_NO_RANDOMIZE if it's set
Frantisek Sumsal [Thu, 9 Jun 2022 09:34:09 +0000 (11:34 +0200)] 
test: account for ADDR_NO_RANDOMIZE if it's set

On ppc64le sanitizers disable ASLR (i.e. by setting ADDR_NO_RANDOMIZE),
which opinionated_personality() doesn't return. Let's tweak the current
personality ourselves in such cases.

See: https://github.com/llvm/llvm-project/commit/78f7a6eaa601bfdd6ae70ffd3da2254c21ff77f9

Resolves: #23666

3 years agoMerge pull request #23348 from medhefgo/log-shutdown-blockers
Yu Watanabe [Thu, 9 Jun 2022 20:33:37 +0000 (05:33 +0900)] 
Merge pull request #23348 from medhefgo/log-shutdown-blockers

shutdown: Log processes that block umount

3 years agoMerge pull request #23658 from keszybz/gcc-warnings-2
Luca Boccassi [Thu, 9 Jun 2022 16:48:09 +0000 (17:48 +0100)] 
Merge pull request #23658 from keszybz/gcc-warnings-2

Fixes for NULL-pointer arguments based on gcc warnings

3 years agobpf: use __always_inline macro in restrict-ifaces.bpf.c
James Hilliard [Thu, 9 Jun 2022 06:36:29 +0000 (00:36 -0600)] 
bpf: use __always_inline macro in restrict-ifaces.bpf.c

This appears to be more reliable at inlining with some compilers.

3 years agomeson: Build with frame pointers in developer mode
Daan De Meyer [Wed, 8 Jun 2022 20:32:49 +0000 (22:32 +0200)] 
meson: Build with frame pointers in developer mode

Profiling tools tend to work better when binaries and libraries
are compiled with frame pointers as without them there's no easy
and fast way to get the current stacktrace.

3 years agoshutdown: Lazy unmount /oldroot/{dev,proc,sys} 23348/head
Jan Janssen [Wed, 18 May 2022 06:12:31 +0000 (08:12 +0200)] 
shutdown: Lazy unmount /oldroot/{dev,proc,sys}

These should not prevent us from cleaning up the remainders of /oldroot
if something in the kernel is blocking these from being unmounted.

3 years agoshutdown: Log processes that block umount
Jan Janssen [Wed, 11 May 2022 09:10:11 +0000 (11:10 +0200)] 
shutdown: Log processes that block umount

3 years agoshutdown: Rename umount_log_level and make it a bool
Jan Janssen [Thu, 9 Jun 2022 14:50:54 +0000 (16:50 +0200)] 
shutdown: Rename umount_log_level and make it a bool

This was already effectively a bool because only ever two states were
valid. To make the meaning of it more clear, also rename it to last_try.

3 years agoMerge pull request #23680 from keszybz/boot-loader-counting
Luca Boccassi [Thu, 9 Jun 2022 12:16:14 +0000 (13:16 +0100)] 
Merge pull request #23680 from keszybz/boot-loader-counting

Move boot counting into BLS proper

3 years agosystemctl: simplify code a bit 23658/head
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 14:26:18 +0000 (16:26 +0200)] 
systemctl: simplify code a bit

gcc insists that bus may be used unitialized here, but I don't see any
possibility of that.

3 years agoshared/bus-util: rename variables to follow newer style
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 14:23:36 +0000 (16:23 +0200)] 
shared/bus-util: rename variables to follow newer style

3 years agoshared/bus-util: simplification
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 14:21:25 +0000 (16:21 +0200)] 
shared/bus-util: simplification

3 years agotest-udev-util: do not pass NULL to printf, style fixes
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 14:10:58 +0000 (16:10 +0200)] 
test-udev-util: do not pass NULL to printf, style fixes

3 years agotest-process-util: do not pass NULL to printf, simplify tests
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 14:03:12 +0000 (16:03 +0200)] 
test-process-util: do not pass NULL to printf, simplify tests

We don't need to fork to test that the function returns -EINVAL
on null input. So let's simplify things a bit.

3 years agotest-dns-domain: a few more "NULL in printf %s"s
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 13:33:22 +0000 (15:33 +0200)] 
test-dns-domain: a few more "NULL in printf %s"s

3 years agotest-fstab-util: one more "NULL in printf %s"
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 13:25:43 +0000 (15:25 +0200)] 
test-fstab-util: one more "NULL in printf %s"

3 years agovarious: indentation
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 13:15:17 +0000 (15:15 +0200)] 
various: indentation

3 years agodocs/AUTOMATIC_BOOT_ASSESSMENT: describe how to integrate a DE viability check 23680/head
Zbigniew Jędrzejewski-Szmek [Thu, 9 Jun 2022 10:21:23 +0000 (12:21 +0200)] 
docs/AUTOMATIC_BOOT_ASSESSMENT: describe how to integrate a DE viability check

I reordered the component list to match chronological order: we first install
an entry, then boot it, then the checks happen, etc. Before it was
ordered by "importance", but that is harder to follow.

3 years agodocs/BLS: move "boot counting" into the main spec
Zbigniew Jędrzejewski-Szmek [Thu, 9 Jun 2022 10:15:46 +0000 (12:15 +0200)] 
docs/BLS: move "boot counting" into the main spec

The boot-counting file-renaming entry-sorting part that the boot
loader implements is moved to the main document. The second document
describes a specific implementation that is provided through systemd
units.

The sorting algorithm is extended to say that bad entries should
be sorted later.

I also added a note that bad entries should be available for booting.

For some reason, the second document said that it applies only to EFI systems.
AFAIK there are no implementations for non-EFI, but the specification should
work just fine, if somebody were to implement it. So that part is dropped.

Fixes #23345.

Sadly, bootctl doesn't implement sorting of boot entries with counting :((((
But I'm leaving that for another PR.

3 years agoMerge pull request #23654 from keszybz/gcc-warnings
Zbigniew Jędrzejewski-Szmek [Thu, 9 Jun 2022 10:55:47 +0000 (12:55 +0200)] 
Merge pull request #23654 from keszybz/gcc-warnings

Fixes for NULL-pointer arguments based on gcc warnings

3 years agoMerge pull request #23678 from aafeijoo-suse/shell-completion-cryptenroll
Zbigniew Jędrzejewski-Szmek [Thu, 9 Jun 2022 10:54:06 +0000 (12:54 +0200)] 
Merge pull request #23678 from aafeijoo-suse/shell-completion-cryptenroll

bash-completion: add systemd-cryptenroll support

3 years agobash-completion: add systemd-cryptenroll support 23678/head
Antonio Alvarez Feijoo [Thu, 9 Jun 2022 09:47:10 +0000 (11:47 +0200)] 
bash-completion: add systemd-cryptenroll support

3 years agobash-completion: fix typos in comments
Antonio Alvarez Feijoo [Thu, 9 Jun 2022 09:46:50 +0000 (11:46 +0200)] 
bash-completion: fix typos in comments

3 years agoResolve conflicts between #23616 and the recent NFT additions
Zbigniew Jędrzejewski-Szmek [Thu, 9 Jun 2022 08:06:11 +0000 (10:06 +0200)] 
Resolve conflicts between #23616 and the recent NFT additions

3 years agoMerge pull request #23616 from keszybz/in-addr-to-string-formatting
Yu Watanabe [Thu, 9 Jun 2022 06:21:57 +0000 (15:21 +0900)] 
Merge pull request #23616 from keszybz/in-addr-to-string-formatting

Add macros that allocate a fixed buffer for in_addr_to_string(), in_addr_prefix+to_string()

3 years agotest-load-fragment: don't print NULLs 23654/head
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 10:22:29 +0000 (12:22 +0200)] 
test-load-fragment: don't print NULLs

3 years agotest-bus-address: silence gcc warning about NULL arg to strcmp()
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 10:13:42 +0000 (12:13 +0200)] 
test-bus-address: silence gcc warning about NULL arg to strcmp()

The code was overly complicated… We know what value we expect, we can test it
directly.

3 years agotest-mountpoint-util: fix NULL arg to %s
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 09:20:09 +0000 (11:20 +0200)] 
test-mountpoint-util: fix NULL arg to %s

3 years agosd-journal: inline variable declarations
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 09:19:47 +0000 (11:19 +0200)] 
sd-journal: inline variable declarations

3 years agosd-journal: use _cleanup_
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 09:12:48 +0000 (11:12 +0200)] 
sd-journal: use _cleanup_

3 years agohwdb: Add HP Dev One
Jeremy Soller [Wed, 8 Jun 2022 13:59:46 +0000 (07:59 -0600)] 
hwdb: Add HP Dev One

This enables the microphone mute and programmable hotkey for the HP Dev
One.

3 years agomeson: Add nspawn-locale meson option
Daan De Meyer [Fri, 3 Jun 2022 11:18:10 +0000 (13:18 +0200)] 
meson: Add nspawn-locale meson option

https://github.com/systemd/systemd/pull/23192 caused breakage in
Arch Linux's build tooling. Let's give users an opt-out aside from
reverting the patch. It's hardly any maintenance work on our side
and gives users an easy way to revert the locale change if needed.

Of course, by default we still pick C.UTF-8 if the option is not
specified.

3 years agoMerge pull request #23675 from enr0n/udev-available-cleanup
Yu Watanabe [Thu, 9 Jun 2022 03:12:01 +0000 (12:12 +0900)] 
Merge pull request #23675 from enr0n/udev-available-cleanup

Use udev_available() where appropriate

3 years agonspawn: use udev_available() 23675/head
Nick Rosbrook [Wed, 8 Jun 2022 19:53:45 +0000 (15:53 -0400)] 
nspawn: use udev_available()

3 years agolibsystemd-network: use udev_available()
Nick Rosbrook [Wed, 8 Jun 2022 19:53:30 +0000 (15:53 -0400)] 
libsystemd-network: use udev_available()

3 years agocifuzz: build fuzzers on i386 as well
Evgeny Vereshchagin [Sun, 29 May 2022 14:15:15 +0000 (14:15 +0000)] 
cifuzz: build fuzzers on i386 as well

It's a follow-up to https://github.com/systemd/systemd/pull/23550.

3 years agopo: Added translation using Weblate (Estonian)
H A [Wed, 8 Jun 2022 20:37:32 +0000 (22:37 +0200)] 
po: Added translation using Weblate (Estonian)

Co-authored-by: H A <contact+fedora@hen.ee>
3 years agocore: firewall integration with DynamicUserNFTSet=
Topi Miettinen [Sun, 22 May 2022 12:17:24 +0000 (15:17 +0300)] 
core: firewall integration with DynamicUserNFTSet=

New directive `DynamicUserNFTSet=` provides a method for integrating
configuration of dynamic users into firewall rules with NFT sets.

Example:
```
table inet filter {
        set u {
                typeof meta skuid
        }

        chain service_output {
                meta skuid != @u drop
                accept
        }
}
```

```
/etc/systemd/system/dunft.service
[Service]
DynamicUser=yes
DynamicUserNFTSet=inet:filter:u
ExecStart=/bin/sleep 1000

[Install]
WantedBy=multi-user.target
```

```
$ sudo nft list set inet filter u
table inet filter {
        set u {
                typeof meta skuid
                elements = { 64864 }
        }
}
$ ps -n --format user,group,pid,command -p `pgrep sleep`
    USER    GROUP     PID COMMAND
   64864    64864   55158 /bin/sleep 1000
```

3 years agocore: firewall integration with ControlGroupNFTSet=
Topi Miettinen [Sun, 22 May 2022 11:21:02 +0000 (14:21 +0300)] 
core: firewall integration with ControlGroupNFTSet=

New directive `ControlGroupNFTSet=` provides a method for integrating services
into firewall rules with NFT sets.

Example:

```
table inet filter {
...
        set timesyncd {
                type cgroupsv2
        }

        chain ntp_output {
                socket cgroupv2 != @timesyncd counter drop
                accept
        }
...
}
```

/etc/systemd/system/systemd-timesyncd.service.d/override.conf
```
[Service]
ControlGroupNFTSet=inet:filter:timesyncd
```

```
$ sudo nft list set inet filter timesyncd
table inet filter {
        set timesyncd {
                type cgroupsv2
                elements = { "system.slice/systemd-timesyncd.service" }
        }
}
```

3 years agonetwork: firewall integration with NFT sets
Topi Miettinen [Sun, 22 May 2022 11:09:06 +0000 (14:09 +0300)] 
network: firewall integration with NFT sets

New directives `NFTSet=`, `IPv4NFTSet=` and `IPv6NFTSet=` provide a method for
integrating configuration of dynamic networks into firewall rules with NFT
sets.

/etc/systemd/network/eth.network
```
[DHCPv4]
...
NFTSet=netdev:filter:eth_ipv4_address
```

```
table netdev filter {
        set eth_ipv4_address {
                type ipv4_addr
                flags interval
        }
        chain eth_ingress {
                type filter hook ingress device "eth0" priority filter; policy drop;
                ip saddr != @eth_ipv4_address drop
                accept
        }
}
```
```
sudo nft list set netdev filter eth_ipv4_address
table netdev filter {
        set eth_ipv4_address {
                type ipv4_addr
                flags interval
                elements = { 10.0.0.0/24 }
        }
}
```

3 years agoMerge pull request #23641 from keszybz/janitorials
Luca Boccassi [Wed, 8 Jun 2022 16:08:13 +0000 (17:08 +0100)] 
Merge pull request #23641 from keszybz/janitorials

Janitorial cleanups

3 years agobasic: Propagate SIGBUS signal info when re-raising signals
Daan De Meyer [Thu, 2 Jun 2022 13:32:44 +0000 (15:32 +0200)] 
basic: Propagate SIGBUS signal info when re-raising signals

raise() won't propagate the siginfo information of the signal that's
re-raised. rt_sigqueueinfo() allows us to provide the original siginfo
struct which makes sure it is propagated to the next signal handler
(or to the coredump).

3 years agobasic/socket-util: align tables 23641/head
Zbigniew Jędrzejewski-Szmek [Mon, 6 Jun 2022 10:33:42 +0000 (12:33 +0200)] 
basic/socket-util: align tables

3 years agoactivate: reduce scope of iterator variables
Zbigniew Jędrzejewski-Szmek [Mon, 6 Jun 2022 10:33:31 +0000 (12:33 +0200)] 
activate: reduce scope of iterator variables

3 years agocore: wrap some long comments
Zbigniew Jędrzejewski-Szmek [Fri, 20 May 2022 15:27:35 +0000 (17:27 +0200)] 
core: wrap some long comments

3 years agoshared/condition: reduce scope of variables
Zbigniew Jędrzejewski-Szmek [Fri, 20 May 2022 10:14:17 +0000 (12:14 +0200)] 
shared/condition: reduce scope of variables

3 years agobootctl: inline iterator variable
Zbigniew Jędrzejewski-Szmek [Wed, 11 May 2022 08:53:25 +0000 (10:53 +0200)] 
bootctl: inline iterator variable

3 years agoMerge pull request #23645 from DaanDeMeyer/journalctl-static-destructor
Daan De Meyer [Tue, 7 Jun 2022 11:28:37 +0000 (12:28 +0100)] 
Merge pull request #23645 from DaanDeMeyer/journalctl-static-destructor

journalctl: Use STATIC_DESTRUCTOR_REGISTER()

3 years agoMerge pull request #23643 from mrc0mmand/asan-tweaks
Frantisek Sumsal [Tue, 7 Jun 2022 11:19:11 +0000 (11:19 +0000)] 
Merge pull request #23643 from mrc0mmand/asan-tweaks

test: fix (not only) TEST-70 under sanitizers

3 years agomeson: adjust rootlibdir default for multiarch
Mike Gilbert [Tue, 7 Jun 2022 00:55:45 +0000 (20:55 -0400)] 
meson: adjust rootlibdir default for multiarch

On Debian, libdir is commonly something like 'lib/x86_64-linux-gnu'.

The result of get_option('libdir') is normalized to a prefix-relative
path by meson, so we can just append it to rootprefixdir.

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

3 years agosd-journal: fix NULL arg to %s in error messages and hashmap lookup
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 09:00:35 +0000 (11:00 +0200)] 
sd-journal: fix NULL arg to %s in error messages and hashmap lookup

The lookup "works", but is not useful. It was introduced in
9c66f528138f4fc856b3e9e137245b7048d5747d.

And printf will NULL args is invalid was introduced in
5d1ce25728856956c1fbfe05b491067f83bd2216 when support for fds was initally
added :(

3 years agosd-hwdb: fix NULL arg to %s in error messages
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 08:52:19 +0000 (10:52 +0200)] 
sd-hwdb: fix NULL arg to %s in error messages

gcc warns about $subject, and it is obviously correct. path may or
may not be set.

3 years agobasic/unit-file: make sure we don't call streq() on NULL
Zbigniew Jędrzejewski-Szmek [Tue, 7 Jun 2022 08:50:42 +0000 (10:50 +0200)] 
basic/unit-file: make sure we don't call streq() on NULL

add_names is called in two places, with fragment_basename=NULL in one of them.
gcc warns that it can be NULL.

Fixes #23646.

3 years agomeson: install libsystemd-shared into rootpkglibdir
Michael Biebl [Wed, 1 Jun 2022 06:23:02 +0000 (08:23 +0200)] 
meson: install libsystemd-shared into rootpkglibdir

Introduce rootpkglibdir for installing libsystemd-{shared,core}.so.
The benefit over using rootlibexecdir is that this path can be
multiarch aware, i.e. this path can be architecture qualified.

This is something we'd like to make use of in Debian/Ubuntu to make
libsystemd-shared co-installable, e.g. for i386 the path would be
/usr/lib/i386-linux-gnu/systemd/libsystemd-shared-*.so and for amd64
/usr/lib/x86_64-linux-gnu/systemd/libsystemd-shared-*.so.
This will allow for example to install and run systemd-boot/i386 on an
amd64 host. It also simplifies/enables cross-building/bootstrapping.

For more infos about Multi-Arch see https://wiki.debian.org/Multiarch.

See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990547

3 years agonetworkd: NetLabel integration
Topi Miettinen [Tue, 3 May 2022 20:43:00 +0000 (23:43 +0300)] 
networkd: NetLabel integration

New directive `NetLabel=` provides a method for integrating dynamic network
configuration into Linux NetLabel subsystem rules, used by Linux security
modules (LSMs) for network access control. The option expects a whitespace
separated list of NetLabel labels. The labels must conform to lexical
restrictions of LSM labels. When an interface is configured with IP addresses,
the addresses and subnetwork masks will be appended to the NetLabel Fallback
Peer Labeling rules. They will be removed when the interface is
deconfigured. Failures to manage the labels will be ignored.

Example:
```
[DHCP]
NetLabel=system_u:object_r:localnet_peer_t:s0
```

With the above rules for interface `eth0`, when the interface is configured with
an IPv4 address of 10.0.0.0/8, `systemd-networkd` performs the equivalent of
`netlabelctl` operation

```
$ sudo netlabelctl unlbl add interface eth0 address:10.0.0.0/8 label:system_u:object_r:localnet_peer_t:s0
```

Result:
```
$ sudo netlabelctl -p unlbl list
...
 interface: eth0
   address: 10.0.0.0/8
    label: "system_u:object_r:localnet_peer_t:s0"
...
```

3 years agohwdb: Add accel orientation quirk for the Aya Neo Next
Maccraft123 [Thu, 2 Jun 2022 18:05:22 +0000 (20:05 +0200)] 
hwdb: Add accel orientation quirk for the Aya Neo Next

3 years agoexecute: fix resource leak
Shreenidhi Shedi [Sat, 4 Jun 2022 09:54:08 +0000 (15:24 +0530)] 
execute: fix resource leak

CID#1431998

3 years agojournalctl: Use STATIC_DESTRUCTOR_REGISTER() 23645/head
Daan De Meyer [Mon, 6 Jun 2022 14:04:53 +0000 (16:04 +0200)] 
journalctl: Use STATIC_DESTRUCTOR_REGISTER()

3 years agoshared: Rename pcre2-dlopen.h/c to pcre2-util.h/c
Daan De Meyer [Mon, 6 Jun 2022 14:01:20 +0000 (16:01 +0200)] 
shared: Rename pcre2-dlopen.h/c to pcre2-util.h/c

We already store the dlopen() stuff for other libraries in util headers
as well so let's do the same for pcre2. We also move the definition of
some trivial cleanup functions from journalctl.c to pcre2-util.h

3 years agotest: fix TEST-70 under sanitizers 23643/head
Frantisek Sumsal [Mon, 6 Jun 2022 12:47:03 +0000 (14:47 +0200)] 
test: fix TEST-70 under sanitizers

Addresses:
  * https://github.com/systemd/systemd/issues/23578#issuecomment-1144089821
  * https://github.com/systemd/systemd-centos-ci/pull/496#issuecomment-1144640305

3 years agotest: set $ASAN_RT_PATH along with $LD_PRELOAD to the ASan runtime DSO
Frantisek Sumsal [Mon, 6 Jun 2022 12:45:11 +0000 (14:45 +0200)] 
test: set $ASAN_RT_PATH along with $LD_PRELOAD to the ASan runtime DSO

Since we unset $LD_PRELOAD in the testsuite-* units (due to another
issue), let's store the path to the ASan DSO in another env variable, so
we can easily access it in the testsuite scripts when needed.

3 years agoMerge pull request #23621 from evverx/clang-release
Zbigniew Jędrzejewski-Szmek [Mon, 6 Jun 2022 10:17:48 +0000 (12:17 +0200)] 
Merge pull request #23621 from evverx/clang-release

ci: build systemd with clang with -Dmode=release --optimization=2

3 years agovarious: use CONST_MAX for array allocation 23616/head
Zbigniew Jędrzejewski-Szmek [Sat, 4 Jun 2022 19:07:27 +0000 (21:07 +0200)] 
various: use CONST_MAX for array allocation

IIUC, with MAX() we get a VLA and the size is "decided" at runtime,
even though the result is always the same, but with CONST_MAX() we
get a normal stack variable.

3 years agoCODING_STYLE: say that inet_ntop() is a no no
Zbigniew Jędrzejewski-Szmek [Sat, 4 Jun 2022 18:56:29 +0000 (20:56 +0200)] 
CODING_STYLE: say that inet_ntop() is a no no

3 years agotree-wide: convert inet_ntop() calls to anonymous-buffer macros
Zbigniew Jędrzejewski-Szmek [Sat, 4 Jun 2022 15:01:06 +0000 (17:01 +0200)] 
tree-wide: convert inet_ntop() calls to anonymous-buffer macros

3 years agobasic/in-addr-util: add IN_ADDR_PREFIX_TO_STRING
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 14:37:38 +0000 (16:37 +0200)] 
basic/in-addr-util: add IN_ADDR_PREFIX_TO_STRING

3 years agobasic/in-addr-util: drop check for prefix length in formatting function
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 13:49:40 +0000 (15:49 +0200)] 
basic/in-addr-util: drop check for prefix length in formatting function

The general rule should be to be strict when parsing data, but lenient
when printing it. Or in other words, we should verify data in verification
functions, but not when printing things. It doesn't make sense to refuse
to print a value that we are using internally.

We were tripping ourselves in some of the print functions:
we want to report than an address was configured with too-long prefix, but
the log line would use "n/a" if the prefix was too long. This is not useful.

Most of the time, the removal of the check doesn't make any difference,
because we verified the prefix length on input.

3 years agolibsystemd-network: minor simplification
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 10:21:53 +0000 (12:21 +0200)] 
libsystemd-network: minor simplification

3 years agoresolved: use TAKE_PTR() in one more place
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 10:21:36 +0000 (12:21 +0200)] 
resolved: use TAKE_PTR() in one more place

3 years agonetworkctl: assume that we can always print local networking addresses
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 10:21:12 +0000 (12:21 +0200)] 
networkctl: assume that we can always print local networking addresses

IN6_ADDR_TO_STRING(…) always returns something, so we can simplify the code a
lot. Also, let's not do step-wise concatenation, but instead handle everything
with one str_extendf() call.

3 years agobasic/in-addr-util: add IN_ADDR_TO_STRING
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 09:24:02 +0000 (11:24 +0200)] 
basic/in-addr-util: add IN_ADDR_TO_STRING

Since we don't need the error value, and the buffer is allocated with a fixed
size, the whole logic provided by in_addr_to_string() becomes unnecessary, so
it's enough to wrap inet_ntop() directly.

inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed
to be large enough, so this should never fail. A bunch of tests of this are added.
This allows all the wrappers like strna(), strnull(), strempty() to be dropped.

The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(),
because log_debug() implements the check outside of the function call. But
log_link_debug() does not, so it we need it to avoid unnecessary evaluation of
the formatting.

3 years agoMerge pull request #23626 from sshedi/retval-fixes
Zbigniew Jędrzejewski-Szmek [Mon, 6 Jun 2022 07:41:12 +0000 (09:41 +0200)] 
Merge pull request #23626 from sshedi/retval-fixes

Retval fixes

3 years agoRevert "Support -D_FORTIFY_SOURCE=3 by using __builtin_dynamic_object_size." 23621/head
Evgeny Vereshchagin [Fri, 3 Jun 2022 19:06:22 +0000 (19:06 +0000)] 
Revert "Support -D_FORTIFY_SOURCE=3 by using __builtin_dynamic_object_size."

This reverts commit 0bd292567a543d124cd303f7dd61169a209cae64.

It isn't guaranteed anywhere that __builtin_dynamic_object_size can
always deduce the size of every object passed to it so systemd
can end up using either malloc_usable_size or
__builtin_dynamic_object_size when pointers are passed around,
which in turn can lead to actual segfaults like the one mentioned in
https://github.com/systemd/systemd/issues/23619.

Apparently __builtin_object_size can return different results for
pointers referring to the same memory as well but somehow it hasn't
caused any issues yet. Looks like this whole
malloc_usable_size/FORTIFY_SOURCE stuff should be revisited.

Closes https://github.com/systemd/systemd/issues/23619 and
https://github.com/systemd/systemd/issues/23150.

Reopens https://github.com/systemd/systemd/issues/22801

3 years agomanager: ignore return value of unit_watch_pid() 23626/head
Shreenidhi Shedi [Sat, 4 Jun 2022 10:33:30 +0000 (16:03 +0530)] 
manager: ignore return value of unit_watch_pid()

Also, explicitly ignore return value of service_set_main_pid() calls in
few places.

Fixes: CID#1474975
3 years agomachinectl: ignore return value of get_process_comm()
Shreenidhi Shedi [Sat, 4 Jun 2022 10:26:45 +0000 (15:56 +0530)] 
machinectl: ignore return value of get_process_comm()

Fixes: CID#1469720
3 years agopolkit: explicitly ignore fd_wait_for_event()'s return value
Shreenidhi Shedi [Sat, 4 Jun 2022 10:18:09 +0000 (15:48 +0530)] 
polkit: explicitly ignore fd_wait_for_event()'s return value

Fixes: CID#1469718
3 years agoci: build systemd with clang with -Dmode=release --optimization=2
Evgeny Vereshchagin [Fri, 3 Jun 2022 18:16:57 +0000 (18:16 +0000)] 
ci: build systemd with clang with -Dmode=release --optimization=2

This is what's most likely used to build systemd with clang in
practice so let's test it as well.

Preparation for reverting https://github.com/systemd/systemd/commit/0bd292567a543d124cd303f7dd61169a209cae64
(which replaced bogus buffer overflow found with _FORTIFY_SOURCE=3
with actual segfaults).

3 years agoshared/microhttp-util: silence gcc warning
Zbigniew Jędrzejewski-Szmek [Sun, 5 Jun 2022 08:24:15 +0000 (10:24 +0200)] 
shared/microhttp-util: silence gcc warning

../src/journal-remote/microhttpd-util.c: In function ‘check_permissions’:
../src/journal-remote/microhttpd-util.c:301:5: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
  301 | int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
      |     ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Fixes #23630.

3 years agomeson: Switch default-locale default to C.UTF-8
Daan De Meyer [Fri, 3 Jun 2022 11:29:47 +0000 (13:29 +0200)] 
meson: Switch default-locale default to C.UTF-8

We're already using C.UTF-8 as the default locale for nspawn. Let's
make the same change for the default-locale option instead of deciding
what to use based on the locale used by the host system. Users can
still override the locale using the default-locale option if needed.

3 years agocore: suppress message about missing libbpf if in initrd()
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 14:45:47 +0000 (16:45 +0200)] 
core: suppress message about missing libbpf if in initrd()

It is quite likely that libbpf is not present in the initrd, and
there isn't much reason to use the bpf filters there.

https://bugzilla.redhat.com/show_bug.cgi?id=2084955#c25

3 years agocryptenroll: fix typo
Antonio Alvarez Feijoo [Fri, 3 Jun 2022 15:09:23 +0000 (17:09 +0200)] 
cryptenroll: fix typo

3 years agoMerge pull request #23297 from medhefgo/trivial-auto-var-init
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 13:27:51 +0000 (15:27 +0200)] 
Merge pull request #23297 from medhefgo/trivial-auto-var-init

meson: Compile with -ftrivial-auto-var-init

3 years agotest: add dlopen test for pam_systemd_home
Yu Watanabe [Thu, 2 Jun 2022 21:40:43 +0000 (06:40 +0900)] 
test: add dlopen test for pam_systemd_home

3 years agosha256: fix compilation on efi-ia32
Zbigniew Jędrzejewski-Szmek [Fri, 3 Jun 2022 07:32:02 +0000 (09:32 +0200)] 
sha256: fix compilation on efi-ia32

/usr/bin/gcc -c ../src/fundamental/sha256.c -o src/boot/efi/sha256.c.o -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -fno-stack-protector -fno-strict-aliasing -fpic -fwide-exec-charset=UCS2 -Wall -Wextra -Wsign-compare -nostdlib -std=gnu99 -ffreestanding -fshort-wchar -fvisibility=hidden -isystem /usr/include/efi -isystem /usr/include/efi/ia32 -I /builddir/build/BUILD/systemd-stable-250.7/src/fundamental -DSD_BOOT -DGNU_EFI_USE_MS_ABI -include src/boot/efi/efi_config.h -include version.h -mno-sse -mno-mmx -flto -O2 -flto=auto
../src/fundamental/sha256.c: In function ‘sha256_finish_ctx’:
../src/fundamental/sha256.c:61:25: error: ‘false’ undeclared (first use in this function)
   61 | # define UNALIGNED_P(p) false
      |                         ^~~~~
../src/fundamental/sha256.c:136:21: note: in expansion of macro ‘UNALIGNED_P’
  136 |                 if (UNALIGNED_P(resbuf))
      |                     ^~~~~~~~~~~
../src/fundamental/sha256.c:32:1: note: ‘false’ is defined in header ‘<stdbool.h>’; did you forget to ‘#include <stdbool.h>’?
   31 | #include "sha256.h"
  +++ |+#include <stdbool.h>
   32 |
...

3 years agoMerge pull request #23583 from yuwata/boot-efi-string-follow-ups
Yu Watanabe [Fri, 3 Jun 2022 01:23:24 +0000 (10:23 +0900)] 
Merge pull request #23583 from yuwata/boot-efi-string-follow-ups

boot: follow-ups for efi-string functions

3 years agoshared/utmp-wtmp: fix build without utmp
Christian Hesse [Thu, 2 Jun 2022 18:49:46 +0000 (20:49 +0200)] 
shared/utmp-wtmp: fix build without utmp

Commit 16618332388442f2f1c3e52b0a9fde00121564a3 changed a function to
add an extra argument. The data types used when building without utmp
missed the change.

3 years agologin: fix typo
Yu Watanabe [Thu, 2 Jun 2022 19:27:40 +0000 (04:27 +0900)] 
login: fix typo

Follow-up for ea74f39c24344eafc238d1c69155bd5aca5f2e08.

3 years agoboot: use CMP() macro for safety 23583/head
Yu Watanabe [Tue, 31 May 2022 21:36:55 +0000 (06:36 +0900)] 
boot: use CMP() macro for safety

3 years agoboot: make several functions inline
Yu Watanabe [Tue, 31 May 2022 21:25:52 +0000 (06:25 +0900)] 
boot: make several functions inline

Follow-ups for #23512.

3 years agoboot: fix typo
Yu Watanabe [Tue, 31 May 2022 21:48:45 +0000 (06:48 +0900)] 
boot: fix typo

3 years agoMerge pull request #23596 from keszybz/bpf-messages-more
Zbigniew Jędrzejewski-Szmek [Thu, 2 Jun 2022 17:48:01 +0000 (19:48 +0200)] 
Merge pull request #23596 from keszybz/bpf-messages-more

Silence messages from libbpf

3 years agotest: enable virtio-rng device for QEMU guests
Franck Bui [Thu, 2 Jun 2022 07:31:55 +0000 (09:31 +0200)] 
test: enable virtio-rng device for QEMU guests

If rngd is included in the host initrd, QEMU guests need at least one source of
entropy otherwise rngd will refuse to start. Hence this patch enables the
virtio RNG device in QEMU guests (exposed as a HW RNG device available at
/dev/hwrng).

As a safety measure, the patch limits the data sent to the guest to 1KB per
second in order to not let the guest starve the host entropy.

3 years agocore: rework variable initialization to avoid gcc warning 23297/head
Zbigniew Jędrzejewski-Szmek [Thu, 2 Jun 2022 15:30:35 +0000 (17:30 +0200)] 
core: rework variable initialization to avoid gcc warning

In file included from ../src/basic/siphash24.h:11,
                 from ../src/basic/hash-funcs.h:6,
                 from ../src/basic/hashmap.h:8,
                 from ../src/shared/fdset.h:6,
                 from ../src/shared/bpf-program.h:9,
                 from ../src/core/unit.h:11,
                 from ../src/core/all-units.h:4,
                 from ../src/core/manager.c:23:
../src/basic/time-util.h: In function 'manager_dispatch_jobs_in_progress':
../src/basic/time-util.h:140:38: error: 'x' may be used uninitialized [-Werror=maybe-uninitialized]
  140 | #define FORMAT_TIMESPAN(t, accuracy) format_timespan((char[FORMAT_TIMESPAN_MAX]){}, FORMAT_TIMESPAN_MAX, t, accuracy)
      |                                      ^~~~~~~~~~~~~~~
In function 'manager_print_jobs_in_progress',
    inlined from 'manager_dispatch_jobs_in_progress' at ../src/core/manager.c:3007:9:
../src/core/manager.c:219:18: note: 'x' was declared here
  219 |         uint64_t x;
      |                  ^
cc1: all warnings being treated as errors

For some reason this (false positive) warning starts appearing after
-ftrivial-auto-var-init is used.

3 years agoMerge pull request #23576 from yuwata/network-erspan-version
Zbigniew Jędrzejewski-Szmek [Thu, 2 Jun 2022 14:58:55 +0000 (16:58 +0200)] 
Merge pull request #23576 from yuwata/network-erspan-version

network: support erspan version 0 and 2

3 years agoMerge pull request #23579 from yuwata/sha256-unaligned
Zbigniew Jędrzejewski-Szmek [Thu, 2 Jun 2022 14:38:19 +0000 (16:38 +0200)] 
Merge pull request #23579 from yuwata/sha256-unaligned

sha256: use memcpy() to accept unaligned result buffer