mirror of
https://github.com/troglobit/finit.git
synced 2026-11-20 19:41:51 +00:00
service: lift the limit of four supplementary groups
A service listing more than four supplementary groups, as in
@user:group,sup1,sup2,..., got only the first four:
too many supplementary groups, max 4
The names were stored in a fixed array of four. It was also only
reset when the new configuration listed groups, so groups dropped from
a service lingered until reboot.
Store the list as one string, split when the service starts, and set
it on every (re)registration. A list longer than 511 characters drops
the name it cuts off, which may otherwise match another group.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
(cherry picked from commit de73b06415)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
5 files changed
+71
-22
No files matched your search
@@ -42,6 +42,7 @@ EXTRA_DIST += global-envs.sh
|
||||
EXTRA_DIST += initctl-status-subset.sh
|
||||
EXTRA_DIST += notify.sh
|
||||
EXTRA_DIST += pidfile.sh
|
||||
EXTRA_DIST += conf-groups.sh
|
||||
EXTRA_DIST += option-lookalike.sh
|
||||
EXTRA_DIST += pidfile-stopped.sh
|
||||
EXTRA_DIST += stale-pidfile.sh
|
||||
@@ -90,6 +91,7 @@ TESTS += global-envs.sh
|
||||
TESTS += initctl-status-subset.sh
|
||||
TESTS += notify.sh
|
||||
TESTS += pidfile.sh
|
||||
TESTS += conf-groups.sh
|
||||
TESTS += option-lookalike.sh
|
||||
TESTS += pidfile-stopped.sh
|
||||
TESTS += stale-pidfile.sh
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
# Verify supplementary groups, @user:group,sup1,sup2,..., are all set on
|
||||
# the service, and that dropping them drops the groups.
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
|
||||
# Optional argument is the supplementary group list, ",sup1,sup2,..."
|
||||
write_conf()
|
||||
{
|
||||
run "echo 'service @root:root${1:-} name:grp serv -np -i grp -- Groups' > $FINIT_CONF"
|
||||
}
|
||||
|
||||
# Kernel sorts the list, so it compares as a plain string.
|
||||
assert_groups()
|
||||
{
|
||||
pid=$(texec initctl -j status grp | jq .pid)
|
||||
assert "Service groups == $1" \
|
||||
"$(texec cat "/proc/$pid/status" | sed -n 's/^Groups:[[:space:]]*//p' | xargs)" = "$1"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/lib/setup.sh"
|
||||
|
||||
say 'Seven supplementary groups'
|
||||
write_conf ',daemon,bin,sys,adm,tty,disk,dialout'
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 serv'
|
||||
retry 'assert_groups "0 1 2 3 4 5 6 20"'
|
||||
|
||||
# The running process keeps its groups, the next start drops them
|
||||
say 'Dropping supplementary groups drops the groups'
|
||||
write_conf
|
||||
run "initctl reload"
|
||||
run "initctl restart grp"
|
||||
|
||||
retry 'assert_groups "0"'
|
||||
Reference in new issue
Block a user