running as root and changing to user nobody programmatically
Hey all.
I'm writing a program that requires being run as root (for interfacing with network card) but during runtime it no longer requires it. I'd like to setuid and setgid to the nobody user/group but don't know how to programmatically determine the UID/GID of the corresponding nobody user/group. I'm trying to avoid having the user enter the UID/GID as an additional parameter or adding it to a conf file (as it would be the only thing in the conf file). Is there a way to determine a uid/gid for nobody without asking the user for it? Thanks for any input on this! |
Have a look at the source of getent, maybe?
$ getent passwd nobody nobody:x:65534:65534:nobody:/nonexistent:/bin/sh Cheers, Tink |
man getpwent
|
Wow getpwent is precisely what I needed! Thanks much guys. I hadn't even heard of this function before.
|
Quote:
Neither - that's why I looked at getent's source ;} |
I use getpwnam and getgrnam.
Kevin Barry |
All times are GMT -5. The time now is 02:31 PM. |