Commit Graph
7168 Commits
Author SHA1 Message Date
Yu Watanabe 17bd68ca74 Merge pull request #27874 from keszybz/test-bus-server-shortening
Simplify the code in test-bus-server
2023-06-01 21:10:55 +09:00
Zbigniew Jędrzejewski-Szmek fa18faf1c0 various: remove typo/unusual spelling
Wikitionary says that "noone" is known, but not preferred by a large margin.
(It's also an obsolete spelling of "noon".)
2023-06-01 09:56:14 +02:00
Yu Watanabe 2485b7e2b8 tree-wide: use memstream-util 2023-06-01 06:48:47 +09:00
Yu Watanabe 24b0c6c2c9 calendarspec: rename arguments 2023-06-01 06:47:48 +09:00
Yu Watanabe a694747d45 elf-util: rename stack_context_destroy() -> stack_context_done() 2023-06-01 06:47:48 +09:00
Yu Watanabe 5d2a48da12 tree-wide: use _cleanup_set_free_ and friends
Instead of _cleanup_(set_freep) or so.
2023-06-01 06:47:48 +09:00
Daan De Meyer 7d52bf16e7 Merge pull request #27628 from ddstreet/tpm2_header_cleanup
Tpm2 header cleanup
2023-05-31 23:06:14 +02:00
Daan De Meyer c4b7e0f812 Merge pull request #27844 from DaanDeMeyer/repart-arch
repart: Add --architecture option
2023-05-31 23:00:19 +02:00
Lennart Poettering 38c86ce329 Merge pull request #27861 from poettering/find-esp-tweaks
minor tweaks to find-esp.c
2023-05-31 15:42:05 +02:00
Dan Streetman ba723ea260 tpm2: sort tpm2 symbol list
Only cosmetic, no functional change.
2023-05-31 09:23:22 -04:00
Dan Streetman b57a7b3d9b tpm2: remove all extern tpm2-tss symbols
These library syms should be restricted to use only in tpm2-util.c,
and all other code should use simpler functions exported in tpm2-util.h.

Also move the Esys_Freep() cleanup function into tpm-util.c, and make
tpm2-tss symbols static.
2023-05-31 09:23:22 -04:00
Daan De Meyer 05d1cbb33c Merge pull request #26969 from DaanDeMeyer/xopenat-label
fs-util: Add labelling support to xopenat()
2023-05-31 14:35:50 +02:00
Lennart Poettering cbf21d1432 Merge pull request #27860 from poettering/loopback-no-prefix-route
loopback-setup: only create a single loopback route when configuring 'lo'
2023-05-31 14:03:04 +02:00
Daan De Meyer 7767b83f4a gpt: Add gpt_partition_type_override_architecture()
Let's add a function that allows changing the architecture of a given
partition type.
2023-05-31 13:48:13 +02:00
Daan De Meyer 716a413a7d gpt: Use FOREACH_ARRAY 2023-05-31 13:32:23 +02:00
Daan De Meyer 420d2e3136 fs-util: Add XOpenFlags with XO_LABEL flag to have xopenat() MAC label files/dirs 2023-05-31 13:15:56 +02:00
Daan De Meyer a452c807a4 label: Introduce LabelOps to do pre/post labelling operations
By default, label_ops is initialized with a NULL pointer which translates
to noop labelling operations. In mac_selinux_init() and the new mac_smack_init(),
we initialize label_ops with a MAC specific LabelOps pointer.

We also introduce mac_init() to initialize any configured MACs and replace all
usages of mac_selinux_init() with mac_init().
2023-05-31 13:15:53 +02:00
Luca Boccassi 1a7e5c51dc Merge pull request #27853 from keszybz/various-bits-and-pieces-included-to-reuse-the-ci-run
Various bits and pieces included to reuse the ci run
2023-05-31 11:08:36 +01:00
Luca Boccassi 5aab673dd1 Merge pull request #27840 from mrc0mmand/gcc-13
ci: add gcc-13, drop gcc-12
2023-05-31 11:07:22 +01:00
Lennart Poettering 53d883d30d loopback-setup: clean up logging
All users of loopback_setup() ignore the return values (with the notable
exception of the test cases). Hence let's adjust the log messaging to
always log at LOG_WARNING level at most, and suffix messages with ",
ignoring", to make clear these failures are ignored.
2023-05-31 11:11:45 +02:00
Lennart Poettering 8557425aaf loopback-setup: set IFA_F_NOPREFIXROUTE when configuring 'lo' ipv6 address
Otherwise the kernel will set up two routes to ::1, one in the "main",
and one in the "local" routing table.

Fixes: #25819
2023-05-31 11:11:45 +02:00
Lennart Poettering 14e5c99236 find-esp: drop some redundant 'else' 2023-05-31 10:12:47 +02:00
Lennart Poettering 0b2aa2064f find-esp: change "unprivileged_mode" parameter to be tristate
Previously, unprivileged mode for find_esp_and_warn() and
find_xbootldr_and_warn() could be enabled or disabled. With this change
it can also be set to negative in which case the functions will enable
it automatically if found to be executing without privileges.

This just moves te geteuid() check we often do for the param inside of
the functions.

At the same time internally in the functions we also pass around the
VerifyESPFlags field across the various functions instead of booleans.

Both changes are just refactoring. No changes in behaviour.
2023-05-31 10:12:47 +02:00
Frantisek Sumsal 241ecd1cc2 core,shared: add a couple of asserts
To appease the LTO overlords:

In file included from ../../../../src/basic/macro.h:446,
                 from ../../../../src/shared/blockdev-util.h:8,
                 from ../../../../src/shared/creds-util.c:11:
../../../../src/shared/creds-util.c: In function 'get_credential_host_secret':
../../../../src/shared/creds-util.c:379:52: error: '%s' directive argument is null [-Werror=format-overflow=]
  379 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../src/basic/log.h:214:86: note: in definition of macro 'log_full_errno_zerook'
  214 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../../../../src/basic/log.h:250:41: note: in expansion of macro 'log_full_errno'
  250 | #define log_debug_errno(error, ...)     log_full_errno(LOG_DEBUG,   error, __VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~
../../../../src/shared/creds-util.c:379:33: note: in expansion of macro 'log_debug_errno'
  379 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                 ^~~~~~~~~~~~~~~
../../../../src/shared/creds-util.c:379:74: note: format string is defined here
  379 |                                 log_debug_errno(r, "Credential secret %s/%s appeared while we were creating it, rereading.",
      |                                                                          ^~
cc1: some warnings being treated as errors

../../../../src/core/transaction.c: In function 'transaction_verify_order_one':
../../../../src/core/transaction.c:338:38: error: '%s' directive argument is null [-Werror=format-overflow=]
  338 |                 sprintf(ans + size, "%s%s", unit_log_field, *unit_id);
      |                                      ^~
cc1: some warnings being treated as errors
2023-05-30 16:23:40 +02:00
Zbigniew Jędrzejewski-Szmek 6483bcef54 shared/loop-util: add comment
Requested in https://github.com/systemd/systemd/commit/afbe20b7d4ed4c3aebbd1b3de00b9b7385dd0ae8#r115653459.
2023-05-30 16:04:35 +02:00
Daan De Meyer 0690160e2c label: Rename to label-util.h 2023-05-30 14:50:56 +02:00
Daan De Meyer 5249e95385 gpt: Fix copy paste error 2023-05-30 13:54:59 +02:00
Zbigniew Jędrzejewski-Szmek afbe20b7d4 shared/loop-util: use longer delay when waiting for loop device
The kernel may be syncing a file system or doing something else that requires
more time. So make the delay a bit longer, but provide some feedback and also
grow the delay exponentially (though with a long exponent). If the kernel is
doing something else, no need to repeat so often. With 38 attempts, we get a
total of slightly above 5000 ms.

I wrote this when I thought that the the delay is not long enough. It turned
out that we were blocking the file system on the loop device, so waiting longer
wasn't helpful. But I think it's nicer to do it this way anyway.
2023-05-30 13:41:56 +02:00
Zbigniew Jędrzejewski-Szmek 1d96dae716 dissect: implement the same logic as gpt-auto-generator
gpt-auto-generator does three checks: 1. whether the directory doesn't have
files, 2. whether it's not in fstab, and 3. whether it is not a mount point.
For dissect logic, 3. is not relevant, and it ignores 2.
But the check whether files exists was done only partially: it was done
for /efi, but not for /boot.

Two changes are made:
- the check whether /boot is empty is now done.
- for ESP, /boot is used in preference to /efi, if not used for XBOOTLDR.

With those changes, the logic in dissect matches what gpt-auto-generator does.
There are the two intentional differences described in the first paragraph,
2023-05-30 00:21:44 +02:00
Luca Boccassi 8340d5003d gpt/DPS: add more aliases for python's machine
In mkosi we set the default architecture to platform.machine() which
is again slightly incompatible for a few architectures, so add more
aliases, so that repart works by default with these names.
2023-05-28 18:33:31 +01:00
Daan De Meyer 30868c1c8d tree-wide: Downgrade a few more noisy log messages to trace 2023-05-27 14:47:56 +02:00
Yu Watanabe 9e39cb2855 Merge pull request #27721 from yuwata/journalctl-cleanup
journalctl: split get_boots() into three
2023-05-27 07:59:22 +09:00
Daan De Meyer dcc5547b8b Merge pull request #27517 from ddstreet/tpm2_calculate_policy
Tpm2 calculate policy
2023-05-26 23:08:15 +02:00
Yu Watanabe c93d3c0512 logs-show: introduce add_match_boot_id() helper function 2023-05-27 03:57:01 +09:00
Mike Yuan 97d822abac Merge pull request #27787 from keszybz/firstboot-synchronous-restart
firstboot: make restart of vconsole-setup synchronuous
2023-05-27 02:30:45 +08:00
Yu Watanabe d4fd160f69 Merge pull request #27786 from YHNdnzj/format-timestamp-monotonic
time-util,format-table: add relative_monotonic variant for timestamp
2023-05-27 03:05:34 +09:00
Luca Boccassi 08a2bb7b82 gpt/DPS: alias amd64 to x86-64 and aarch64 to arm64
The DSP and our implementation mixes Debian terminology with CPU
terminology. It uses arm64 which is a Debian thing instead of
aarch64, but x86-64 which is a CPU thing instead of amd64.
Add some convenience and transparent aliasing, so that we don't
need to maintain architecture-specific and tool-specific translation
layers in mkosi among other places, while at the same time the DDIs
still look the same (ie: the partlabel does not change depending on
which alias is used, the canonical label is used on disk).
2023-05-26 18:33:35 +01:00
Dan Streetman d9a1f1a724 tpm2: add tpm2_calculate_sealing_policy()
This adds a function to fully calculate the authPolicy needed to seal a secret,
and updates tpm2_seal() to use the new function instead of a trial policy.
2023-05-26 11:12:22 -04:00
Dan Streetman 524cef3ff5 tpm2: use tpm2_policy_authorize()
This updates the function to build the sealing policy to use the dedicated
function to perform PolicyAuthorize.

This is separate from the previous commit to make each commit easier to read.
2023-05-26 11:12:22 -04:00
Dan Streetman 5c7852f78c tpm2: add tpm2_policy_authorize()
This adds functions to get the digest for a PolicyAuthorize operation. For
building a policy hash, this provides a function to calculate the hash; and for
building a policy hash to satisfy the authPolicy for an existing object, this
provides a function to perform PolicyAuthorize with an existing session.
2023-05-26 11:12:12 -04:00
Dan Streetman 8a716354bb tpm2: add tpm2_policy_auth_value()
This adds functions to get the digest for a PolicyAuthValue operation. For
building a policy hash, this provides a function to calculate the hash; and for
building a policy hash to satisfy the authPolicy for an existing object, this
provides a function to perform PolicyAuthValue with an existing session.
2023-05-26 11:11:50 -04:00
Dan Streetman dcbc4674e3 tpm2: add tpm2_policy_pcr()
This adds functions to get the digest for a PolicyPCR operation. For building
a policy hash, this provides a function to calculate the hash; and for building
a policy hash to satisfy the authPolicy for an existing object, this provides a
function to perform PolicyPCR with an existing session.
2023-05-26 11:11:25 -04:00
Dan Streetman c648a4b85e tpm2: rename pcr_values_size vars to n_pcr_values
Using the n_ prefix is more appropriate/conventional than the _size suffix.

No functional change, this is cosmetic only.
2023-05-26 11:06:53 -04:00
Dan Streetman dbae4b9535 tpm2: add tpm2_get_name()
This adds functions to get the "name" of a key. The key "name", as defined
by the TPM2 spec, includes its entire public area (with attribute fields),
not only its key fingerprint.

A function is added to calculate the name of a provided key public area,
as well as a function to get the name of a key which is present in the TPM.
2023-05-26 11:06:53 -04:00
Dan Streetman 409a65f829 tpm2: add tpm2_set_auth()
This provides a function to perform the SetAuth TPM function, which provides
the authValue for a key.
2023-05-26 11:06:53 -04:00
Dan Streetman 94a4ff2dc1 tpm2: replace hash_pin() with tpm2_digest_*() functions
The hash_pin() function is just a specific use case of the digest functions.
2023-05-26 11:06:53 -04:00
Dan Streetman da92d39a85 tpm2: add tpm2_digest_*() functions
These functions allow extending (or initializing) a TPM2B_DIGEST with additional
data, using a specified hash operation. This is needed to perform hash
calculations instead of relying on the TPM to perform the calculations in
trial sessions.
2023-05-26 11:06:20 -04:00
Daan De Meyer 61f695f40a mount-util: Downgrade another noisy debug log to trace level 2023-05-26 17:01:58 +02:00
Zbigniew Jędrzejewski-Szmek f3f8bd6a38 various: fix error message for bus_wait_for_jobs_new()
As pointed out by Mike Yuan in review of grandparent commit,
bus_wait_for_jobs_new() can also fail for non-oom reasons.
2023-05-26 15:09:03 +02:00
Mike Yuan d65c289fbf time-util,format-table: add relative_monotonic variant for timestamp 2023-05-26 13:29:54 +08:00