diff options
Diffstat (limited to 'src/sulogin-shell/sulogin-shell.c')
-rw-r--r-- | src/sulogin-shell/sulogin-shell.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c index d0e5a89f1f..6d65efbb9e 100644 --- a/src/sulogin-shell/sulogin-shell.c +++ b/src/sulogin-shell/sulogin-shell.c @@ -9,6 +9,7 @@ #include "bus-util.h" #include "bus-error.h" #include "def.h" +#include "env-util.h" #include "log.h" #include "process-util.h" #include "sd-bus.h" @@ -59,16 +60,16 @@ static int start_default_target(sd_bus *bus) { "ss", "default.target", "isolate"); if (r < 0) - log_error("Failed to start default target: %s", bus_error_message(&error, r)); + return log_error_errno(r, "Failed to start default target: %s", bus_error_message(&error, r)); - return r; + return 0; } static int fork_wait(const char* const cmdline[]) { pid_t pid; int r; - r = safe_fork("(sulogin)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); + r = safe_fork("(sulogin)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pid); if (r < 0) return r; if (r == 0) { @@ -89,16 +90,22 @@ static void print_mode(const char* mode) { } int main(int argc, char *argv[]) { - static const char* const sulogin_cmdline[] = {SULOGIN, NULL}; + const char* sulogin_cmdline[] = { + SULOGIN, + NULL, /* --force */ + NULL + }; _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; int r; - log_set_target(LOG_TARGET_AUTO); - log_parse_environment(); - log_open(); + log_setup_service(); print_mode(argc > 1 ? argv[1] : ""); + if (getenv_bool("SYSTEMD_SULOGIN_FORCE") > 0) + /* allows passwordless logins if root account is locked. */ + sulogin_cmdline[1] = "--force"; + (void) fork_wait(sulogin_cmdline); r = bus_connect_system_systemd(&bus); |