summaryrefslogtreecommitdiff
path: root/src/basic/os-util.c
Commit message (Collapse)AuthorAgeFilesLines
* chase: replace path_prefix_root_cwd() with chaseat_prefix_root()Yu Watanabe2023-04-191-2/+2
| | | | | | | | | | | | | | The function path_prefix_root_cwd() was introduced for prefixing the result from chaseat() with root, but - it is named slightly generic, - the logic is different from what chase() does. This makes the name more explanative and specific for the result of the chaseat(), and make the logic consistent with chase(). Fixes https://github.com/systemd/systemd/pull/27199#issuecomment-1511387731. Follow-up for #27199.
* os-util: introduce several _at() variants of os-release parsersYu Watanabe2023-04-111-14/+112
|
* os-util: make $SYSTEMD_OS_RELEASE prefixed with the root directoryYu Watanabe2023-04-111-1/+1
| | | | | | | | To make it consistent with other env vars, e.g. $SYSTEMD_ESP_PATH or $SYSTEMD_XBOOTLDR_PATH. This is useful when the root is specified by a file descriptor, instead of a path.
* os-util: merge parse_{extension,os}_release()Yu Watanabe2023-04-111-24/+9
|
* os-util: shorten temporal variable namesYu Watanabe2023-04-111-40/+28
| | | | No functional change, just refactoring.
* os-util: log one more error causeYu Watanabe2023-04-111-2/+3
|
* os-util: do not use 'r' for storing loop statusYu Watanabe2023-04-111-8/+6
| | | | | | | The variable 'r' is usually used for storing return value of functional call. Let's introduce another boolean to store the current loop status. No functional change, just refactoring.
* os-util: return earlier when unsupported image class is specifiedYu Watanabe2023-04-111-0/+3
|
* os-util: return earlier when extension release file is foundYu Watanabe2023-04-111-64/+65
| | | | No functional change, just refactoring.
* os-util: split-out open_os_release() from open_extension_release()Yu Watanabe2023-04-111-89/+101
| | | | | | The logics of opening os-release and extension-release are completely different. No functional change, just refactoring.
* os-util: fix fd leak on failureYu Watanabe2023-04-111-1/+2
|
* os-util: make open_extension_release() return O_PATH fdYu Watanabe2023-04-111-12/+2
|
* os-util: drop fopen_extension_release()Yu Watanabe2023-04-111-30/+6
|
* os-util: drop redundant declaration of load_os_release_pairs()Yu Watanabe2023-04-111-15/+0
|
* os-util: use _IMAGE_CLASS_INVALIDYu Watanabe2023-04-111-3/+1
| | | | | | When extension is not specified, image class is not necessary to be specified. Let's use _IMAGE_CLASS_INVALID as an indicator that no extension is specified.
* os-util: move declaration of string table lookup for image classYu Watanabe2023-04-111-0/+10
|
* os-util: add a new confext image type and the ability to parse their release ↵maanyagoenka2023-04-051-18/+45
| | | | | | | | | 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.
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-12/+6
| | | | | | | | | 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.
* tree-wide: fix typo and comment style updateYu Watanabe2023-02-151-1/+1
|
* os-util: optionally, return EOL time in os_release_support_ended()Lennart Poettering2023-01-241-3/+5
|
* os-util: accept SUPPORT_END= with empty string as explicit way to disable ↵Lennart Poettering2023-01-241-3/+3
| | | | concept
* os-util: when determining support end, don't treat /etc/os-release file as errorLennart Poettering2023-01-241-2/+2
| | | | Instead, let's just treat it as "field unset".
* os-util: determine distro EOL in UTC, not local timezoneLennart Poettering2023-01-241-1/+1
| | | | | | Presumably vendors establish a global EOL time, hence its better to interpret the date specification everywhere the same, instead of timezone dependent.
* tree-wide: unify how we pick OS pretty name to displayLennart Poettering2023-01-241-0/+9
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -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.
* portable: allow caller to override extension-release name checkLuca Boccassi2022-10-121-18/+20
| | | | | When the --force flag is used, do not insist that the extension-release file has to match the extension image name
* os-util: split out extension-release xattr helperLuca Boccassi2022-10-121-25/+41
|
* 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.
* manager: add taint flag "support-ended"Zbigniew Jędrzejewski-Szmek2022-07-101-0/+35
| | | | | | | | | | | | | | In the welcome line, use NAME= as the fallback for PRETTY_NAME=. PRETTY_NAME= doesn't have to be set, but NAME= should. Example output: --- Welcome to Fedora Linux 37 (Rawhide Prerelease)! [ !! ] This OS version (Fedora Linux 37 (Rawhide Prerelease)) is past its end-of-support date (1999-01-01) Queued start job for default target graphical.target. [ OK ] Created slice system-getty.slice. ---
* tree-wide: allow ASCII fallback for … in logsDavid Tardon2022-06-281-2/+4
|
* basic: add new variable $SYSTEMD_OS_RELEASE to override location of os-releaseZbigniew Jędrzejewski-Szmek2022-03-291-5/+11
| | | | | | The test for the variable is added in test-systemctl-enable because there we can do it almost for free, and the variable is most likely to be used with 'systemctl enable --root' anyway.
* strv: declare iterator of FOREACH_STRING() in the loopZbigniew Jędrzejewski-Szmek2022-03-231-2/+0
| | | | | | | | | | | Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* Add debug logs of extension-release scanningZbigniew Jędrzejewski-Szmek2021-11-241-11/+24
|
* xattr-util: merge various getxattr()/listxattr() helpers into ↵Lennart Poettering2021-10-071-1/+1
| | | | | | | | | | | | | | getxattr_at_malloc() + listxattr_at_malloc() Unfortunately fgetxattr() and flistxattr() don't work via O_PATH fds. Let's thus add fallbacks to go via /proc/self/fd/ in these cases. Also, let's merge all the various flavours we have here into singular implementations that can do everything we need: 1. malloc() loop handling 2. by fd, by path, or combination (i.e. a proper openat() like API) 3. work on O_PATH
* basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch]Lennart Poettering2021-10-051-0/+1
|
* extension-release: search for other files if expected name not foundLuca Boccassi2021-08-171-2/+91
| | | | | | | | | | | | In some cases image names are unpredictable - some orchestrators/deployment tools like to mangle names to suit their internal formats. In these cases, the requirement that the extension-release file matches exactly the image name where it's contained cannot work. Allow falling back to loading the first regular file which name starts with 'extension-release' located in /usr/lib/extension-release.d/ and tagged with a user.extension-release.strict extended attribute with a true value, if the one with the expected name cannot be found.
* basic/os-util: adjust indentationZbigniew Jędrzejewski-Szmek2021-03-071-6/+5
|
* basic/os-util: make the sentinel implicitZbigniew Jędrzejewski-Szmek2021-02-221-2/+2
|
* Move os-util.[ch] to basic/Zbigniew Jędrzejewski-Szmek2021-02-221-0/+213
| | | | parse_os_release() will be used basic/hostname-util.c later on.
* Move various files that don't need to be in basic/ to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-117/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't have much effect on the final build, because we link libbasic.a into libsystemd-shared.so, so in the end, all the object built from basic/ end up in libsystemd-shared. And when the static library is linked into binaries, any objects that are included in it but are not used are trimmed. Hence, the size of output artifacts doesn't change: $ du -sb /var/tmp/inst* 54181861 /var/tmp/inst1 (old) 54207441 /var/tmp/inst1s (old split-usr) 54182477 /var/tmp/inst2 (new) 54208041 /var/tmp/inst2s (new split-usr) (The negligible change in size is because libsystemd-shared.so is bigger by a few hundred bytes. I guess it's because symbols are named differently or something like that.) The effect is on the build process, in particular partial builds. This change effectively moves the requirements on some build steps toward the leaves of the dependency tree. Two effects: - when building items that do not depend on libsystemd-shared, we build less stuff for libbasic.a (which wouldn't be used anyway, so it's a net win). - when building items that do depend on libshared, we reduce libbasic.a as a synchronization point, possibly allowing better parallelism. Method: 1. copy list of .h files from src/basic/meson.build to /tmp/basic 2. $ for i in $(grep '.h$' /tmp/basic); do echo $i; git --no-pager grep "include \"$i\"" src/basic/ 'src/lib*' 'src/nss-*' 'src/journal/sd-journal.c' |grep -v "${i%.h}.c";echo ;done | less
* fileio: drop "newline" parameter for env file parsersLennart Poettering2018-11-141-2/+2
| | | | | | | Now that we don't (mis-)use the env file parser to parse kernel command lines there's no need anymore to override the used newline character set. Let's hence drop the argument and just "\n\r" always. This nicely simplifies our code.
* os-util: add helpers for finding /etc/os-releaseLennart Poettering2018-05-241-0/+117
Place this new helpers in a new source file os-util.[ch], and move the existing and related call path_is_os_tree() to it as well.