Kernel: Add unveil('b')

This is a new "browse" permission that lets you open (and subsequently list
contents of) directories underneath the path, but not regular files or any other
types of files.
This commit is contained in:
Sergey Bugaev 2020-11-21 22:55:20 +03:00 committed by Andreas Kling
commit 098070b767
Notes: sideshowbarker 2024-07-19 01:17:40 +09:00
5 changed files with 30 additions and 6 deletions

View file

@ -28,6 +28,7 @@ include the following characters:
* `w`: May write to a file at this path
* `x`: May execute a program image at this path
* `c`: May create or remove a file at this path
* `b`: May browse directories at this path
A single `unveil()` call may specify multiple permission characters at once.
Subsequent `unveil()` calls may take away permissions from the ones allowed
@ -78,6 +79,9 @@ unveil("/etc/WindowServer/WindowServer.ini", "rwc");
// Allow the process to execute Calendar:
unveil("/bin/Calendar", "x");
// Allow the process to browse files from /usr/share:
unveil("/usr/share", "b");
// Disallow any further veil manipulation:
unveil(nullptr, nullptr);
```