I am trying to understand how setuid works. So far my understanding is that a process which executes the file on which the setuid is applied is run as if the owner of the file executed it irrespective of who actually did it.But why not just set the execute permission for all (after all I assume that is what happens effectively)? I probably am missing something obvious here?
Setting up setuid VS giving execute permissions
linux
Yes, you're missing something obvious.When you run cat (or ls, sed, awk, vi, or any other ordinary program),you run it as yourself, so the program/process is constrainedby your permissions. When you run a setuid program like passwd,the process runs with a UID of root, so that it can modify /etc/shadow(which you, running under your own UID, cannot access -- not even read).