Support for starting finit-getty with a given user

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-09-04 20:02:59 +02:00
1 parent 47f3e2ca04
commit 79207dcb22
2 files changed
+9 -5

No files matched your search

+3 -3
View File
@@ -38,6 +38,8 @@
#define NUM_ARGS 16 #define NUM_ARGS 16
int getty(char *tty, char *baud, char *term, char *user);
/* Wait for process completion, returns status of waitpid(2) syscall */ /* Wait for process completion, returns status of waitpid(2) syscall */
int complete(char *cmd, int pid) int complete(char *cmd, int pid)
@@ -213,8 +215,6 @@ int run_interactive(char *cmd, char *fmt, ...)
return status; return status;
} }
int getty(char *tty, char *baud, char *term);
pid_t run_getty(char *tty, char *speed, char *term, int console) pid_t run_getty(char *tty, char *speed, char *term, int console)
{ {
pid_t pid; pid_t pid;
@@ -233,7 +233,7 @@ pid_t run_getty(char *tty, char *speed, char *term, int console)
else else
prctl(PR_SET_NAME, "finit-getty", 0, 0, 0); prctl(PR_SET_NAME, "finit-getty", 0, 0, 0);
_exit(getty(tty, speed, term)); _exit(getty(tty, speed, term, NULL));
} }
return pid; return pid;
+6 -2
View File
@@ -268,7 +268,7 @@ static speed_t do_parse_speed(char *baud)
return B0; return B0;
} }
int getty(char *tty, char *baud, char *UNUSED(term)) int getty(char *tty, char *baud, char *UNUSED(term), char *user)
{ {
int fd; int fd;
char name[30]; char name[30];
@@ -308,7 +308,11 @@ int getty(char *tty, char *baud, char *UNUSED(term))
stty(fd, speed); stty(fd, speed);
utmp_set_login(tty, NULL); utmp_set_login(tty, NULL);
do_getty(tty, name, sizeof(name)); if (!user)
do_getty(tty, name, sizeof(name));
else
strlcpy(name, user, sizeof(name));
return do_login(name); return do_login(name);
} }