From 69009b983a31efd4fb5a6d6a4b969ab9af2bba35 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 6 Mar 2019 22:31:40 +0100 Subject: run login shell --- fbcon.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'fbcon.c') diff --git a/fbcon.c b/fbcon.c index eb491fa..ef5743c 100644 --- a/fbcon.c +++ b/fbcon.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -495,6 +496,9 @@ static void fbcon_child_exec(struct winsize *win, enum fbcon_mode mode, int argc, char **argv) { + struct passwd *pwent; + char *shell; + /* reset terminal */ fprintf(stderr, "\x1b[0m"); @@ -525,12 +529,18 @@ static void fbcon_child_exec(struct winsize *win, switch (mode) { case FBCON_MODE_EXEC: execvp(argv[0], argv); - fprintf(stderr, "failed to exec %s: %s\n", argv[0], strerror(errno)); + fprintf(stderr, "failed to exec %s: %s\n", + argv[0], strerror(errno)); break; case FBCON_MODE_SHELL: default: - execl("/bin/sh", "-sh", NULL); - fprintf(stderr, "failed to exec /bin/sh: %s\n", strerror(errno)); + pwent = getpwent(); + shell = strdup(pwent->pw_shell); + shell = strrchr(shell, '/'); + *shell = '-'; + execl(pwent->pw_shell, shell, NULL); + fprintf(stderr, "failed to exec %s: %s\n", + pwent->pw_shell, strerror(errno)); break; } } -- cgit