-/* $OpenBSD: main.c,v 1.8 2015/09/30 11:36:07 semarie Exp $ */
+/* $OpenBSD: main.c,v 1.9 2015/10/06 15:24:54 semarie Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
close(fd);
}
+static void
+test_rpath()
+{
+ int fd;
+ char data[512];
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) == -1)
+ _exit(errno);
+
+ if (read(fd, data, sizeof(data)) == -1)
+ _exit(errno);
+
+ close(fd);
+}
+
+static void
+test_wpath()
+{
+ int fd;
+ char data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
+
+ if ((fd = open("/dev/null", O_WRONLY, 0)) == -1)
+ _exit(errno);
+
+ if (write(fd, data, sizeof(data)) == -1)
+ _exit(errno);
+
+ close(fd);
+}
+
+static void
+test_cpath()
+{
+ const char filename[] = "/tmp/generic-test-cpath";
+
+ if (mkdir(filename, S_IRWXU) == -1)
+ _exit(errno);
+
+ if (rmdir(filename) == -1)
+ _exit(errno);
+}
+
int
main(int argc, char *argv[])
{
start_test(&ret, "abort", NULL, test_allowed_syscalls);
start_test(&ret, "fattr", NULL, test_allowed_syscalls);
+ start_test(&ret, "rpath", NULL, test_rpath);
+ start_test(&ret, "wpath", NULL, test_wpath);
+ start_test(&ret, "cpath", NULL, test_cpath);
+
/*
* test whitelist path
*/
-# $OpenBSD: tests.out,v 1.7 2015/09/30 11:36:07 semarie Exp $
+# $OpenBSD: tests.out,v 1.8 2015/10/06 15:24:54 semarie Exp $
test(test_nop): tame=("",NULL) status=0 exit=0
test(test_inet): tame=("",NULL) status=9 signal=9 tamed_syscall=97
test(test_inet): tame=("abort",NULL) status=134 signal=6 coredump=present tamed_syscall=97
test(test_allowed_syscalls): tame=("cpath",NULL) status=9 signal=9 tamed_syscall=89
test(test_allowed_syscalls): tame=("abort",NULL) status=134 signal=6 coredump=present tamed_syscall=89
test(test_allowed_syscalls): tame=("fattr",NULL) status=9 signal=9 tamed_syscall=89
+test(test_rpath): tame=("rpath",NULL) status=0 exit=0
+test(test_wpath): tame=("wpath",NULL) status=0 exit=0
+test(test_cpath): tame=("cpath",NULL) status=0 exit=0
test(test_wpaths): tame=("stdio rpath",NULL)
open_close("/etc/passwd") fd=3 errno=0
open_close("generic") fd=3 errno=0