mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
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>
72 lines
2.6 KiB
Bash
Executable File
72 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify tty block settings that have no equivalent elsewhere. The
|
|
# 'passenv' flag is handed to the built-in getty as -p, which it turns
|
|
# into 'login -p', passing the environment on to the login program.
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
# shellcheck disable=SC2034
|
|
BOOTSTRAP="tty console {
|
|
runlevel = \"12345\"
|
|
device = \"/dev/console\"
|
|
passenv = true
|
|
noclear = true
|
|
}"
|
|
|
|
# The built-in getty is exec'd with -p ahead of the device, so the flag
|
|
# is visible in the command Finit registered.
|
|
assert_cmd_has()
|
|
{
|
|
assert "Command of $1 contains '$2'" \
|
|
"$(texec initctl status "$1" | grep 'Command' | grep -c -- "$2")" -eq 1
|
|
}
|
|
|
|
test_teardown()
|
|
{
|
|
say "Running test teardown."
|
|
run "rm -f $FINIT_CONF"
|
|
}
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/lib/setup.sh"
|
|
|
|
say 'The tty block loaded, so passenv is a known setting'
|
|
retry 'assert_loaded tty:console 1'
|
|
|
|
say 'passenv reaches the built-in getty as -p'
|
|
assert_cmd_has tty:console " -p"
|
|
|
|
say 'Waiting for bootstrap to finish before rewriting the configuration'
|
|
retry "test \"\$(texec sh -c \"initctl runlevel | awk '{print \\\$2;}'\")\" = 2" 20 1
|
|
|
|
say 'Without passenv the flag is absent'
|
|
run "echo 'tty console {' > $FINIT_CONF"
|
|
run "echo ' runlevel = \"12345\"' >> $FINIT_CONF"
|
|
run "echo ' device = \"/dev/console\"' >> $FINIT_CONF"
|
|
run "echo ' noclear = true' >> $FINIT_CONF"
|
|
run "echo '}' >> $FINIT_CONF"
|
|
run "initctl reload"
|
|
|
|
retry 'assert_loaded tty:console 1'
|
|
assert "Command has no -p" \
|
|
"$(texec initctl status tty:console | grep 'Command' | grep -c -- ' -p')" -eq 0
|
|
|
|
# passenv is a built-in getty flag. An external getty takes its
|
|
# arguments from command, so there is nowhere to put it, and the
|
|
# setting is refused rather than silently dropped. Note the device
|
|
# still has to be in there: an external getty is told which TTY to
|
|
# open by its own arguments, and that is also where Finit reads it
|
|
# from to name the service.
|
|
say 'passenv with an external getty is refused, the tty still loads'
|
|
run "echo 'tty extgetty {' > $FINIT_CONF"
|
|
run "echo ' runlevel = \"12345\"' >> $FINIT_CONF"
|
|
run "echo ' command = \"/bin/sh /dev/console\"' >> $FINIT_CONF"
|
|
run "echo ' passenv = true' >> $FINIT_CONF"
|
|
run "echo '}' >> $FINIT_CONF"
|
|
run "initctl reload"
|
|
|
|
retry 'assert_loaded tty:console 1'
|
|
assert "external getty command has no -p" \
|
|
"$(texec initctl status tty:console | grep 'Command' | grep -c -- ' -p')" -eq 0
|