Commit Graph
544 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 1cd53a1f91 repart: remove duplicate word in --help
My bad; follow-up for 4955d2e367.
2024-05-16 20:01:08 +02:00
Daan De Meyer 0b6891abf5 repart: Improve error message 2024-05-16 12:34:28 +02:00
Yu Watanabe c876cbdd19 time-util: define TIMESPEC_OMIT
Follow-up for 34c3d57474.
2024-05-10 10:11:06 +09:00
Zbigniew Jędrzejewski-Szmek 4955d2e367 repart,measure: reword help descriptions
This is a follow-up/extension for ec361ea9ce.
2024-05-08 15:13:14 +02:00
Mike Yuan 8aed85875d repart: correct timespec_store usage too 2024-05-08 00:19:38 +08:00
Moritz Sanft 34c3d57474 repart: respect SOURCE_DATE_EPOCH on mkdir_p_root
This let's systemd-repart respect the `SOURCE_DATE_EPOCH` environment
variable when creating directories in the local tree through `CopyFiles`
or `MakeDirectories`.

To do this, we pass a timestamp `ts` to `mkdir_p_root`, which it will
use to fix up `mtime` and `atime` of the directory it creates as
well as the `mtime` of the directory it creates the other directory *in*,
as the `mtime` of the latter is modified when creating a directory in it.

For the same reason, it also needs to fixup the `mtime` of the upper
directory when copying a file into it through `CopyFiles`.

If `SOURCE_DATE_EPOCH`, times are left as is. (`UTIME_OMIT`)
2024-05-07 09:29:58 +02:00
Yu Watanabe 4e494e6aac tree-wise: several cleanups for logging
- drop unnecessary SYNTHETIC_ERRNO() when the logger does not propagate
  error code,
- drop unnecessary '%m' in error message when the error code is
  specified with SYNTHETIC_ERRNO(),
- add missing full stop at the end of log message,
- use RET_GATHER(),
- add missing ", ignoring.",
- upeercase the first letter, etc., etc...
2024-05-01 04:41:06 +09:00
Luca Boccassi ec361ea9ce Fix spelling errors found by Lintian 2024-04-27 10:58:35 +02:00
Daan De Meyer aa976d8788 tree-wide: Use log_setup() everywhere
Otherwise the default log target is the console and we won't use
the journal socket even if it is available.
2024-04-25 17:06:43 +02:00
Lennart Poettering 21a3bc6b9f tpm2-util: add generic wrapper tpm2_context_new_or_warn() that wrpas tpm2_context_new and logs about errors
We so far just print a short log message that is not very useful, let's
add some recognizable error codes, and output better log messages if we
can't get TPM stuff to work.

Fixes: #31925
2024-04-22 12:40:09 +02:00
Luca Boccassi 8707c9b244 gcrypt: dlopenify for libsystemd
gcrypt is used only for journal sealing operations in libsystemd, so it
can be made into a dlopen dependency that is used only on demand. This
allows to reduce the footprint of libsystemd in the most common cases.

Keep systemd-pull and systemd-resolved with normal linking, as they are
executables, and usually built with OpenSSL support anyway.
2024-04-03 11:50:25 +01:00
Daan De Meyer 3799fa803e repart: Add DefaultSubvolume= setting
We already have Subvolumes= to create subvolumes, let's add
DefaultSubvolume= as well to set the default subvolume.
2024-03-30 00:08:12 +00:00
Zbigniew Jędrzejewski-Szmek a954b427e9 src/partition: remove unnecessary uses of "make sure" 2024-03-14 11:15:55 +01:00
Zbigniew Jędrzejewski-Szmek ec596fe34e Merge pull request #30480 from keszybz/kernel-install-more-paths
Read kernel-install config from /run/kernel too
2024-03-08 08:25:07 +01:00
Zbigniew Jędrzejewski-Szmek 76d75d8b7b constants: drop duplicated CONF_PATHS defines
Follow-up for b0d3095fd6.
2024-03-07 18:47:50 +01:00
Mike Yuan 4f49512695 extract-word: modernize extract_many_words 2024-03-03 19:01:00 +08:00
Luca Boccassi a73144bbdf repart: add --private-key-source and drop --private-key-uri
It turns out it's mostly PKCS11 that supports the URI format,
and other engines just take files. For example the tpm2-tss-openssl
engine just takes a sealed private key file path as the key input,
and the engine needs to be specified separately.

