summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-03-23 01:02:47 +0000
committerLuca Boccassi <bluca@debian.org>2023-03-28 10:36:01 +0100
commit62b7c23f79bcbcbc141c90c3a0931fa46a1652a2 (patch)
tree3cc65621bc5e472396d6ce9f5fc13d377cac02f4 /src/portable
parent2ed74695b310207deca33fcc95a890b0fdb9e622 (diff)
downloadsystemd-62b7c23f79bcbcbc141c90c3a0931fa46a1652a2.tar.gz
portable: use parse_env_file_fd to keep FD valid
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.
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/portable.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 770cac9e1f..2b06e61f75 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -566,18 +566,13 @@ static int extract_image_and_extensions(
* extension-release metadata match, otherwise reject it immediately as invalid, or it will fail when
* the units are started. Also, collect valid portable prefixes if caller requested that. */
if (validate_sysext || ret_valid_prefixes) {
- _cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *prefixes = NULL;
- r = take_fdopen_unlocked(&os_release->fd, "r", &f);
- if (r < 0)
- return r;
-
- r = parse_env_file(f, os_release->name,
- "ID", &id,
- "VERSION_ID", &version_id,
- "SYSEXT_LEVEL", &sysext_level,
- "PORTABLE_PREFIXES", &prefixes);
+ r = parse_env_file_fd(os_release->fd, os_release->name,
+ "ID", &id,
+ "VERSION_ID", &version_id,
+ "SYSEXT_LEVEL", &sysext_level,
+ "PORTABLE_PREFIXES", &prefixes);
if (r < 0)
return r;
if (isempty(id))