summaryrefslogtreecommitdiff
path: root/src/portable
Commit message (Collapse)AuthorAgeFilesLines
* machine,portable: fix a typo in an info messageFrantisek Sumsal2023-05-131-1/+1
|
* Merge pull request #25608 from poettering/dissect-moarLennart Poettering2023-04-123-6/+34
|\ | | | | dissect: add dissection policies
| * tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-053-6/+34
| |
* | tree-wide: drop unneeded output paramsDavid Tardon2023-04-121-5/+1
| | | | | | | | | | | | Neither of the callers of bus_deserialize_and_dump_unit_file_changes() touches the changes array, so let's simplify things and keep it internal to the function.
* | Merge pull request #27033 from dtardon/array-cleanupYu Watanabe2023-04-123-33/+24
|\ \ | | | | | | Use CLEANUP_ARRAY more
| * | portabled-image-bus: use CLEANUP_ARRAYDavid Tardon2023-04-111-14/+10
| | |
| * | portabled-image-bus: use CLEANUP_ARRAYDavid Tardon2023-04-111-6/+4
| | |
| * | portabled-image-bus: use CLEANUP_ARRAYDavid Tardon2023-04-111-6/+4
| | |
| * | portabled-bus: use CLEANUP_ARRAYDavid Tardon2023-04-111-6/+4
| | |
| * | portablectl: use CLEANUP_ARRAYDavid Tardon2023-04-111-1/+2
| | |
* | | portable: always reopen fd of release fileYu Watanabe2023-04-111-3/+3
| | | | | | | | | | | | To make it support the case that the fd is O_PATH.
* | | extension-release: establish compatibility between host file and ↵maanyagoenka2023-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | extension-release file The release file that accompanies the confext images needs to be host compatible to be able to be merged into the host /etc/ directory. This commit checks for version compatibility between the image file and the host file.
* | | os-util: add a new confext image type and the ability to parse their release ↵maanyagoenka2023-04-051-5/+5
| |/ |/| | | | | | | | | | | | | | | files Adds a new image type called IMAGE_CONFEXT which is similar to IMAGE_SYSEXT but works for the /etc/ directory instead of /usr/ and /opt/. This commit also adds the ability to parse the release file that is present with the confext image in /etc/confext-release.d/ directory.
* | rename extension-release.[c|h] -> extension-util.[c|h]Luca Boccassi2023-03-301-1/+1
| | | | | | | | | | It will be used for other extension DDI validation, not just for extension-release validation
* | portablectl: display sysext-specific fieldsLuca Boccassi2023-03-281-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wrong fields were being displayed, if at all. ID and VERSION_ID in sysexts are used for matching, they don't identify the sysext itself. Parse the newly defined fields and display them separately from the compatibility fields. Before: Image: /home/bluca/git/systemd/base.raw Portable Service: n/a Operating System: Debian GNU/Linux 10 (buster) Extension: /home/bluca/git/systemd/app0.raw Extension Scope: n/a Extension Compatibility Level: n/a Portable Service: n/a Portable Prefixes: n/a Operating System: n/a (debian 10) Extension: /home/bluca/git/systemd/app1.raw Extension Scope: n/a Extension Compatibility Level: n/a Portable Service: n/a Portable Prefixes: n/a Operating System: n/a (debian 10) Unit files: app0.service app1.service After: Image: /home/bluca/git/systemd/base.raw Portable Service: n/a Operating System: Debian GNU/Linux 10 (buster) Extension: /home/bluca/git/systemd/app0.raw Extension Scope: n/a Extension Compatibility Level: n/a Extension Compatibility OS: debian Extension Compatibility OS Version: 10 Portable Service: n/a Portable Prefixes: n/a Extension Image: ID: app Version: 0 Extension: /home/bluca/git/systemd/app1.raw Extension Scope: n/a Extension Compatibility Level: n/a Extension Compatibility OS: debian Extension Compatibility OS Version: 10 Portable Service: n/a Portable Prefixes: n/a Extension Image: ID: app Version: 1 Unit files: app0.service app1.service
* | portable: add PORTABLE_NAME_AND_VERSION= and other metadata to LogsExtraFields=Luca Boccassi2023-03-281-8/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is useful to identify log messages with metadata from the images they run on. Look for ID/VERSION_ID/IMAGE_ID/IMAGE_VERSION/BUILD_ID, with a SYSEXT_ prefix if we are looking at an extension, and append via LogExtraFields= as respectively PORTABLE_NAME_AND_VERSION= in case of a single image. In case of extensions, append as PORTABLE_ROOT_NAME_AND_VERSION= for the base and one PORTABLE_EXTENSION_AND_VERSION= for each extension. Example with a base and two extensions, with the unit coming from the first extension: [Service] RootImage=/home/bluca/git/systemd/base.raw Environment=PORTABLE=app0.raw BindReadOnlyPaths=/etc/os-release:/run/host/os-release LogExtraFields=PORTABLE=app0.raw Environment=PORTABLE_ROOT=base.raw LogExtraFields=PORTABLE_ROOT=base.raw LogExtraFields=PORTABLE_ROOT_NAME_AND_VERSION=debian_10 ExtensionImages=/home/bluca/git/systemd/app0.raw LogExtraFields=PORTABLE_EXTENSION=app0.raw LogExtraFields=PORTABLE_EXTENSION_NAME_AND_VERSION=app_0 ExtensionImages=/home/bluca/git/systemd/app1.raw LogExtraFields=PORTABLE_EXTENSION=app1.raw LogExtraFields=PORTABLE_EXTENSION_NAME_AND_VERSION=app_1
* | portable: include base and extension images in log fieldsLuca Boccassi2023-03-281-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a portable service uses extensions, we use the 'main' image name (the one where the unit was found in) as PORTABLE=. It is useful to also list all the images actually used at runtime, as they might contain libraries and so on. Use PORTABLE_ROOT= for the image/directory that is used as RootImage= or RootDirectory=, and PORTABLE_EXTENSION= for the image/directory that is used as ExtensionImages= or ExtensionDirectories=. Note that these new fields are only added if extensions are used, there's no change for single-DDI portables. Example with a base and two extensions, with the unit coming from the first extension: [Service] RootImage=/home/bluca/git/systemd/base.raw Environment=PORTABLE=app0.raw BindReadOnlyPaths=/etc/os-release:/run/host/os-release LogExtraFields=PORTABLE=app0.raw LogExtraFields=PORTABLE_ROOT=base.raw ExtensionImages=/home/bluca/git/systemd/app0.raw LogExtraFields=PORTABLE_EXTENSION=app0.raw ExtensionImages=/home/bluca/git/systemd/app1.raw LogExtraFields=PORTABLE_EXTENSION=app1.raw
* | portable: use parse_env_file_fd to keep FD validLuca Boccassi2023-03-281-10/+5
| | | | | | | | | | | | take_fdopen_unlocked invalidates the FD in the PortableMetadata object, so it cannot be used later. Use parse_env_file_fd instead which is non destructive.
* | env: add load_env_file_pairs_fd()Luca Boccassi2023-03-281-7/+1
|/
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-242-4/+4
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* fileio: add new helper fdopen_independent()Lennart Poettering2023-03-231-6/+1
| | | | | | | | This is a combination of fdopen() and fd_reopen(). i.e. it first reopens the fd, and then converts that into a FILE*. We do this at various places already manually. let's move this into a helper call of its own.
* copy: Move chattr arguments to full function signaturesDaan De Meyer2023-03-211-1/+1
| | | | | These are almost never used, so let's move them to the _full() functions signatures.
* basic: add RuntimeScope enumLennart Poettering2023-03-102-7/+7
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* tree-wide: replace IOVEC_INIT with IOVEC_MAKEYu Watanabe2023-03-061-1/+1
| | | | | | | | We use gnu11 to build, hence we can use structured initializer with casting, and it is not necessary to use different patterns on initialization and assignment. Addresses https://github.com/systemd/systemd/pull/26560#discussion_r1118875447.
* tmpfile-util: teach link_tmpfile() to optionally replace filesLennart Poettering2023-03-031-1/+1
|
* portabled: hook up SIGRTMIN+18 and memory pressureLennart Poettering2023-03-011-1/+10
|
* tree-wide: port various things over to CLEANUP_ARRAY()Lennart Poettering2023-02-231-14/+6
|
* meson: Do not include headers in source listsJan Janssen2023-01-241-5/+0
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* loop-util: always tell kernel explicitly about loopback sector sizeLennart Poettering2023-01-181-1/+1
| | | | | | Let's not leave the sector size unspecified: either set a user supplied value, or auto-detect the right size by probing the disk image accordingly.
* portable: port basename() → path_extract_filename()Lennart Poettering2022-12-231-5/+12
|
* tree-wide: introduce PIPE_EBADF macroYu Watanabe2022-12-202-2/+2
|
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-192-2/+2
| | | | In some places, initialization is dropped when unnecesary.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-194-14/+14
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* dissect: rework DISSECT_IMAGE_ADD_PARTITION_DEVICES + ↵Lennart Poettering2022-12-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DISSECT_IMAGE_OPEN_PARTITION_DEVICES Curently, these two flags were implied by dissect_loop_device(), but that's not right, because this means systemd-gpt-auto-generator will dissect the root block device with these flags set and that's not desirable: the generator should not cause the partition devices to be created (we don't intend to use them right-away after all, but expect udev to find/probe them first, and then mount them though .mount units). And there's no point in opening the partition devices, since we do not intend to mount them via fds either. Hence, rework this: instead of implying the flags, specify them explicitly. While we are at it, let's also rename the flags to make them more descriptive: DISSECT_IMAGE_MANAGE_PARTITION_DEVICES becomes DISSECT_IMAGE_ADD_PARTITION_DEVICES, since that's really all this does: add the partition devices via BLKPG. DISSECT_IMAGE_OPEN_PARTITION_DEVICES becomes DISSECT_IMAGE_PIN_PARTITION_DEVICES, since we not only open the devices, but keep the devices open continously (i.e. we "pin" them). Also, drop the DISSECT_IMAGE_BLOCK_DEVICE combination flag, since it is misleading, i.e. it suggests it was appropriate to specify on all dissected blocking devices, but that's precisely not the case, see the systemd-gpt-auto-generator case. My guess is that the confusion around this was actually the cause for this bug we are addressing here. Fixes: #25528
* portable: add a few more useful debug log messagesLuca Boccassi2022-11-231-3/+3
| | | | | | | When attaching and /etc/systemd/system.attached can't be created or used (eg: dead symlink) the logs are pretty much useless as even at debug level there's no indication of what is going wrong. Add some debug logs, and return a more specific error string over D-Bus.
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-083-3/+3
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* tree-wide: do not use "re" with fmemopenZbigniew Jędrzejewski-Szmek2022-10-191-2/+2
| | | | | | The man page says nothing about "e". Glibc clearly accepts it without fuss, but it is meaningless for a memory object (and probably doesn't work). This use is not portable, so let's avoid it.
* shared/install: rename UnitFileChange to InstallChangeZbigniew Jędrzejewski-Szmek2022-10-131-2/+2
| | | | | It's shorter and more generic. The struct can contain info about changes to unit files, but also symlinks and errors.
* portable: allow caller to override extension-release name checkLuca Boccassi2022-10-124-16/+36
| | | | | When the --force flag is used, do not insist that the extension-release file has to match the extension image name
* portable: rename flag PORTABLE_FORCE -> PORTABLE_FORCE_ATTACHLuca Boccassi2022-10-123-6/+6
| | | | | The name is used only internally, also it was just added. Allows adding different types of force flags.
* tree-wide: add ERRNO_IS_XATTR_ABSENT() helperLennart Poettering2022-10-101-1/+1
| | | | | We check the same list of error codes on various xattr operations, and we should on some more. Add a common helper for this purpose.
* portablectl: add --force attach/detachLuca Boccassi2022-09-303-23/+36
| | | | | | | | | | Allows to skip check that ensures units must not be running. I have a use case that would use reattach, except the orchestrator is using a non-standard versioning scheme, so image matching cannot work. As a workaround, need to be able to detach and then attach manually, without stopping the units to avoid extended downtimes and loss of FD store.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-134-16/+8
|
* dissect-image: use backing_file stored in LoopDevice object to generate ↵Yu Watanabe2022-09-071-1/+0
| | | | | | | | image name Follow-up for e374439f4b8def786031ddbbd7dfdae3a335d4d2 (#24322). This also simplify the logic of generating image name from image path.
* Use original filename for extension name checkKai Lueke2022-09-061-0/+1
| | | | | | | | | | | | | The loading of an extension image from a symlink "NAME.raw" to "NAME-VERSION.raw" failed because the release file name check worked with the backing file of the loop device which already resolves the symlink and thus the found name "NAME-VERSION" mismatched "NAME". Pass the original filename and use it instead of the backing file when available. This fixes the loading of "NAME.raw" extensions which are a symlink to "NAME-VERSION.raw" as, e.g., may be the case when systemd-sysupdate manages multiple versions. Fixes https://github.com/systemd/systemd/issues/24293
* dissect-image: introduce dissect_loop_device() which takes LoopDevice objectYu Watanabe2022-09-031-5/+2
|
* loop-util: rework how we lock loopback block devicesLennart Poettering2022-09-011-5/+1
| | | | | | | | | | | | | | | | | | | | Let's rework how we lock loopback block devices in two ways: 1. Lock a separate fd, instead of the main block device fd. We already did that for our internal locking when allocating loopback block devices, but do so for the exposed locking (i.e. loop_device_flock()), too, so that the lock is independent of the main fd we actually use of IO. 2. Instead of locking the device during allocation of the loopback device, then unlocking it (which will make udev run), and then re-locking things if we need, let's instead just keep the lock the whole time, to make things a bit safer and faster, and not have to wait for udev at all. This is done by adding a "lock_op" parameter to loop device allocation functions that declares the initial state of the lock, and is one of LOCK_UN/LOCK_SH/LOCK_EX. This change also shortens a lot of code, since we allocate + immediately lock loopback devices pretty much everywhere.
* tree-wide: use path_join() instead of prefix_roota() in various casesLennart Poettering2022-08-221-5/+20
| | | | | | | | | | | | | | | | | | | prefix_roota() is something we should stop using. It is bad for three reasons: 1. As it names suggests it's supposed to be used when working relative to some root directory, but given it doesn't follow symlinks (and instead just stupidly joins paths) it is not a good choice for that. 2. More often than not it is currently used with inputs under control of the user, and that is icky given it typically allocates memory on the stack. 3. It's a redundant interface, where chase_symlinks() and path_join() already exist as better, safer interfaces. Hence, let's start moving things from prefix_roota() to path_join() for the cases where that's appropriate.
* Merge pull request #24054 from keszybz/initrd-no-reloadFrantisek Sumsal2022-08-181-1/+1
|\ | | | | Don't do daemon-reload in the initrd