Commit Graph
4080 Commits
Author SHA1 Message Date
Lennart Poettering 84be0c710d tree-wide: hook up image dissection policy logic everywhere 2023-04-05 20:45:30 +02:00
Lennart Poettering d452335aa4 dissect: add image dissection policy framework 2023-04-05 20:44:36 +02:00
Yu Watanabe 70650ae345 test: add tests for dir_fd_is_root_or_cwd()
Follow-up for e212f42279.
2023-04-05 19:38:08 +01:00
Zbigniew Jędrzejewski-Szmek 6eccc3cfa9 test-core-unit: add new test file for unit_escape_setting() and friends
None of the existing test files fit very well. test-unit-serialize is
pretty close, but it does special cgroup setup, which we don't need in
this case. I hope we can add more tests in the future for this basic
functionality, so I'm adding a brand new file names after the source file
it's testing.
2023-04-04 21:28:36 +02:00
Zbigniew Jędrzejewski-Szmek 23c3c5d423 meson: redo grouping of tests under src/test/
Move the tests that link to libcore into a separate subgroup.
They are special and it makes sense to keep them together. While
at it, make the list alphabetical.

Also, merge the list additions into one. No idea why it was like that.
2023-04-04 21:28:36 +02:00
Yu Watanabe edd595f760 specifier: always convert missing machine-id file to EUNATCH
Then, use id128_get_machine().
2023-04-05 00:52:56 +09:00
Yu Watanabe 1adbc2a428 test: add tests for id128_get_machine() and _at() 2023-04-05 00:52:56 +09:00
Yu Watanabe 99e6d7941b test: add tests for ID128_REFUSE_NULL 2023-04-05 00:52:56 +09:00
Yu Watanabe 9853542dd3 test: add tests for id128_{read,write}_at() 2023-04-04 11:46:18 +09:00
William Roberts acbb504eaf tpm2: add support for a trusted SRK
Prevent attackers from spoofing the tpmKey portion of the AuthSession by
adding a trusted key to the LUKS header metadata. Also, use a persistent
object rather than a transient object.

This provides the following benifits:
1. No way to MITM the tpmKey portion of the session, see [1] for
details.

2. Strengthens the encrypted sessions, note that the bindKey could be
   dropped now.

3. Speed, once it's created we just use it.

4. Owner Auth is needed to call create primary, so using the SRK
   creates a scratch space for normal users.

This is a "first to set" model, in where the first person to set the key
in the LUKS header wins. Thus, setup should be done in a known good
state. If an SRK, which is a primary key at a special persistent
address, is found, it will use whatever is there. If not, it creates an
SRK. The SRK follows the convetions used through the tpm2-software
organization code on GitHub [2], however, a split has occured between
Windows and Linux with respect to SRK templates. The Linux SRK is
generated with the unique field size set to 0, in Windows, it properly
sets the size to key size in bytes and the unique data to all 0's of that
size. Note the proper templates for SRKs is covered in spec [3].
However, the most important thing, is that both SRKs are passwordless,
and thus they should be interchangable. If Windows is the first to make
the SRK, systemd will gladly accept it and vice-versa.

1. Without the bindKey being utilized, an attacker was able to intercept
this and fake a key, thus being able to decrypt and encrypt traffic as
needed. Introduction of the bindKey strengthened this, but allows for
the attacker to brute force AES128CFB using pin guesses. Introduction of
the salt increases the difficulty of this attack as well as DA attacks
on the TPM objects itself.

2. https://github.com/tpm2-software

3. https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdf

Fixes: #20668
Fixes: #22637

