in reply to running cgi as user other than nobody

Before heading off into setuid land, I suggest figuring out why you're having permission problems.

As long as you're writing into a directory that's 777, your CGI should be able to chmod. Check your directory permission, and double-check that the file path you're passing to chmod is exactly the same as the file you just created.