roar
|
#include <jail.hpp>
Public Member Functions | |
Jail (std::filesystem::path const &jailRoot) | |
Construct a new Jail object that can be used to restrict paths to "jailRoot". | |
bool | isWithinJail (std::filesystem::path const &other) const |
std::optional< std::filesystem::path > | relativeToRoot (std::filesystem::path const &other, bool fakeJailAsRoot=false) const |
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 jail path. | |
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". | |
Private Attributes | |
std::filesystem::path | jailRoot_ |
Not meant to be 100% abuse proof.
Roar::Jail::Jail | ( | std::filesystem::path const & | jailRoot | ) |
Construct a new Jail object that can be used to restrict paths to "jailRoot".
jailRoot | The path to restrict relative paths to. |
std::filesystem::path Roar::Jail::fakeJailAsRoot | ( | std::filesystem::path const & | other | ) | const |
Returns the jailed path as if it were coming from root like "/jail/asdf.txt".
other | A relative path to the jail. |
bool Roar::Jail::isWithinJail | ( | std::filesystem::path const & | other | ) | const |
Is the given path within the jail.
std::optional< std::filesystem::path > Roar::Jail::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 jail path.
other | A relative path to the jail. |
std::optional< std::filesystem::path > Roar::Jail::relativeToRoot | ( | std::filesystem::path const & | other, |
bool | fakeJailAsRoot = false |
||
) | const |
Will return a path, that is relative to the jail, if the path is within the jail.
|
private |