]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agoman: mention pages with more settings at end of each option list 20849/head
Zbigniew Jędrzejewski-Szmek [Mon, 27 Sep 2021 07:09:30 +0000 (09:09 +0200)] 
man: mention pages with more settings at end of each option list

For some unit types we have hundreds of options, and the reader may easily miss
that more options are described in other pages. We already mentioned this in
the introduction and then at the top of the option list, but it can't hurt to
repeat the information.

Also, add an (almost empty) Options section for the unit types which don't have
any custom options. It is nicer to have the same page structure in all cases,
so people can jump between pages for different types more easily.

2 years agoman: refresh description of sysvinit compat for services
Zbigniew Jędrzejewski-Szmek [Mon, 27 Sep 2021 06:43:10 +0000 (08:43 +0200)] 
man: refresh description of sysvinit compat for services

The existing text must have been written before systemd-sysv-generator was
created. We don't create the wrappers dynamically since a long time.

Also add more links and make the description conditional on "if compat
is enabled".

2 years agoman: minor grammar fixups in systemd-cryptenroll
Zbigniew Jędrzejewski-Szmek [Fri, 24 Sep 2021 07:12:02 +0000 (09:12 +0200)] 
man: minor grammar fixups in systemd-cryptenroll

2 years agodocs: add spdx tags to all .md files
Zbigniew Jędrzejewski-Szmek [Tue, 14 Sep 2021 14:05:21 +0000 (16:05 +0200)] 
docs: add spdx tags to all .md files

I have no idea if this is going to cause rendering problems, and it is fairly
hard to check. So let's just merge this, and if it github markdown processor
doesn't like it, revert.

2 years agoman: cross-reference DeviceAllow= and PrivateDevices=
Zbigniew Jędrzejewski-Szmek [Wed, 8 Sep 2021 13:46:17 +0000 (15:46 +0200)] 
man: cross-reference DeviceAllow= and PrivateDevices=

They are somewhat similar, but not easy to discover, esp. considering that
they are described in different pages.

For PrivateDevices=, split out the first paragraph that gives the high-level
overview. (The giant second paragraph could also use some heavy editing to break
it up into more digestible chunks, alas.)

2 years agosmack: move helper function to smack-util.c
Zbigniew Jędrzejewski-Szmek [Tue, 21 Sep 2021 16:29:23 +0000 (18:29 +0200)] 
smack: move helper function to smack-util.c

The function was in basic/fileio.c, but it's more appropriate to
keep it out of src/basic.

Fixes compilation with -Dsmack-run-label= set.

2 years agoMerge pull request #20690 from DaanDeMeyer/oomd-user-services
Luca Boccassi [Tue, 21 Sep 2021 14:39:48 +0000 (15:39 +0100)] 
Merge pull request #20690 from DaanDeMeyer/oomd-user-services

oom: Support for user services

2 years agomeson: fix creation of man pages indices
Zbigniew Jędrzejewski-Szmek [Tue, 21 Sep 2021 08:59:13 +0000 (10:59 +0200)] 
meson: fix creation of man pages indices

Fixes #20795. Bug introduced in f12c5d36a9a162f833987b03fbf0b65248581cbb.

3 years agoDrop bundled copy of linux/if_arp.h
Zbigniew Jędrzejewski-Szmek [Wed, 15 Sep 2021 14:33:05 +0000 (16:33 +0200)] 
Drop bundled copy of linux/if_arp.h

As far as I can see, we use this to get a list of ARPHRD_* defines (used in
particular for Type= in .link files). If we drop our copy, and build against
old kernel headers, the user will have a shorter list of types available.  This
seems OK, and I don't think it's worth carrying our own version of this file
just to have newest possible entries.

7c5b9952c4f6e2b72f90edbe439982528b7cf223 recently updated this file, but we'd
have to update it every time the kernel adds new entries. But if we look at
the failure carefully:

src/basic/arphrd-from-name.gperf:65:16: error: ‘ARPHRD_MCTP’ undeclared (first use in this function); did you mean ‘ARPHRD_FCPP’?
   65 | MCTP, ARPHRD_MCTP
      |                ^~
      |                ARPHRD_FCPP

we see that the list we were generating was from the system headers, so it was
only as good as the system headers anyway, without the newer entries in our
bundled copy, if there were any. So let's make things simpler by always using
system headers.

And if somebody wants to fix things so that we always have the newest list,
then we should just generate and store the converted list, not the full header.

3 years agoMerge pull request #20790 from poettering/boot-fixes
Lennart Poettering [Tue, 21 Sep 2021 09:35:04 +0000 (11:35 +0200)] 
Merge pull request #20790 from poettering/boot-fixes

various EFI/boot fixes

3 years agostub: prepare section pointers in separate steps 20790/head
Lennart Poettering [Fri, 17 Sep 2021 08:15:57 +0000 (10:15 +0200)] 
stub: prepare section pointers in separate steps

