Thread: Testing super user
i want test if current user super user. think root super user. true that, root super user?
here simple algorithm:
i pretty sure not way. can tell me how can current user super user or not.code:#include <iostream> #include <string> #include <cstdlib> using namespace std; int main() { string name = getenv("user"); if(name == "root") cout << "super user\n"; else cout << "not super user\n"; return 0; }
in advance.![]()
ha! don't use user comparisons; environment variable can spoofed.
use geteuid() or getuid() instead. tend see applications use former.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Testing super user
Ubuntu
Comments
Post a Comment