mirror of
https://github.com/SELinuxProject/selinux
synced 2025-03-11 04:37:29 +00:00
policycoreutils: sandbox: Maintain the LANG environment into the sandbox
When running an app within a sandbox, the application currently switches to no LANG. This patch will cause the sandboxed app to use the users LANG. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
1d274aca2d
commit
5c2a0d143d
@ -944,6 +944,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (child == 0) {
|
if (child == 0) {
|
||||||
char *display = NULL;
|
char *display = NULL;
|
||||||
|
char *LANG = NULL;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
if (unshare(CLONE_NEWNS) < 0) {
|
if (unshare(CLONE_NEWNS) < 0) {
|
||||||
@ -969,12 +970,23 @@ int main(int argc, char **argv) {
|
|||||||
goto childerr;
|
goto childerr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* construct a new environment */
|
||||||
|
if ((LANG = getenv("LANG")) != NULL) {
|
||||||
|
if ((LANG = strdup(LANG)) == NULL) {
|
||||||
|
perror(_("Out of memory"));
|
||||||
|
goto childerr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((rc = clearenv()) != 0) {
|
if ((rc = clearenv()) != 0) {
|
||||||
perror(_("Failed to clear environment"));
|
perror(_("Failed to clear environment"));
|
||||||
goto childerr;
|
goto childerr;
|
||||||
}
|
}
|
||||||
if (display)
|
if (display)
|
||||||
rc |= setenv("DISPLAY", display, 1);
|
rc |= setenv("DISPLAY", display, 1);
|
||||||
|
if (LANG)
|
||||||
|
rc |= setenv("LANG", LANG, 1);
|
||||||
rc |= setenv("HOME", pwd->pw_dir, 1);
|
rc |= setenv("HOME", pwd->pw_dir, 1);
|
||||||
rc |= setenv("SHELL", pwd->pw_shell, 1);
|
rc |= setenv("SHELL", pwd->pw_shell, 1);
|
||||||
rc |= setenv("USER", pwd->pw_name, 1);
|
rc |= setenv("USER", pwd->pw_name, 1);
|
||||||
@ -1000,6 +1012,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, _("Failed to execute command %s: %s\n"), argv[optind], strerror(errno));
|
fprintf(stderr, _("Failed to execute command %s: %s\n"), argv[optind], strerror(errno));
|
||||||
childerr:
|
childerr:
|
||||||
free(display);
|
free(display);
|
||||||
|
free(LANG);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user