roar
Loading...
Searching...
No Matches
jail.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <optional>
5
6namespace Roar
7{
11 class Jail
12 {
13 public:
19 Jail(std::filesystem::path const& jailRoot);
20
24 bool isWithinJail(std::filesystem::path const& other) const;
25
29 std::optional<std::filesystem::path>
30 relativeToRoot(std::filesystem::path const& other, bool fakeJailAsRoot = false) const;
31
39 std::optional<std::filesystem::path> pathAsIsInJail(std::filesystem::path const& other) const;
40
47 std::filesystem::path fakeJailAsRoot(std::filesystem::path const& other) const;
48
49 private:
50 std::filesystem::path jailRoot_;
51 };
52}
Definition jail.hpp:12
std::optional< std::filesystem::path > relativeToRoot(std::filesystem::path const &other, bool fakeJailAsRoot=false) const
Definition jail.cpp:27
std::filesystem::path jailRoot_
Definition jail.hpp:50
std::filesystem::path fakeJailAsRoot(std::filesystem::path const &other) const
Returns the jailed path as if it were coming from root like "/jail/asdf.txt".
Definition jail.cpp:52
std::optional< std::filesystem::path > pathAsIsInJail(std::filesystem::path const &other) const
First tests if the path is in the jail and then returns a full path of the resource including the jai...
Definition jail.cpp:44
bool isWithinJail(std::filesystem::path const &other) const
Definition jail.cpp:20
Definition authorization.hpp:10