Add --private-key-source=file|engine:foo|provider:bar to
manually specify how to use the private key parameter.

Follow-up for 0a8264080a
2024-03-01 17:32:19 +00:00
Lennart Poettering f4a63ce25f dissect-image: add flag for explicitly enabling userspace verity signature checking
let's make userspace verity signature checking optional. This adds a
dissection flag to enable the logic and patches through all our users to
enable it by default, thus effectively not changing anything from the
status quo ante. However, know we have a knob to turn this off in
certain scenarios.
2024-02-28 16:17:40 +01:00
Yu Watanabe 1651c914df repart: fix typo
Follow-up for 1a0541d44c.
2024-02-12 02:52:37 +09:00
Daan De Meyer 1a0541d44c repart: Add --generate-fstab= and --generate-crypttab= options
These can be used along with two new settings MountPoint= and
EncryptedVolume= to write fstab and crypttab entries to the given
paths respectively in the root directory that repart is operating on.

This is useful to cover scenarios that aren't covered by the
Discoverable Partitions Spec. For example when one wants to mount
/home as a separate btrfs subvolume. Because multiple btrfs subvolumes
can be mounted from the same partition, we allow specifying MountPoint=
multiple times to add multiple entries for the same partition.
2024-02-10 13:07:02 +01:00
Luca Boccassi 0a8264080a repart: support OpenSSL engines/providers for signing
The provider API which is new requires providers, which are not
widely available and don't work very well yet, so also use a
fallback with the legacy engine API.
2024-02-09 15:11:25 +00:00
Mike Yuan b409aacb0a mountpoint-util: introduce path_is_mount_point_full 2024-02-06 15:09:28 +08:00
Yu Watanabe e53fcb0932 repart: fix typo
Follow-up for a575f2148f.
2024-02-02 09:14:50 +09:00
Luca Boccassi f70daee8f2 Merge pull request #30130 from poettering/pcrlock-root
pcrlock: add support for unlocking a root fs with a pcrlock file
2024-01-23 21:41:02 +00:00
Lennart Poettering a575f2148f repart: don't try to determine sector size from a disk image we should consider empty
If we are told to start from scratch we shouldn't look into the old
image to determine sector size. Looking there is confusing at best, but
plain wrong in many other cases.
2024-01-23 19:58:08 +00:00
Lennart Poettering d37c312b87 pcrlock: when unlocking try to pick up pcrlock policy from system credentials 2024-01-22 15:20:22 +01:00
Antonio Alvarez Feijoo ecb4c5a63e repart: fix memory leak
With the `--image` option, if `arg_node` is NULL, it's being assigned via
`strdup`.
2024-01-10 19:07:21 +00:00
Frantisek Sumsal f569dc6af2 repart: don't crash when looping over dropped partitions
Properly skip over dropped partitions and make sure they don't affect
the final graphical output (for example by leaving empty "spaces" where
their definition file name would otherwise be).

Resolves: #30742
2024-01-07 05:26:38 +09:00
Lennart Poettering 8d042bc40a tpm2-util: more iovec'ification
Let's move more code to using struct iovec for passing around binary
chunks of data.

No real changes in behaviour, just refactoring.
2024-01-05 11:34:46 +01:00
Frantisek Sumsal c490b6ddc2 tree-wide: use IOVEC_MAKE() in a couple more places 2023-12-25 18:26:59 +01:00
Lennart Poettering 01db9c85cf blockdev-util: add new helper blockdev_get_device_size()
This function is just a wrapper around the BLKGETSIZE64. Which is a
pretty simple ioctl. The only reason to wrap it, is that the headers we
need to call it are a bit messy (as "linux/fs.h" is incompatible with
certain glibc headers). Hence add the simple helper that wraps it and
allows us to do the header mess needed in one file only.

It's also nicely symmetric to blockdev_get_sector_size().
2023-12-13 17:35:22 +01:00
Daan De Meyer 4ae703b2b5 repart: Don't look for --make-ddi= definitions inside --root=
It doesn't really make sense to go looking for these inside the
given root directory. While we should resolve specifiers and such
based on the given root directory, let's look up the image definitions
on the host system as there's a good chance they're coupled to the
repart version we're using so there's all kinds of chances for problems
if we use the definitions from the image we're building instead of those
from the host.
2023-12-08 09:33:24 +01:00
Daan De Meyer 0122c7d060 repart: Re-open file descriptor to partition target after mkfs
The mkfs binary might unlink the path we give it and replace it with
a new file so let's make sure that our fd points to any new file rather
than the old deleted file.

