Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2009 03:22:13 GMT
From:      Jonathan Anderson <jona@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 166427 for review
Message-ID:  <200907230322.n6N3MD0a042709@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166427

Change 166427 by jona@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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907230322.n6N3MD0a042709>