PERFORCE change 164569 for review
Robert Watson
rwatson at FreeBSD.org
Wed Jun 17 11:26:40 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=164569
Change 164569 by rwatson at rwatson_freebsd_capabilities on 2009/06/17 11:25:40
Unify libcapability_exec/sandbox_echo.
Affected files ...
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/libcapability_exec/Makefile#2 delete
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/libcapability_exec/libcapability_exec.c#4 delete
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_echo/Makefile#4 edit
.. //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_echo/sandbox_echo.c#6 edit
Differences ...
==== //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_echo/Makefile#4 (text+ko) ====
@@ -1,6 +1,6 @@
PROG=sandbox_echo
NO_MAN=
-CFLAGS=-Wall -g
+CFLAGS=-Wall -g -rdynamic
DPADD= ${LIBCAPABILITY}
LDADD= -lcapability
==== //depot/projects/trustedbsd/capabilities/src/tools/cap/sandbox_echo/sandbox_echo.c#6 (text+ko) ====
@@ -50,6 +50,42 @@
int
main(int argc, char *argv[])
{
+ struct lc_sandbox *lcsp;
+ char *sandbox_argv[3] = { argv[1], "nested", NULL };
+ struct iovec iov;
+ size_t len;
+ char ch;
+ int i;
+
+ if (argc != 1)
+ errx(-1, "usage: sandbox_echo");
+
+ if (lch_start_flags(MYNAME, sandbox_argv, LCH_PERMIT_STDERR, &lcsp)
+ < 0)
+ err(-1, "lch_start %s", argv[1]);
+
+ for (i = 0; i < 10; i++) {
+ ch = i;
+ iov.iov_base = &ch;
+ iov.iov_len = sizeof(ch);
+ if (lch_rpc(lcsp, 0, &iov, 1, &iov, 1, &len) < 0)
+ err(-1, "lch_rpc");
+ if (len != sizeof(ch))
+ errx(-1, "lch_rpc returned size %d not %d", len,
+ sizeof(ch));
+ if (ch != i)
+ errx(-1, "lch_recv: expected %d and got %d", i, ch);
+ printf(".");
+ fflush(stdout);
+ }
+ printf(" OK\n");
+
+ lch_stop(lcsp);
+}
+
+int
+cap_main(int argc, char *argv[])
+{
char *sandbox_argv[3] = { MYNAME, NULL };
struct lc_sandbox *lcsp;
struct lc_host *lchp;
More information about the p4-projects
mailing list