mirror of
https://github.com/troglobit/finit.git
synced 2026-11-07 16:01:08 +00:00
tty: add support for 'passenv' flag to /bin/login
This change makes it possible tell the bundled/built-in getty to call /bin/login with the '-p' flag, to preserve any environment set in the Finit .conf files. Issue #286 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
2a98b2f055
commit
d904ec1602
2 files changed
+20
-3
No files matched your search
+9
-2
@@ -49,6 +49,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static long logname_len = 32; /* useradd(1) limit at 32 chars */
|
static long logname_len = 32; /* useradd(1) limit at 32 chars */
|
||||||
|
static int passenv = 0; /* Set /bin/login -p or not */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read one character from stdin.
|
* Read one character from stdin.
|
||||||
@@ -185,7 +186,10 @@ static int do_login(char *name)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
execl(_PATH_LOGIN, _PATH_LOGIN, name, NULL);
|
if (passenv)
|
||||||
|
execl(_PATH_LOGIN, _PATH_LOGIN, "-p", name, NULL);
|
||||||
|
else
|
||||||
|
execl(_PATH_LOGIN, _PATH_LOGIN, name, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Failed to exec login, should not happen on normal systems.
|
* Failed to exec login, should not happen on normal systems.
|
||||||
@@ -252,11 +256,14 @@ int main(int argc, char *argv[])
|
|||||||
char *tty, *speed = "0", *term = NULL;
|
char *tty, *speed = "0", *term = NULL;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "h?")) != EOF) {
|
while ((c = getopt(argc, argv, "h?p")) != EOF) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
return usage(0);
|
return usage(0);
|
||||||
|
case 'p':
|
||||||
|
passenv = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return usage(1);
|
return usage(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ char *tty_atcon(void)
|
|||||||
int tty_parse_args(char *cmd, struct tty *tty)
|
int tty_parse_args(char *cmd, struct tty *tty)
|
||||||
{
|
{
|
||||||
char *dev = NULL;
|
char *dev = NULL;
|
||||||
|
int passenv = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -165,6 +166,8 @@ int tty_parse_args(char *cmd, struct tty *tty)
|
|||||||
tty->nologin = 1;
|
tty->nologin = 1;
|
||||||
else if (!strcmp(cmd, "notty"))
|
else if (!strcmp(cmd, "notty"))
|
||||||
tty->notty = 1; /* for board bringup */
|
tty->notty = 1; /* for board bringup */
|
||||||
|
else if (!strcmp(cmd, "passenv"))
|
||||||
|
passenv = 1;
|
||||||
else if (!strcmp(cmd, "rescue"))
|
else if (!strcmp(cmd, "rescue"))
|
||||||
tty->rescue = 1; /* for rescue shells */
|
tty->rescue = 1; /* for rescue shells */
|
||||||
else if (whichp(cmd)) /* in $PATH? */
|
else if (whichp(cmd)) /* in $PATH? */
|
||||||
@@ -228,8 +231,15 @@ int tty_parse_args(char *cmd, struct tty *tty)
|
|||||||
tty->dev, tty->baud ?: "0", tty->term ?: "N/A");
|
tty->dev, tty->baud ?: "0", tty->term ?: "N/A");
|
||||||
|
|
||||||
/* Built-in getty now comes as standalone program */
|
/* Built-in getty now comes as standalone program */
|
||||||
if (!tty->cmd)
|
if (!tty->cmd) {
|
||||||
|
if (passenv && tty->num < NELEMS(tty->args)) {
|
||||||
|
for (i = tty->num; i > 0; i--)
|
||||||
|
tty->args[i] = tty->args[i - 1];
|
||||||
|
tty->args[0] = "-p";
|
||||||
|
tty->num++;
|
||||||
|
}
|
||||||
tty->cmd = _PATH_GETTY;
|
tty->cmd = _PATH_GETTY;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user