Skip to content

fix: chown run_dir so non-root run_as can use the temp dir - #2

Merged
ZhongmingFan merged 1 commit into
bklitefrom
cursor/bklite-script-rundir-chown-746d
Sep 28, 2026
Merged

ZhongmingFan merged 1 commit into
bklitefrom
cursor/bklite-script-rundir-chown-746d

Conversation

@ZhongmingFan

Copy link
Copy Markdown

Summary

When Telegraf starts as root and run_as is a non-root user, inputs.bklite_script created $TMPDIR/bklite_script (or run_dir) as root:root 0700 before resolving credentials. Only the temp script file was chowned. CreateTemp and the dropped-privilege child then got Permission denied on that directory.

Init now resolves run_as uid/gid first, creates run_dir with mode 0700, then chowns that directory to the target user (and chmod 0700 so the owner can use it). Temp-script chownScript is unchanged.

This also covers a leftover root-owned 0700 directory from a previous start: after drop, the non-root user can create and run files under run_dir.

Unix-only chown (Windows stub is a no-op, same as chownScript). Unit tests mock os.Chown so they do not require root.

Checklist

  • No AI generated code was used in this PR

Related issues

No linked GitHub issue.

Open in Web Open in Cursor 

Resolve run_as uid/gid during Init, create run_dir, then chown it to
that user (mode 0700). A leftover root-owned 0700 directory no longer
blocks CreateTemp or the dropped-privilege child. Temp-script chown
is unchanged.

Co-authored-by: ZhongmingFan <ZhongmingFan@users.noreply.github.com>
@ZhongmingFan
ZhongmingFan merged commit 197dc6f into bklite Sep 28, 2026
1 of 2 checks passed
@ZhongmingFan
ZhongmingFan deleted the cursor/bklite-script-rundir-chown-746d branch September 28, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant