summaryrefslogtreecommitdiff
path: root/src/shared/dissect-image.c
Commit message (Collapse)AuthorAgeFilesLines
* dissect: add a bit of debug logging if dm-crypt fails on usLennart Poettering2017-08-291-2/+6
|
* dissect: when dissecting block devices, ignore weird MMC RPMB partitions (#6165)Lennart Poettering2017-06-221-1/+7
| | | | | | For now, let's just special-case this in the sources. If more partition types like this show up we should probably find some other solution. Fixes: #5806
* libshared: fix compilation without libblkidZbigniew Jędrzejewski-Szmek2017-04-211-3/+5
| | | | | | | This reverts a75e27eb. a75e27eb fixed the case of libcryptsetup=no, libblkid=yes, but broke the case of libcryptsetup=no, libblkid=yes. Instead of trying to define the function only when used, which would result in too much ifdeffery, just silence the warning.
* shared/dissect-image: fix warning about unused function when !HAVE_BLKIDZbigniew Jędrzejewski-Szmek2017-04-041-4/+2
|
* Avoid strict DM interface version dependencies (#5519)Michael Biebl2017-03-021-1/+1
| | | | | | | | | | | | | | | Compiling against the dm-ioctl.h header as provided by the Linux kernel will embed the DM interface version number. Running an older kernel can result in an error like this on shutdown: Could not detach DM dm-11: ioctl mismatch, kernel(4.34.4), user(4.35.4) Work around this by shipping a local copy of dm-ioctl.h. We need at least the version from 3.13 for DM_DEFERRED_REMOVE [1], so bump the requirements in README accordingly. [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2c140a246dc0bc085b98eddde978060fcec1080c Fixes: #5492
* tree-wide: simplify handling of blkid errorsZbigniew Jędrzejewski-Szmek2017-02-211-24/+8
|
* Merge pull request #4962 from poettering/root-directory-2Zbigniew Jędrzejewski-Szmek2017-02-081-15/+83
|\ | | | | Add new MountAPIVFS= boolean unit file setting + RootImage=
| * dissect: try to read roothash value off user.verity.roothash xattr of image fileLennart Poettering2017-02-071-14/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This slightly extends the roothash loading logic to first check for a user.verity.roothash extended attribute on the image file. If it exists, it is used as Verity root hash and the ".roothash" file is not used. This should improve the chance that the roothash is retained when the file is moved around, as the data snippet is attached directly to the image file. The field is still detached from the file payload however, in order to make sure it may be trusted independently. This does not replace the ".roothash" file loading, it simply adds a second way to retrieve the data. Extended attributes are often a poor choice for storing metadata like this as it is usually difficult to discover for admins and users, and hard to fix if it ever gets out of sync. However, in this case I think it's safe as verity implies read-only access, and thus there's little chance of it to get out of sync.
| * core,nspawn,dissect: make nspawn's .roothash file search reusableLennart Poettering2017-02-071-0/+51
| | | | | | | | | | | | | | This makes nspawn's logic of automatically discovering the root hash of an image file generic, and then reuses it in systemd-dissect and in PID1's RootImage= logic, so that verity is automatically set up whenever we can.
| * dissect: make sure to manually follow symlinks when mounting dissected imageLennart Poettering2017-02-071-15/+24
| | | | | | | | | | | | If the dissected image contains symlinks for the mount points we need we need to make sure to follow this with chase_symlinks() so that we don't leave the image.
* | dissect: don't honour NOAUTO flags when looking for ESP (#5224)Lennart Poettering2017-02-071-3/+36
|/ | | | | | | | | | The flag is originally defined for "basic data partitions", but not for the ESP. We reuse it for the various partitions defined by the Discoverable Partitions Spec, but it isn't defined for the ESP, hence don't check for it. Instead, do check for GPT_FLAG_NO_BLOCK_IO_PROTOCOL, as that flag actually is defined for all partition types, and recommended to use by the UEFI spec. Fixes: #5218
* dissect: make using a generic partition as root partition optionalLennart Poettering2016-12-211-8/+17
| | | | | | | | | | In preparation for reusing the image dissector in the GPT auto-discovery logic, only optionally fail the dissection when we can't identify a root partition. In the GPT auto-discovery we are completely fine with any kind of root, given that we run when it is already mounted and all we do is find some additional auxiliary partitions on the same disk.
* dissect: return the GPT partition UUID, tooLennart Poettering2016-12-211-0/+4
| | | | | This is useful as we can match up the EFI UUID with the one the firmware supposedly used.
* dissect: optionally, only look for GPT partition tables, nothing elseLennart Poettering2016-12-201-41/+48
| | | | | This is useful for reusing the dissector logic in the gpt-auto-discovery logic: there we really don't want to use MBR or naked file systems as root device.
* dissect: assume GPT_ROOT_SECONDARY_VERITY is defined when GPT_ROOT_SECONDARY isZbigniew Jędrzejewski-Szmek2016-12-101-8/+2
| | | | | We define those macros, and there's no reason to have one without the other.
* nspawn/dissect: automatically discover dm-verity verity partitionsLennart Poettering2016-12-071-26/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for discovering and making use of properly tagged dm-verity data integrity partitions. This extends both systemd-nspawn and systemd-dissect with a new --root-hash= switch that takes the root hash to use for the root partition, and is otherwise fully automatic. Verity partitions are discovered automatically by GPT table type UUIDs, as listed in https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/ (which I updated prior to this change, to include new UUIDs for this purpose. mkosi with https://github.com/systemd/mkosi/pull/39 applied may generate images that carry the necessary integrity data. With that PR and this commit, the following simply lines suffice to boot up an integrity-protected container image: ``` # mkdir test # cd test # mkosi --verity # systemd-nspawn -i ./image.raw -bn ``` Note that mkosi writes the image file to "image.raw" next to a a file "image.roothash" that contains the root hash. systemd-nspawn will look for that file and use it if it exists, in case --root-hash= is not specified explicitly.
* dissect: add support for encrypted imagesLennart Poettering2016-12-071-60/+397
| | | | | | | | | | | | | | | This adds support to the image dissector to deal with encrypted images (only LUKS). Given that we now have a neatly isolated image dissector codebase, let's add a new feature to it: support for automatically dealing with encrypted images. This is then exposed in systemd-dissect and nspawn. It's pretty basic: only support for passphrase-based encryption. In order to ensure that "systemd-dissect --mount" results in mount points whose backing LUKS DM devices are cleaned up automatically we use the DM_DEV_REMOVE ioctl() directly on the device (in DM_DEFERRED_REMOVE mode). libgcryptsetup at the moment doesn't provide a proper API for this. Thankfully, the ioctl() API is pretty easy to use.
* util-lib: split out image dissecting code and loopback code from nspawnLennart Poettering2016-12-071-0/+548
This adds two new APIs to systemd: - loop-util.h is a simple internal API for allocating, setting up and releasing loopback block devices. - dissect-image.h is an internal API for taking apart disk images and figuring out what the purpose of each partition is. Both APIs are basically refactored versions of similar code in nspawn. This rework should permit us to reuse this in other places than just nspawn in the future. Specifically: to implement RootImage= in the service image, similar to RootDirectory=, but operating on a disk image; to unify the gpt-auto-discovery generator code with the discovery logic in nspawn; to add new API to machined for determining the OS version of a disk image (i.e. not just running containers). This PR does not make any such changes however, it just provides the new reworked API. The reworked code is also slightly more powerful than the nspawn original one. When pointing it to an image or block device with a naked file system (i.e. no partition table) it will simply make it the root device.