summaryrefslogtreecommitdiffstats
path: root/src/partition (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Rename src/partition to src/repartZbigniew Jędrzejewski-Szmek2024-11-1111-9408/+0
|
* Move growfs+makefs to src/growfs/Zbigniew Jędrzejewski-Szmek2024-11-103-373/+0
| | | | | Those two programs are used together and it makes sense to keep them together. makefs is smaller, so name the directory after growfs.
* tree-wide: Introduce --certificate-source= optionDaan De Meyer2024-11-071-6/+35
| | | | | | | This allows loading the X.509 certificate from an OpenSSL provider instead of a file system path. This allows loading certficates directly from hardware tokens instead of having to export them to a file on disk first.
* openssl-util: Query engine/provider pin via ask-passwordDaan De Meyer2024-11-031-110/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In mkosi, we want to support signing via a hardware token. We already support this in systemd-repart and systemd-measure. However, if the hardware token is protected by a pin, the pin is asked as many as 20 times when building an image as the pin is not cached and thus requested again for every operation. Let's introduce a custom openssl ui when we use engines and providers and plug systemd-ask-password into the process. With systemd-ask-password, the pin can be cached in the kernel keyring, allowing us to reuse it without querying the user again every time to enter the pin. We use the private key URI as the keyring identifier so that the cached pin can be shared across multiple tools. Note that if the private key is pin protected, openssl will prompt both when loading the private key using the pkcs11 engine and when actually signing the roothash. To make sure our custom UI is used when signing the roothash, we have to also configure it with ENGINE_ctrl() which takes a non-owning pointer to the UI_METHOD object and its userdata object which we have to keep alive so we introduce a new AskPasswordUserInterface struct which we use to keep both objects alive together with the EVP_PKEY object. Because the AskPasswordRequest struct stores non-owning pointers to its fields, we change repart to store the private key URI as a global variable again instead of the EVP_PKEY object so that we can use the private key argument as the keyring field of the AskPasswordRequest instance without running into lifetime issues.
* efivars: Remove STRINGIFY() helper macrosDaan De Meyer2024-11-021-2/+2
| | | | | | | | The names of these conflict with macros from efi.h that we'll move to efi-fundamental.h in a later commit. Let's avoid the conflict by getting rid of these helpers. Arguably this also improves readability by clearly indicating we're passing arbitrary strings and not constants to the macros when we invoke them.
* pretty-print: add format-string version of draw_progress_bar()Lennart Poettering2024-10-291-11/+9
| | | | | We often format the prefix string via asprintf() before, let's hence add a helper for that.
* sd-json,tree-wide: add sd_json_format_enabled() and use it everwhereZbigniew Jędrzejewski-Szmek2024-10-281-7/+7
| | | | | | | | | | | | | | | | | | | We often used a pattern like if (!FLAGS_SET(flags, SD_JSON_FORMAT_OFF)), which is rather verbose and also contains a double negative, which we try to avoid. Add a little helper to avoid an explicit bit check. This change clarifies an aditional thing: in some cases we treated SD_JSON_FORMAT_OFF as a flag (flags & SD_JSON_FORMAT_OFF), while in other cases we treated it as an independent enum value (flags == SD_JSON_FORMAT_OFF). In the first form, flags like SD_JSON_FORMAT_SSE do _not_ turn the json output on, while in the second form they do. Let's use the first form everywhere. No functional change intended. Initially I wasn't sure if this helper should be made public or just internal, but it seems such a common pattern that if we expose the flags, we might just as well expose it too, to make life easier for any consumers.
* repart: fix typoYu Watanabe2024-10-091-1/+1
| | | | Follow-up for d3032e651e2131c47d276e3fbdcbdf9fc51c8ef9.
* repart: derive hash partition size from SizeMaxBytes= of data siblingWilliButz2024-10-091-5/+106
| | | | | | | | | | This change makes it possible for repart to create dm-verity hash partitions for a custom amount of protected data. When the property `SizeMaxBytes=` is specified for a dm-verity data partition, the size of the corresponding hash partition is set to accommodate hash data for this maximum size, rather than the actual contents its data sibling. However, the contained hash data continues to be generated from said sibling.
* tree-wide: drop doubled empty linesYu Watanabe2024-10-071-1/+0
|
* repart: Don't copy root directory mode from source fileDaan De Meyer2024-10-041-0/+2
| | | | | If the source is a file, don't copy the mode and such from it to the root directory, even if the target is /.
* repart: Handle empty arg_copy_source in file_is_denylisted()Daan De Meyer2024-10-041-2/+2
|
* repart: open target devices before UUID creationMichael Ferrari2024-10-031-5/+5
| | | | | | | This is to ensure that the UUIDs from the CopyBlocks= devices are copied to the corresponding new partition instead of creating a new UUID for it. With this verity partitions can be copied, keeping their UUIDs to ensure that they still match up with what is specified in roothash=.
* repart: Apply denylist to individual files as wellDaan De Meyer2024-09-301-0/+47
|
* repart: Shortcut copy if source or target starts with exclude pathDaan De Meyer2024-09-301-0/+8
| | | | | | If the source or target we're copying to is a subdirectory of any of the directories specified in ExcludeFiles= or ExcludeFilesTarget=, shortcut the entire copy operation.
* repart: Determine verity sig size based on partition designatorDaan De Meyer2024-09-241-1/+1
| | | | | | Verity= is an image build concept, not a first boot concept, whereas a partition designator is always available, so let's do the size stuff based on that.
* repart: Use swap format for swap partition even if encryptedDaan De Meyer2024-09-231-3/+3
|
* repart: Add a log message when we're about to fsync().Daan De Meyer2024-09-231-0/+2
|
* tree-wide: use strv_extend_strv_consume() where appropriateMike Yuan2024-09-211-2/+2
|
* repart: Drop unprivileged subvolumes logic for btrfsDaan De Meyer2024-09-181-58/+9
| | | | | | The functionality was explicitly not included in 6.11 for some unknown reason so drop the logic from systemd-repart as well so we don't release v257 with it included.
* repart: Support specifying multiple directories to ExcludeFiles=Daan De Meyer2024-09-181-12/+27
|
* repart: Add SupplementFor= logicAdrian Vovk2024-09-171-54/+369
| | | | | | | This was designed to deal with $BOOT, as defined by the Boot Loader Specification, but it was made a generic mechanism because it is useful elsewhere too. See the updated man page for usage examples, motivation, and an explanation of how this works.
* repart: Consider existing partitions when placingAdrian Vovk2024-09-171-2/+10
| | | | | | | | | | | Fixes an oversight in `context_allocate_partitions` that makes it succeed in cases where it should fail. Essentially, there was nothing actually enforcing SizeMinBytes= and PaddingMinBytes= for partitions that exist, only for new partitions. This behavior is inconsistent with the docs, which state that existing partitions will be grown to at least the specified minimum size, and that "If the backing device does not provide enough space to fulfill the constraints placing the partition will fail".
* repart: Fix log messages in partition_populate_directory()Daan De Meyer2024-09-151-2/+2
| | | | | We're not actually populating a filesystem here, we're preparing to populate a filesystem, so update the log messages accordingly.
* repart: Add MakeSymlinks=Daan De Meyer2024-09-111-5/+95
| | | | Similar to MakeDirectories=, but creates symlinks in the filesystem.
* repart: Add missing parameter commentDaan De Meyer2024-09-111-1/+1
|
* repart: Fix memory corruptionDaan De Meyer2024-09-111-2/+3
|
* repart: Reuse partition_needs_populate() moreDaan De Meyer2024-09-111-14/+12
|
* repart: Initialize split_name_format in copy_from_one()Daan De Meyer2024-09-091-0/+4
| | | | | Let's allow splitting the partitions from an existing disk image by initializing split_name_format when using --copy-from=.
* cryptenroll/cryptsetup: allow combined signed TPM2 PCR policy + pcrlock policyLennart Poettering2024-09-061-13/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far you had to pick: 1. Use a signed PCR TPM2 policy to lock your disk to (i.e. UKI vendor blesses your setup via signature) or 2. Use a pcrlock policy (i.e. local system blesses your setup via dynamic local policy stored in NV index) It was not possible combine these two, because TPM2 access policies do not allow the combination of PolicyAuthorize (used to implement #1 above) and PolicyAuthorizeNV (used to implement #2) in a single policy, unless one is "further upstream" (and can simply remove the other from the policy freely). This is quite limiting of course, since we actually do want to enforce on each TPM object that both the OS vendor policy and the local policy must be fulfilled, without the chance for the vendor or the local system to disable the other. This patch addresses this: instead of trying to find a way to come up with some adventurous scheme to combine both policy into one TPM2 policy, we simply shard the symmetric LUKS decryption key: one half we protect via the signed PCR policy, and the other we protect via the pcrlock policy. Only if both halves can be acquired the disk can be decrypted. This means: 1. we simply double the unlock key in length in case both policies shall be used. 2. We store two resulting TPM policy hashes in the LUKS token JSON, one for each policy 3. We store two sealed TPM policy key blobs in the LUKS token JSON, for both halves of the LUKS unlock key. This patch keeps the "sharding" logic relatively generic (i.e. the low level logic is actually fine with more than 2 shards), because I figure sooner or later we might have to encode more shards, for example if we add further TPM2-based access policies, for example when combining FIDO2 with TPM2, or implementing TOTP for this.
* repart: initialize seed earlierYu Watanabe2024-09-051-4/+4
| | | | | | As the seed is used by context_load_partition_table() -> derive_uuid(). Fixes #34257.
* repart: Add compression supportDaan De Meyer2024-09-032-33/+48
| | | | | | | | | | | | | | | | | | | | | Now that mkfs.btrfs is adding support for compressing the generated filesystem (https://github.com/kdave/btrfs-progs/pull/882), let's add general support for specifying the compression algorithm and compression level to use. We opt to not parse the specified compression algorithm and instead pass it on as is to the mkfs tool. This has a few benefits: - We support every compression algorithm supported by every tool automatically. - Users don't need to modify systemd-repart if a mkfs tool learns a new compression algorithm in the future - We don't need to maintain a bunch of tables for filesystem to map from our generic compression algorithm enum to the filesystem specific names. We don't add support for btrfs just yet until the corresponding PR in btrfs-progs is merged.
* Merge pull request #34149 from DaanDeMeyer/btrfsDaan De Meyer2024-09-031-23/+236
|\ | | | | repart: Switch to new mkfs.btrfs subvolume API
| * repart: Switch to new mkfs.btrfs subvolume APIDaan De Meyer2024-08-301-20/+233
| | | | | | | | | | | | | | | | | | In https://github.com/kdave/btrfs-progs/pull/877 the API is changing to "--subvol <path>:ro,default" so let's adapt our usage to match. This also adds support for read-only subvolumes. Fixes #34134
| * repart: Remove unused Context argument from make_subvolumes_set()Daan De Meyer2024-08-301-3/+1
| |
| * repart: Fix memory leakDaan De Meyer2024-08-301-0/+2
| |
* | tree-wide: drop msg argument for DEFINE_CONFIG_PARSE() macro and friendsYu Watanabe2024-09-011-3/+3
| | | | | | | | | | This makes the macros use log_syntax_parse_error(), hopefully which provides more informative log message in general, and reduces binary size.
* | progress-bar: Put a space after the prefixAdrian Vovk2024-08-311-1/+1
| | | | | | | | | | We always want a space there. So let's just put one in the drawing routine, and adjust the call cites to avoid adding a second one.
* | repart: Keep existing directory timestamps intact when copyingDaan De Meyer2024-08-301-2/+2
|/ | | | | | | | Otherwise, when merging multiple directory trees, the output becomes unreproducible as the directory timestamps will be changed to the current time when copying identical directories from the second tree. We introduce a new copy flag to achieve this behavior.
* repart: Use streq_ptr() in one more placeDaan De Meyer2024-08-261-1/+1
|
* Merge pull request #33498 from DaanDeMeyer/btrfsDaan De Meyer2024-08-211-19/+44
|\ | | | | repart: Allow Subvolumes= when running offline
| * repart: Allow Subvolumes= and DefaultSubvolume= when running offlineDaan De Meyer2024-08-211-17/+39
| | | | | | | | | | | | | | mkfs.btrfs has recently learned new options --subvol and --default-subvol so let's stop failing when Subvolumes= and DefaultSubvolume= are used offline and use the new --subvol and --default-subvol options instead to create subvolumes in the generated root filesystem without root privileges or loop devices.
| * repart: Don't add same dir to MakeDirectories= or Subvolumes= twiceDaan De Meyer2024-08-211-0/+3
| |
| * repart: Constify partition_needs_populate()Daan De Meyer2024-08-211-1/+1
| |
| * repart: Use loop_device_error_is_fatal() in one more placeDaan De Meyer2024-08-211-1/+1
| |
* | tree-wide: use isatty_safe() moreLennart Poettering2024-08-201-1/+1
|/
* repart: Create disk image file with copy-on-write disabled on btrfsDaan De Meyer2024-07-241-1/+1
| | | | | | COW on btrfs generally does not play well lots of random writes so let's make the disk images generated by repart NOCOW by default on btrfs like we do elsewhere across the codebase.
* repart: Make partition files NOCOW if the disk image is NOCOWDaan De Meyer2024-07-241-18/+53
| | | | | | On btrfs, reflinks into a disk image that has copy-on-write disabled only work if the source has copy-on-write disabled as well so let's make sure that's the case if the disk image has copy-on-write disabled.
* repart: use new style for pointers in function signaturesZbigniew Jędrzejewski-Szmek2024-07-221-3/+3
|
* table: Fix JSON name mangling breaking changesAdrian Vovk2024-07-171-0/+4
| | | | | | | | | 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.