VideoTools
|
A class which acquires the process's special privileges on construction and releases them on destruction. More...
#include <groot.h>
Public Member Functions | |
Root () | |
Default constructor. More... | |
Root (bool change_group) | |
Constructor overload with explicit control over whether to change the group-id or not. More... | |
~Root () | |
Desctructor. More... | |
Static Public Member Functions | |
static void | init (const std::string &non_root, bool default_change_group=true) |
Initialises this class on process start-up by releasing root (or suid) privileges. More... | |
static Identity | nobody () |
Returns the 'nobody' identity corresponding to the init() user name. More... | |
static Identity | start (SignalSafe) |
A signal-safe alternative to construction. | |
static void | stop (SignalSafe, Identity) |
A signal-safe alternative to destruction. | |
A class which acquires the process's special privileges on construction and releases them on destruction.
Despite the name of the class the special privileges are not necessarily root privileges; they can be suid privileges.
The class must be initialised by calling a static init() method. If instances are nested then the inner instances have no effect.
The effect of this class depends on whether the process's real-id is root or not. If the real-id is root then the effective-id is switched to some named 'ordinary' user's id at startup, and then back to what it was (ie. root or the suid id) for the critical sections. Otherwise, the effective-id is switched to the real-id at startup and switched back to what it was for the critical sections.
The implementation uses G::Process and G::Identity.
G::Root::Root | ( | ) |
|
explicit |
G::Root::~Root | ( | ) |
|
static |
Initialises this class on process start-up by releasing root (or suid) privileges.
The string parameter gives a non-privileged username which is used if the real user-id is root.
The group-id behaviour of the default constructor is modified by the boolean parameter.
|
static |