From owner-p4-projects@FreeBSD.ORG Sat Jan 26 22:22:28 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9E7C416A418; Sat, 26 Jan 2008 22:22:28 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B44616A420 for ; Sat, 26 Jan 2008 22:22:28 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3E3DD13C465 for ; Sat, 26 Jan 2008 22:22:28 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0QMMSpX069043 for ; Sat, 26 Jan 2008 22:22:28 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0QMMSN1069040 for perforce@freebsd.org; Sat, 26 Jan 2008 22:22:28 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 26 Jan 2008 22:22:28 GMT Message-Id: <200801262222.m0QMMSN1069040@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 134152 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jan 2008 22:22:28 -0000 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 -__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 #include +#include #include #include #include @@ -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) {