fix(telegraf): correct supplementary group handling when dropping privileges#903
Open
skartikey wants to merge 1 commit into
Open
fix(telegraf): correct supplementary group handling when dropping privileges#903skartikey wants to merge 1 commit into
skartikey wants to merge 1 commit into
Conversation
…vileges
On Alpine, the base image bakes root into several default groups (bin,
daemon, sys, adm, disk, wheel, floppy, dialout, tape, video), so the
container's root process is granted them at runtime and the entrypoint's
group-forwarding loop passed all of them to the telegraf process:
$ docker run --rm telegraf:1.39-alpine id -Gn
telegraf bin daemon sys adm disk wheel floppy dialout tape video
Under su-exec the process ran with 'telegraf' only. Fix it at the source
by dropping root from those groups at build time, which also keeps
'docker run --group-add video' working (an entrypoint-side exclusion
list would silently swallow it).
In addition, seed the forwarded group list from the telegraf user's own
/etc/group memberships instead of the literal 'telegraf', restoring the
initgroups semantics su-exec provided: a derived image that adds the
telegraf user to a group no longer loses that membership, since
'setpriv --groups' replaces the supplementary set rather than extending
it. The Debian entrypoints get the same change for consistency; their
base image bakes no root memberships, so they only gain the initgroups
behaviour.
See #724.
skartikey
force-pushed
the
skartikey/telegraf-group-handling
branch
from
July 16, 2026 18:41
7ec3421 to
a82330c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #861 and the question raised in #724.
Two issues with the su-exec to setpriv migration:
Alpine images leak root's baked-in groups to telegraf. The Alpine base image puts root in
bin daemon sys adm disk wheel floppy dialout tape video, and the entrypoint loop forwards them all:Under su-exec this was
telegrafonly. Fixed at build time by dropping root from those groups, which keeps an intentional--group-add videoworking. Debian images are unaffected.setpriv --groupsreplaces the supplementary set, dropping the telegraf user's own/etc/groupmemberships (su-exec usedgetgrouplist()). Entrypoints now seed the list fromid -Gn telegraf, so derived images that add telegraf to a group keep that membership.Verified on a patched 1.39/alpine build and the Debian entrypoint: default run yields
telegrafonly;--group-add(numeric and named) and baked memberships are preserved; non-root passthrough unchanged.Now that #861 is merged,
telegraf/nightly/alpineis included and carries the identical entrypoint.