Signed-off-by: William Roberts <william.c.roberts@intel.com>
2023-04-03 13:10:49 +02:00
taniishkaaa 6cc19afac1 Added unit test for strv_env_name_is_valid() function listed in env-util.c (#27100)
tests: add test for strv_env_name_is_valid function listed in env-util.c
2023-04-02 14:27:29 +01:00
Yu Watanabe 5b6f203c95 Revert "Revert "test: add more testcases for rm_rf()""
This reverts commit 8c81a61810.
2023-03-31 11:54:23 +09:00
Luca Boccassi ed2a4e8d78 Merge pull request #27075 from mrc0mmand/test-tweaks
test: a couple of coverage-related test tweaks
2023-03-31 01:18:15 +01:00
Frantisek Sumsal 1d6052ba5c test: make make_addresses() actually return the addresses
I noticed missing coverage in the reports and turns out this has been
broken since forever (i.e. 2016 - 9f7672b3bc), whoopsie.
2023-03-30 20:42:47 +02:00
Luca Boccassi 8c81a61810 Revert "test: add more testcases for rm_rf()"
This reverts commit 0278b1c801.
2023-03-30 16:48:18 +01:00
Zbigniew Jędrzejewski-Szmek e61bab2b55 Merge pull request #26883 from yuwata/rm-rf
rm-rf: also chmod directory if cannot be opened
2023-03-30 14:54:59 +02:00
Daan De Meyer 2e82d82445 Merge pull request #27060 from yuwata/fd-get-path
fd-util: make fd_get_path() support AT_FDCWD
2023-03-30 07:59:25 +02:00
Yu Watanabe 8f22fe3207 test: split-out tests for chase() and friends to test-chase.c 2023-03-30 12:18:40 +09:00
Yu Watanabe 564a7545aa test: rename test-chase -> test-chase-manual 2023-03-30 12:18:40 +09:00
Yu Watanabe 46693a7925 fd-util: make fd_get_path() support AT_FDCWD 2023-03-30 12:03:33 +09:00
Yu Watanabe 8067fe86ff test: add tests for fd_get_path() 2023-03-30 12:03:33 +09:00
Luca Boccassi 89c632dfda Merge pull request #27020 from 1awesomeJ/nit
systemd-cryptenroll: adding integration test cases
2023-03-29 12:24:08 +01:00
Daan De Meyer ee2975a9d9 log: Add LOG_SET_PREFIX() macro
LOG_SET_PREFIX() sets a logging prefix for the current block. The
prefix is prepended to every logging message in the block, followed
by ": ". If a logging prefix is already configured, it is overridden
for the duration of the block, after which it is restored.

A use case for this macro is when we're operating on an image or
directory (using --root or --image). We can use LOG_SET_PREFIX() to
prefix all logging messages with the directory or image that we're
operating on.
2023-03-29 13:00:33 +09:00
Yu Watanabe 6339d3e602 proc-cmdline: filter PID1 arguments when we are running in a container
Otherwise, PID1 arguments e.g. "--deserialize 16" may be parsed
unexpectedly by generators.

Fixes the issue reported at
https://github.com/systemd/systemd/issues/24452#issuecomment-1475004433.
2023-03-29 10:34:41 +09:00
Yu Watanabe 94e0130ab0 proc-cmdline: introduce proc_cmdline_strv()
When we are running in a container, we parse the command line of PID1 in
proc_cmdline_parse() or friends. Previously, first we merge the command
line nulstr as a single string, and then split by using
extract_first_word(). That's not only redundant, but also unsafe when
the command line argument contain a space.

This drops the redundant steps, hence we can safely parse arguments with
space.
2023-03-29 10:34:39 +09:00
Frantisek Sumsal e3201a69eb test: don't go through all time zones if slow tests are disabled
Let's skip going through all locally available time zones if we're built
with slow tests disabled, as that's quite slow, but do at least one test
with the UTC zone.
2023-03-28 18:16:38 +01:00
Luca Boccassi a4d1d1f63d Merge pull request #26941 from bluca/portable_version
portable: introduce SYSEXT_ fields to identify sysexts, and include more metadata in log messages via LogExtraFields=
2023-03-28 17:49:52 +01:00
Yu Watanabe 201423d801 process-util: introduce get_process_cmdline_strv()
The reason why get_process_cmdline() is so complicated is that we
need to escape and quote arguments for building a single result
string.

That's necessary when we want to log or print the command line.
However, when we want to parse the command line, it is not necessary
that the result is a single string, but can be strv.

This will be used when we parse the command line.
2023-03-28 17:09:15 +02:00
Luca Boccassi 2ed74695b3 strv: add helper to find value in key/value pairs from list of keys 2023-03-28 10:36:01 +01:00
Luca Boccassi 6255bbe262 env: add load_env_file_pairs_fd() 2023-03-28 10:36:01 +01:00
Yu Watanabe 409759634e env-util: introduce strv_env_assign_many() 2023-03-28 02:51:54 +09:00
OMOJOLA JOSHUA DAMILOLA 72a992354c compare-operator:unit test 2023-03-27 14:15:40 +00:00
Lennart Poettering 09a7cef5ab test-fd-util: use stat_inode_same() where appropriate 2023-03-27 12:28:48 +02:00
Lennart Poettering fdb583e6a9 fd-util: cover some corner cases with fd_reopen() on symlinks
The /proc/self/fd/ interface cannot be used to follow symlinks pinned
via O_PATH. Add a comment + test for that. Moreover, using fd_reopen()
with O_NOFOLLOW cannot work. Add an explicit check and test for that, to
make behaviour uniform.
2023-03-27 12:28:48 +02:00
Daan De Meyer 4e24df3cc3 Merge pull request #26961 from DaanDeMeyer/chase-and-pin
chase-symlinks: Add chase_and_open_parent() + at() variant
2023-03-27 10:41:08 +02:00
Daan De Meyer 670afc182a chase-symlinks: Add chase_and_open_parent() + at() variant
Helper to chase a path, pin its parent directory and return the filename
of the resolved path in its parent directory.
2023-03-26 20:31:10 +02:00
Yu Watanabe 0278b1c801 test: add more testcases for rm_rf() 2023-03-25 05:57:58 +09:00
Lennart Poettering 7b82d95f8d string-util: add new helper for finding line starting with specific string in a text buffer
We have implemented this manually a couple of times, and always wrong.
Hence let's implement this correctly for once and use everywhere.
2023-03-24 18:30:20 +01:00
Daan De Meyer f461a28da7 chase-symlinks: Rename chase_symlinks() to chase()
Chasing symlinks is a core function that's used in a lot of places
so it deservers a less verbose names so let's rename it to chase()
and chaseat().

We also slightly change the pattern used for the chaseat() helpers
so we get chase_and_openat() and similar.
2023-03-24 13:43:51 +01:00
Daan De Meyer 12962485e4 Merge pull request #26958 from yuwata/nulstr-optionally-drop-trailing-nulstr
nulstr: make strv_parse_nulstr() optionally drop trailing NULs
2023-03-24 11:33:58 +01:00
Yu Watanabe 55479c208d test: add tests from strv_parse_nulstr_full() 2023-03-24 15:21:59 +09:00
Yu Watanabe a3cb11f841 test-proc-cmdline: test proc_cmdline_get_key() actually parses EFI options
Follow-up for 53aa0d02ad.
2023-03-24 15:20:05 +09:00
Yu Watanabe 2a6911bb1f proc-cmdline: make proc_cmdline_parse_given() static
It is used only in proc-cmdline.c and its test. And the test can be
covered by proc_cmdline_parse().
2023-03-24 15:20:05 +09:00
Yu Watanabe 1479799c4d proc-cmdline: use proc_cmdline_key_string() when we search for key 2023-03-24 15:20:05 +09:00
Luca Boccassi 2a775d5faf Merge pull request #26935 from keszybz/test-parse_aux
Add test for auxv parsing
2023-03-23 23:13:42 +00:00
Luca Boccassi d024c4d0e1 Merge pull request #26949 from DaanDeMeyer/xopenat-reopen
loop-util: Add loop_device_make_by_path_at()
2023-03-23 23:08:21 +00:00
Lennart Poettering b839101aac fileio: add new helper fdopen_independent()
This is a combination of fdopen() and fd_reopen(). i.e. it first reopens
the fd, and then converts that into a FILE*.

We do this at various places already manually. let's move this into a
helper call of its own.
2023-03-23 22:48:00 +00:00
Zbigniew Jędrzejewski-Szmek f39546a881 test-coredump-util: also test parse_auxv() with unaligned data 2023-03-23 18:07:45 +01:00
Zbigniew Jędrzejewski-Szmek 2f809d29e8 test-coredump-util: add tests for parse_aux()
The test files are /proc//auxv files copies from various architecutres
signified by the file name suffix.

Those tests are fairly simple, but when we run them on n architectures, we do
~n² cross-arch tests.
2023-03-23 18:06:46 +01:00
Daan De Meyer 06ca2db39d fs-util: Allow xopenat() to reopen existing file descriptors 2023-03-23 17:31:55 +01:00