The previous implementation attempted to set GID after dropping root UID, which would fail (silently) and made the posix_setgid() call effectively a no-op. This swaps the order to set the target GID first.
Also refactored for clarity:
- Renamed dropPrivileges to switchToConfigFileOwner for clearer intent
- Update docblock to explicitly state best-effort limitations
- Use more descriptive variable names
- Re-organized for readability
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>