user


Description

An os_user represents a user. Most entities, such as processes, files, and IPC mechanisms are owned by a user. An os_user object can be constructed from either a numeric user ID or a symbolic user name. Once constructed, an os_user accesses information about a user, such as the user's name.

Library

Security<ToolKit>

Declaration

#include <ospace/security/user.h>

class os_user

Interface

Constructor
os_user( const char* name , enum Encoding enc = Ascii )
Constructs a user that represents the user with name name . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.

Throws: os_security_toolkit_error

Constructor
os_user( const string& name , enum Encoding enc = Ascii )
Constructs a user that represents the user with name name . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.

Throws: os_security_toolkit_error

Constructor
os_user( const os_uid_t& user )
Constructs a user with user ID user (default OS_UNDEFINED_USER ).

Throws: os_security_toolkit_error

Constructor
os_user( const os_user& user )
Constructs a user that is a copy of user .
<
bool operator<( const os_user& user ) const
Returns true if this user's ID is less than user 's.
=
os_user& operator=( const os_user& user )
Assigns this user from user .
=
os_user& operator=( os_uid_t user )
Assigns this user from user .
==
bool operator==( const os_user& user ) const
Returns true if this user's ID is the same as user 's.
(os_uid_t)
operator os_uid_t() const
Returns this user's ID.
defined
bool defined() const
Returns true if this user's ID is not OS_UNDEFINED_USER .
domain
string domain( enum Encoding enc = Ascii ) const
Returns this user's domain name. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
gid
os_gid_t gid() const
Returns the ID of this user's primary group. If this information cannot be obtained from the user database, returns OS_UNDEFINED_GROUP .
name
string name( enum Encoding enc = Ascii ) const
Returns this user's name. If this information cannot be obtained from the user database, returns an empty string. Default enc is Ascii. Valid value for enc can be Ascii or Utf8.
print
void print( ostream& stream ) const
Prints this user's name and user ID to stream .
uid
void uid( const os_uid_t& user )
Sets this user's ID to user .
uid
os_uid_t uid() const
Returns this user's ID.

UNIX-Specific interface

Constructor
os_user( const struct passwd& pwd )
Constructs this user from pwd .
comment
string comment() const
Returns this user's associated comment. If this information cannot be obtained from the user database, returns an empty string.
groups
vector< os_gid_t > groups() const
Returns a vector of all this user's group IDs.
home_directory
string home_directory() const
Returns this user's home directory path. If this information cannot be obtained from the user database, returns an empty string.
password
string password() const
Returns this user's password. If this information cannot be obtained from the user database, returns an empty string.
shell
string shell() const
Returns the name of this user's shell. If this information cannot be obtained from either the user database or the environment, returns an empty string.
super_user
bool super_user() const
Returns true if this user is a superuser.
users
/* static */ vector< os_uid_t > users()
Returns a vector of all user IDs.

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_user& user )
Prints user to stream .

Universal Streaming Service

#include <ospace/uss/security.h>

<<
os_bstream& operator<<( os_bstream& stream , const os_user& user )
Writes user to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_user& user )
Reads user from stream .
 

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.