1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00
Commit Graph

53128 Commits

Author SHA1 Message Date
Lennart Poettering
f9755203b9 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)
2021-09-15 16:32:40 +02:00
Lennart Poettering
6aebfec3a5 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.
2021-09-15 16:32:40 +02:00
Lennart Poettering
13239c86e0 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.
2021-09-15 16:19:45 +02:00
Lennart Poettering
be991d7678 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.
2021-09-15 16:19:45 +02:00
Lennart Poettering
7ab7547a40 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.
2021-09-15 16:19:45 +02:00
Luca Boccassi
8f8e9ad7cb
Merge pull request #20650 from fbuihuu/watchdog-rework
Watchdog rework
2021-09-15 14:44:49 +01:00
Franck Bui
f6fca35e64 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 4f413af2a0, 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.
2021-09-15 15:10:15 +02:00
Luca Boccassi
e236711fd7 test: document autopkgtest CI infrastructure 2021-09-15 14:58:38 +02:00
Yu Watanabe
65bf08dd4a
Merge pull request #20729 from yuwata/ethtool-features-set
ethtool-util: support more offloading feature settings
2021-09-15 20:28:24 +09:00
Yu Watanabe
2c577df6f7
Merge pull request #20728 from yuwata/network-introduce-source-and-state-neighbor-rule-and-nexthops
network: introduce NetworkConfigSource/State
2021-09-15 20:26:44 +09:00
Yu Watanabe
3c76b1a157
Merge pull request #20742 from pdmorrow/startup_cpus
add StartupAllowedCPUs= and StartupAllowedMemoryNodes= directives
2021-09-15 20:26:10 +09:00
Franck Bui
10fd2b1180 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.
2021-09-15 12:14:53 +02:00
Franck Bui
484752e26a shutdown: introduce init_watchdog()
No functional change.
2021-09-15 12:14:53 +02:00
Franck Bui
bcc3a1830e watchdog: constify watchdog_set_device() parameter 2021-09-15 12:14:53 +02:00
Franck Bui
d74965e6fe 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.
2021-09-15 12:14:34 +02:00
Antonio Alvarez Feijoo
aff870ef61 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.
2021-09-15 11:38:47 +02:00
Franck Bui
9692ead197 watchdog: minor simplification of watchdog_runtime_wait()
No functional change.
2021-09-15 11:32:21 +02:00
Franck Bui
e94f9e720c watchdog: no need to ping the device twice in watchdog_ping() if the device has just been opened 2021-09-15 11:32:21 +02:00
Franck Bui
564096795e 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.
2021-09-15 11:32:10 +02:00
Franck Bui
2628b98f0c 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.
2021-09-15 10:56:26 +02:00
Franck Bui
ae4a0ec45c core: call watchdog_ping() unconditionally
This basically reverts commit 61927b9f11 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.
2021-09-15 10:54:24 +02:00
Franck Bui
5bbf2db1e4 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.
2021-09-15 10:54:19 +02:00
Peter Morrow
88a56dc8d6 fuzz: add StartupAllowedCPUs and StartupAllowedMemoryNodes to directives
Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
2021-09-15 09:52:12 +01:00
Peter Morrow
c93a7d4ad3 docs: update docs with StartupAllowedCPUs and StartupAllowedMemoryNodes details
Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
2021-09-15 09:52:12 +01:00
Peter Morrow
31d3a52029 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>
2021-09-15 09:30:12 +01:00
Yu Watanabe
89fa013349 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.
2021-09-15 16:50:23 +09:00
Yu Watanabe
eb72fa3ad2 network: use NetworkConfigSource/State to manage routing policy rules
This also changes the logic when Priority= is not specified.
Previously, we request without FRA_PRIORITY attribute and kernel picks
the highest unused priority for the rule.
This makes networkd picks the highest unused priority and always request
FRA_PRIORITY attribute.
2021-09-15 16:50:23 +09:00
Yu Watanabe
193c4af94b network: use NetworkConfigSource/State to manage neighbors 2021-09-15 16:50:23 +09:00
Yu Watanabe
a093533c33 network: introduce NetworkConfigSource and NetworkConfigState
These will be used in later commits.
2021-09-15 16:50:23 +09:00
Kai Wohlfahrt
679de14112 Respect install_sysconfdir
This was lost e11a25cadb and c900d89faa while adding jinja2
templating. Breaks builds on NixOS.
2021-09-15 09:04:12 +02:00
Daan De Meyer
27bf0ab76e sd-journal: Don't compare hashes from different journal files
In sd_journal_enumerate_fields(), we check if we've already handled
a field by checking if we can find it in any of the already processed
journal files. We do this by calling
journal_file_find_field_object_with_hash(), which compares the size,
payload and hash of the given field against all fields in a journal file,
trying to find a match. However, since we now use per file hash functions,
hashes for the same fields will differ between different journal files,
meaning we'll never find an actual match.

