Open daniellawson opened 6 years ago
Daniel, totally right. I'm one of those people that usually runs netperf as root. :) Have time to submit a patch that uses umask instead of chmod? (That way you get credit for spotting+fixing this)
For those not wanting to search further, the following should work on most distros:
$ sudo -u nobody netserver
On non-Windows systems, if you run netserver without the -d parameter, it sets the debug output file 'FileName' to /dev/null
eg, see open_debug_file() in netserver.c:259
Later on in the same function, it then calls chmod(FileName,0644); (netserver.c:281). If the executing user has the right permissions (eg, is root), netserver will change the permissions on /dev/null which may then cause other issues on the machine, as many non-root processes assume they can write to /dev/null
Arguably, no one should be running netserver as root, but there are plenty of people who do.
I'm not entirely sure why the chmod call is needed - I suspect setting a better umask on netserver in general, or at least when opening the debug log file, would be better. The other improvement would be that instead of continuing to write debug logs to /dev/null, to just not write them out at all. But I've only just skimmed the source, I don't think I fully understand the way debug logging is implemented