sbuild  1.7.1
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
sbuild::personality Class Reference

Chroot personality. More...

#include <personality.h>

+ Collaboration diagram for sbuild::personality:

Public Types

enum  error_code { BAD, SET }
 Error codes. More...
 
typedef unsigned long type
 Personality type.
 
typedef custom_error< error_codeerror
 Exception type.
 

Public Member Functions

 personality ()
 The constructor. More...
 
 personality (const std::string &persona)
 The constructor. More...
 
 ~personality ()
 
const std::string & get_name () const
 Get the name of the personality. More...
 
void set_name (const std::string &persona)
 Set the name of the personality. More...
 
type get () const
 Get the personality. More...
 
void set () const
 Set the process personality. More...
 

Static Public Member Functions

static std::string get_personalities ()
 Print a list of the available personalities. More...
 

Static Private Member Functions

static type find_personality (const std::string &persona)
 Find a personality by name. More...
 
static std::string const & find_personality (type persona)
 Find a personality by number. More...
 

Private Attributes

std::string persona_name
 The name of the current personality.
 
type persona
 The personality type.
 

Static Private Attributes

static std::map< std::string,
type
personalities
 Mapping between personality name and type. More...
 

Friends

template<class charT , class traits >
std::basic_istream< charT,
traits > & 
operator>> (std::basic_istream< charT, traits > &stream, personality &rhs)
 Get the personality name from a stream. More...
 
template<class charT , class traits >
std::basic_ostream< charT,
traits > & 
operator<< (std::basic_ostream< charT, traits > &stream, const personality &rhs)
 Print the personality name to a stream. More...
 

Detailed Description

Chroot personality.

A chroot may have a personality (also knows as a process execution domain) which is used to run non-native binaries. For example, running 32-bit Linux binaries on a 64-bit Linux system, or an SVR4 binary on a 32-bit Linux system. This is currently a Linux only feature; it does nothing on non-Linux systems. This is a wrapper around the personality(2) system call.

Member Enumeration Documentation

Error codes.

Enumerator
BAD 

Personality is unknown.

SET 

Could not set personality.

Constructor & Destructor Documentation

sbuild::personality::personality ( )

The constructor.

On Linux systems, this is initialised with the current process' personality. On non-Linux systems, it is initialised as "undefined".

References set_name().

sbuild::personality::personality ( const std::string &  persona)

The constructor.

Parameters
personathe persona to set.

References set_name().

sbuild::personality::~personality ( )
  • The destructor.

Member Function Documentation

sbuild::personality::type sbuild::personality::find_personality ( const std::string &  persona)
staticprivate

Find a personality by name.

Parameters
personathe personality to find.
Returns
the personality type; this is -1 if the personality was undefined, or -2 if the personality was unknown (not found).
std::string const & sbuild::personality::find_personality ( type  persona)
staticprivate

Find a personality by number.

Parameters
personathe personality to find.
Returns
the personality name, "undefined" if the personality was not defined, or "unknown" if the personality was not found.
sbuild::personality::type sbuild::personality::get ( ) const

Get the personality.

Returns
the personality.
std::string const & sbuild::personality::get_name ( ) const

Get the name of the personality.

Returns
the personality name.
std::string sbuild::personality::get_personalities ( )
static

Print a list of the available personalities.

Returns
a string of the available personalities.

References sbuild::_().

Referenced by set_name().

+ Here is the caller graph for this function:

void sbuild::personality::set ( ) const

Set the process personality.

This sets the personality (if valid) using the personality(2) system call. If setting the personality fails, an error is thown.

Referenced by sbuild::session::run_child().

+ Here is the caller graph for this function:

void sbuild::personality::set_name ( const std::string &  persona)

Set the name of the personality.

Parameters
personathe persona to set.
Returns
the personality name.

References BAD, get_personalities(), and sbuild::error_base::set_reason().

Referenced by personality().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

template<class charT , class traits >
std::basic_ostream<charT,traits>& operator<< ( std::basic_ostream< charT, traits > &  stream,
const personality rhs 
)
friend

Print the personality name to a stream.

Parameters
streamthe stream to output to.
rhsthe personality to output.
Returns
the stream.
template<class charT , class traits >
std::basic_istream<charT,traits>& operator>> ( std::basic_istream< charT, traits > &  stream,
personality rhs 
)
friend

Get the personality name from a stream.

Parameters
streamthe stream to get input from.
rhsthe personality to set.
Returns
the stream.

Member Data Documentation

std::map< std::string, sbuild::personality::type > sbuild::personality::personalities
staticprivate
Initial value:
=
{
{"undefined", 0xffffffff},
{"linux", PER_LINUX},
{"linux_32bit", PER_LINUX_32BIT},
{"svr4", PER_SVR4},
{"scorvr3", PER_SCOSVR3},
{"osr5", PER_OSR5},
{"wysev386", PER_WYSEV386},
{"iscr4", PER_ISCR4},
{"bsd", PER_BSD},
{"sunos", PER_SUNOS},
{"xenix", PER_XENIX},
{"linux32", PER_LINUX32},
{"irix32", PER_IRIX32},
{"irixn32", PER_IRIXN32},
{"irix64", PER_IRIX64},
{"riscos", PER_RISCOS},
{"solaris", PER_SOLARIS},
{"uw7", PER_UW7},
{"hpux", PER_HPUX},
{"osf4", PER_OSF4}
}

Mapping between personality name and type.


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