I'm trying to use setuid() and setgid() to set the respective id's of a program to drop privileges down from root, but to use them I need to know the uid and gid of the user I want to change to.
Is there a system call to do this? I don't want to hardcode it or parse from /etc/passwd .
Also I'd like to do this programmatically rather than using:
id -u USERNAME
Any help would be greatly appreciated
Have a look at the getpwnam() and getgrnam() functions.