ladybird/Kernel/UnveilNode.h
Max Wipfli e8a317023d Kernel: Allow unveiling subfolders regardless of parent's permissions
This fixes a bug where unveiling a subdirectory of an already unveiled
path would sometimes be allowed and sometimes not (depending on what
other unveil calls have been made).

Now, it is always allowed to unveil a subdirectory of an already
unveiled directory, even if it has higher permissions.

This removes the need for the permissions_inherited_from_root flag in
UnveilMetadata, so it has been removed.
2021-06-08 12:15:04 +02:00

41 lines
885 B
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <AK/Trie.h>
namespace Kernel {
enum UnveilAccess {
Read = 1,
Write = 2,
Execute = 4,
CreateOrRemove = 8,
Browse = 16,
None = 0,
};
struct UnveilNode;
struct UnveilMetadata {
String full_path;
UnveilAccess permissions { None };
bool explicitly_unveiled { false };
};
struct UnveilNode final : public Trie<String, UnveilMetadata, Traits<String>, UnveilNode> {
using Trie<String, UnveilMetadata, Traits<String>, UnveilNode>::Trie;
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; }
};
}