Projects
Mega:23.03
systemd
_service:tar_scm:backport-nspawn-if-we-refuse-t...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:backport-nspawn-if-we-refuse-to-operate-on-some-directory-exp.patch of Package systemd
From aff7ae0d67e0cd4b3c60e043ea9112d3c2972fce Mon Sep 17 00:00:00 2001 From: Lennart Poettering <lennart@poettering.net> Date: Thu, 17 Mar 2022 10:31:55 +0100 Subject: [PATCH] nspawn: if we refuse to operate on some directory, explain why (Also, some refactoring to use safer path_join()) --- src/nspawn/nspawn.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 1a654d8817..a185585b50 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -5612,31 +5612,36 @@ static int run(int argc, char *argv[]) { } if (arg_start_mode == START_BOOT) { + _cleanup_free_ char *b = NULL; const char *p; - if (arg_pivot_root_new) - p = prefix_roota(arg_directory, arg_pivot_root_new); - else + if (arg_pivot_root_new) { + b = path_join(arg_directory, arg_pivot_root_new); + if (!b) + return log_oom(); + + p = b; + } else p = arg_directory; if (path_is_os_tree(p) <= 0) { - log_error("Directory %s doesn't look like an OS root directory (os-release file is missing). Refusing.", p); - r = -EINVAL; + r = log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Directory %s doesn't look like an OS root directory (os-release file is missing). Refusing.", p); goto finish; } } else { - const char *p, *q; + _cleanup_free_ char *p = NULL; if (arg_pivot_root_new) - p = prefix_roota(arg_directory, arg_pivot_root_new); + p = path_join(arg_directory, arg_pivot_root_new, "/usr/"); else - p = arg_directory; - - q = strjoina(p, "/usr/"); + p = path_join(arg_directory, "/usr/"); + if (!p) + return log_oom(); - if (laccess(q, F_OK) < 0) { - log_error("Directory %s doesn't look like it has an OS tree. Refusing.", p); - r = -EINVAL; + if (laccess(p, F_OK) < 0) { + r = log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Directory %s doesn't look like it has an OS tree (/usr/ directory is missing). Refusing.", arg_directory); goto finish; } } -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2