-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstudyuid.c
44 lines (37 loc) · 931 Bytes
/
studyuid.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*************************************************************************
> File Name: studyuid.c
> Author: NiGo
> Mail: [email protected]
> Created Time: 2020年04月24日 星期五 22时39分13秒
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <string.h>
void my_err(const char *str)
{
perror(str);
exit(1);
}
int main(int argc, char *argv[])
{
int fd;
printf("uid study: \n");
printf("Process's uid = %d, euid = %d\n", getuid(), geteuid());
if ((fd = open("test.c", O_RDWR)) == -1)
{
printf("Open failure, errno is %d: %s\n", errno, strerror(errno));
exit(1);
}
else
{
printf("Open successfully!\n");
}
close(fd);
exit(0);
}