mirror of
https://github.com/troglobit/finit.git
synced 2026-10-30 12:50:34 +00:00
tty: Clear tty before login: prompt by default, add 'noclear' option
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
60f73dc952
commit
e48901b90f
6 files changed
+17
-14
No files matched your search
+1
-1
@@ -136,7 +136,7 @@ Syntax:
|
|||||||
* `include <CONF>`
|
* `include <CONF>`
|
||||||
Include another configuration file. Absolute path required.
|
Include another configuration file. Absolute path required.
|
||||||
|
|
||||||
* `tty [LVLS] <DEV> [BAUD] [TERM]`
|
* `tty [LVLS] <DEV> [BAUD] [TERM] [noclear]`
|
||||||
Start a getty on the given TTY device DEV, in the given runlevels. If
|
Start a getty on the given TTY device DEV, in the given runlevels. If
|
||||||
no tty setting is given in `finit.conf` no login is possible. Use the
|
no tty setting is given in `finit.conf` no login is possible. Use the
|
||||||
`service` stanza to start a stand-alone shell for really bare bones
|
`service` stanza to start a stand-alone shell for really bare bones
|
||||||
|
|||||||
+3
-3
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#define NUM_ARGS 16
|
#define NUM_ARGS 16
|
||||||
|
|
||||||
int getty(char *tty, char *baud, char *term, char *user);
|
int getty(char *tty, char *baud, char *term, int noclear, char *user);
|
||||||
|
|
||||||
|
|
||||||
/* Wait for process completion, returns status of waitpid(2) syscall */
|
/* Wait for process completion, returns status of waitpid(2) syscall */
|
||||||
@@ -212,7 +212,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t run_getty(char *tty, char *speed, char *term, int console)
|
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int console)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
@@ -230,7 +230,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, NULL));
|
_exit(getty(tty, speed, term, noclear, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
|
|||||||
+5
-6
@@ -63,7 +63,7 @@ static int readch(char *tty)
|
|||||||
return ch1 & 0xFF;
|
return ch1 & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stty(int fd, speed_t speed)
|
static void stty(int fd, speed_t speed, int noclear)
|
||||||
{
|
{
|
||||||
struct termios term;
|
struct termios term;
|
||||||
|
|
||||||
@@ -98,9 +98,8 @@ static void stty(int fd, speed_t speed)
|
|||||||
term.c_cc[VERASE] = CERASE;
|
term.c_cc[VERASE] = CERASE;
|
||||||
tcsetattr(fd, TCSANOW, &term);
|
tcsetattr(fd, TCSANOW, &term);
|
||||||
|
|
||||||
/* Clear screen in silent mode */
|
if (!noclear)
|
||||||
if (log_is_silent())
|
print("\e[r\e[H\e[J");
|
||||||
print("\033[r\033[H\033[J");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -291,7 +290,7 @@ static speed_t do_parse_speed(char *baud)
|
|||||||
return B0;
|
return B0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getty(char *tty, char *baud, char *term, char *user)
|
int getty(char *tty, char *baud, char *term, int noclear, char *user)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char name[30];
|
char name[30];
|
||||||
@@ -328,7 +327,7 @@ int getty(char *tty, char *baud, char *term, char *user)
|
|||||||
sa.sa_handler = _exit;
|
sa.sa_handler = _exit;
|
||||||
sigaction(SIGQUIT, &sa, NULL);
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
|
|
||||||
stty(fd, speed);
|
stty(fd, speed, noclear);
|
||||||
close(fd);
|
close(fd);
|
||||||
utmp_set_login(tty, NULL);
|
utmp_set_login(tty, NULL);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ void set_hostname (char **hostname);
|
|||||||
int complete (char *cmd, int pid);
|
int complete (char *cmd, int pid);
|
||||||
int run (char *cmd);
|
int run (char *cmd);
|
||||||
int run_interactive (char *cmd, char *fmt, ...);
|
int run_interactive (char *cmd, char *fmt, ...);
|
||||||
pid_t run_getty (char *tty, char *speed, char *term, int console);
|
pid_t run_getty (char *tty, char *speed, char *term, int noclear, int console);
|
||||||
int run_parts (char *dir, char *cmd);
|
int run_parts (char *dir, char *cmd);
|
||||||
|
|
||||||
static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ static pid_t fallback = 0;
|
|||||||
static LIST_HEAD(, tty_node) tty_list = LIST_HEAD_INITIALIZER();
|
static LIST_HEAD(, tty_node) tty_list = LIST_HEAD_INITIALIZER();
|
||||||
|
|
||||||
|
|
||||||
/* tty [!1-9,S] <DEV> [BAUD[,BAUD,...]] [TERM] */
|
/* tty [!1-9,S] <DEV> [BAUD[,BAUD,...]] [TERM] [noclear] */
|
||||||
int tty_register(char *line)
|
int tty_register(char *line)
|
||||||
{
|
{
|
||||||
tty_node_t *entry;
|
tty_node_t *entry;
|
||||||
int insert = 0;
|
int insert = 0, noclear = 0;
|
||||||
char *tok, *dev = NULL, *baud = NULL;
|
char *tok, *dev = NULL, *baud = NULL;
|
||||||
char *runlevels = NULL, *term = NULL;
|
char *runlevels = NULL, *term = NULL;
|
||||||
|
|
||||||
@@ -65,6 +65,8 @@ int tty_register(char *line)
|
|||||||
dev = tok;
|
dev = tok;
|
||||||
else if (isdigit(tok[0]))
|
else if (isdigit(tok[0]))
|
||||||
baud = tok;
|
baud = tok;
|
||||||
|
else if (!strcmp(tok, "noclear"))
|
||||||
|
noclear = 1;
|
||||||
else
|
else
|
||||||
term = tok;
|
term = tok;
|
||||||
|
|
||||||
@@ -87,6 +89,7 @@ int tty_register(char *line)
|
|||||||
entry->data.name = strdup(dev);
|
entry->data.name = strdup(dev);
|
||||||
entry->data.baud = baud ? strdup(baud) : NULL;
|
entry->data.baud = baud ? strdup(baud) : NULL;
|
||||||
entry->data.term = term ? strdup(term) : NULL;
|
entry->data.term = term ? strdup(term) : NULL;
|
||||||
|
entry->data.noclear = noclear;
|
||||||
entry->data.runlevels = conf_parse_runlevels(runlevels);
|
entry->data.runlevels = conf_parse_runlevels(runlevels);
|
||||||
_d("Registering tty %s at %s baud with term=%s on runlevels %s",
|
_d("Registering tty %s at %s baud with term=%s on runlevels %s",
|
||||||
dev, baud ?: "NULL", term ?: "N/A", runlevels ?: "[2-5]");
|
dev, baud ?: "NULL", term ?: "N/A", runlevels ?: "[2-5]");
|
||||||
@@ -212,7 +215,7 @@ void tty_start(finit_tty_t *tty)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tty->pid = run_getty(dev, tty->baud, tty->term, is_console);
|
tty->pid = run_getty(dev, tty->baud, tty->term, tty->noclear, is_console);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tty_stop(finit_tty_t *tty)
|
void tty_stop(finit_tty_t *tty)
|
||||||
|
|||||||
Reference in new issue
Block a user