Reading File Permission Checks by Operation

Operating systems can check permissions separately for reading, changing, or executing a file and for traversing its containing directories.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a directory entry
  2. Use an actual operation test
  3. Analyze access to the path and the operation
  4. Use the applicable account and filesystem in a test

Trace a directory entry

Knowing a filename and being able to read an ordinary file are separate from listing every name in the containing directory. On Unix-like systems directory permissions distinguish listing, traversing, and editing entries. Path resolution makes the intermediate checks visible.

Use an actual operation test

A permission check should be interpreted for the user's process identity and the exact operation. A successfully listed name can still fail to open. Open, read, and decode failures supply distinct diagnostic stages.[1]

Analyze access to the path and the operation

On a POSIX-style filesystem, opening a file for content writes and removing a directory entry involve different permission checks. Removing a name normally involves permissions on its parent directory and can depend on other rules such as a sticky bit. See directory entries and open files.

Read bytes → resolve path and check read access
Write bytes → check write access to the object
Remove name → check directory and applicable policy

Use the applicable account and filesystem in a test

Ownership, ACLs, inherited policy and administrator privileges can change the outcome. Diagnose permission errors by the operation that failed. A successful read does not establish permission to write or rename.

References

  1. Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau, Operating Systems: Three Easy Pieces ↩