G::Process Class Reference

A static interface for doing things with processes. More...

#include <gprocess.h>

Inheritance diagram for G::Process:

G::IdentityUser

List of all members.

Static Public Member Functions

static void closeFiles (bool keep_stderr=false)
 Closes all open file descriptors.
static void closeFiles (int fd)
 Closes all open file descriptors except the given one.
static void closeStderr ()
 Closes stderr.
static void cd (const Path &dir)
 Changes directory.
static bool cd (const Path &dir, NoThrow)
 Changes directory. Returns false on error.
static int errno_ ()
 Returns the process's current 'errno' value.
static int errno_ (int)
 Sets the process's 'errno' value.
static std::string strerror (int errno_)
 Translates an 'errno' value into a meaningful diagnostic string.
static void revokeExtraGroups ()
 Revokes secondary group memberships if really root or if suid.
static Identity beOrdinary (Identity nobody, bool change_group=true)
 Revokes special privileges (root or suid).
static Identity beSpecial (Identity special, bool change_group=true)
 Re-acquires special privileges (either root or suid).
static Identity beOrdinary (SignalSafe, Identity nobody, bool change_group=true)
 A signal-safe overload.
static Identity beSpecial (SignalSafe, Identity special, bool change_group=true)
 A signal-safe overload.
static void beNobody (Identity)
 If currently running with a real identity of root then the real identity is set to the nobody identity and the effective identity is set to root.

Classes

class  Id
 Process-id class. More...
class  IdImp
 A private implementation class used by G::Process. More...
class  NoThrow
 An overload discriminator for Process. More...
class  Umask
 Used to temporarily modify the process umask. More...


Detailed Description

A static interface for doing things with processes.

See also:
G::Identity

Definition at line 44 of file gprocess.h.


Member Function Documentation

void G::Process::closeFiles ( bool  keep_stderr = false  )  [static]

Closes all open file descriptors.

Definition at line 74 of file gprocess_unix.cpp.

Referenced by G::NewProcess::spawn().

void G::Process::closeFiles ( int  fd  )  [static]

Closes all open file descriptors except the given one.

Definition at line 79 of file gprocess_unix.cpp.

References G_ASSERT, and G::FileSystem::nullDevice().

void G::Process::closeStderr (  )  [static]

Closes stderr.

Definition at line 67 of file gprocess_unix.cpp.

References G::FileSystem::nullDevice().

void G::Process::cd ( const Path dir  )  [static]

Changes directory.

Definition at line 56 of file gprocess_unix.cpp.

References G::Path::str().

Referenced by G::Daemon::detach().

bool G::Process::cd ( const Path dir,
NoThrow   
) [static]

Changes directory. Returns false on error.

Definition at line 62 of file gprocess_unix.cpp.

References G::Path::str().

int G::Process::errno_ (  )  [static]

Returns the process's current 'errno' value.

Definition at line 111 of file gprocess_unix.cpp.

Referenced by gcleanup_unix_handler_(), and G::File::link().

int G::Process::errno_ ( int  e  )  [static]

Sets the process's 'errno' value.

Returns the old value. Used in signal handlers.

Definition at line 116 of file gprocess_unix.cpp.

std::string G::Process::strerror ( int  errno_  )  [static]

Translates an 'errno' value into a meaningful diagnostic string.

Definition at line 123 of file gprocess_unix.cpp.

void G::Process::revokeExtraGroups (  )  [static]

Revokes secondary group memberships if really root or if suid.

Definition at line 129 of file gprocess_unix.cpp.

References G::Identity::effective(), and G::Identity::real().

Referenced by G::Root::init().

G::Identity G::Process::beOrdinary ( Identity  nobody,
bool  change_group = true 
) [static]

Revokes special privileges (root or suid).

If really root (as opposed to suid root) then the effective id is changed to that passed in.

If suid (including suid-root), then the effective id is changed to the real id, and the parameter is ignored.

Returns the old identity, which can be passed to beSpecial().

See also class G::Root.

Definition at line 158 of file gprocess_unix.cpp.

References G::Identity::effective(), G::Identity::real(), G::Identity::root(), G::IdentityUser::setEffectiveGroupTo(), and G::IdentityUser::setEffectiveUserTo().

Referenced by G::Root::init(), G::Root::stop(), and G::Root::~Root().

G::Identity G::Process::beSpecial ( Identity  special,
bool  change_group = true 
) [static]

Re-acquires special privileges (either root or suid).

The parameter must have come from a previous call to beOrdinary().

Returns the old identity (which is normally ignored).

See also class G::Root.

Definition at line 138 of file gprocess_unix.cpp.

References G::Identity::effective(), G::Identity::isRoot(), G::Identity::real(), G::IdentityUser::setEffectiveGroupTo(), and G::IdentityUser::setEffectiveUserTo().

Referenced by G::Root::Root(), and G::Root::start().

G::Identity G::Process::beOrdinary ( SignalSafe  safe,
Identity  nobody,
bool  change_group = true 
) [static]

G::Identity G::Process::beSpecial ( SignalSafe  safe,
Identity  special,
bool  change_group = true 
) [static]

void G::Process::beNobody ( Identity  nobody  )  [static]

If currently running with a real identity of root then the real identity is set to the nobody identity and the effective identity is set to root.

Must only be used before exec()ing a new executable image, in which case the old effective ids are lost anywas by the exec().

Definition at line 196 of file gprocess_unix.cpp.

References G::Identity::real(), G::Identity::root(), G::IdentityUser::setEffectiveUserTo(), G::IdentityUser::setRealGroupTo(), and G::IdentityUser::setRealUserTo().

Referenced by G::NewProcess::spawn().


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5