Debian Codegraph @

tests/012_test_chown.c

raw symbols SCIP
1 /*
2 chown test
3 Used by 012 and 020 tests.
4 */
5
6 /* for fchown */
7 /*#define _BSD_SOURCE*/
8
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 //#include <sys/types.h>
13 //#include <sys/stat.h>
14 //#include <fcntl.h>
15
16 int main(int argc, char **argv) {
17 uid_t uid = getuid();
18 gid_t gid;
19 //int fid;
20
21 /* test that four args are given. */
22 if (argc < 5) {
23 exit(1);
24 }
25
26 gid = atoi(argv[1]); /* get the gid to change to */
27
28 printf("chown %s\n", argv[2]);
29 chown(argv[2], uid, gid);
30
31 //fid=open(argv[3], O_RDONLY);
32 //if (fchown(fid, uid, gid)!=-1) /* this func will fail */
33 // return 1;
34 //close(fid);
35
36 printf("lchown %s\n", argv[4]);
37 lchown(argv[4], uid, gid);
38
39 return 0;
40 }