Skip to main content

Thread: Testing super user


i want test if current user super user. think root super user. true that, root super user?

here simple algorithm:
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; }
i pretty sure not way. can tell me how can current user super user or not.

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

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support