In a follow-up patch we are going to modify the initrd, hence prepare
the pointers/"physical addresses" to it, first, so that we can do so
easily.

Also, do some other tweaks and cleanups to physical address/pointer
conversion.

3 years agostub: use proper enums instead of hardcoded numeric indexes for identifying PE sections
Lennart Poettering [Thu, 16 Sep 2021 21:59:39 +0000 (23:59 +0200)] 
stub: use proper enums instead of hardcoded numeric indexes for identifying PE sections

3 years agoboot: ReallocatePool() supports NULL pointers as first argument
Lennart Poettering [Mon, 20 Sep 2021 12:06:23 +0000 (14:06 +0200)] 
boot: ReallocatePool() supports NULL pointers as first argument

Just like userspace realloc() the EFIlib ReallocatePool() function is
happy to use a NULL pointer as input, in which case it is equivalent to
AllocatePool(). See:

https://github.com/vathpela/gnu-efi/blob/269ef9dbc77ebec2723e0e6ae082bbca9516f5f1/lib/misc.c#L57

3 years agoboot: modernize measure.c
Lennart Poettering [Mon, 20 Sep 2021 11:33:18 +0000 (13:33 +0200)] 
boot: modernize measure.c

Let's use _cleanup_freepool_, compound literals for initialization,
OFFSETOF() and let's remove some unnecessary casts.

No change in behaviour.

3 years agoboot: move TCG/TPM protocol definitions into missing_efi.h
Lennart Poettering [Mon, 20 Sep 2021 11:32:12 +0000 (13:32 +0200)] 
boot: move TCG/TPM protocol definitions into missing_efi.h

That's what it is for...

3 years agoboot: use cleanup-based file handle closing a bit more
Lennart Poettering [Fri, 17 Sep 2021 08:32:33 +0000 (10:32 +0200)] 
boot: use cleanup-based file handle closing a bit more

3 years agoboot: invert if check, to reduce indentation level
Lennart Poettering [Thu, 16 Sep 2021 14:02:36 +0000 (16:02 +0200)] 
boot: invert if check, to reduce indentation level

3 years agounits: hookup systemd-boot-update.service
Lennart Poettering [Mon, 20 Sep 2021 15:46:26 +0000 (17:46 +0200)] 
units: hookup systemd-boot-update.service

It was apparently missed to hook this up in
71c8bf28378958a5ab2348e9ec586fbe78c71dfd.

3 years agoboot: don't build bootctl when -Dgnu-efi=false is set
Michal Sekletar [Mon, 30 Aug 2021 16:38:09 +0000 (18:38 +0200)] 
boot: don't build bootctl when -Dgnu-efi=false is set

3 years agooom: Add support for user unit ManagedOOM property updates 20690/head
Daan De Meyer [Thu, 9 Sep 2021 15:12:55 +0000 (16:12 +0100)] 
oom: Add support for user unit ManagedOOM property updates

Compared to PID1 where systemd-oomd has to be the client to PID1
because PID1 is a more privileged process than systemd-oomd, systemd-oomd
is the more privileged process compared to a user manager so we have
user managers be the client whereas systemd-oomd is now the server.

The same varlink protocol is used between user managers and systemd-oomd
to deliver ManagedOOM property updates. systemd-oomd now sets up a varlink
server that user managers connect to to send ManagedOOM property updates.

We also add extra validation to make sure that non-root senders don't
send updates for cgroups they don't own.

The integration test was extended to repeat the chill/bloat test using
a user manager instead of PID1.

