This question already has an answer here:
- How do the internals of sudo work? 3 answers
This question might be stupid, but I am unable to answer it myself.
I always thought that "sudo" just starts another login-process, specifically using "root" as a username and asking for the Password to login. After running some program, it ends and logs out (or: keeps the open session for some time and then quits it). No idea where I heard that from, but that seemed reasonable to me.
But now I discovered this sudoers-option:
ALL ALL = (root) NOPASSWD: /my/command
This allows me to run any program from any user as a root without asking for any password. This left me wondering:
How does that work? How does a program gain user-rights? Does sudo need a server (running as root as daemon or so) and connects to that server, sends it what should be executed and that server executes it with root-rights?
How about other users?
Is there any good and simple explanation how this works?