Let's say I want to spawn a process from a daemon (running as root) using exec() and fork(), and that I also want to impersonate a different user before spawning the process using seteuid() and setegid(). If I also want to inherit the environmental variables set for that particular user, what's the best way you can suggest to do so ? Is there also another way without invoking a /sbin/sh and/or sudo ?
Would like to do that either on Linux and on Mac OS X !
Thanks !