3 years agohwdb: add touchpad fuzz for Asus UX362FA (#20770)
Lukas Senionis [Mon, 20 Sep 2021 04:00:42 +0000 (07:00 +0300)] 
hwdb: add touchpad fuzz for Asus UX362FA (#20770)

3 years agoMerge pull request #20780 from mrc0mmand/test-storage-btrfs
Luca Boccassi [Sun, 19 Sep 2021 18:04:45 +0000 (19:04 +0100)] 
Merge pull request #20780 from mrc0mmand/test-storage-btrfs

test: btrfs-related udev tests

3 years agotest: dump the test output to console as well for easier debugging 20780/head
Frantisek Sumsal [Sat, 18 Sep 2021 21:18:57 +0000 (23:18 +0200)] 
test: dump the test output to console as well for easier debugging

3 years agotest: regenerate module dependencies after installing all modules
Frantisek Sumsal [Sat, 18 Sep 2021 21:06:36 +0000 (23:06 +0200)] 
test: regenerate module dependencies after installing all modules

3 years agotest: fix error handling with `set -e`
Frantisek Sumsal [Sat, 18 Sep 2021 19:44:38 +0000 (21:44 +0200)] 
test: fix error handling with `set -e`

Unfortunately, when checking the return/exit code using &&, ||, if,
while, etc., `set -e` is disabled for all nested functions as well,
which leads to incorrectly ignored errors, *sigh*.

Example:

```
set -eu
set -o pipefail

task() {
    echo "task init"
    echo "this should fail"
    false
    nonexistentcommand
    echo "task end (we shouldn't be here)"
}

if ! task; then
    echo >&2 "The task failed"
    exit 1
else
    echo "The task passed"
fi
```

```
$ bash test.sh
task init
this should fail
test.sh: line 10: nonexistentcommand: command not found
task end (we shouldn't be here)
The task passed
$ echo $?
0
```

But without the `if`, everything works "as expected":

```
set -eu
set -o pipefail

task() {
    echo "task init"
    echo "this should fail"
    false
    nonexistentcommand
    echo "task end (we shouldn't be here)"
}

task
```

```
$ bash test.sh
task init
this should fail
$ echo $?
1
```

Wonderful.

3 years agotest: btrfs-related udev tests
Frantisek Sumsal [Fri, 17 Sep 2021 17:28:38 +0000 (19:28 +0200)] 
test: btrfs-related udev tests

3 years agotest: check symlinks under /dev/mapper by default as well
Frantisek Sumsal [Sat, 18 Sep 2021 17:02:10 +0000 (19:02 +0200)] 
test: check symlinks under /dev/mapper by default as well

3 years agotest: use subshells a bit more
Frantisek Sumsal [Fri, 17 Sep 2021 21:59:38 +0000 (23:59 +0200)] 
test: use subshells a bit more

to tweak shell flags in specific functions without affecting the rest of
the script.

3 years agotest: cleanup the intermediate disk images
Frantisek Sumsal [Fri, 17 Sep 2021 21:03:44 +0000 (23:03 +0200)] 
test: cleanup the intermediate disk images

3 years agotest: tidy up the feature handling
Frantisek Sumsal [Fri, 17 Sep 2021 17:28:22 +0000 (19:28 +0200)] 
test: tidy up the feature handling

3 years agotest: add a btrfs helper
Frantisek Sumsal [Fri, 17 Sep 2021 17:19:23 +0000 (19:19 +0200)] 
test: add a btrfs helper

3 years agotest: lower the number of iterations in LVM tests
Frantisek Sumsal [Sat, 18 Sep 2021 18:43:50 +0000 (20:43 +0200)] 
test: lower the number of iterations in LVM tests

as some of the operations take a really long time.

3 years agobash-completion: circumvent aliases for 'ls'
Lia Lenckowski [Fri, 17 Sep 2021 21:08:19 +0000 (23:08 +0200)] 
bash-completion: circumvent aliases for 'ls'

3 years agotest: unify handling of supported "features"
Frantisek Sumsal [Fri, 17 Sep 2021 15:45:39 +0000 (17:45 +0200)] 
test: unify handling of supported "features"

3 years agoci: temporarily set -Wno-deprecated-declarations in Packit
Frantisek Sumsal [Fri, 17 Sep 2021 09:24:07 +0000 (11:24 +0200)] 
ci: temporarily set -Wno-deprecated-declarations in Packit

to suppress OpenSSL 3.0 deprecation warnings (until a proper solution
is deployed):

```
../src/shared/creds-util.c: In function ‘sha256_hash_host_and_tpm2_key’:
../src/shared/creds-util.c:412:9: error: ‘SHA256_Init’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  412 |         if (SHA256_Init(&sha256_context) != 1)
      |         ^~
In file included from /usr/include/openssl/x509.h:41,
                 from ../src/shared/openssl-util.h:8,
                 from ../src/shared/creds-util.c:21:
/usr/include/openssl/sha.h:73:27: note: declared here
   73 | OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
      |                           ^~~~~~~~~~~
../src/shared/creds-util.c:415:9: error: ‘SHA256_Update’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  415 |         if (host_key && SHA256_Update(&sha256_context, host_key, host_key_size) != 1)
      |         ^~
In file included from /usr/include/openssl/x509.h:41,
                 from ../src/shared/openssl-util.h:8,
                 from ../src/shared/creds-util.c:21:
/usr/include/openssl/sha.h:74:27: note: declared here
   74 | OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
      |                           ^~~~~~~~~~~~~
../src/shared/creds-util.c:418:9: error: ‘SHA256_Update’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  418 |         if (tpm2_key && SHA256_Update(&sha256_context, tpm2_key, tpm2_key_size) != 1)
      |         ^~
In file included from /usr/include/openssl/x509.h:41,
                 from ../src/shared/openssl-util.h:8,
                 from ../src/shared/creds-util.c:21:
/usr/include/openssl/sha.h:74:27: note: declared here
   74 | OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
      |                           ^~~~~~~~~~~~~
../src/shared/creds-util.c:421:9: error: ‘SHA256_Final’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  421 |         if (SHA256_Final(ret, &sha256_context) != 1)
      |         ^~
In file included from /usr/include/openssl/x509.h:41,
                 from ../src/shared/openssl-util.h:8,
                 from ../src/shared/creds-util.c:21:
/usr/include/openssl/sha.h:76:27: note: declared here
   76 | OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
      |                           ^~~~~~~~~~~~
cc1: all warnings being treated as errors

```

3 years agoMerge pull request #20769 from weblate/weblate-systemd-master
Frantisek Sumsal [Thu, 16 Sep 2021 18:23:51 +0000 (20:23 +0200)] 
Merge pull request #20769 from weblate/weblate-systemd-master

Translations update from Weblate

3 years agopo: Translated using Weblate (Portuguese) 20769/head
Hugo Carvalho [Thu, 16 Sep 2021 18:05:00 +0000 (20:05 +0200)] 
po: Translated using Weblate (Portuguese)

Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: Hugo Carvalho <hugokarvalho@hotmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/pt/
Translation: systemd/main

3 years agopo: Translated using Weblate (German)
Christian Wehrli [Thu, 16 Sep 2021 18:05:00 +0000 (20:05 +0200)] 
po: Translated using Weblate (German)

Currently translated at 71.4% (135 of 189 strings)

Co-authored-by: Christian Wehrli <christian@chw.onl>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/de/
Translation: systemd/main

3 years agoMerge pull request #20763 from poettering/fileio-test
Lennart Poettering [Thu, 16 Sep 2021 15:47:03 +0000 (17:47 +0200)] 
Merge pull request #20763 from poettering/fileio-test

test-fileio: test read_virtual_file() with more files from /proc

3 years agopo: add false positives to POTFILES.skip
Piotr Drąg [Thu, 16 Sep 2021 12:48:05 +0000 (14:48 +0200)] 
po: add false positives to POTFILES.skip

3 years agocore: Introduce build_managed_oom_cgroups_json()
Daan De Meyer [Thu, 2 Sep 2021 12:32:31 +0000 (14:32 +0200)] 
core: Introduce build_managed_oom_cgroups_json()

Will be reused to build the varlink message contents sent by user
instances of systemd to systemd-oomd's varlink server in a future
commit.

3 years agooom: Introduce process_managed_oom_message()
Daan De Meyer [Thu, 2 Sep 2021 11:24:23 +0000 (13:24 +0200)] 
oom: Introduce process_managed_oom_message()

Gets rid of a few gotos, allows removing the extra ret variable and
will also be used in a future commit by the codepath that receives
cgroups from user instances of systemd.

3 years agooom: Add missing sd-bus.h include
Daan De Meyer [Thu, 2 Sep 2021 11:17:42 +0000 (13:17 +0200)] 
oom: Add missing sd-bus.h include

3 years agotest-fileio: test read_virtual_file() with more files from /proc 20763/head
Lennart Poettering [Thu, 16 Sep 2021 09:31:52 +0000 (11:31 +0200)] 
test-fileio: test read_virtual_file() with more files from /proc

i.e. let's pick some files we know are too large, or where struct stat's
.st_size is zero even though non-empty, and test read_virtual_file()
with that, to ensure things are handled sensibly. Goal is to ensure all
three major codepaths in read_virtual_file() are tested.

Prompted-by: #20743
3 years agofileio: fix truncated read handling in read_virtual_file()
Lennart Poettering [Thu, 16 Sep 2021 10:20:09 +0000 (12:20 +0200)] 
fileio: fix truncated read handling in read_virtual_file()

We mishandled the case where the size we read from the file actually
matched the maximum size fully. In that case we cannot really make a
determination whether the file was fully read or only partially. In that
case let's do another loop, so that we operate with a buffer, and
we can detect the EOF (which will be signalled to us via a short read).

3 years agojournal,network,timesync: fix segfault on 32bit timeval/timespec systems
Yu Watanabe [Wed, 15 Sep 2021 14:29:11 +0000 (23:29 +0900)] 
journal,network,timesync: fix segfault on 32bit timeval/timespec systems

Fixes #20741.

3 years agofileio: start with 4k buffer for procfs
Anita Zhang [Tue, 14 Sep 2021 23:33:10 +0000 (16:33 -0700)] 
fileio: start with 4k buffer for procfs

There's a very gradual increase of anonymous memory in systemd-journald that
blames to 2ac67221bb6270f0fbe7cbd0076653832cd49de2.

systemd-journald makes many calls to read /proc/PID/cmdline and
/proc/PID/status, both of which tend to be well under 4K. However the
combination of allocating 4M read buffers, then using `realloc()` to
shrink the buffer in `read_virtual_file()` appears to be creating
fragmentation in the heap (when combined with the other allocations
systemd-journald is doing).

To help mitigate this, try reading /proc with a 4K buffer as
`read_virtual_file()` did before 2ac67221bb6270f0fbe7cbd0076653832cd49de2.
If it isn't big enough then try again with the larger buffers.

3 years agoMerge pull request #20758 from yuwata/test-17-udev-cleanups
Luca Boccassi [Thu, 16 Sep 2021 08:45:10 +0000 (09:45 +0100)] 
Merge pull request #20758 from yuwata/test-17-udev-cleanups

test: several cleanups for TEST-17-UDEV

3 years agoMerge pull request #20721 from mrc0mmand/test-storage-lvm
Yu Watanabe [Thu, 16 Sep 2021 03:39:24 +0000 (12:39 +0900)] 
Merge pull request #20721 from mrc0mmand/test-storage-lvm

test: udev/LVM storage tests

3 years agoMerge pull request #20738 from mrc0mmand/ci-llvm-13
Yu Watanabe [Thu, 16 Sep 2021 00:32:21 +0000 (09:32 +0900)] 
Merge pull request #20738 from mrc0mmand/ci-llvm-13

ci: build with clang-13

3 years agoMerge pull request #20483 from medhefgo/boot
Lennart Poettering [Wed, 15 Sep 2021 22:03:41 +0000 (00:03 +0200)] 
Merge pull request #20483 from medhefgo/boot

sd-boot: Add support for changing console mode at runtime

3 years agoMerge pull request #20731 from a-wai/main
Lennart Poettering [Wed, 15 Sep 2021 22:02:05 +0000 (00:02 +0200)] 
Merge pull request #20731 from a-wai/main

hostnamed: add support for getting the chassis type from device-tree

3 years agoMerge pull request #20746 from poettering/sysctl-rework
Lennart Poettering [Wed, 15 Sep 2021 22:01:18 +0000 (00:01 +0200)] 
Merge pull request #20746 from poettering/sysctl-rework

various sysctl-util.c cleanups

3 years agotest: drop unnecessary sleep and 'udevadm settle' 20758/head
Yu Watanabe [Wed, 15 Sep 2021 21:04:28 +0000 (06:04 +0900)] 
test: drop unnecessary sleep and 'udevadm settle'

After the triggered events are processed, all symlinks which store
watch handles should be valid.

3 years agotest: use --settle option for udevadm trigger
Yu Watanabe [Wed, 15 Sep 2021 21:38:08 +0000 (06:38 +0900)] 
test: use --settle option for udevadm trigger

3 years agotest: use --settle option for udevadm trigger
Yu Watanabe [Wed, 15 Sep 2021 21:34:45 +0000 (06:34 +0900)] 
test: use --settle option for udevadm trigger

Then, we can drop the loops.
This also drops unnecessary `udevadm control --reload`.

3 years agotest: use /dev/null instead of the loop back network interface
Yu Watanabe [Wed, 15 Sep 2021 21:14:18 +0000 (06:14 +0900)] 
test: use /dev/null instead of the loop back network interface

It should faster to be processed. So, we can shorten the timeout.
Also, this makes the test use `udevadm trigger`.

3 years agotest: use --settle option for udevadm trigger
Yu Watanabe [Wed, 15 Sep 2021 21:22:18 +0000 (06:22 +0900)] 
test: use --settle option for udevadm trigger

3 years agoMerge pull request #20751 from poettering/watchdog-tweaklet
Luca Boccassi [Wed, 15 Sep 2021 20:48:39 +0000 (21:48 +0100)] 
Merge pull request #20751 from poettering/watchdog-tweaklet

two minor watchdog tweaklets

3 years agotest: basic LVM tests 20721/head
Frantisek Sumsal [Mon, 13 Sep 2021 17:30:41 +0000 (19:30 +0200)] 
test: basic LVM tests

3 years agosd-journal: Ignore data threshold if set to zero in sd_journal_enumerate_fields()
Daan De Meyer [Wed, 15 Sep 2021 12:05:46 +0000 (13:05 +0100)] 
sd-journal: Ignore data threshold if set to zero in sd_journal_enumerate_fields()

According to the documentation, Setting the data threshold to zero disables the
data threshold alltogether. Let's make sure we actually implement this behaviour
in sd_journal_enumerate_fields() by only applying the data threshold if it exceeds
zero.

3 years agopo: Added translation using Weblate (Portuguese)
Hugo Carvalho [Wed, 15 Sep 2021 14:44:46 +0000 (16:44 +0200)] 
po: Added translation using Weblate (Portuguese)

Co-authored-by: Hugo Carvalho <hugokarvalho@hotmail.com>
3 years agohostnamed: add support for getting the chassis type from device-tree 20731/head
Arnaud Ferraris [Tue, 14 Sep 2021 13:40:42 +0000 (15:40 +0200)] 
hostnamed: add support for getting the chassis type from device-tree

Device-tree based devices can't get the chassis type from DMI or ACPI,
and so far need a custom `/etc/machine-info` to set this property right.

A new 'chassis-type' toplevel device tree property has recently been
approved into the DT specification, making it possible to automate
chassis type detection on such devices.

This patch therefore falls back to reading this device-tree property if
nothing is available through both DMI and ACPI.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
3 years agobasic: nulstr-util: add nulstr_get() returning the matching string
Arnaud Ferraris [Tue, 14 Sep 2021 14:20:20 +0000 (16:20 +0200)] 
basic: nulstr-util: add nulstr_get() returning the matching string

Currently `nulstr_contains` returns a boolean, making it difficult to
identify which of the input strings matches the "needle".

Adding a new `nulstr_get()` function, returning a const pointer to the
matching string, eases this process and allows us to directly re-use the
result of a call to this function without additional processing or
memory allocation.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
3 years agotest: add test case for sysctl-util.[ch] 20746/head
Lennart Poettering [Tue, 14 Sep 2021 21:13:36 +0000 (23:13 +0200)] 
test: add test case for sysctl-util.[ch]

3 years agotest: make array in test-sysctl fully read-only
Lennart Poettering [Tue, 14 Sep 2021 21:13:23 +0000 (23:13 +0200)] 
test: make array in test-sysctl fully read-only

3 years agosysctl-util: per coding style, compare chars explicit against 0.
Lennart Poettering [Wed, 15 Sep 2021 07:23:56 +0000 (09:23 +0200)] 
sysctl-util: per coding style, compare chars explicit against 0.

3 years agosysctl-util: make sysctl_read_ip_property() a wrapper around sysctl_read()
Lennart Poettering [Wed, 15 Sep 2021 07:22:06 +0000 (09:22 +0200)] 
sysctl-util: make sysctl_read_ip_property() a wrapper around sysctl_read()

let's do what we did for sysctl_write()/sysctl_write_ip_property() also
for the read paths: i.e. make one a wrapper of the other, and add more
careful input validation.

3 years agosysctl-util: modernize sysctl_read() a bit
Lennart Poettering [Wed, 15 Sep 2021 07:20:49 +0000 (09:20 +0200)] 
sysctl-util: modernize sysctl_read() a bit

Let's add similar path validation to sysctl_read() as we already have in
sysctl_write().

Let's also drop the trailing newline from the returned string, like
sysctl_read_ip_property() already does it.

(I checked all users of this, they don't care)

3 years agosysctl-util: make sysctl_write_ip_property() a wrapper around sysctl_write()
Lennart Poettering [Wed, 15 Sep 2021 07:19:04 +0000 (09:19 +0200)] 
sysctl-util: make sysctl_write_ip_property() a wrapper around sysctl_write()

It does the same stuff, let's use the same codepaths as much as we can.

And while we are at it, let's generate good error codes in case we are
called with unsupported parameters/let's validate stuff more that might
originate from user input.

3 years agosd-boot: Add support for changing console mode at runtime 20483/head
Jan Janssen [Sun, 15 Aug 2021 11:44:47 +0000 (13:44 +0200)] 
sd-boot: Add support for changing console mode at runtime

3 years agosysctl-util: rework sysctl_write() to wrap write_string_file()
Lennart Poettering [Tue, 14 Sep 2021 21:19:38 +0000 (23:19 +0200)] 
sysctl-util: rework sysctl_write() to wrap write_string_file()

The sysctl_write_ip_property() call already uses write_string_file(), so
let's do so here, too, to make the codepaths more uniform.

While we are at it, let's also validate the passed path a bit, since we
shouldn't allow sysctls with /../ or such in the name. Hence simplify
the path first, and then check if it is normalized, and refuse if not.

3 years agofileio: set O_NOCTTY when reading virtual files
Lennart Poettering [Tue, 14 Sep 2021 21:11:55 +0000 (23:11 +0200)] 
fileio: set O_NOCTTY when reading virtual files

Better be safe than sorry, maybe someone points this call to a TTY one
day, and we'd rather not make it our controlling TTY in that case.

3 years agofileio: lower maximum virtual file buffer size by one byte
Lennart Poettering [Tue, 14 Sep 2021 21:03:37 +0000 (23:03 +0200)] 
fileio: lower maximum virtual file buffer size by one byte

When reading virtual files (i.e. procfs, sysfs, …) we currently put a
limit of 4M-1 on that. We have to pick something, and we have to read
these files in a single read() (since the kernel generally doesn't
support continuation read()s for them). 4M-1 is actually the maximum
size the kernel allows for reads from files in /proc/sys/, all larger
reads will result in an ENOMEM error (which is really weird, but the
kernel does what the kernel does). Hence 4M-1 sounds like a smart
choice.

However, we made one mistake here: in order to be able to detect EOFs
properly we actually read one byte more than we actually intend to
return: if that extra byte can be read, then we know the file is
actually larger than our limit and we can generate an EFBIG error from
that. However, if it cannot be read then we know EOF was hit, and we are
good. So ultimately after all we issued a single 4M read, which the
kernel then responds with ENOMEM to.  And that means read_virtual_file()
actually doesn't work properly right now on /proc/sys/. Let's fix that.

The fix is simple, lower the limit of the the buffer we intend to return
by one, i.e. 4M-2. That way, the read() we'll issue is exactly as large
as the limit the kernel allows, and we still get safely detect EOF from
it.

3 years agowatchdog: add ", ignoring" to log messages about errors we ignore 20751/head
Lennart Poettering [Wed, 15 Sep 2021 13:52:53 +0000 (15:52 +0200)] 
watchdog: add ", ignoring" to log messages about errors we ignore

As per coding style. Also downgrade relevant log messages to
LOG_WARNING.

3 years agowatchdog: pass right error code to log function so that %m works
Lennart Poettering [Wed, 15 Sep 2021 13:43:42 +0000 (15:43 +0200)] 
watchdog: pass right error code to log function so that %m works

3 years agorepart: mark an assert()-only variable as unused 20738/head
Frantisek Sumsal [Wed, 15 Sep 2021 13:46:19 +0000 (15:46 +0200)] 
repart: mark an assert()-only variable as unused

otherwise compilation with -Db_ndebug=true complains about a
set-but-not-used variable:

```
 ../src/partition/repart.c:907:33: error: variable 'left' set but not used [-Werror,-Wunused-but-set-variable]
                 uint64_t start, left;
                                                 ^
                                                 1 error generated.
```

3 years agoMerge pull request #20650 from fbuihuu/watchdog-rework
Luca Boccassi [Wed, 15 Sep 2021 13:44:49 +0000 (14:44 +0100)] 
Merge pull request #20650 from fbuihuu/watchdog-rework

Watchdog rework

3 years agojournalctl: never fail at flushing when the flushed flag is set
Franck Bui [Wed, 4 Aug 2021 09:20:07 +0000 (11:20 +0200)] 
journalctl: never fail at flushing when the flushed flag is set

Even if journald was not running, flushing the volatile journal used to work if
the journal was already flushed (ie the flushed flag
/run/systemd/journald/flushed was created).

However since commit 4f413af2a0a, this behavior changed and now '--flush' fails
because it tries to contact journald without checking the presence of the
flushed flag anymore.

This patch restores the previous behavior since there's no reason to fail when
journalctl can figure out that the flush is not necessary.

3 years agotest: document autopkgtest CI infrastructure
Luca Boccassi [Wed, 15 Sep 2021 12:49:04 +0000 (13:49 +0100)] 
test: document autopkgtest CI infrastructure

3 years agoMerge pull request #20729 from yuwata/ethtool-features-set
Yu Watanabe [Wed, 15 Sep 2021 11:28:24 +0000 (20:28 +0900)] 
Merge pull request #20729 from yuwata/ethtool-features-set

ethtool-util: support more offloading feature settings

3 years agoMerge pull request #20728 from yuwata/network-introduce-source-and-state-neighbor...
Yu Watanabe [Wed, 15 Sep 2021 11:26:44 +0000 (20:26 +0900)] 
Merge pull request #20728 from yuwata/network-introduce-source-and-state-neighbor-rule-and-nexthops

network: introduce NetworkConfigSource/State

3 years agoMerge pull request #20742 from pdmorrow/startup_cpus
Yu Watanabe [Wed, 15 Sep 2021 11:26:10 +0000 (20:26 +0900)] 
Merge pull request #20742 from pdmorrow/startup_cpus

add StartupAllowedCPUs= and StartupAllowedMemoryNodes= directives

3 years agotree-wide: mark set-but-not-used variables as unused to make LLVM happy
Frantisek Sumsal [Wed, 15 Sep 2021 08:56:21 +0000 (10:56 +0200)] 
tree-wide: mark set-but-not-used variables as unused to make LLVM happy

LLVM 13 introduced `-Wunused-but-set-variable` diagnostic flag, which
trips over some intentionally set-but-not-used variables or variables
attached to cleanup handlers with side effects (`_cleanup_umask_`,
`_cleanup_(notify_on_cleanup)`, `_cleanup_(restore_sigsetp)`, etc.):

```
../src/basic/process-util.c:1257:46: error: variable 'saved_ssp' set but not used [-Werror,-Wunused-but-set-variable]
        _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL;
                                                     ^
                                                     1 error generated.
```

3 years agowatchdog: use MIN() in update_timeout() 20650/head
Franck Bui [Wed, 15 Sep 2021 09:20:17 +0000 (11:20 +0200)] 
watchdog: use MIN() in update_timeout()

Also the previous expression was probably wrong as "(int) t >= INT_MAX" is
likely to always evaluate to false.

3 years agoshutdown: introduce init_watchdog()
Franck Bui [Wed, 15 Sep 2021 07:13:12 +0000 (09:13 +0200)] 
shutdown: introduce init_watchdog()

No functional change.

3 years agowatchdog: constify watchdog_set_device() parameter
Franck Bui [Wed, 15 Sep 2021 07:14:17 +0000 (09:14 +0200)] 
watchdog: constify watchdog_set_device() parameter

3 years agowatchdog: rename watchdog_set_timeout() into watchdog_setup()
Franck Bui [Tue, 14 Sep 2021 20:36:14 +0000 (22:36 +0200)] 
watchdog: rename watchdog_set_timeout() into watchdog_setup()

"watchdog_set_timeout()" was misleading as the function is not just a setter -
it must be called for activating the watchdog device.

3 years agomeson: add missing include directory when using xkbcommon
Antonio Alvarez Feijoo [Wed, 15 Sep 2021 06:46:40 +0000 (08:46 +0200)] 
meson: add missing include directory when using xkbcommon

Otherwise the build fails:

FAILED: systemd-localed.p/src_locale_localed.c.o
cc -Isystemd-localed.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -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=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Werror=unused-function -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 -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -Werror=shadow -include config.h -MD -MQ systemd-localed.p/src_locale_localed.c.o -MF systemd-localed.p/src_locale_localed.c.o.d -o systemd-localed.p/src_locale_localed.c.o -c ../src/locale/localed.c
../src/locale/localed.c:9:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
    9 | #include <xkbcommon/xkbcommon.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

3 years agowatchdog: minor simplification of watchdog_runtime_wait()
Franck Bui [Mon, 6 Sep 2021 12:31:30 +0000 (14:31 +0200)] 
watchdog: minor simplification of watchdog_runtime_wait()

No functional change.

3 years agowatchdog: no need to ping the device twice in watchdog_ping() if the device has just...
Franck Bui [Mon, 6 Sep 2021 10:42:50 +0000 (12:42 +0200)] 
watchdog: no need to ping the device twice in watchdog_ping() if the device has just been opened

3 years agowatchdog: update watchdog_timeout with the closest timeout found by the driver
Franck Bui [Mon, 6 Sep 2021 10:12:45 +0000 (12:12 +0200)] 
watchdog: update watchdog_timeout with the closest timeout found by the driver

Store the actual timeout value found by the driver in watchdog_timeout since
this value is more accurate for calculating the next time for pinging the
device.

3 years agocore: watchdog_set_timeout() doesn't need to return the timeout value used by the HW
Franck Bui [Mon, 6 Sep 2021 10:12:06 +0000 (12:12 +0200)] 
core: watchdog_set_timeout() doesn't need to return the timeout value used by the HW

The manager currently doesn't need it and if it does in the future an helper
should probably be introduced instead.

3 years agocore: call watchdog_ping() unconditionally
Franck Bui [Mon, 6 Sep 2021 06:26:30 +0000 (08:26 +0200)] 
core: call watchdog_ping() unconditionally

This basically reverts commit 61927b9f116bf45bfdbf19dc2981d4a4f527ae5f and
relies on the fact that watchdog_ping() will open and setup the watchdog for us
in case the device appears later on.

Also unlike what is said in comment
https://github.com/systemd/systemd/pull/17460#pullrequestreview-517434377, both
m->watchdog[] and m->overriden_watchdog[] are not supposed to store the actual
timeout used by the watchdog device but stores the value defined by the user.

If the HW timeout value is really needed by the manager then it's probably
better to read it via an helper defined in watchdog.c instead. However the HW
timeout value is currently only needed by the watchdog code itself mainly when
it calculates the time for the next ping.

3 years agowatchdog: make watchdog_ping() a NOP when the watchdog is disabled or closed
Franck Bui [Mon, 6 Sep 2021 06:47:08 +0000 (08:47 +0200)] 
watchdog: make watchdog_ping() a NOP when the watchdog is disabled or closed

This patch allows watchdog_ping() to be used unconditionally regardless of
whether watchdog_set_timeout() or watchdog_close() has been previously called
or not and in both cases watchdog_ping() does nothing.

shutdown.c has been updated to cope with this change.

3 years agofuzz: add StartupAllowedCPUs and StartupAllowedMemoryNodes to directives 20742/head
Peter Morrow [Tue, 14 Sep 2021 18:31:07 +0000 (19:31 +0100)] 
fuzz: add StartupAllowedCPUs and StartupAllowedMemoryNodes to directives

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
3 years agodocs: update docs with StartupAllowedCPUs and StartupAllowedMemoryNodes details
Peter Morrow [Tue, 14 Sep 2021 16:28:46 +0000 (17:28 +0100)] 
docs: update docs with StartupAllowedCPUs and StartupAllowedMemoryNodes details

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
3 years agosd-boot: Simplify setting console mode
Jan Janssen [Sun, 15 Aug 2021 11:44:42 +0000 (13:44 +0200)] 
sd-boot: Simplify setting console mode

3 years agocgroup: add support for StartupAllowedCPUs and StartupAllowedMemoryNodes
Peter Morrow [Tue, 14 Sep 2021 16:14:53 +0000 (17:14 +0100)] 
cgroup: add support for StartupAllowedCPUs and StartupAllowedMemoryNodes

Add new settings which can be used to control cpuset based cpu affinity
during the startup phase only.

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
3 years agonetwork: use NetworkConfigSource/State to manage nexthops 20728/head
Yu Watanabe [Mon, 6 Sep 2021 00:58:59 +0000 (09:58 +0900)] 
network: use NetworkConfigSource/State to manage nexthops

This also changes the logic when Id= is not specified.
Previously, kernel picks the lowest unused ID, but now networkd picks
the lowest unused ID.