core: unset HOME=/ that the kernel gives us

Partially fixes #12389.

%h would return "/" in a machine, but "/root" in a container. Let's fix
this by resetting $HOME to the expected value.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-05-22 16:28:02 +02:00
parent 8da24acad5
commit 9d48671c62
+5
View File
@@ -1546,6 +1546,11 @@ static int fixup_environment(void) {
if (setenv("TERM", t, 1) < 0)
return -errno;
/* The kernels sets HOME=/ for init. Let's undo this. */
if (path_equal_ptr(getenv("HOME"), "/") &&
unsetenv("HOME") < 0)
log_warning_errno(errno, "Failed to unset $HOME: %m");
return 0;
}