summaryrefslogtreecommitdiff
path: root/src/libnm-systemd-shared/src/basic/locale-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-systemd-shared/src/basic/locale-util.c')
-rw-r--r--src/libnm-systemd-shared/src/basic/locale-util.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libnm-systemd-shared/src/basic/locale-util.c b/src/libnm-systemd-shared/src/basic/locale-util.c
index d8518ec06a..d94fbcff4b 100644
--- a/src/libnm-systemd-shared/src/basic/locale-util.c
+++ b/src/libnm-systemd-shared/src/basic/locale-util.c
@@ -10,7 +10,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
-#include "def.h"
+#include "constants.h"
#include "dirent-util.h"
#include "env-util.h"
#include "fd-util.h"
@@ -95,7 +95,7 @@ static int add_locales_from_archive(Set *locales) {
const struct locarhead *h;
const struct namehashent *e;
const void *p = MAP_FAILED;
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
size_t sz = 0;
struct stat st;
int r;
@@ -286,8 +286,9 @@ void init_gettext(void) {
}
bool is_locale_utf8(void) {
- const char *set;
static int cached_answer = -1;
+ const char *set;
+ int r;
/* Note that we default to 'true' here, since today UTF8 is
* pretty much supported everywhere. */
@@ -295,6 +296,13 @@ bool is_locale_utf8(void) {
if (cached_answer >= 0)
goto out;
+ r = getenv_bool_secure("SYSTEMD_UTF8");
+ if (r >= 0) {
+ cached_answer = r;
+ goto out;
+ } else if (r != -ENXIO)
+ log_debug_errno(r, "Failed to parse $SYSTEMD_UTF8, ignoring: %m");
+
if (!setlocale(LC_ALL, "")) {
cached_answer = true;
goto out;