root launch
Posted: Sun Oct 20, 2024 10:30 am
How do I know if a program is running as an administrator, superuser?
Code: Select all
OpenConsole()
PrintN("Real user ID: " + Str(getuid_()))
PrintN("Effective user ID: " + Str(geteuid_()))
PrintN("Real group ID: " + Str(getgid_()))
PrintN("Effective group ID: " + Str(getegid_()))
CloseConsole()$ ./tmp/showuserid
Real user ID: 1000
Effective user ID: 1000
Real group ID: 1000
Effective group ID: 1000
And if the executable owner is root and the setuid bit is set it can look like this:$ sudo ./tmp/showuserid
[sudo] Passwort für nicolas:
Real user ID: 0
Effective user ID: 0
Real group ID: 0
Effective group ID: 0
In this case you can differentiate between the user that executed the program and the one who is the owner of the executable.$ sudo chown root:root tmp/showuserid
$ sudo chmod +s ./tmp/showuserid
$ ./tmp/showuserid
Real user ID: 1000
Effective user ID: 0
Real group ID: 1000
Effective group ID: 0