Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else {
- uid_t id= getuid();
- gid_t gid = getgid();
- struct passwd* user = getpwuid(id);
- string name = user -> pw_name;
- struct group* groups = getgrgid(gid);
- string name_1 = groups -> gr_name;
- if (strcmp(argv[1], "-u") == 0)
- cout << id;
- if (strcmp(argv[1], "-g") == 0)
- cout << groups -> gr_name;
- if (strcmp(argv[1], "-G") == 0)
- do{
- gid = groups -> gr_gid;
- for (int i = 0; *(groups->gr_mem) != 0; i++, (groups -> gr_mem)++)
- if (strcmp(*(groups->gr_mem), user->pw_name) == 0)
- cout << gid << " ";
- groups = getgrent();
- } while (groups != NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement