mininet/mininet — pull request #30 by lantz (2012-03-14 07:09:25+00:00)
Title: Patches/sudo

So, this may be slightly controversial, but I'm inclined to merge it in.

Basically, if we use sudo mn and make quietRun use sudo, then we can run the Mininet master process as a regular user (assuming that user can run sudo -n.) The advantages are:

1) mininet can be imported as a library into python code that isn't running as root
2) we can run mn without being root

The disadvantages are that

1) existing mininet scripts which assume you're running as root may fail - unless they use quietRun, which Ed conveniently changed to run sudo! It's kind of crafty, actually...

2) fixLimits can't raise the hard limit using setrlimit() if you're not root, leading to possible failures as non-root which won't happen as root; perhaps this is bad behavior and we should not even try to raise the limit?

I have to say there is a sort of fascinating feature of Unix/Linux which is that I'm unaware of an easy way for non-root processes to gain root privileges in the middle of execution, even if the user can provide the root password or can sudo without a password. In theory it should be possible to exec a sudo process which magically reattaches all of your resources and allows you to run as root and then calls seteuid() to drop privileges, but that is a project for another day. I'd really just prefer a sudo() system call - I wonder if OS X has one?