summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/InodeMetadata.cpp
blob: 6cbfb157feecc24b9d202168d7e2e6ff998b5227 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/Tasks/Process.h>

namespace Kernel {

bool InodeMetadata::may_read(Credentials const& credentials, UseEffectiveIDs use_effective_ids) const
{
    bool eids = use_effective_ids == UseEffectiveIDs::Yes;
    return may_read(eids ? credentials.euid() : credentials.uid(), eids ? credentials.egid() : credentials.gid(), credentials.extra_gids());
}

bool InodeMetadata::may_write(Credentials const& credentials, UseEffectiveIDs use_effective_ids) const
{
    bool eids = use_effective_ids == UseEffectiveIDs::Yes;
    return may_write(eids ? credentials.euid() : credentials.uid(), eids ? credentials.egid() : credentials.gid(), credentials.extra_gids());
}

bool InodeMetadata::may_execute(Credentials const& credentials, UseEffectiveIDs use_effective_ids) const
{
    bool eids = use_effective_ids == UseEffectiveIDs::Yes;
    return may_execute(eids ? credentials.euid() : credentials.uid(), eids ? credentials.egid() : credentials.gid(), credentials.extra_gids());
}

}