mirror of
https://github.com/troglobit/finit.git
synced 2026-10-11 17:02:42 +07:00
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:
@@ -34,6 +34,7 @@ EXTRA_DIST += cond-start-task.sh
|
||||
EXTRA_DIST += conf-format.sh
|
||||
EXTRA_DIST += conf-command.sh
|
||||
EXTRA_DIST += conf-provides.sh
|
||||
EXTRA_DIST += conf-tty.sh
|
||||
EXTRA_DIST += conf-dup-title.sh
|
||||
EXTRA_DIST += conf-dirs.sh
|
||||
EXTRA_DIST += conf-if.sh
|
||||
@@ -86,6 +87,7 @@ TESTS += cond-start-task.sh
|
||||
TESTS += conf-format.sh
|
||||
TESTS += conf-command.sh
|
||||
TESTS += conf-provides.sh
|
||||
TESTS += conf-tty.sh
|
||||
TESTS += conf-dup-title.sh
|
||||
TESTS += conf-dirs.sh
|
||||
TESTS += conf-if.sh
|
||||
|
||||
@@ -15,14 +15,6 @@ BOOTSTRAP="service service.sh {
|
||||
command = \"service.sh\"
|
||||
}"
|
||||
|
||||
# initctl status prints a detail block for a single match and a table
|
||||
# only for several, so count lines in the full listing instead.
|
||||
assert_loaded()
|
||||
{
|
||||
assert "Service $1 loaded: $2" \
|
||||
"$(texec initctl -t status | awk -v n="$1" '$2 == n' | wc -l)" -eq "$2"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Running test teardown."
|
||||
|
||||
@@ -43,14 +43,6 @@ service mixed {
|
||||
command = \"serv -np -i mixed\"
|
||||
}"
|
||||
|
||||
# initctl status prints a detail block for a single match and a table
|
||||
# only for several, so count lines in the full listing instead.
|
||||
assert_loaded()
|
||||
{
|
||||
assert "Service $1 loaded: $2" \
|
||||
"$(texec initctl -t status | awk -v n="$1" '$2 == n' | wc -l)" -eq "$2"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Running test teardown."
|
||||
|
||||
@@ -32,14 +32,6 @@ service downstream {
|
||||
command = \"serv -np -i downstream\"
|
||||
}"
|
||||
|
||||
# initctl status prints a detail block for a single match and a table
|
||||
# only for several, so count lines in the full listing instead.
|
||||
assert_loaded()
|
||||
{
|
||||
assert "Service $1 loaded: $2" \
|
||||
"$(texec initctl -t status | awk -v n="$1" '$2 == n' | wc -l)" -eq "$2"
|
||||
}
|
||||
|
||||
# The IDENT column of 'initctl cond dump' names the owner of a
|
||||
# condition, which for a provided one is the service that claimed it.
|
||||
assert_provider()
|
||||
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/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
|
||||
@@ -41,6 +41,16 @@ assert_num_services()
|
||||
assert "$1 services are loaded" "$(texec initctl -t status "$2" | wc -l)" -eq "$1"
|
||||
}
|
||||
|
||||
# Unlike assert_num_services() this matches the identity exactly, so
|
||||
# 'foo' does not count 'foobar', and an instance must be spelled out as
|
||||
# 'foo:1'. initctl status prints a detail block for a single match and
|
||||
# a table only for several, hence counting lines in the full listing.
|
||||
assert_loaded()
|
||||
{
|
||||
assert "Service $1 loaded: $2" \
|
||||
"$(texec initctl -t status | awk -v n="$1" '$2 == n' | wc -l)" -eq "$2"
|
||||
}
|
||||
|
||||
assert_forking()
|
||||
{
|
||||
assert "service $1 forking:$2" "$(texec initctl -j status "$1" | jq -M .forking)" = "$2"
|
||||
|
||||
Reference in New Issue
Block a user