-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12.c
More file actions
27 lines (23 loc) · 704 Bytes
/
12.c
File metadata and controls
27 lines (23 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
#include <limits.h>
int main()
{
gid_t a[NGROUPS_MAX];
int i;
printf("PID:%d,\n",getpid());
printf("PPID:%d,\n", getppid());
printf("PGID:%d,\n", getpgrp());
printf("UID:%d(%s),\n", getuid(), getpwuid(getuid())->pw_name);
printf("GID:%d(%s),\n",getgid(), getgrgid(getgid())->gr_name);
printf("SID:%d,\n",getsid(0));
printf("EUID:%d(%s),\n",geteuid, getpwuid(geteuid())->pw_name);
printf("EGID:%d(%s),\n",getegid, getgrgid(getegid())->gr_name);
printf("GROUPS:\n");
for (i=0;i<getgroups(NGROUPS_MAX, a);i++)
printf("%d(%s)\n",a[i],getgrgid(a[i])->gr_name);
return 0;
}