En algún momento, está en el código. Por ejemplo, a mitad de camino hwclock.c
, encontrarás:
if (getuid() == 0)
permitted = TRUE;
else {
/* program is designed to run setuid (in some situations) */
if (set || systohc || adjust) {
warnx(_("Sorry, only the superuser can change "
"the Hardware Clock."));
[...]
lo que cambiará el comportamiento del programa si eres root o no.
In most other cases, it's implicit; delegated to the kernel. For example, if the program calls the system call that let you reboot the system, it will work only if you are root. If you are not root, you will have a "permission denied" error that the application (if well written) simply reports to you. Or you are trying to delete a file; if you have the right permission on the file to do it, it will succeed; if not, it depends if you are root or not --- when rm
calls unlink()
the kernel will check permissions.
So no, in principle you can't say just looking at the permission of the executable if the program requires root privileges or not. A lot of programs will require them only for some operation, so it will be really difficult to do something like that. The case of hwclock
is one (anyone can read the clock but only root can set it), but there are hundreds of them (kill
, rm
, cat
... )
Then there is the related and interesting world of setuid programs...
/bin
o/sbin
directorios. El problema es que algunos de esos programas se ejecutan de manera diferente según el usuario que los ejecute.