$ ls -l /usr/bin/sudo
-rwsr-xr-x 1 root root 136808 Jul 4 2017 /usr/bin/sudo
so sudo
is runnable by any user, and any user who runs sudo
will have root as the effective user ID of the process because the set-user-id bit of /usr/bin/sudo
is set.
From https://unix.stackexchange.com/a/11287/674
the most visible difference between sudo and su is that sudo requires the user's password and su requires root's password.
Which user's password does
sudo
asks for? Is it the user represented by the real user ID of the process?If yes, doesn't any user can gain the superuser privilege by running
sudo
and then providing their own password? Can Linux restrict that on some users?Is it correct that
sudo
asks for the password afterexecve()
starts to executemain()
of/usr/bin/sudo
?Since the euid of the process has been changed to root (because the set-user-id bit of /usr/bin/sudo is set), what is the point of sudo asking for password later?
Thanks.
I have read https://unix.stackexchange.com/a/80350/674, but it doesn't answer the questions above.