I'd like to fork and exec and program as a non root user while the parent retains root permissions.
pseudo code:
pid = fork();
if (pid == 0) {
if (RunAsUser(ConvertStringToUserId("John")) == false) {
stop();
}
if (RunAsUser(ConvertStringToUserId("admin")) == true) {
stop();
}
CreateProcess();
}
If you want to drop privileges in C code, use the function setuid
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With