aboutsummaryrefslogtreecommitdiffstats
path: root/fbcon.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-03-06 22:31:40 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-03-06 22:31:40 +0100
commit69009b983a31efd4fb5a6d6a4b969ab9af2bba35 (patch)
tree1c9e08736ac6fe9bc72d91d550e1958c11d7e21a /fbcon.c
parent3d01b2190df79e1bd395de8e483a337b3cc24dc8 (diff)
downloadfbida-69009b983a31efd4fb5a6d6a4b969ab9af2bba35.tar.gz
run login shell
Diffstat (limited to 'fbcon.c')
-rw-r--r--fbcon.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fbcon.c b/fbcon.c
index eb491fa..ef5743c 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -16,6 +16,7 @@
#include <wchar.h>
#include <setjmp.h>
#include <pty.h>
+#include <pwd.h>
#include <sys/time.h>
#include <sys/ioctl.h>
@@ -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;
}
}