PERFORCE change 166427 for review
Jonathan Anderson
jona at FreeBSD.org
Thu Jul 23 03:22:15 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166427
Change 166427 by jona at jona-trustedbsd-belle-vmware on 2009/07/23 03:21:47
Test that cap_new(capability) wraps the original file properly
Affected files ...
.. //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_capabilities.c#4 edit
Differences ...
==== //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_capabilities.c#4 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_capabilities.c#3 $");
+__FBSDID("$P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/security/cap_test/cap_test_capabilities.c#4 $");
#include <sys/param.h>
#include <sys/capability.h>
@@ -57,8 +57,8 @@
{
struct stat sb;
struct statfs sf;
- int fd_cap;
- ssize_t ssize;
+ int fd_cap, fd_capcap;
+ ssize_t ssize, ssize2;
off_t off;
void *p;
char ch;
@@ -68,6 +68,11 @@
if (fd_cap < 0)
err(-1, "cap_new");
+ fd_capcap = cap_new(fd_cap, rights);
+ if ((fd_capcap < 0) || (fd_capcap == fd_cap))
+ err(-1, "cap_new: fd_capcap = %i, fd_cap = %i",
+ fd_capcap, fd_cap);
+
ssize = read(fd_cap, &ch, sizeof(ch));
if ((rights & (CAP_READ | CAP_SEEK)) == (CAP_READ | CAP_SEEK)) {
if (ssize < 0)
@@ -82,6 +87,11 @@
}
ssize = pread(fd_cap, &ch, sizeof(ch), 0);
+ ssize2 = pread(fd_cap, &ch, sizeof(ch), 0);
+ if(ssize != ssize2)
+ err(-1, "pread(fd_capcap) != pread(fd_cap) (%i != %i)",
+ ssize2, ssize);
+
if (rights & CAP_READ) {
if (ssize < 0)
warnx("rights 0x%llx pread failed error %d", rights,
More information about the p4-projects
mailing list