1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:17:35 +00:00

Kernel: Allow 'elevating' unveil permissions if implicitly inherited from '/'

This can happen when an unveil follows another with a path that is a
sub-path of the other one:
```c++
unveil("/home/anon/.config/whoa.ini", "rw");
unveil("/home/anon", "r"); // this would fail, as "/home/anon" inherits
                           // the permissions of "/", which is None.
```
This commit is contained in:
AnotherTest 2020-12-26 17:54:01 +03:30 committed by Andreas Kling
parent 3be9a9ac76
commit 7b5aa06702
3 changed files with 14 additions and 5 deletions

View file

@ -41,15 +41,19 @@ enum UnveilAccess {
None = 0,
};
struct UnveilNode;
struct UnveilMetadata {
String full_path;
UnveilAccess permissions { None };
bool explicitly_unveiled { false };
bool unveil_inherited_from_root { false }; // true if permissions are inherited from the tree root (/).
};
struct UnveilNode final : public AK::Trie<String, UnveilMetadata, Traits<String>, UnveilNode> {
using AK::Trie<String, UnveilMetadata, Traits<String>, UnveilNode>::Trie;
bool permissions_inherited_from_root() const { return this->metadata_value().unveil_inherited_from_root; }
bool was_explicitly_unveiled() const { return this->metadata_value().explicitly_unveiled; }
UnveilAccess permissions() const { return this->metadata_value().permissions; }
const String& path() const { return this->metadata_value().full_path; }