locale-setup.c revision 0a1beeb64207eaa88ab9236787b1cbc2f704ae14
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "locale-setup.h"
#include "util.h"
#include "macro.h"
#include "virt.h"
#include "fileio.h"
#include "strv.h"
#include "env-util.h"
#include "locale-util.h"
int locale_setup(char ***environment) {
char **add;
char *variables[_VARIABLE_LC_MAX] = {};
int r = 0, i;
if (detect_container(NULL) <= 0) {
NULL);
if (r < 0 && r != -ENOENT)
log_warning_errno(-r, "Failed to read /proc/cmdline: %m");
}
/* Hmm, nothing set on the kernel cmd line? Then let's
* try /etc/locale.conf */
if (r <= 0) {
NULL);
if (r < 0 && r != -ENOENT)
log_warning_errno(-r, "Failed to read /etc/locale.conf: %m");
}
for (i = 0; i < _VARIABLE_LC_MAX; i++) {
char *s;
if (!variables[i])
continue;
if (!s) {
r = -ENOMEM;
goto finish;
}
if (strv_consume(&add, s) < 0) {
r = -ENOMEM;
goto finish;
}
}
if (!strv_isempty(add)) {
char **e;
if (!e) {
r = -ENOMEM;
goto finish;
}
*environment = e;
}
r = 0;
for (i = 0; i < _VARIABLE_LC_MAX; i++)
return r;
}