tty: add basic security, call sulogin in rescue mode (notty)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-24 20:27:26 +02:00
parent 96534789db
commit 221ab20898
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -51,6 +51,7 @@
#endif
#define _PATH_LOGIT FINIT_LIBPATH_ "/logit"
#define _PATH_SULOGIN FINIT_LIBPATH_ "/sulogin"
#define CMD_SIZE 256
#define LINE_SIZE 1024
+8
View File
@@ -240,7 +240,15 @@ int tty_exec(svc_t *svc)
char *dev;
int i, j;
/* try to protect system with sulogin, fall back to root shell */
if (svc->notty) {
/* util-linux or busybox, no args for compat */
if (whichp("sulogin"))
return execlp("sulogin", "sulogin", NULL);
/* check if bundled one is available */
if (whichp(_PATH_SULOGIN) && !systemf(_PATH_SULOGIN))
_exit(0);
/*
* Become session leader and set controlling TTY
* to enable Ctrl-C and job control in shell.