nspawn: support pivot-root option during directory validation

Signed-off-by: Arnaud Rebillout <arnaud.rebillout@collabora.com>
This commit is contained in:
Arnaud Rebillout 2018-05-21 11:10:21 +07:00 committed by Lennart Poettering
parent 2fcbdd2d3f
commit c9fe05e07d
1 changed files with 19 additions and 6 deletions

View File

@ -4194,17 +4194,30 @@ int main(int argc, char *argv[]) {
}
if (arg_start_mode == START_BOOT) {
if (path_is_os_tree(arg_directory) <= 0) {
log_error("Directory %s doesn't look like an OS root directory (os-release file is missing). Refusing.", arg_directory);
const char *p;
if (arg_pivot_root_new)
p = prefix_roota(arg_directory, arg_pivot_root_new);
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;
goto finish;
}
} else {
const char *p;
const char *p, *q;
p = strjoina(arg_directory, "/usr/");
if (laccess(p, F_OK) < 0) {
log_error("Directory %s doesn't look like it has an OS tree. Refusing.", arg_directory);
if (arg_pivot_root_new)
p = prefix_roota(arg_directory, arg_pivot_root_new);
else
p = arg_directory;
q = strjoina(p, "/usr/");
if (laccess(q, F_OK) < 0) {
log_error("Directory %s doesn't look like it has an OS tree. Refusing.", p);
r = -EINVAL;
goto finish;
}