Commit Graph
3663 Commits
Author SHA1 Message Date
Yu Watanabe 60e761d8f3 chase: replace path_prefix_root_cwd() with chaseat_prefix_root()
The function path_prefix_root_cwd() was introduced for prefixing the
result from chaseat() with root, but
- it is named slightly generic,
- the logic is different from what chase() does.

This makes the name more explanative and specific for the result of the
chaseat(), and make the logic consistent with chase().

Fixes https://github.com/systemd/systemd/pull/27199#issuecomment-1511387731.

Follow-up for #27199.
2023-04-19 03:38:59 +09:00
Yu Watanabe 24be89ebd8 chase: make the result absolute when a symlink is absolute
As the path may be outside of the specified dir_fd.
2023-04-19 03:28:34 +09:00
Yu Watanabe c0552b359c chase: make chaseat() provides absolute path also when dir_fd points to the root directory
Usually, we pass the file descriptor of the root directory to chaseat()
when `--root=` is not specified. Previously, even in such case, the
result was relative, and we need to prefix the path with "/" when we
want to pass the path to other functions that do not support dir_fd, or
log or show the path. That's inconvenient.
2023-04-19 03:28:34 +09:00
Frantisek Sumsal 3d9c3b7e89 test: modernize test-async a bit
Mainly to give it some debug output to, hopefully, see why it sometimes
gets stuck in CI when run with sanitizers.
2023-04-16 20:30:58 +02:00
Yu Watanabe f384ce1187 Merge pull request #27283 from mrc0mmand/assorted-test-tweaks
test: a bunch of assorted tweaks, Saturday edition
2023-04-16 19:39:58 +09:00
Yu Watanabe d8e75260e9 Merge pull request #27253 from yuwata/cmsg-find-and-copy-data
socket-util: introduce CMSG_FIND_AND_COPY_DATA()
2023-04-16 16:28:26 +09:00
Frantisek Sumsal 841834d9c3 test: add a couple of tests with invalid UTF-8 characters 2023-04-16 09:21:13 +02:00
Frantisek Sumsal 192242c986 test: add a simple test for getenv_path_list() 2023-04-16 09:21:13 +02:00
Frantisek Sumsal 10a9466135 test: add a simple test for secure-bits stuff 2023-04-16 09:21:13 +02:00
Frantisek Sumsal 9f7fcf80ad test: add tests for uuid/uint64 specifiers
They're used in repart, but are not part of the "common" specifier
lists, so cover them explicitly.
2023-04-16 09:21:13 +02:00
Frantisek Sumsal cb68860ece test: add a test case for table_dup_cell()
Also, sneak in coverage for "less popular" cell types.
2023-04-15 23:36:40 +02:00
Daan De Meyer e77e07f601 preset: Add ignore directive
The ignore directive specifies to not do anything with the given
unit and leave existing configuration intact. This allows distributions
to gradually adopt preset files by shipping a ignore * preset file.
2023-04-14 20:27:59 +01:00
Lennart Poettering d791013ff5 string-util: add strstrafter()
strstrafter() is like strstr() but returns a pointer to the first
character *after* the found substring, not on the substring itself.
Quite often this is what we actually want.

Inspired by #27267 I think it makes sense to add a helper for this,
to avoid the potentially fragile manual pointer increment afterwards.
2023-04-14 16:56:15 +02:00
Yu Watanabe 4ea0bcb922 chase: CHASE_MKDIR_0755 requires CHASE_NONEXISTENT and/or CHASE_PARENT
When CHASE_MKDIR_0755 is specified without CHASE_NONEXISTENT and
CHASE_PARENT, then chase() succeeds only when the file specified by
the path already exists, and in that case, chase() does not create
any parent directories, and CHASE_MKDIR_0755 is meaningless.

