usrinfogetpwuid

1

Click here to load reader

Upload: karthic-rao

Post on 09-Jul-2015

104 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Usrinfogetpwuid

/*HACKINTOSH RAO \m/ , codes for GNU/LINUX PROGRAM TO GET THE COMPLETE INFORMATION OF THE USER USING "getpwuid" system call in gnu/LINUX SYSTEM CALLS USED: 1) struct passwd *getpwuid(int uid); DESCRIPTION: "getpwuid" system call takes uid of the a user as parameter and then fills in the entries of the built in structure 'passwd'( check out the header pwd.h under /usr/include to get the details of the passwd structure) and returns a pointer to it .Using the pointer the members of the structure are accessed to get the user info 2)uid_t/int getuid() DESCRIPTION:'getuid' system call returns UID of a user who runs the executable of the code*/#include<pwd.h> //header for getpwuid system call#include<unistd.h>//header for getuid system call#include<stdlib.h>int main(){ struct passwd *usrinfo; usrinfo=getpwuid(getuid()); printf("\nUser name: %s",usrinfo->pw_name); printf("\n\nUserID:%d",usrinfo->pw_uid); printf("\n\nEncrypted password of the user:%s",usrinfo->pw_passwd); printf("\n\nGroup ID:%d",usrinfo->pw_gid); printf("\n\nReal name:%s",usrinfo->pw_gecos); printf("\n\nHOME DIRECTORY OF THE USER:%s",usrinfo->pw_dir); printf("\n\nDefault login shell:%s\n\n\n\n",usrinfo->pw_shell);

return 0;

}