I was asked, what is the correct way to drop privileges in Linux.
So here is a list of things I usually do, when implementing unprivileged sub process:
fork
in some cases you would also want to do these:
clear the environment(leave only the required variables)
close all file descriptors(except the ones you need)
clear memory regions that are [...]