PERFORCE change 166488 for review

Jonathan Anderson jona at FreeBSD.org
Fri Jul 24 04:30:47 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166488

Change 166488 by jona at jona-trustedbsd-belle-vmware on 2009/07/24 04:29:44

	Make output consistent, added a simple regression test

Affected files ...

.. //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_qt/sandbox_qt.cpp#6 edit

Differences ...

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_qt/sandbox_qt.cpp#6 (text+ko) ====

@@ -118,13 +118,6 @@
 
 	QApplication app(argc, argv);
 
-	cout << "host:\t\tReading from /etc/passwd using normal open()..." << endl;
-	QFile passwd("/etc/passwd");
-	if(!passwd.open(QIODevice::ReadOnly | QIODevice::Text))
-		err(EX_IOERR, "Error opening /etc/passwd");
-
-	cout << passwd.readLine().data() << endl;
-
 	int my_fd = open(argv[0], O_RDONLY);
 	char *sargv[2] = { (char*) "sandbox_qt", NULL };
 	struct lc_sandbox *sandbox;
@@ -265,6 +258,18 @@
 	fflush(stdout);
 
 
+	printf("sandbox:\tOpening /etc/passwd directly... ");
+	fflush(stdout);
+
+	int tmp = open("/etc/passwd", O_RDONLY);
+	if((tmp != -1) || (errno != ENOSYS))
+		err(-1, "Was able to open /etc/passwd directly from sandbox");
+	else
+		printf("ENOSYS (sandbox working!)\n");
+	fflush(stdout);
+
+
+
 	// get a file descriptor for our host
 	struct lc_host *lchpp;
 	if(lcs_get(&lchpp) < 0) err(EX_IOERR, "Error getting lc_host");
@@ -379,8 +384,8 @@
 
 	char buf[80];
 	bzero(buf, 80);
-	if(read(fd, buf, 50) < 0) perror("Error reading /etc/passwd");
-	else printf("Read from /etc/passwd: ");
+	if(read(fd, buf, 35) < 0) perror("Error reading /etc/passwd");
+	else printf("sandbox:\tRead from /etc/passwd: ");
 
 	puts(buf);
 	fflush(stdout);
@@ -389,21 +394,20 @@
 	if(!f) err(EX_IOERR, "Error opening passwd via angel");
 
 	bzero(buf, 80);
-	if(!fgets(buf, 55, f) < 0) perror("Error reading /etc/passwd");
-	else printf("Read from /etc/passwd: ");
+	if(!fgets(buf, 36, f) < 0) perror("Error reading /etc/passwd");
+	else printf("sandbox:\tRead from /etc/passwd: ");
 
 	puts(buf);
 	fflush(stdout);
 
-	printf("Reading via QFile...\n");
+	printf("sandbox:\tReading /etc/group via QFile:\n");
 	fflush(stdout);
 
 	QFile group("/etc/group");
 	if(!group.open(QIODevice::ReadOnly | QIODevice::Text))
 		err(EX_IOERR, "Error opening /etc/group");
 
-	printf("Filename: %s\n", group.fileName().toStdString().c_str());
-	printf("Data: %s\n", group.readLine().data());
+	printf("\t\t%s\n", group.readLine().data());
 	fflush(stdout);
 	
 


More information about the p4-projects mailing list