PERFORCE change 179110 for review

Robert Watson rwatson at FreeBSD.org
Wed Jun 2 18:01:37 UTC 2010


http://p4web.freebsd.org/@@179110?ac=10

Change 179110 by rwatson at rwatson_cinnamon on 2010/06/02 18:01:07

	Prefer style(9) in many spots, and in one case, prefer sandbox() to
	cap_main() in order to compile.

Affected files ...

.. //depot/projects/trustedbsd/capabilities/src/tools/cap/cap_exec/cap_exec.c#9 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/cap_exec/main.c#5 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/fdlist/fdlist.c#11 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/fdrpc/fdrpc.c#10 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/fdsendrecv/fdsendrecv.c#7 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/ld_libdirs/ld_libdirs.c#3 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_echo/sandbox_echo.c#14 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_world/sandbox_world.c#9 edit
.. //depot/projects/trustedbsd/capabilities/src/usr.bin/gzip/gzip.c#11 edit
.. //depot/projects/trustedbsd/capabilities/src/usr.bin/gzip/gzsandbox.c#16 edit

Differences ...

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/cap_exec/cap_exec.c#9 (text+ko) ====


==== //depot/projects/trustedbsd/capabilities/src/tools/cap/cap_exec/main.c#5 (text+ko) ====

@@ -9,23 +9,25 @@
 int
 sandbox(int argc, char *argv[])
 {
+
 	printf("pid %d cap_main(%d, %p)\n", getpid(), argc, argv);
-	return 0;
+	return (0);
 }
 
 int
 main(int argc, char *argv[])
 {
-	if (ld_insandbox()) return sandbox(argc, argv);
+
+	if (ld_insandbox())
+		return (sandbox(argc, argv));
 
 	printf("pid %d main(%d, %p)\n", getpid(), argc, argv);
 
-	if(opendir("./") == NULL)
+	if (opendir("./") == NULL)
 		printf("Call to opendir() failed (good!) - errno %i (%s)\n",
-		       errno, strerror(errno));
+		    errno, strerror(errno));
 	else
 		fprintf(stderr, "Call to opendir() didn't fail!");
 
-	return 0;
+	return (0);
 }
-

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/fdlist/fdlist.c#11 (text+ko) ====

@@ -49,7 +49,7 @@
 int	ld_insandbox(void);
 int	sandbox(void);
 
-static void print_fdlist(struct lc_fdlist *lfp);
+static void	print_fdlist(struct lc_fdlist *lfp);
 
 
 /*
@@ -61,7 +61,8 @@
 	struct lc_fdlist *lfp;
 	int testfd;
 
-	if (ld_insandbox()) return sandbox();
+	if (ld_insandbox())
+		return (sandbox());
 
 	printf("fdlist: PID %d\n", getpid());
 
@@ -71,26 +72,25 @@
 		err(-1, "lc_fdlist_new()");
 
 	lc_fdlist_addcap(lfp, "org.freebsd.test.fdlist", "stdin", "",
-	                 0, CAP_READ);
+	    0, CAP_READ);
 
 	lc_fdlist_addcap(lfp, "org.freebsd.test.fdlist", "stdout", "",
-	                 1, CAP_WRITE | CAP_SEEK);
+	    1, CAP_WRITE | CAP_SEEK);
 
 	lc_fdlist_addcap(lfp, "org.freebsd.test.fdlist", "stderr", "",
-	                 2, CAP_WRITE | CAP_SEEK);
+	    2, CAP_WRITE | CAP_SEEK);
 
 	lc_fdlist_add(lfp, "org.freebsd.test.fdlist", "testfile",
-	              "/etc/passwd", open("/etc/passwd", O_RDONLY));
+	    "/etc/passwd", open("/etc/passwd", O_RDONLY));
 	lc_fdlist_addcap(lfp, "org.freebsd.test.fdlist", "testfile",
-	                 "/etc/group", open("/etc/group", O_RDONLY), CAP_READ);
+	    "/etc/group", open("/etc/group", O_RDONLY), CAP_READ);
 
 	print_fdlist(lfp);
 
 	char *name;
 	if (lc_fdlist_lookup(lfp, "org.freebsd.test.fdlist", "stdin",
-	                     &name, &testfd, NULL) < 0) {
+	    &name, &testfd, NULL) < 0)
 		err(-1, "lc_fdlist_lookup: can't find stdin");
-	}
 
 	printf("Starting sandbox...\n");
 
@@ -103,23 +103,23 @@
 	struct lc_sandbox *sandbox;
 
 	if (lch_startfd(me, "fdlist-sandbox", sargv,
-	                LCH_PERMIT_STDOUT | LCH_PERMIT_STDERR, lfp, &sandbox))
-
+	    LCH_PERMIT_STDOUT | LCH_PERMIT_STDERR, lfp, &sandbox))
 		err(-1, "Error starting sandbox");
 
 	sleep(1);
-	return 0;
+	return (0);
 }
 
-
-
 int
-sandbox()
+sandbox(void)
 {
-	printf("sandbox alive\n"); fflush(stdout);
+
+	printf("sandbox alive\n");
+	fflush(stdout);
 
 	struct lc_fdlist *global_fdlist = lc_fdlist_global();
-	printf("Received FD list:\n"); fflush(stdout);
+	printf("Received FD list:\n");
+	fflush(stdout);
 
 	int pos = 0;
 	char *subsystem;
@@ -128,13 +128,13 @@
 	int fd;
 
 	while (lc_fdlist_getentry(global_fdlist, &subsystem, &class,
-	                          &name, &fd, &pos) >= 0)
-		printf("%d\t'%s'.'%s': '%s' (%d)\n",
-		       pos, subsystem, class, name, fd);
+	    &name, &fd, &pos) >= 0)
+		printf("%d\t'%s'.'%s': '%s' (%d)\n", pos, subsystem, class,
+		    name, fd);
 
 	printf("OK.\n");
 
-	return 0;
+	return (0);
 }
 
 void
@@ -147,8 +147,8 @@
 	int fd;
 
 	while (lc_fdlist_getentry(lfp, &subsystem, &class, &name, &fd, &pos)
-	        >= 0) {
+	    >= 0) {
 		printf("%d\t'%s'.'%s': '%s' (%d)\n",
-		       pos, subsystem, class, name, fd);
+		    pos, subsystem, class, name, fd);
 	}
 }

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/fdrpc/fdrpc.c#10 (text+ko) ====

@@ -68,7 +68,8 @@
 	size_t len;
 	char ch;
 
-	if (ld_insandbox()) return sandbox();
+	if (ld_insandbox())
+		return (sandbox());
 
 	if (argc != 1)
 		errx(-1, "usage: fdrpc_host");
@@ -112,7 +113,7 @@
  * descriptors to the host.
  */
 int
