Commit Graph
2933 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 3c9fbb993b variuos: add missing includes 2021-09-22 12:58:46 +02:00
Lennart Poettering f3b751220b 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
2021-09-16 12:23:32 +02:00
Lennart Poettering 3448711b7e test: add test case for sysctl-util.[ch] 2021-09-15 16:32:40 +02:00
Lennart Poettering 89edc243e4 test: make array in test-sysctl fully read-only 2021-09-15 16:32:40 +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 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
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
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 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 af7c37a486 test: do not try to remove /dev 2021-09-07 14:08:21 +09:00
Yu Watanabe 4e046c5c2f fs-util: rewrite rmdir_parents() with path_find_last_component() 2021-09-07 14:08:21 +09:00
Lennart Poettering b03803f0dc format-table: allow to explicitly override JSON field names
In some cases it's useful to explicitly generate the JSON field names to
generate for table columns, instead of auto-mangling them from table
header names that are intended for human consumption.

This adds the infra and a test for it.

It's intended to be used by #20544, for the first column, which in text
mode should have an empty header field, but have an explicit name in
json output mode.
2021-09-03 14:37:26 +01:00
Luca Boccassi 1f08acf406 Merge pull request #20257 from bluca/seqno
Use new diskseq block device property
2021-08-31 09:06:33 +01:00
Yu Watanabe 42867dfeef test-execute: add a testcase for MountAPIVFS=no 2021-08-26 02:54:37 +09:00
Yu Watanabe aa2727517e test-execute: logs can_share flag 2021-08-24 02:04:24 +09:00
Yu Watanabe 455bb37a8b Merge pull request #20499 from poettering/align-to-tweak
ALIGN_TO() tweaks
2021-08-21 12:50:07 +09:00
Yu Watanabe cc97ef5627 Merge pull request #20494 from bluca/snprintf_voidify
tree-wide: voidify unchecked snprintf calls or use snprintf_ok
2021-08-21 06:45:58 +09:00
Lennart Poettering c7ed718720 macro: handle overflow in ALIGN_TO() somewhat reasonably
The helper call rounds up to next multiple of specified boundary. If one
passes a very large value as first argument, then there might not be a
next multiple. So far we ignored that. Let's handle this now and return
SIZE_MAX in this case, as special indicator that we reached the end.

Of course, IRL this should not happen. With this new change we at least
do something somewhat reasonable, leaving it to the caller to handle it
further.
2021-08-20 22:00:48 +02:00
Lennart Poettering eeed637fea test: split out macro tests into own test-macro.c
No changes in code, just a split out of tests for stuff from macro.h
into test-macro.c
2021-08-20 22:00:48 +02:00
Luca Boccassi 121ed16caf tree-wide: voidify unchecked snprintf calls
According to Coverity, 194 ouf of 227 times we check for snprintf return code.
Voidify the rest.

CID#1461512
CID#1461513
CID#1461514
CID#1461515
CID#1461516
CID#1461518
CID#1461519
CID#1461520
CID#1461522
2021-08-20 18:29:40 +01:00
Maanya Goenka 5ef8b072e9 set: modify the previously incorrect definition of set_copy and add test for it 2021-08-20 10:02:49 -07:00
Lennart Poettering 72fba0c4e5 Merge pull request #20488 from yuwata/timesync-fix
timesync: fix wrong type for receiving timestamp in nanoseconds
2021-08-20 13:34:20 +02:00
Lennart Poettering 85b55869bc tree-wide: port everything over to new sd-id128 compund literal bliss 2021-08-20 11:09:48 +02:00
Lennart Poettering dc131951b5 Merge pull request #18385 from kinvolk/mauricio/restrict-network-interfaces
Add RestrictNetworkInterfaces=
2021-08-20 03:41:11 +02:00
Yu Watanabe 6f96bdc587 timesync: fix wrong type for receiving timestamp in nanoseconds
Fixes #20482.
2021-08-20 08:42:13 +09:00
Lennart Poettering 48a01cd934 test: add test for FORMAT_PROC_FD_PATH() 2021-08-19 09:19:23 +02:00
Mauricio Vásquez 2ce150f5ec src/test: add restrict network interfaces to test-cgroup-mask
Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
2021-08-18 15:55:54 -05:00
Luca Boccassi 5ce46344fd xattr-util: add fgetxattrat_fake_malloc variant 2021-08-17 13:04:44 +01:00
Lennart Poettering 7a6abbe937 env-util: add unsetenv_erase() helper
Let's unify how we remove secrets from the env block.
2021-08-17 13:17:44 +02:00
Lennart Poettering 235be6bcea shared: add generic helper tools for installing files/dir trees
This adds a bit of generic helper tools for installing files/dir trees.
"installing" is supposed to mean the final step when preparing a disk
image or directory tree, where the result is renamed to its final name.
It has some bells and whistles, as it is able to replace existing files
sanely, can fsync() things carefully and can mark things read-only in a
nice way.

