conf: add missing passenv to tty blocks

The line-based format has had the flag since v4.4 (issue #286), where
it prepends -p to the built-in getty, which turns it into login -p and
passes the environment on.  The block format was written from the three
documented tty variants and the flags listed in the tty documentation,
and passenv was in neither, so it was left out.  Converting a tty line
that used it therefore lost it, with nothing said.

It only reaches the built-in getty.  An external getty is handed its
arguments through command, so there is nowhere to put a -p, and the
setting is refused with a warning rather than quietly ignored.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-08-05 17:59:11 +02:00
parent 96c5b4b031
commit 6b77a16f8b
10 changed files with 109 additions and 24 deletions
+15
View File
@@ -313,6 +313,7 @@ static cfg_opt_t tty_opts[] = {
CFG_BOOL ("noclear", cfg_false, CFGF_NODEFAULT),
CFG_BOOL ("nowait", cfg_false, CFGF_NODEFAULT),
CFG_BOOL ("nologin", cfg_false, CFGF_NODEFAULT),
CFG_BOOL ("passenv", cfg_false, CFGF_NODEFAULT),
CFG_STR_LIST("command", NULL, CFGF_NODEFAULT), /* candidates, see svc_command() */
CFG_BOOL ("notty", cfg_false, CFGF_NODEFAULT),
CFG_BOOL ("rescue", cfg_false, CFGF_NODEFAULT),
@@ -1748,6 +1749,20 @@ static void tty_translate(cfg_t *sec, struct rlimit rlimit[], char *file)
if (sec_getbool(sec, "nologin", NULL))
addtok(line, sizeof(line), "nologin");
/*
* passenv is handed to the built-in getty as -p, which it turns
* into login -p. An external getty gets its arguments from
* command, so there is nowhere to put it.
*/
if (sec_getbool(sec, "passenv", NULL)) {
if (dev || !cmd)
addtok(line, sizeof(line), "passenv");
else
logit(LOG_WARNING, "%s: %s: passenv applies to the"
" built-in getty, pass -p in command instead,"
" ignoring", file, cfg_title(sec));
}
if (dev && (str = sec_getstr(sec, "term", NULL)))
addtok(line, sizeof(line), "%s", str);