#include // getpw* #include // getpw* #include // getuid #include // perror #include using namespace std; void PrintUser(passwd * user) { cout << "\tname is " << user->pw_name << endl ; cout << "\tpassword is " << user->pw_passwd << endl; cout << "\tuid is " << user->pw_uid << endl; cout << "\tgid is " << user->pw_gid << endl; cout << "\tgecos is " << user->pw_gecos << endl; cout << "\thome is " << user->pw_dir << endl; cout << "\tshell is " << user->pw_shell << endl; cout << endl; } int main(int argc, char * argv[]) { int i = 1; passwd * user; uid_t uid; uid = getuid(); user = getpwuid(uid); if (NULL == user) { perror("getpwuid"); return -1; } cout << "The user running the process is " << endl; PrintUser(user); cout << endl; while (i < argc) { user = getpwnam(argv[i]); if (NULL == user) { perror("getpwnam"); return -1; } cout << "information about " << argv[i] << endl; PrintUser(user) ; i++; } return 0; }