I'm confused about what effect the uid or gid has on the ability of a process to execute a file. I read the section I could find on them in APUE, but I must have missed the part where Stevens explains this. I know that the superuser has an id of 0 and can execute any file, but I am lost what happens with specific uid or gid numbers. I am also not particularly sure if uid or gid is relevant, or if euid and egid are the only things that matter?

For example, this is a question we got in class:

Assume a process with effective user id 4 and effective group id 7 tries to execute a file with user id 4, group id 9, and permissions rw-r-x--x. What will happen (and why)?

So I suppose since user write permission is not granted the process should not be able to execute the file? Or since the uid and euid are the same the process can execute the file? Where does the egid and gid come into this?


I think I figured it out, so if the euid matches the uid and user execute permissions are granted then the file will be executed. Similarly, if the egid and gid match and the gid execute bit is set or the other execute bit is set (there is no other id to check so the other execute bit suffices) the execute will go through. If none of these are true then permission will be denied.

So in the example above the the euid matches the uid, but the user execute bit is not set. The group execute bit is set, but the egid does not match the gid. But other execute bit is set, so the file will be executed successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.