logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

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

Author

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

libbobcat-dev_6.07.01                               2005-2025                                 FBB::User(3bobcat)

Bobcat

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

Bobcat Project Files

       o      https://fbb-git.gitlab.io/bobcat/: gitlab project page;

       Debian Bobcat project files:

       o      libbobcat6: debian package containing the shared library, changelog and copyright note;

       o      libbobcat-dev: debian package containing the static library, headers, manual pages, and  developer
              info;

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.

Constructors

       o      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.

       o      User(size_tuid):
              The  data  of  the  user  whose  user-id is uid are determined.  If the data could not be found an
              Exception is thrown.

       o      User(std::stringconst&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.

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.

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

Inherits From

       -

Member Functions

       o      size_teGroupid()const:
              Returns the user’s effective group-id.

       o      size_teUserid()const:
              Returns the user’s effective user-id.

       o      size_tgroupid()const:
              Returns the user’s group-id.

       o      std::stringhomedir()const:
              Returns the user’s home directory (including a trailing /).

       o      boolinGroup(size_tgid,booluseEffective=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).

       o      std::stringname()const:
              Returns the user’s user-name.

       o      std::stringpassword()const:
              Returns the user’s encrypted password. But see also the BUGS section.

       o      std::stringrealname()const:
              Returns the user’s real name, as listed in the /etc/passwd’s gecos field.

       o      std::stringshell()const:
              Returns the user’s shell.

       o      size_tuserid()const:
              Returns the user’s user-id.

Name

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

Namespace

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

See Also

bobcat(7), getpwent(3)

Synopsis

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

See Also