19 #ifndef ROSTLAB_CXXPWD
20 #define ROSTLAB_CXXPWD 1
24 #include <sys/types.h>
43 inline cxx_passwd(
const std::string& __pw_name,
const std::string& __pw_passwd, uid_t __pw_uid, gid_t __pw_gid,
const std::string& __pw_gecos,
const std::string& __pw_dir,
const std::string& __pw_shell ) :
51 inline uid_t
getpwnam_r(
const std::string& __uname );
67 long int buflen = sysconf( _SC_GETPW_R_SIZE_MAX );
70 struct passwd *pwbufp;
72 int _errno =
getpwuid_r( __uid, &pwbuf, buf, buflen, &pwbufp );
76 if( pwbufp == NULL )
throw uid_not_found_error( bo::str( bo::format(
"uid '%d' not found") % __uid ) );
78 __passwd =
cxx_passwd( pwbuf.pw_name, pwbuf.pw_passwd, pwbuf.pw_uid, pwbuf.pw_gid, pwbuf.pw_gecos, pwbuf.pw_dir, pwbuf.pw_shell );
93 long int buflen = sysconf( _SC_GETPW_R_SIZE_MAX );
96 struct passwd *pwbufp;
98 int _errno =
getpwnam_r( __uname.c_str(), &pwbuf, buf, buflen, &pwbufp );
102 if( pwbufp == NULL )
throw uname_not_found_error( bo::str( bo::format(
"uname '%s' not found") % __uname ) );
104 __passwd =
cxx_passwd( pwbuf.pw_name, pwbuf.pw_passwd, pwbuf.pw_uid, pwbuf.pw_gid, pwbuf.pw_gecos, pwbuf.pw_dir, pwbuf.pw_shell );
114 #endif // ROSTLAB_CXXPWD