From 025be2361b3ee7cc3732fb3963d36b8583842064 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 6 Sep 2024 13:18:59 +0900 Subject: [PATCH] nspawn: only remount /usr/ with idmap when --volatile=yes The root directory is already mounted with a picked UID shift, hence it is not necessary to remount with idmap. However, /usr/ is a bind-mount, hence it must be remounted with idmap. With this change, now '-U --volatile=yes' works fine. Fixes #34254. --- src/nspawn/nspawn.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 655dc7c6976..ec73e427091 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -3995,11 +3995,14 @@ static int outer_child( arg_uid_shift != 0) { _cleanup_strv_free_ char **dirs = NULL; - r = strv_extend(&dirs, directory); - if (r < 0) - return log_oom(); + if (arg_volatile_mode != VOLATILE_YES) { + r = strv_extend(&dirs, directory); + if (r < 0) + return log_oom(); + } - if (dissected_image && dissected_image->partitions[PARTITION_USR].found) { + if ((dissected_image && dissected_image->partitions[PARTITION_USR].found) || + arg_volatile_mode == VOLATILE_YES) { char *s = path_join(directory, "/usr"); if (!s) return log_oom(); -- 2.47.3