in reply to Re: Re: Faster way to do su
in thread Faster way to do su

Ahhh; the code watching for a password prompt from su was giving the impression you weren't root already.

If you just need to switch to a different user and you're already root then just fork, set $< to the uid of the user in question (or call POSIX::setuid), and exec the script which does the real work.

Update: OK, reading again it looks like it is nobody that'll be running this. Again, I'd see no problems with a sudo config which allows nobody to run one specific script which immediately drops to the user UID and execs another specific script to do the actual work. If you were truly paranoid you'd write a minimalist wrapper in C and make that suid root (if you're really, really paranoid you'll snip the cat5 and be done with it . . . :).

Another possibility: use suexec to run this one CGI as another not-nobody unpriviledged account which is allowed to sudo to the desired user and run the real work.