Who is allowed: users, root and capabilities

: the kernel sitting between every program and the machine. This lesson is about the question the kernel asks at that door: who is asking, and are they allowed?
You run a small web server. Web browsers expect it on port 80, and Linux lets only root open a port below 1024. So you start the server as root. Months later a bug in the server lets a stranger send it a strange request. The stranger now controls a program that is root, so the stranger can read every file and change every setting on the machine. One small bug has cost you the whole computer.
By the end you will be able to read the numbers the kernel checks (who you are and what you may do), explain why a program like passwd can change a file you cannot touch, and give a server only the one power it needs instead of all of root.
The history (optional)
On 9 July 1973 Dennis Ritchie of Bell Labs filed a patent for a small idea: an extra permission bit on an executable file. When the bit is set, a person who runs the file takes on the identity of the file’s owner for as long as it runs. The US patent office granted it as number 4,135,240 on 16 January 1979. That bit is the setuid bit in this lesson.
Bob Coggeshall and Cliff Spencer wrote sudo around 1980 at SUNY Buffalo. Sources give only “around 1980”.
In June 2000 a Linux bug showed what goes wrong when the powers of root are split badly. Wojciech Purczynski found that a local user could set things up so that a setuid program, such as sendmail, could not give up its powers when it tried to. Alan Cox checked it and patched the kernel, and Linux 2.2.16 fixed it (CVE-2000-0506).
Before you start. A process is one running program, and the kernel is the program underneath all of them (Processes, Threads & the Kernel). In The tap on the shoulder a process could send a signal to another, and kill was one way to send it. This lesson explains who is allowed to do that. A fork copies a process and an exec loads a new program into it (The program that starts programs). Both come back in the setuid section.