From 76d2b8e281bf0cf25a8bd657aed51278291c1572 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 15 Jan 2025 11:48:28 +0100 Subject: [PATCH] nspawn: trivial scope reduction --- src/nspawn/nspawn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index bc9b91d2383..7ceda0b30c3 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -3943,7 +3943,6 @@ static int outer_child( _cleanup_(bind_user_context_freep) BindUserContext *bind_user_context = NULL; _cleanup_strv_free_ char **os_release_pairs = NULL; - _cleanup_close_ int mntns_fd = -EBADF; bool idmap = false, enable_fuse; const char *p; pid_t pid; @@ -4012,6 +4011,8 @@ static int outer_child( return r; if (arg_userns_mode != USER_NAMESPACE_NO) { + _cleanup_close_ int mntns_fd = -EBADF; + mntns_fd = namespace_open_by_type(NAMESPACE_MOUNT); if (mntns_fd < 0) return log_error_errno(mntns_fd, "Failed to pin outer mount namespace: %m"); -- 2.47.3