From: Christian Brauner Date: Thu, 28 Jan 2021 17:59:55 +0000 (+0100) Subject: attach: move config init into get_attach_context() X-Git-Tag: lxc-5.0.0~313^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1874ef74680260d369d59d8382ae719fe77743d8;p=thirdparty%2Flxc.git attach: move config init into get_attach_context() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index e3d642ebd..f44147d24 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -131,6 +131,12 @@ static int get_attach_context(struct attach_context *ctx, if (ctx->personality < 0) return log_error_errno(-ENOENT, ENOENT, "Failed to get personality of the container"); + if (!ctx->container->lxc_conf) { + ctx->container->lxc_conf = lxc_conf_init(); + if (!ctx->container->lxc_conf) + return log_error_errno(-ENOMEM, ENOMEM, "Failed to allocate new lxc config"); + } + return 0; } @@ -1014,18 +1020,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, return -1; } - if (!ctx->container->lxc_conf) { - ctx->container->lxc_conf = lxc_conf_init(); - if (!ctx->container->lxc_conf) { - put_attach_context(ctx); - return -1; - } - } conf = ctx->container->lxc_conf; - if (!conf) { - put_attach_context(ctx); - return log_error_errno(-EINVAL, EINVAL, "Missing container confifg"); - } if (!fetch_seccomp(ctx->container, options)) WARN("Failed to get seccomp policy");