-sandbox()
+sandbox(void)
 {
 	int fd, fdcount;
 	struct lc_host *lchp;

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/fdsendrecv/fdsendrecv.c#7 (text+ko) ====

@@ -51,7 +51,6 @@
 int	ld_insandbox(void);
 int	sandbox(void);
 
-
 int
 main(int argc, char *argv[])
 {
@@ -60,7 +59,8 @@
 	int fdarray[2], fdcount;
 	char ch;
 
-	if (ld_insandbox()) return sandbox();
+	if (ld_insandbox())
+		return (sandbox());
 
 	if (argc != 1)
 		errx(-1, "usage: fdsendrecv_host");
@@ -92,7 +92,7 @@
 }
 
 int
-sandbox()
+sandbox(void)
 {
 	struct lc_host *lchp;
 	ssize_t len;

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/ld_libdirs/ld_libdirs.c#3 (text+ko) ====

@@ -52,14 +52,14 @@
 
 void	print_fdlist(struct lc_fdlist*);
 
-
 int
 main(int argc, char *argv[])
 {
 	struct lc_sandbox *lcsp;
 	char *sandbox_argv[3] = { argv[1], "sandbox", NULL };
 
-	if (ld_insandbox()) return sandbox();
+	if (ld_insandbox())
+		return (sandbox());
 
 	for (int i = 0; i < 200; i++) {
 		int size = i;
@@ -87,7 +87,7 @@
 }
 
 int
-sandbox()
+sandbox(void)
 {
 	struct lcs_host *host;
 
@@ -136,12 +136,13 @@
 			break;
 		}
 	}
-
-	return 0;
+	return (0);
 }
 
 
-void print_fdlist(struct lc_fdlist *fds) {
+void
+print_fdlist(struct lc_fdlist *fds)
+{
 
 	char *subsystem;
 	char *classname;
@@ -149,10 +150,8 @@
 	int fd, pos = 0;
 
 	while(lc_fdlist_getentry(fds, &subsystem, &classname, &name, &fd, &pos)
-	       >= 0) {
-
+	    >= 0) {
 		printf("%d\t'%s'.'%s': %d ('%s')\n",
 		       pos, subsystem, classname, fd, name);
 	}
 }
-

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_echo/sandbox_echo.c#14 (text+ko) ====

@@ -48,7 +48,7 @@
 #define	MYNAME	"sandbox_echo"
 
 
-int sandbox(int argc, char *argv[]);
+int	sandbox(int argc, char *argv[]);
 
 int
 main(int argc, char *argv[])
@@ -60,7 +60,8 @@
 	char ch;
 	int i;
 
-	if(ld_insandbox()) return cap_main(argc, argv);
+	if (ld_insandbox())
+		return (sandbox(argc, argv));
 
 	if (argc != 1)
 		errx(-1, "usage: sandbox_echo");

==== //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_world/sandbox_world.c#9 (text+ko) ====

@@ -68,7 +68,8 @@
 	size_t len;
 	char ch;
 
-	if (ld_insandbox()) return sandbox();
+	if (ld_insandbox())
+		return (sandbox());
 
 	if (argc != 1)
 		errx(-1, "usage: sandbox_world");
@@ -104,7 +105,7 @@
  * Sandboxed process implementing a 'printf hello world' RPC.
  */
 int
-sandbox()
+sandbox(void)
 {
 	struct lc_host *lchp;
 	u_int32_t opno, seqno;
@@ -148,5 +149,5 @@
 		free(buffer);
 	}
 
-	return 0;
+	return (0);
 }

==== //depot/projects/trustedbsd/capabilities/src/usr.bin/gzip/gzip.c#11 (text+ko) ====

@@ -303,7 +303,8 @@
 	int ch;
 
 #ifndef NO_SANDBOX_SUPPORT
-	if (ld_insandbox()) return gzsandbox();
+	if (ld_insandbox())
+		return (gzsandbox());
 #endif
 
 	/* XXX set up signals */

==== //depot/projects/trustedbsd/capabilities/src/usr.bin/gzip/gzsandbox.c#16 (text+ko) ====

@@ -327,7 +327,8 @@
 /*
  * Main entry point for capability-mode 
  */
-int gzsandbox(void)
+int
+gzsandbox(void)
 {
 	int fdarray[2], fdcount;
 	struct lc_host *lchp;


More information about the p4-projects mailing list