To fix the issue(), let's use journal_file_find_field_object() when one
or more of the files we're comparing is using per file keyed hashes.
journal_file_find_field_object() only takes the field payload and size
as arguments and calculates the hash itself using the hash function from
the journal file we're searching in.
2021-09-15 11:00:49 +09:00
Marcus Harrison
2709d02906
Fix error building repart with no libcryptsetup (#20739) 2021-09-15 10:55:07 +09:00
Franck Bui
12663295ca core: watchdog_runtimeout_wait() already returns USEC_INFINITY when the watchdog is disabled or closed 2021-09-14 21:39:21 +02:00
Franck Bui
3178d23ddd main: use timestamp_is_set() in become_shutdown() 2021-09-14 21:39:21 +02:00
Jan Kuparinen
74973e3ed0 po: Translated using Weblate (Finnish)
Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/fi/
Translation: systemd/main
2021-09-15 04:34:44 +09:00
Yu Watanabe
77bf5c31de ethtool-util: add more network device features
Then, we can easily add new settings to configure features in .link
file.
2021-09-15 02:12:02 +09:00
Yu Watanabe
7a4f203547 ethtool-util: apply tx-checksum-* features at last
NET_DEV_FEAT_TX matches multiple features. In the next commit, all
features whose strings start with "tx-checksum-" will be added.
To make them take precedence over NET_DEV_FEAT_TX, it will be applied
only when each explicit feature is not applied.
2021-09-15 02:07:15 +09:00
Yu Watanabe
008d3a370c ethtool: do not set unavailable or never_changed bits 2021-09-15 01:56:19 +09:00
Yu Watanabe
4253dab576 ethtool-util: shorten code a bit
Also fixes a error code in debugging log.
2021-09-15 01:41:19 +09:00
Yu Watanabe
6d9a72f3b9 ethtool-util: use sizeof() 2021-09-15 01:32:35 +09:00
Lennart Poettering
9a89ab26d6 man: extend documentation about TPM2 PCRs
This is an effort to compile a somewhat complete list how PCRs are
actually used on Linux systems these days. It contains data from: the
UEFI PC spec, the shim, the IMA, grub documentation.

I validated these PCRs to some level in the sources.

The grub specific stuff I only added in comments, since I was too lazy
too validate it (also, meh, grub).

It also gives people a hint on which PCR to bind to (and maybe kind of
an explanation of our default choice).
2021-09-14 17:37:06 +02:00
Lennart Poettering
2fe29f3135
Merge pull request #20697 from yuwata/in-addr-prefix
core: rewrite IPAddressAllow/Deny= parser
2021-09-14 15:58:20 +02:00
Luca Boccassi
76ab98fa2b docs: generic info about adding directives in ARCHITECTURE.md 2021-09-14 13:55:05 +01:00
Yu Watanabe
9d01399d44 network: replace config_parse_address_filter() with config_parse_in_addr_prefixes() 2021-09-14 20:31:17 +09:00
Yu Watanabe
84ebe6f013 core: replace IPAddressAccessItem with struct in_addr_prefix
Previously, if a unit file which contains n IPAddressAllow/Deny= lines,
then the computational order of parsing the file was O(n^3), as
ip_address_access_reduce(), whose order is O(n^2), is called for each line.

By replacing in_addr_prefix related functions, now the computational
order is O(n log n).

Fixes #20680.
2021-09-14 20:30:09 +09:00
Yu Watanabe
60da07ecc7 core/cgroup: set bitfield to reduce struct size 2021-09-14 20:30:09 +09:00
Yu Watanabe
0856e78df0 test: add tests for in-addr-prefix-util.c 2021-09-14 20:30:09 +09:00
Yu Watanabe
0bc311bbe9 test: slightly modernize test-in-addr-util.c 2021-09-14 20:30:09 +09:00
Yu Watanabe
bffaa49ec4 in-addr-prefix-util: introduce several utilities for address prefix 2021-09-14 20:30:09 +09:00
Yu Watanabe
c4f06a75ea
Merge pull request #20700 from yuwata/network-dhcp-cleanups
network: several DHCP related cleanups
2021-09-14 20:29:27 +09:00