diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-07-10 19:19:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-07-10 19:19:59 +0200 |
commit | cd3bd60a2e4bb08526d953a323bbe1a0ace78b9e (patch) | |
tree | 465cfcaa0896697ed0f0e7d4e144f9d4f1ffbbe3 /src/core/shutdown.c | |
parent | 94163dd54328780b4539e7296eb0ba75b7290367 (diff) |
switch-root: reopen /dev/console before we switch root
Diffstat (limited to 'src/core/shutdown.c')
-rw-r--r-- | src/core/shutdown.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/core/shutdown.c b/src/core/shutdown.c index baef66dd9d..194a1ccf21 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -267,9 +267,10 @@ static int prepare_new_root(void) { } static int pivot_to_new_root(void) { - int fd; - - chdir("/run/initramfs"); + if (chdir("/run/initramfs") < 0) { + log_error("Failed to change directory to /run/initramfs: %m"); + return -errno; + } /* In case some evil process made "/" MS_SHARED @@ -288,18 +289,11 @@ static int pivot_to_new_root(void) { } chroot("."); - log_info("Successfully changed into root pivot."); - fd = open("/dev/console", O_RDWR); - if (fd < 0) - log_error("Failed to open /dev/console: %m"); - else { - make_stdio(fd); + setsid(); + make_console_stdio(); - /* Initialize the controlling terminal */ - setsid(); - ioctl(STDIN_FILENO, TIOCSCTTY, NULL); - } + log_info("Successfully changed into root pivot."); return 0; } |