FBB::User(3bobcat)

πŸ’– FBB::User πŸ’– β€” the /etc/passwd tea on your current user

ok so bestie, this is page 3bobcat in the manual, and it's literally all about the FBB::User class. no cap.


✨ NAME ✨

FBB::User β€” hands you the /etc/passwd info of the current user. that's it, that's the whole job 🫢


✨ SYNOPSIS ✨

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

like, that's how you pull it into your code, periodt πŸ’…


✨ DESCRIPTION ✨

so basically this class goes and fetches the info about the current user out of what's sitting in /etc/passwd. and the way it does that is lowkey simple β€” it's just a cute lil wrapper class hanging around the getpwent(3) function. nothing complicated, just vibes 🌸


✨ NAMESPACE ✨

FBB

every single constructor, member, operator and manipulator mentioned on this page lives in the FBB namespace. all of them. no strays πŸ’œ


✨ INHERITS FROM ✨

-

aka nothing. it inherits from absolutely no one, it's independent, it's got main character energy πŸ‘‘


✨ CONSTRUCTORS ✨

  • User() β€” the default constructor figures out the current user's data. ⚠️ heads up though: if the current user's name can't be found in /etc/passwd, this constructor throws an Exception because it couldn't finish properly. 😭
  • User(size_t uid) β€” this one goes and gets the data of the user whose user-id is uid. and if that data can't be found? boom, an Exception gets thrown. no data, no peace πŸ’€
  • User(std::string const &name) β€” same deal but for the user whose user-name is name. can't find it? Exception, thrown, bye πŸ™ˆ

oh and btw, copy and move constructors (plus their assignment operators) are all available too. you're covered bestie πŸŽ€


✨ MEMBER FUNCTIONS ✨

  • size_t eGroupid() const β€” returns the user's effective group-id. effective, not the regular one, iykyk.
  • size_t eUserid() const β€” returns the user's effective user-id. again, effective > regular here.
  • size_t groupid() const β€” returns the user's group-id. the plain one. the regular one. πŸ’…
  • std::string homedir() const β€” returns the user's home directory, and yes it includes a trailing / at the end. don't say I didn't warn you 🏠
  • bool inGroup(size_t gid, bool useEffective = true) const β€” returns true if the current user is a member of group gid, otherwise you get false back. and if useEffective is set to true, the user's effective group id gets checked too β€” and fun fact, true is the default function argument, so it's doing that by default unless you say otherwise ✨
  • std::string name() const β€” returns the user's user-name. that's their login name bestie πŸͺͺ
  • std::string password() const β€” returns the user's encrypted password. BUT πŸ‘€ go read the BUGS section below before you get too excited, fr fr.
  • std::string realname() const β€” returns the user's real name, the one that's listed in the gecos field of /etc/passwd 🌸
  • std::string shell() const β€” returns the user's shell. the lil home of their terminal 🐚
  • size_t userid() const β€” returns the user's user-id. the classic. the icon. πŸ”₯

✨ EXAMPLE ✨

here's a whole lil program showing it off, adorbs:

#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 β€” this is the file that defines the class interface πŸ’–

✨ SEE ALSO ✨

bobcat(7), getpwent(3)

go read those too bestie, they're in the friend group 🌈


✨ BUGS ✨

ok so real talk, there are two things you need to know and they're not great:

  • if the user is a member of multiple groups, then groupid() only ever returns the single group id that's listed in /etc/passwd. just the one. sorry πŸ’€
  • and if shadow passwording is being used, then the string that password() gives you will probably not contain the encrypted password. like, it just won't. don't count on it 😭

✨ BOBCAT PROJECT FILES ✨

and the Debian Bobcat project files:

  • libbobcat6 β€” the debian package containing the shared library, plus the changelog and copyright note πŸŽ€
  • libbobcat-dev β€” the debian package containing the static library, headers, manual pages, and developer info 🫢

✨ BOBCAT ✨

fun fact: Bobcat is an acronym of Brokken’s Own Base Classes And Templates. iconic name origin ngl πŸ‘‘


this is free software, distributed under the terms of the GNU General Public License (GPL). free as in freedom, slay πŸ’œ


✨ AUTHOR ✨

Frank B. Brokken (f.b.brokken@rug.nl). the legend themselves πŸ™Œ


and that's the whole page bestie!! this was libbobcat-dev_6.15.01 from 2005-2026, and yes i'm still on my FBB::User(3bobcat) era βœ¨πŸ’… go forth and read /etc/passwd responsibly πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from