libmoost
moost::process::ownership Class Reference

Process ownership information and manipulation. More...

#include <ownership.hpp>

Collaboration diagram for moost::process::ownership:

List of all members.

Public Types

typedef detail::ownership::uid_type uid_type
typedef detail::ownership::gid_type gid_type

Public Member Functions

bool is_superuser () const
 Check for superuser privileges.
bool lookup_user (std::string &name, const uid_type &uid) const
 Lookup user name by user id.
bool lookup_uid (uid_type &uid, const std::string &name) const
 Lookup user id by user name.
bool lookup_uid (uid_type &uid, gid_type &gid, const std::string &name) const
 Lookup user id and group id by user name.
void set_uid (uid_type uid)
 Set new user id.
void set_effective_uid (uid_type uid)
 Set new effective user id.
uid_type get_uid () const
 Get current user id.
uid_type get_effective_uid () const
 Get current effective user id.
bool lookup_group (std::string &name, const gid_type &gid) const
 Lookup group name by group id.
bool lookup_gid (gid_type &gid, const std::string &name) const
 Lookup group id by group name.
void set_gid (gid_type gid)
 Set new group id.
void set_effective_gid (gid_type gid)
 Set new effective group id.
gid_type get_gid () const
 Get current group id.
gid_type get_effective_gid () const
 Get current effective group id.
bool set_user (const std::string &name)
 Set new user id by user name.
bool set_effective_user (const std::string &name)
 Set new effective user id by user name.
bool set_group (const std::string &name)
 Set new group id by group name.
bool set_effective_group (const std::string &name)
 Set new effective group id by group name.
std::string get_user () const
 Get current user name.
std::string get_effective_user () const
 Get current effective user name.
std::string get_group () const
 Get current group name.
std::string get_effective_group () const
 Get current effective group name.
void drop_privileges (const std::string &user, const std::string &group="")
 Drop process ownership privileges.

Private Attributes

detail::ownership m_impl

Detailed Description

Process ownership information and manipulation.

This class allows a process to retrieve information about or manipulate its ownership. For example, it allows a daemon process to drop privileges when being run by the superuser.

Platform specific abstractions are provided for Win32 and POSIX systems, although the Win32 abstraction is just a dummy at the moment.

Definition at line 45 of file ownership.hpp.


Member Typedef Documentation


Member Function Documentation

void moost::process::ownership::drop_privileges ( const std::string &  user,
const std::string &  group = "" 
) [inline]

Drop process ownership privileges.

Parameters:
userUser name to continue to run this process as.
groupOptional group name to run this process as. Defaults to the primary group of the user.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when either user or group could not be found.

Definition at line 419 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Get current effective group id.

Returns:
Group id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 235 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string moost::process::ownership::get_effective_group ( ) const [inline]

Get current effective group name.

Returns:
String holding the group name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the group could not be found.

Definition at line 396 of file ownership.hpp.

Here is the call graph for this function:

Get current effective user id.

Returns:
User id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 155 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string moost::process::ownership::get_effective_user ( ) const [inline]

Get current effective user name.

Returns:
String holding the user name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the user could not be found.

Definition at line 356 of file ownership.hpp.

Here is the call graph for this function:

Get current group id.

Returns:
Group id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 223 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string moost::process::ownership::get_group ( ) const [inline]

Get current group name.

Returns:
String holding the group name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the group could not be found.

Definition at line 376 of file ownership.hpp.

Here is the call graph for this function:

Get current user id.

Returns:
User id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 143 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string moost::process::ownership::get_user ( ) const [inline]

Get current user name.

Returns:
String holding the user name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the user could not be found.

Definition at line 336 of file ownership.hpp.

Here is the call graph for this function:

bool moost::process::ownership::is_superuser ( ) const [inline]

Check for superuser privileges.

Returns:
Boolean indicating whether the process is currently running with superuser privileges.

Definition at line 57 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::lookup_gid ( gid_type gid,
const std::string &  name 
) const [inline]

Lookup group id by group name.

Parameters:
gidReference to native type to store the group id in.
nameGroup name.
Returns:
Boolean indicating whether the group id was found.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 187 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::lookup_group ( std::string &  name,
const gid_type gid 
) const [inline]

Lookup group name by group id.

Parameters:
nameReference to a string to store the group name in.
gidGroup id in the platform's native format.
Returns:
Boolean indicating whether the group name was found.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 171 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::lookup_uid ( uid_type uid,
const std::string &  name 
) const [inline]

Lookup user id by user name.

Parameters:
uidReference to native type to store the user id in.
nameUser name.
Returns:
Boolean indicating whether the user id was found.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 89 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::lookup_uid ( uid_type uid,
gid_type gid,
const std::string &  name 
) const [inline]

Lookup user id and group id by user name.

Parameters:
uidReference to native type to store the user id in.
uidReference to native type to store the group id in.
nameUser name.
Returns:
Boolean indicating whether the user id was found.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 107 of file ownership.hpp.

Here is the call graph for this function:

bool moost::process::ownership::lookup_user ( std::string &  name,
const uid_type uid 
) const [inline]

Lookup user name by user id.

Parameters:
nameReference to a string to store the user name in.
uidUser id in the platform's native format.
Returns:
Boolean indicating whether the user name was found.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 73 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Set new effective group id.

Parameters:
uidGroup id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 211 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::set_effective_group ( const std::string &  name) [inline]

Set new effective group id by group name.

Parameters:
nameString holding the group name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the group could not be found.

Definition at line 314 of file ownership.hpp.

Here is the call graph for this function:

Set new effective user id.

Parameters:
uidUser id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 131 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::set_effective_user ( const std::string &  name) [inline]

Set new effective user id by user name.

Parameters:
nameString holding the user name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the user could not be found.

Definition at line 270 of file ownership.hpp.

Here is the call graph for this function:

Set new group id.

Parameters:
uidGroup id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 199 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::set_group ( const std::string &  name) [inline]

Set new group id by group name.

Parameters:
nameString holding the group name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the group could not be found.

Definition at line 292 of file ownership.hpp.

Here is the call graph for this function:

Set new user id.

Parameters:
uidUser id in the platform's native format.
Exceptions:
Throwsan instance of boost::system::system_error on failure.

Definition at line 119 of file ownership.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool moost::process::ownership::set_user ( const std::string &  name) [inline]

Set new user id by user name.

Parameters:
nameString holding the user name.
Exceptions:
Throwsan instance of boost::system::system_error on failure or a std::runtime_error when the user could not be found.

Definition at line 248 of file ownership.hpp.

Here is the call graph for this function:


Member Data Documentation


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