Specifically this fixes erofs partition generation.
2023-12-08 10:59:36 +09:00
Daan De Meyer 3ed6f7a57e Merge pull request #30340 from yuwata/repart-error-handling-ftruncate
repart: fix coding style of error handling
2023-12-06 22:02:01 +01:00
Daan De Meyer ebd6606515 repart: Add Minimize=best to --make-ddi= partition definitions
Otherwise, repart won't calculate the minimal size of the partition
automatically and things will fail once the partitions exceed the
minimal partition size (10M).
2023-12-06 11:54:48 +01:00
Mike Yuan 9f08d7f777 repart: use correct errno 2023-12-06 10:03:21 +01:00
Yu Watanabe 6c7f4badea repart: fix coding style of error handling
Follow-up for c4a87b76c3.
2023-12-06 11:35:10 +09:00
Daan De Meyer 0689d46a75 repart: Fix sysext definitions for --make-ddi=
CopyFiles= does not support multiple directories separated by
whitespace. Instead the setting has to be specified multiple times.
2023-12-05 19:26:58 +00:00
Krzesimir Nowak 59c8afbc89 repart: Fix compilation warning when tpm2 is disabled
The warning is about unused variable "flags":

```
../src/partition/repart.c: In function ‘partition_encrypt’:
../src/partition/repart.c:3690:19: warning: unused variable ‘flags’ [-Wunused-variable]
 3690 |         TPM2Flags flags = 0;
      |                   ^~~~~
```

Move the flags variable into the scope where it is actually used, which happens
to be inside the HAVE_TPM2 block.
2023-11-15 19:55:50 +00:00
Frantisek Sumsal 968d232db5 tree-wide: unify OpenSSL spelling in log messages
Seeing three different spellings of OpenSSL in one log file triggers
some inner OCD I didn't even know I have.
2023-11-13 20:47:17 +01:00
Lennart Poettering dc7e34b369 repart: downgrade pcrlock pickup log message
This is not relevant in most cases, hence don't mention this all the
time.
2023-11-10 22:53:49 +01:00
Lennart Poettering acdf6bcfdb repart: say on which device we apply things
So far we never mention the device in our output. Let's fix that.
2023-11-10 22:53:49 +01:00
Lennart Poettering a053f801f8 repart: when we copy in blocks, indicate we are doing from an offset
At first I thought when using --copy-from= that it was copying in my
whole disk into a partition instead of just a partition into a
partition.

Let's make the log message clearer and say that we copy starting from an
offset.
2023-11-10 22:53:49 +01:00
Lennart Poettering b7786df093 repart: mention how long it took to copy in data blocks
This is quite interesting information, show it.
2023-11-10 22:53:49 +01:00
Luca Boccassi be0916f77c Merge pull request #29955 from poettering/repart-seal-key
repart: add --tpm2-seal-key= support, matching the recently added support cryptenroll has
2023-11-10 16:52:00 +00:00
Luca Boccassi 2dbfb4f9f2 Merge pull request #29954 from DaanDeMeyer/fix
repart: Fix size round up/round down
2023-11-09 16:30:37 +00:00
Lennart Poettering fadc7d8cd7 repart: add missing --tpm2-pcrlock= in --help text
Follow-up for: 404aea7815
2023-11-09 11:36:13 +00:00
Lennart Poettering 78fdf0f68b repart: add --tpm2-device-key= to repart, too
This adds what was added to systemd-cryptenroll recently to
systemd-repart too.

Follow-up for: c3a2a681be
2023-11-09 12:27:43 +01:00
Daan De Meyer 6563aede88 repart: Fix size round up/round down
Currently, we round minimum sizes up and maximum size down, whereas
it should be the opposite as the current approach means that if the
same size is used for min and max, the min size will end up bigger
than the max size after rounding.
2023-11-09 12:10:53 +01:00
Lennart Poettering 404aea7815 tree-wide: hook everything up with pcrlock policy
Make sure cryptenroll and repart can enroll TPM2 policies with pcrlock
logic.

Make sure cryptsetup can unlock TPM2 policies with pcrlock in effect.
2023-11-03 11:24:24 +01:00