From: Daan De Meyer Date: Tue, 26 Apr 2022 09:05:08 +0000 (+0100) Subject: nspawn: Set LANG to C.UTF-8 X-Git-Tag: v251-rc2~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b626f6959bcee11d966f96bd29a00502f4aa2ce4;p=thirdparty%2Fsystemd.git nspawn: Set LANG to C.UTF-8 Let's default to a UTF-8 locale when running commands using nspawn. --- diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index d2300755655..59768bcc0b8 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -3218,6 +3218,7 @@ static int inner_child( NULL, /* LISTEN_PID */ NULL, /* NOTIFY_SOCKET */ NULL, /* CREDENTIALS_DIRECTORY */ + NULL, /* LANG */ NULL }; const char *exec_target; @@ -3486,6 +3487,16 @@ static int inner_child( n_env++; } + if (arg_start_mode != START_BOOT) { + /* If we're running a command in the container, let's default to the C.UTF-8 locale as it's + * part of glibc these days and was backported to most distros a long time before it got + * added to upstream glibc. */ + envp[n_env] = strdup("LANG=C.UTF-8"); + if (!envp[n_env]) + return log_oom(); + n_env++; + } + env_use = strv_env_merge(envp, os_release_pairs, arg_setenv); if (!env_use) return log_oom();