Let's mention that CHASE_MKDIR_0755 needs to be specified with
CHASE_NONEXISTENT or CHASE_PARENT, and adds a assertion about that.
2023-04-14 16:36:13 +09:00
Yu Watanabe 1113e50796 tree-wide: replace __alignof__() with alignof()
Addresses https://github.com/systemd/systemd/pull/27254#discussion_r1165267046.
2023-04-14 14:39:06 +09:00
Luca Boccassi 6ef721cbc7 user units: implicitly enable PrivateUsers= when sandboxing options are set
Enabling these options when not running as root requires a user
namespace, so implicitly enable PrivateUsers=.
This has a side effect as it changes which users are visible to the unit.
However until now these options did not work at all for user units, and
in practice just a handful of user units in Fedora, Debian and Ubuntu
mistakenly used them (and they have been all fixed since).

This fixes the long-standing confusing issue that the user and system
units take the same options but the behaviour is wildly (and sometimes
silently) different depending on which is which, with user units
requiring manually specifiying PrivateUsers= in order for sandboxing
options to actually work and not be silently ignored.
2023-04-13 21:33:48 +01:00
OMOJOLA JOSHUA DAMILOLA 96ead603b8 systemd-cryptenroll: add string aliases for tpm2 PCRs
Fixes #26697. RFE.
2023-04-13 12:08:32 +01:00
Yu Watanabe 85ba4ca8f6 test: add several assertions
Follow-up for 7947dbe322.

Fixes CID#1508781 and CID#1508783.
2023-04-13 11:57:29 +01:00
Lennart Poettering 39857544ee Merge pull request #27027 from dtardon/unit-file-list-cleanup
Use _cleanup_ for UnitFileList hash
2023-04-13 09:10:17 +02:00
David Tardon 1abcc826ca test: use _cleanup_ for UnitFileList hash 2023-04-12 17:09:41 +02:00
Lennart Poettering 7947dbe322 test: add varlink fd passing test 2023-04-12 15:14:21 +02:00
Lennart Poettering 3af48a86d9 Merge pull request #25608 from poettering/dissect-moar
dissect: add dissection policies
2023-04-12 13:46:08 +02:00
Tanishka fd7623193d Modified to use STRV_MAKE() in strv_env_name_is_valid() function listed in env-util.c 2023-04-11 21:05:22 +02:00
Yu Watanabe 7ef43c78df os-util: invert order of arguments in extension release parser
For consistency with other functions.
Unfortunately, va_start() requires that the previous argument is a
pointer, hence the order of the arguments in the internal function
cannot be changed.
2023-04-11 18:49:23 +09:00
Yu Watanabe bfeaa62dbc compress: replace compress_blob() with compress_blob_explicit()
And make compress_xyz() return 0 on success, as we know which compression
algorithm is used when calling compress_blob().

Follow-up for 2360352ef0.
2023-04-11 09:14:34 +02:00
Yu Watanabe c689c541a1 Merge pull request #27201 from yuwata/o-path-support
Support O_PATH more
2023-04-11 12:37:37 +09:00
Yu Watanabe 75cc8d7c42 path-util: introduce path_prefix_root_cwd() 2023-04-11 06:27:05 +09:00
Yu Watanabe e63d070373 copy: make copy_bytes() support O_PATH fds 2023-04-11 05:17:10 +09:00
Yu Watanabe de68bf7896 test: add tests about iterator position for path_find_{first,last}_component()
When path_find_first_component() returns the last component, the iterator
must be an empty string. The fact is heavily used in chaseat(). Let's
explicitly test it.
2023-04-10 09:39:14 +09:00
Yu Watanabe add762605a test: add tests for conf_files_list_at() and friends 2023-04-08 06:01:10 +09:00
Yu Watanabe 6808e00463 path-util: introduce path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe b6b446cb62 test: handle one more error gracefully
Fixes #27175.
2023-04-07 20:54:23 +02:00
Zbigniew Jędrzejewski-Szmek ddd43f31e3 Merge pull request #26887 from yuwata/proc-cmdline-filter-arguments
proc-cmdline: filter PID1 arguments on container
2023-04-07 10:55:30 +02:00
maanyagoenka f7700ea599 test-os-util: add tests for sysext and confext release files 2023-04-05 21:50:04 +00:00
Lennart Poettering a594288d79 sysext: default to a stricter image policy when reading /.extra/sysext/ DDIs 2023-04-05 20:53:04 +02:00
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
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