ARC SDK
Public Member Functions
Arc::User Class Reference

Platform independent representation of system user. More...

#include <arc/User.h>

Public Member Functions

 User ()
 Construct user from current process owner. More...
 
 User (const std::string &name, const std::string &group="")
 Construct user from username and optional group name. More...
 
 User (int uid, int gid=-1)
 Construct user from uid and optional gid. More...
 
 operator bool () const
 Returns true if this is a valid user. More...
 
bool operator! () const
 Returns true is this is not a valid user. More...
 
const std::string & Name (void) const
 Returns the name of this user. More...
 
const std::string & Home (void) const
 Returns the path to the user's home directory. More...
 
int get_uid (void) const
 Returns the user's uid. More...
 
int get_gid (void) const
 Returns the user's gid. More...
 
bool operator== (const std::string &n)
 Returns true if this User's name is the same as n. More...
 
int check_file_access (const std::string &path, int flags) const
 Check if this User has the rights specified by flags on the given path. More...
 
bool SwitchUser () const
 Change the owner of the current process. More...
 

Detailed Description

Platform independent representation of system user.

Constructor & Destructor Documentation

◆ User() [1/3]

Arc::User::User ( )

Construct user from current process owner.

◆ User() [2/3]

Arc::User::User ( const std::string &  name,
const std::string &  group = "" 
)

Construct user from username and optional group name.

If group is not specified it is determined automatically.

◆ User() [3/3]

Arc::User::User ( int  uid,
int  gid = -1 
)

Construct user from uid and optional gid.

If gid is not specified it is determined automatically.

Member Function Documentation

◆ check_file_access()

int Arc::User::check_file_access ( const std::string &  path,
int  flags 
) const

Check if this User has the rights specified by flags on the given path.

Returns
0 if User has the rights

◆ get_gid()

int Arc::User::get_gid ( void  ) const
inline

Returns the user's gid.

◆ get_uid()

int Arc::User::get_uid ( void  ) const
inline

Returns the user's uid.

◆ Home()

const std::string& Arc::User::Home ( void  ) const
inline

Returns the path to the user's home directory.

◆ Name()

const std::string& Arc::User::Name ( void  ) const
inline

Returns the name of this user.

◆ operator bool()

Arc::User::operator bool ( ) const
inline

Returns true if this is a valid user.

◆ operator!()

bool Arc::User::operator! ( void  ) const
inline

Returns true is this is not a valid user.

Python interface deviation
Method is unavailable in Python interface

◆ operator==()

bool Arc::User::operator== ( const std::string &  n)
inline

Returns true if this User's name is the same as n.

◆ SwitchUser()

bool Arc::User::SwitchUser ( ) const

Change the owner of the current process.

Internally this method calls setuid() and setgid() with this User's values. It can be used in the initializer of Arc::Run to switch the owner of a child process just after fork(). To temporarily change the owner of a thread in a multi-threaded environment UserSwitch should be used instead.

Returns
true if switch succeeded.

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