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 anExceptionbecause it couldn't finish properly. πUser(size_t uid)β this one goes and gets the data of the user whose user-id isuid. and if that data can't be found? boom, anExceptiongets thrown. no data, no peace πUser(std::string const &name)β same deal but for the user whose user-name isname. 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β returnstrueif the current user is a member of groupgid, otherwise you getfalseback. and ifuseEffectiveis set totrue, the user's effective group id gets checked too β and fun fact,trueis 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 thegecosfield 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 β¨
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 β¨
https://fbb-git.gitlab.io/bobcat/β the gitlab project page π¦
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 π
β¨ COPYRIGHT β¨
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
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms