System Programming: Can D binaries be set suid root without the risk of unwanted privilege escalation?
Forum User
forumuser at example.com
Thu Aug 20 14:16:47 UTC 2026
On Monday, 16 February 2026 at 01:24:59 UTC, Julian Fondren wrote:
Thanks for the thorough answers and the link.
> [..] For example, suppose you have a setuid program that edits
> /home/$user/somedir/somefile . If you do this straightforwardly
> in D you open yourself up to a ton of potential race conditions
> that can result in you editing or deleting random files across
> the filesystem, or pulling secrets and exposing them to the
> user.
Such access I would usually perform with the effective user and
effective group set to $user (`seteuid`, `setegid`). For some
edge cases the supplementary groups must also be set (assume a
`root:video` owned file `data` has permissions `0704` and assume
the accessing user either has or has not `video` in its
supplementary groups list: In the first case they cannot access
`data` while in the second they can via `o=r` permission.)
More information about the Digitalmars-d
mailing list