Commit Graph

562 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
52031044bf repart: use new style for pointers in function signatures 2024-07-22 11:48:26 +02:00
Adrian Vovk
c82dfaf7e2 table: Fix JSON name mangling breaking changes
In previous commits, we've changed the JSON name mangling logic. This,
of course, will cause breaking changes to occur on anything that relied
on the JSON mangling logic.

This commit fixes those breaking changes by manually forcing the JSON
name back to what it was before.
2024-07-17 14:15:44 -04:00
Zbigniew Jędrzejewski-Szmek
c80c5c20d4 Merge pull request #33599 from keszybz/link-executor-statically
Link executor statically
2024-07-08 12:46:41 +02:00
Zbigniew Jędrzejewski-Szmek
732ed8a84e meson: rename libbasic to libbasic_static
Our variables for internal libraries are named 'libfoo' for the shared lib
variant, and 'libfoo_static' for the static lib variant. The only exception was
libbasic, because we didn't have a shared variant for it. But let's rename it
for consitency. This makes the build config easier to understand.
2024-07-03 17:25:26 +02:00
Daan De Meyer
90a255779d repart: Allow overriding fstype per partition designator
$SYSTEMD_REPART_OVERRIDE_FSTYPE is too invasive. Often you want to
override the fstype only for a specific designator, so let's support
that as well.
2024-07-03 15:45:51 +02:00
Lennart Poettering
3a37a13a02 repart: add --list-devices switch for listing candidate block devices 2024-07-01 16:39:40 +02:00
Lennart Poettering
bff5d2fd5a blockdev-util: add partscan check function that takes an sd_device* 2024-07-01 16:35:56 +02:00
Lennart Poettering
68debef4c1 repart: add sections to --help text 2024-07-01 16:35:56 +02:00
Daan De Meyer
d34361149f repart: Don't set filesystem sector size to 512
We want to use 4K as the default sector size for filesystems so they
don't have to be regenerated to work on 512, 2048 or 4096 sector sizes.
2024-06-29 15:37:49 +02:00
Daan De Meyer
0e445aaa85 repart: Log more about filesystem sector size 2024-06-29 02:09:55 +02:00
Lennart Poettering
add090ea82 repart: show progress bar when initializing partition via CopyBlocks=
This might take a while, hence make it pretty.
2024-06-25 10:05:07 +02:00
Lennart Poettering
468d09c319 repart: allow reading from char device for CopyBlocks=
Sometimes it is useful to allow initializing a partition with randomized
data, hence allow reading from a char device as source for CopyBlocks=
2024-06-25 10:05:07 +02:00
Lennart Poettering
be5bee2a13 tree-wide: port over to new builder apis 2024-06-19 22:50:02 +02:00
Antonio Alvarez Feijoo
a81f5ffd40 repart: fix memory leak 2024-06-18 15:47:12 +01:00
Lennart Poettering
309a747fa6 libsystemd: turn json.[ch] into a public API
This is preparation for making our Varlink API a public API. Since our
Varlink API is built on top of our JSON API we need to make that public
first (it's a nice API, but JSON APIs there are already enough, this is
purely about the Varlink angle).

I made most of the json.h APIs public, and just placed them in
sd-json.h. Sometimes I wasn't so sure however, since the underlying data
structures would have to be made public too. If in doubt I didn#t risk
it, and moved the relevant API to src/libsystemd/sd-json/json-util.h
instead (without any sd_* symbol prefixes).

This is mostly a giant search/replace patch.
2024-06-12 18:42:22 +02:00
Daan De Meyer
726fc7ae69 repart: Use CRYPT_ACTIVATE_PRIVATE
Let's skip udev device scanning when activating a LUKS volume in
systemd-repart as we don't depend on any udev symlinks and don't
expect anything except repart to access the volume.

Suggested by https://github.com/systemd/systemd/issues/33129#issuecomment-2143390941.
2024-06-12 14:05:23 +01:00
Daan De Meyer
b99b294127 repart: Use crypt_reencrypt_run() if available
crypt_reencrypt() is deprecated, so let's look for and prefer
crypt_reencrypt_run() if it is available.
2024-06-12 18:53:37 +09:00
Daan De Meyer
1d877271c4 repart: Fix unused variable warning 2024-06-03 15:18:01 +09:00
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