mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 13:02:37 +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>
80 lines
3.4 KiB
Bash
Executable File
80 lines
3.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify duplicate section titles. The title is the service identity,
|
|
# and libconfuse merges two sections that share one, silently folding
|
|
# two declarations into a single service. A file doing that is
|
|
# rejected. Across files the same title is still how an administrator
|
|
# overrides a system .conf, so that has to keep working.
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
# shellcheck disable=SC2034
|
|
BOOTSTRAP="service service.sh {
|
|
description = \"Base\"
|
|
runlevel = \"S12345\"
|
|
command = \"service.sh\"
|
|
}"
|
|
|
|
test_teardown()
|
|
{
|
|
say "Running test teardown."
|
|
run "rm -f $FINIT_RCSD/dup.conf $FINIT_RCSD/override.conf"
|
|
}
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/lib/setup.sh"
|
|
|
|
say 'The service from the bootstrap file is running'
|
|
retry 'assert_num_children 1 service.sh'
|
|
assert_desc "Base" service.sh
|
|
|
|
# Written as two blocks the file used to load as one service, gated by
|
|
# whichever if came last. Rejecting the file makes that visible.
|
|
say 'Two blocks with one title are rejected, and the file loads nothing'
|
|
run "echo 'service dupsvc {' > $FINIT_RCSD/dup.conf"
|
|
run "echo ' if = \"service.sh\"' >> $FINIT_RCSD/dup.conf"
|
|
run "echo ' command = \"serv -np -i dupsvc\"' >> $FINIT_RCSD/dup.conf"
|
|
run "echo '}' >> $FINIT_RCSD/dup.conf"
|
|
run "echo 'service dupsvc {' >> $FINIT_RCSD/dup.conf"
|
|
run "echo ' if = \"nosuchservice\"' >> $FINIT_RCSD/dup.conf"
|
|
run "echo ' command = \"serv -np -i dupsvc\"' >> $FINIT_RCSD/dup.conf"
|
|
run "echo '}' >> $FINIT_RCSD/dup.conf"
|
|
run "initctl reload"
|
|
|
|
assert_loaded dupsvc 0
|
|
|
|
# A rejected file must not reach the legacy parser either, and the
|
|
# rest of the configuration has to survive it.
|
|
say 'The other .conf files are unaffected'
|
|
retry 'assert_num_children 1 service.sh'
|
|
assert_desc "Base" service.sh
|
|
|
|
# Detection of the format has to stay syntactic for this: a probe that
|
|
# answers "not block format" on a duplicate title would hand the file
|
|
# to the legacy parser, which registers a bogus service per line.
|
|
say 'A distinct title in the same file loads as its own service'
|
|
run "rm -f $FINIT_RCSD/dup.conf"
|
|
run "echo 'service dupsvc:1 {' > $FINIT_RCSD/dup.conf"
|
|
run "echo ' command = \"serv -np -i dupsvc1\"' >> $FINIT_RCSD/dup.conf"
|
|
run "echo '}' >> $FINIT_RCSD/dup.conf"
|
|
run "echo 'service dupsvc:2 {' >> $FINIT_RCSD/dup.conf"
|
|
run "echo ' command = \"serv -np -i dupsvc2\"' >> $FINIT_RCSD/dup.conf"
|
|
run "echo '}' >> $FINIT_RCSD/dup.conf"
|
|
run "initctl reload"
|
|
|
|
retry 'assert_loaded dupsvc:1 1'
|
|
assert_loaded dupsvc:2 1
|
|
|
|
# finit.d is read after finit.conf, so the later declaration of the
|
|
# same identity replaces the earlier one. This is the override path,
|
|
# and it is a different file, so no duplicate title is involved.
|
|
say 'The same title in another file overrides, it does not conflict'
|
|
run "echo 'service service.sh {' > $FINIT_RCSD/override.conf"
|
|
run "echo ' description = \"Override\"' >> $FINIT_RCSD/override.conf"
|
|
run "echo ' command = \"service.sh\"' >> $FINIT_RCSD/override.conf"
|
|
run "echo '}' >> $FINIT_RCSD/override.conf"
|
|
run "initctl reload"
|
|
|
|
retry 'assert_desc "Override" service.sh'
|
|
assert_num_children 1 service.sh
|