03-3-perms
03-3-perms
Jan Schaumann
[email protected]
https://stevens.netmeister.org/631/
CS631 - Advanced Programming in the UNIX Environment
The st_mode also encodes the file access permissions (S_IRUSR, S_IWUSR,
S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH). Uses of
the permissions are summarized as follows:
• To open a file, need execute permission on each directory component of the path.
• To open a file with O_RDONLY or O_RDWR, need read permission.
• To open a file with O_WRONLY or O_RDWR, need write permission.
• To use O_TRUNC, must have write permission.
• To create a new file, must have write+execute permission for the directory.
• To delete a file, need write+execute on directory, file doesn’t matter.
• To execute a file (via exec family), need execute permission.
2
Jan Schaumann 2020-09-13
CS631 - Advanced Programming in the UNIX Environment
4
Jan Schaumann 2020-09-13
CS631 - Advanced Programming in the UNIX Environment
We've learned all about permissions and file ownership and how access decisions are
made.
We note that the order of checks is fixed and important; as a result, it's possible to
create fine-grained access controls through group membership and carefully set file
permissions.
Coming up next: using the syscalls that set the file permissions and ownerships. (Yay,
more code!)
5
Jan Schaumann 2020-09-13