roar
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Roar::Jail Class Reference

#include <jail.hpp>

Collaboration diagram for Roar::Jail:

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_
 

Detailed Description

Not meant to be 100% abuse proof.

Constructor & Destructor Documentation

◆ Jail()

Roar::Jail::Jail ( std::filesystem::path const &  jailRoot)

Construct a new Jail object that can be used to restrict paths to "jailRoot".

Parameters
jailRootThe path to restrict relative paths to.

Member Function Documentation

◆ fakeJailAsRoot()

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".

Parameters
otherA relative path to the jail.
Returns
std::filesystem::path Path or nothing if not in jail.

◆ isWithinJail()

bool Roar::Jail::isWithinJail ( std::filesystem::path const &  other) const

Is the given path within the jail.

◆ pathAsIsInJail()

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.

Parameters
otherA relative path to the jail.
Returns
std::optional<std::filesystem::path> Path or nothing if not in jail.

◆ relativeToRoot()

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.

Member Data Documentation

◆ jailRoot_

std::filesystem::path Roar::Jail::jailRoot_
private

The documentation for this class was generated from the following files: