KUser::KUser(UIDMode mode) { long _uid = ::getuid(), _euid; if (mode == UseEffectiveUID && (_euid = ::geteuid()) != _uid ) fillPasswd( ::getpwuid( _euid ) ); else { fillName( ::getenv( "LOGNAME" ) ); if (uid() != _uid) { fillName( ::getenv( "USER" ) ); if (uid() != _uid) fillPasswd( ::getpwuid( _uid ) ); } } }
Private(const passwd *p) : uid(uid_t(-1)), gid(gid_t(-1)) { fillPasswd(p); }
Private(const char *name) : uid(uid_t(-1)), gid(gid_t(-1)) { fillPasswd(name ? ::getpwnam( name ) : 0); }
KUser::KUser(struct passwd *p) { fillPasswd(p); }
KUser::KUser(long uid) { fillPasswd( ::getpwuid( uid ) ); }
void KUser::fillName(const char *name) { fillPasswd(name ? ::getpwnam( name ) : 0); }