Start privilege testing framework
[dragonfly.git] / tools / regression / priv / test_acct.c
blob7bae90f43a4e1e924cee9396a56a40c2f0514094
1 #include <unistd.h>
2 #include <errno.h>
3 #include <fcntl.h>
4 #include <sys/types.h>
5 #include "test.h"
7 static char *tmp_file;
9 void
10 setup() {
11 tmp_file = "./tmpfile";
12 int fh = open(tmp_file, O_CREAT | O_TRUNC | O_WRONLY, 0666);
13 close(fh);
16 void
17 teardown() {
18 unlink(tmp_file);
21 int
22 test_acct() {
23 int error;
25 error = acct(tmp_file);
26 if (error == -1)
27 return errno;
29 error = acct(NULL);
30 if (error == -1)
31 return errno;
33 return 0;
36 int main()
38 test_as_root (test_acct, 0, "acct");
39 test_as_jailed_root (test_acct, EPERM, "acct");
40 test_as_unpriv (test_acct, EPERM, "acct");
41 test_as_jailed_unpriv (test_acct, EPERM, "acct");
43 return 0;