Date: Sat, 26 Jan 2008 22:22:28 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 134152 for review Message-ID: <200801262222.m0QMMSN1069040@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134152 Change 134152 by rwatson@rwatson_freebsd_capabilities on 2008/01/26 22:21:52 Test more system calls. Test for failure for get*id() a bit differently. Affected files ... .. //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_syscalls.c#2 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_syscalls.c#2 (text+ko) ==== @@ -31,10 +31,11 @@ */ #include <sys/cdefs.h> -__FBSDID("$P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_syscalls.c#1 $"); +__FBSDID("$P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_syscalls.c#2 $"); #include <sys/types.h> #include <sys/capability.h> +#include <sys/mman.h> #include <sys/mount.h> #include <sys/socket.h> #include <sys/stat.h> @@ -104,6 +105,12 @@ } else warnx("test_syscalls:access succeeded"); + if (acct("/tmp/cap_test_syscalls_acct") < 0) { + if (errno != ENOSYS) + warnx("test_syscalls:acct %d", errno); + } else + warnx("test_syscalls:acct succeeded"); + if (chdir("/tmp/cap_test_syscalls_chdir") < 0) { if (errno != ENOSYS) warnx("test_syscalls:chdir %d", errno); @@ -128,6 +135,12 @@ } else warnx("test_syscalls:chown succeeded"); + if (chroot("/tmp/cap_test_syscalls_chroot") < 0) { + if (errno != ENOSYS) + warnx("test_syscalls:chroot %d", errno); + } else + warnx("test_syscalls:chroot succeeded"); + if (close(fd_close)) { if (errno == ENOSYS) warnx("test_syscalls:close ENOSYS"); @@ -142,6 +155,13 @@ } else if (errno != ENOSYS) warnx("test_syscalls:creat %d", errno); + fd = dup(fd_file); + if (fd < 0) { + if (errno == ENOSYS) + warnx("test_syscalls:dup ENOSYS"); + } else + close(fd); + if (fchdir(fd_dir) < 0) { if (errno != ENOSYS) warnx("test_syscall:fchdir %d", errno); @@ -180,15 +200,26 @@ else warnx("test_syscalls:fork %d", errno); + if (fstat(fd_file, &sb) < 0) { + if (errno == ENOSYS) + warnx("test_syscalls:fstat ENOSYS"); + } + + /* + * getegid() can't return an error but check for it anyway. + */ + errno = 0; + (void)getegid(); + if (errno == ENOSYS) + warnx("test_syscalls:getegid ENOSYS"); + /* * geteuid() can't return an error but check for it anyway. */ - if ((int)(geteuid()) < 0) { - if (errno == ENOSYS) - warnx("test_syscalls:geteuid ENOSYS"); - else - warnx("test_syscalls:geteuid %d", errno); - } + errno = 0; + geteuid(); + if (errno == ENOSYS) + warnx("test_syscalls:geteuid ENOSYS"); if (getfsstat(&statfs, sizeof(statfs), MNT_NOWAIT) < 0) { if (errno != ENOSYS) @@ -196,30 +227,40 @@ } else warnx("test_syscalls:getfsstat succeeded"); + /* + * getgid() can't return an error but check for it anyway. + */ + errno = 0; + getgid(); + if (errno == ENOSYS) + warnx("test_syscalls:getgid ENOSYS"); + if (getpeername(fd_socket, NULL, NULL) < 0) { if (errno == ENOSYS) warnx("test_syscalls:getpeername ENOSYS"); } + if (getlogin() == NULL) { + if (errno != ENOSYS) + warnx("test_sycalls:getlogin ENOSYS"); + } else + warnx("test_syscalls:getlogin succeeded"); + /* * getpid() can't return an error but check for it anyway. */ - if (getpid() < 0) { - if (errno == ENOSYS) - warnx("test_syscalls:getpid ENOSYS"); - else - warnx("test_syscalls:getpid %d", errno); - } + errno = 0; + (void)getpid(); + if (errno == ENOSYS) + warnx("test_syscalls:getpid ENOSYS"); /* * getppid() can't return an error but check for it anyway. */ - if (getppid() < 0) { - if (errno == ENOSYS) - warnx("test_syscalls:getppid ENOSYS"); - else - warnx("test_syscalls:getppid %d", errno); - } + errno = 0; + (void)getppid(); + if (errno == ENOSYS) + warnx("test_syscalls:getppid ENOSYS"); if (getsockname(fd_socket, NULL, NULL) < 0) { if (errno == ENOSYS) @@ -229,12 +270,12 @@ /* * getuid() can't return an error but check for it anyway. */ - if ((int)(getuid()) < 0) { - if (errno == ENOSYS) - warnx("test_syscalls:getuid ENOSYS"); - else - warnx("test_syscals:getuid %d", errno); - } + errno = 0; + (void)getuid(); + if (errno == ENOSYS) + warnx("test_syscalls:getuid ENOSYS"); + + /* XXXRW: ktrace */ if (link("/tmp/foo", "/tmp/bar") < 0) { if (errno != ENOSYS) @@ -271,6 +312,11 @@ } else warnx("test_syscalls:mount succeeded"); + if (msync(&fd_file, 8192, MS_ASYNC) < 0) { + if (errno == ENOSYS) + warnx("test_syscalls:msync ENOSYS"); + } + fd = open("/dev/null", O_RDWR); if (fd >= 0) { warnx("test_syscalls:open succeeded"); @@ -283,12 +329,23 @@ } else if (errno == ENOSYS) warnx("test_syscalls:pipe ENOSYS"); + if (profil(NULL, 0, 0, 0) < 0) { + if (errno == ENOSYS) + warnx("test_syscalls:profile ENOSYS"); + } + /* XXXRW: ptrace. */ len = read(fd_file, &ch, sizeof(ch)); if (len < 0 && errno == ENOSYS) warnx("test_syscalls:read ENOSYS"); + if (readlink("/tmp/cap_test_syscalls_readlink", NULL, 0) < 0) { + if (errno != ENOSYS) + warnx("test_syscalls:readlink %d", errno); + } else + warnx("test_syscalls:readlink succeeded"); + len = recvfrom(fd_socket, NULL, 0, 0, NULL, NULL); if (len < 0 && errno == ENOSYS) warnx("test_syscalls:recvfrom ENOSYS"); @@ -297,6 +354,12 @@ if (len < 0 && errno == ENOSYS) warnx("test_syscalls:recvmsg ENOSYS"); + if (revoke("/tmp/cap_test_syscalls_revoke") < 0) { + if (errno != ENOSYS) + warnx("test_syscalls:revoke %d", errno); + } else + warnx("test_syscalls:revoke succeeded"); + len = sendmsg(fd_socket, NULL, 0); if (len < 0 && errno == ENOSYS) warnx("test_syscalls:sendmsg ENOSYS"); @@ -312,6 +375,13 @@ } else warnx("test_syscalls:stat succeeded"); + if (symlink("/tmp/cap_test_syscalls_symlink_from", + "/tmp/cap_test_syscalls_symlink_to") < 0) { + if (errno != ENOSYS) + warnx("test_syscalls:symlink %d", errno); + } else + warnx("test_syscalls:symlink succeeded"); + /* XXXRW: No error return from sync(2) to test. */ if (unlink("/tmp/cap_test_syscalls_unlink") < 0) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801262222.m0QMMSN1069040>