2 * Test this family of functions
3 * lchmod chownat lchownat
16 char tmpfile
[] = "/tmp/test_chmod_chown.XXXXXX";
17 char tmplink
[] = "/tmp/test_chx_link.XXXXXX";
18 int tmpfd
= mkstemp(tmpfile
);
21 memset(buff
, 0, sizeof(buff
));
22 sprintf(buff
, "some data");
23 write(tmpfd
, buff
, strlen(buff
)+1);
26 DIR* tmpdir
= opendir("/tmp");
28 int tmpdirfd
= dirfd(tmpdir
);
30 if (-1 == symlinkat(tmpfile
+5, tmpdirfd
, tmplink
+5)) {
31 perror("linkat failed");
34 if (-1 == lchmod(tmplink
, S_IRWXU
|S_IRWXG
|S_IRWXO
))
36 perror("lchmod failed:");
39 if (fchmodat(tmpdirfd
, tmpfile
+5, S_IRWXU
|S_IRWXG
|S_IRWXO
, 0))
41 perror("fchmodat failed:");
44 // no test for failure as not everyone runnning this will be a member of group 921
45 fchownat(tmpdirfd
, tmpfile
+5, getuid(), 920, 0);
54 char* badstring
= strdup("foo");
61 lchmod(badstring
, badint1
);
62 fchmodat(badint1
, badstring
, badint2
, badint3
);
63 fchownat(badint1
, badstring
, badint2
, badint3
, badint4
);