Scroll to navigation

FBB::User(3bobcat) /etc/passwd user info FBB::User(3bobcat)

NAME

FBB::User - Provides the /etc/passwd info of the current user

SYNOPSIS

#include <bobcat/user>
Linking option: -lbobcat

DESCRIPTION

This class retrieves the information of the current user from the information in /etc/passwd. The class is a simple wrapper class around the getpwent(3) function.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

CONSTRUCTORS

User():
The default constructor determines the current user’s data. This constructor throws an Exception exception if it did not properly complete because the current user name could not be found in /etc/passwd.
User(size_t uid):
The data of the user whose user-id is uid are determined. If the data could not be found an Exception is thrown.
User(std::string const &name):
The data of the user whose user-name is name are determined. If the data could not be found an Exception is thrown.

Copy and move constructors (and assignment operators) are available.

MEMBER FUNCTIONS

size_t eGroupid() const:
Returns the user’s effective group-id.
size_t eUserid() const:
Returns the user’s effective user-id.
size_t groupid() const:
Returns the user’s group-id.
std::string homedir() const:
Returns the user’s home directory (including a trailing /).
bool inGroup(size_t gid, bool useEffective = true) const:
Returns true if the current user is a member of group gid, otherwise false is returned. The user’s effective group id is also checked if useEffective is specified as true (which is provided as default function argument).
std::string name() const:
Returns the user’s user-name.
std::string password() const:
Returns the user’s encrypted password. But see also the BUGS section.
std::string realname() const:
Returns the user’s real name, as listed in the /etc/passwd’s gecos field.
std::string shell() const:
Returns the user’s shell.
size_t userid() const:
Returns the user’s user-id.

EXAMPLE

#include <bobcat/user>
#include <iostream>
using namespace std;
using namespace FBB;
int main()
{

User user;
cout << "\n"
"name : " << user.name() << "\n" <<
"password : " << user.password() << "\n" <<
"user id : " << user.userid() << "\n" <<
"group id : " << user.groupid() << "\n" <<
"real name : " << user.realname() << "\n" <<
"home dir : " << user.homedir() << "\n" <<
"shell : " << user.shell() << "\n" << endl; }

FILES

bobcat/user - defines the class interface

SEE ALSO

bobcat(7), getpwent(3)

BUGS

If the user is a member of multiple groups, only the group id listed in /etc/passwd is returned by groupid().

If shadow passwording is used, the string returned by password() will probably not contain the encrypted password.

BOBCAT PROJECT FILES

https://fbb-git.gitlab.io/bobcat/: gitlab project page;
bobcat_5.09.01-x.dsc: detached signature;
bobcat_5.09.01-x.tar.gz: source archive;
bobcat_5.09.01-x_i386.changes: change log;
libbobcat1_5.09.01-x_*.deb: debian package containing the libraries;
libbobcat1-dev_5.09.01-x_*.deb: debian package containing the libraries, headers and manual pages;

BOBCAT

Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).

2005-2021 libbobcat-dev_5.09.01