This is supposed to be generic, unified code that can be used eventually
for any of our tools that prepare disk images/directory trees, including
importd, nspawn's --template= mechanism, the discover-image.c logic,
and more.
2021-08-17 10:08:48 +02:00
Lennart Poettering 2c3735d6ba Merge pull request #20350 from medhefgo/boot
Grab bag of sd-boot improvements
2021-08-13 09:22:12 +02:00
Lennart Poettering a0c5a3f0c0 Merge pull request #20419 from keszybz/setenv-no-value
Allow --setenv=FOO in various programs
2021-08-11 17:47:45 +02:00
Jan Janssen f862e84724 macro: Move some macros to macro-fundamental.h
Also, make sure STRLEN works with wide strings too.
2021-08-11 14:59:46 +02:00
Zbigniew Jędrzejewski-Szmek a14af47e64 basic/env-util: add a mode where we pull in the variable value from environment 2021-08-11 09:16:05 +02:00
Zbigniew Jędrzejewski-Szmek 43cadb64d4 test-env-util: extend the test for strv_env_merge() a bit 2021-08-11 09:11:58 +02:00
Zbigniew Jędrzejewski-Szmek 4ab3d29ff0 Add implicit sentinel to strv_env_merge()
Just to make it a tiny bit nicer to use.
2021-08-11 09:11:42 +02:00
Maanya Goenka 36f4af0568 path-util: teach find_executable_full how to look into the root directory
When the root parameter in find_executable_full is set, chase_symlinks prefixes this root
to every check of the path name to find the complete path of the execuatble in case the
path provided is not absolute. This is only done for the non NULL root because otherwise
the chase_symlinks function would alter the behavior of some of the callers which would
in turn alter the outputs in a way that is undesirable. The find_execuatble_full function is
invoked by the verify_executable function in analyze-verify.
2021-08-10 10:14:01 -07:00
Maanya Goenka 2a7cf953e1 systemd-analyze: add --root option for 'verify' verb and allow path parsing
-------------------------------------------------------------------------------
Example Run:

foobar.service created below is a service unit file that has a non-existing key-value
pairing (foo = bar) and is thus, syntactically invalid.

maanya-goenka@debian:~/systemd (img-support)$ cat <<EOF>img/usr/lib/systemd/system/foobar.service
> [Unit]
> foo = bar
>
> [Service]
> ExecStart = /opt/script0.sh
> EOF

The failure to create foobar.service because of the recursive dependency searching and verification has been addressed
in a different PR: systemd-analyze: add option to return an error value when unit verification fails #20233

maanya-goenka@debian:~/systemd (img-support)$ sudo build/systemd-analyze verify --root=img/ foobar.service
/home/maanya-goenka/systemd/img/usr/lib/systemd/system/foobar.service:2: Unknown key name 'foo' in section 'Unit', ignoring.
foobar.service: Failed to create foobar.service/start: Unit sysinit.target not found.
2021-08-10 02:41:12 -07:00
Zbigniew Jędrzejewski-Szmek 169d980bc8 test-log: move logging call where we can still see it
We crank the level up in the loop, so we wouldn't see message
from log_info_errno().

Also move the loop iterator declaration inline.
2021-08-07 08:50:27 +02:00
Zbigniew Jędrzejewski-Szmek 04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Lennart Poettering 7d963260a1 Merge pull request #20172 from poettering/import-util-tweaks
Import-util: URL processing tweaks
2021-07-30 19:05:06 +02:00
Lennart Poettering 9554c51425 test: add simple test for import-util 2021-07-30 16:31:24 +02:00
Lennart Poettering bf18f4b671 glyph-util: add three more emojis to emoji list 2021-07-30 16:18:05 +02:00
Luca Boccassi a36429971a dissect: use DISKSEQ when waiting for block devices
DISKSEQ is a reliable way to find out if we missed a uevent or not, as
it's monotonically increasing. If we parse an event with a smaller or
no sequence number, we know we need to wait longer. If we parse an
event with a greater sequence number, we know we missed it and the
device was reused.
2021-07-28 20:07:01 +01:00
Zbigniew Jędrzejewski-Szmek 81875efe20 meson: use project_build_root
As documented in /meson.build where the variable is defined,
meson.build_root() doesn't work as expected with project nesting. I have
no idea why anyone would want to embed systemd in another meson project,
but let's use the variable if we have it.
2021-07-27 18:53:22 +02:00
Yu Watanabe f843f85da8 tree-wide: FORMAT_TIMESTAMP() or friends must be used as a function argument
Follow-ups for #20109.
2021-07-15 20:03:46 +09:00
Yu Watanabe e18f21e349 Merge pull request #20109 from keszybz/timestamp-macros
Add macros that define scratch buffer internally for timestamp/timespan formatting
2021-07-14 16:14:08 +09:00
Luca Boccassi 5c8cf104e7 Merge pull request #20157 from keszybz/numerical-uids-in--M
Allow numerical UIDs in systemctl -M uid@ and similar
2021-07-09 16:58:45 +01:00
Zbigniew Jędrzejewski-Szmek eeb91d29b0 basic/escape: add helper for quoting command lines 2021-07-09 11:18:21 +02:00