summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-19 17:00:36 +0200
committerLennart Poettering <lennart@poettering.net>2016-07-22 15:33:12 +0200
commit84af7821b65ad11417ac2984717cf42a3655fcd7 (patch)
treed3d618c57556cb748324772eabaa1a8a3430f40f /src/core
parentf7903e8db673505328ba904f050f5ec52cf79c23 (diff)
main: simplify things a bit by moving container check into fixup_environment()
Diffstat (limited to 'src/core')
-rw-r--r--src/core/main.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/main.c b/src/core/main.c
index fc04fb8051..4c767a3c9d 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1298,6 +1298,11 @@ static int fixup_environment(void) {
_cleanup_free_ char *term = NULL;
int r;
+ /* We expect the environment to be set correctly
+ * if run inside a container. */
+ if (detect_container() > 0)
+ return 0;
+
/* When started as PID1, the kernel uses /dev/console
* for our stdios and uses TERM=linux whatever the
* backend device used by the console. We try to make
@@ -1314,7 +1319,7 @@ static int fixup_environment(void) {
if (r == 0) {
term = strdup(default_term_for_tty("/dev/console") + 5);
if (!term)
- return -errno;
+ return -ENOMEM;
}
if (setenv("TERM", term, 1) < 0)
@@ -1508,13 +1513,10 @@ int main(int argc, char *argv[]) {
}
if (arg_system) {
- /* We expect the environment to be set correctly
- * if run inside a container. */
- if (detect_container() <= 0)
- if (fixup_environment() < 0) {
- error_message = "Failed to fix up PID1 environment";
- goto finish;
- }
+ if (fixup_environment() < 0) {
+ error_message = "Failed to fix up PID1 environment";
+ goto finish;
+ }
/* Try to figure out if we can use colors with the console. No
* need to do that for user instances since they never log