Commit graph

167 commits

Author SHA1 Message Date
Mariusz Zaborski 832dc76b63 libcasper: Introduce cap_net a network service for Casper.
Reviewed by:	emaste, markj (previous version), bcr (man page)
Differential Revision:	https://reviews.freebsd.org/D24688
2020-08-16 18:12:21 +00:00
Mateusz Piotrowski f4b792fa67 Fix trailing-comma-related typos in the tree when the Xr macro is used
MFC after:	1 week
2020-06-27 11:13:45 +00:00
Gordon Bergling 421f325efc libcasper(3): Document HISTORY within the manpages
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:		7 days
Differential Revision:	https://reviews.freebsd.org/D24695
2020-06-16 16:48:52 +00:00
Mark Johnston c78e42e207 cap_fileargs: Fix a descriptor leak in the service process.
The service handler for fileargs_open() tries to pre-open multiple files
and pass descriptors for each back to the sandboxed process in a single
message.  This is to amortize the cost of round-trips between the two
processes.

The service process adds a "cache" nvlist to the reply to "open",
containing file descriptors for pre-opened files.  However, when adding
that nvlist to the reply, it was making a copy, effectively leaking the
cached descriptors.

While here, fix spelling in a local variable name.

PR:		241226
Reviewed by:	oshogbo
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25095
2020-06-01 15:32:13 +00:00
Alan Somers 133b8ab5bb cap_dns.3: fix some orphan .Xr links
Reported by:	phk
MFC after:	2 weeks
2020-04-18 20:13:43 +00:00
Conrad Meyer b30c6ac9f9 libcasper(3): Export functions to C++
We must wrap C declarations in __BEGIN / __END_DECLS to avoid C++ name-mangling
of the declaration when including the C header; name-mangling causes the linker
to attempt to locate the wrong (C++ ABI) symbol name.

Reviewed by:	markj, oshogbo (earlier version both)
Differential Revision:	https://reviews.freebsd.org/D24323
2020-04-07 16:40:41 +00:00
Conrad Meyer 2750f1b954 libcasper: Constify cap_sysctl_limit_mib() mib parameter
No functional change. Minor API change that is nicer for consumers. ABI is
identical; the routine never needed to modify the pointed to value.

Reviewed by:	emaste, markj
Differential Revision:	https://reviews.freebsd.org/D24319
2020-04-06 23:07:56 +00:00
Simon J. Gerraty 2c9a9dfc18 Update Makefile.depend files
Update a bunch of Makefile.depend files as
a result of adding Makefile.depend.options files

Reviewed by:	 bdrewery
MFC after:	1 week
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22494
2019-12-11 17:37:53 +00:00
Kyle Evans b3bec79d36 cap_sysctl: correct typo from r347534-ish
operation & ~limit where limit is a bool is clearly not what was intended,
given the line prior. Correct it to use the calculated mask for validation.

The cap_sysctl tests should now be functional again.
2019-10-23 03:23:14 +00:00
Kyle Evans e735aa5a74 libcasper/services: include <src.opts.mk> to hook tests to build
Note that the cap_sysctl tests are currently failing and need some
attention.
2019-10-23 01:50:41 +00:00
Emmanuel Vadot 724fad3ad0 pkgbase: Move libcap_ to FreeBSD-runtime
A lot of binaries present in FreeBSD-runtime depend on it so move
the libs there.

Reviewed by:	bapt, gjb
Differential Revision:	https://reviews.freebsd.org/D21501
2019-09-05 14:10:26 +00:00
Mariusz Zaborski 9509775394 cap_filergs: limit size of the file name
The limit of the name in fileargs is twice the size of the MAXPATH.
The nvlist will not add an element with the longer name.
We can detect at this point that the path is too big, and simple return
the same error as open(2) would.

PR:		239700
Reported by:	markj
Tested by:	markj
MFC after:	2 weeks
2019-08-07 19:30:33 +00:00
Mariusz Zaborski 64b3a6b3b3 fileargs: fix formating in EXAMPLES
PR:		239523
Submitted by:	mikael.urankar@gmail.com
2019-07-30 08:53:03 +00:00
Mariusz Zaborski 8cf7941693 libcasper: remove reference to deprecated system.random 2019-07-29 21:26:26 +00:00
Mark Johnston a76f78dc3f Remove cap_random(3).
Now that we have a way to obtain entropy in capability mode
(getrandom(2)), libcap_random is obsolete.  Remove it.

Bump __FreeBSD_version in case anything happens to use it, though I've
found no consumers.

Reviewed by:	delphij, emaste, oshogbo
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21033
2019-07-24 22:50:43 +00:00
Mark Johnston 89e9665b8d Link fileargs_lstat.3.
Sponsored by:	The FreeBSD Foundation
2019-07-21 16:35:49 +00:00
Mariusz Zaborski 4b3f792718 fileargs: add wrapping/unwrapping functions
Those function may be useful to pass fileargs connections around.
2019-06-12 19:31:26 +00:00
Mark Johnston adbb25df4b Extend the libcap_sysctl tests.
- Add some coverage for cap_sysctl(3).
- Add a test for the case where the caller wishes to find the sysctl
  output length without specifying an output buffer.

Reviewed by:	oshogbo
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17856
2019-05-13 17:53:03 +00:00
Mark Johnston 3c766430f7 Convert the libcap_sysctl test cases to ATF.
Reviewed by:	oshogbo
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17855
2019-05-13 17:51:03 +00:00
Mark Johnston 1608c46ea4 Add cap_sysctl(3) and cap_sysctlnametomib(3).
These complement cap_sysctlbyname(3) to provide a drop-in
replacement for the corresponding libc functions.

Also revise the libcap_sysctl limit interface to provide access
to sysctls by MIB, and to avoid direct manipulation of nvlists
by the caller.

Reviewed by:	oshogbo
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17854
2019-05-13 17:49:54 +00:00
Adrian Chadd d2fd7f28fe [casper] fix compilation when casper is disabled.
This triggers an error in gcc-mips 6.4.0 complaining about unused arguments.

Tested:

* compiled/run on mips32; nothing complained.
2019-04-17 16:58:38 +00:00
Ed Maste 151744cf5c cap_fileargs: fix test after r346318
Reported by:	danfe, mjg
MFC after:	3 weeks
MFC with:	r346315
Sponsored by:	The FreeBSD Foundation
2019-04-17 16:45:42 +00:00
Ed Maste b6539d47bd cap_fileargs: fix GCC build, don't shadow 'stat'
Reported by:	ci.freebsd.org
MFC after:	3 weeks
MFC with:	r346315
Sponsored by:	The FreeBSD Foundation
2019-04-17 16:31:30 +00:00
Ed Maste 7b558caee3 cap_fileargs: add fileargs_lstat service
Add fileargs_lstat function to cap_fileargs casper service to be able to
lstat files while in capability mode.  It can only lstat files given in
fileargs_init.

Submitted by:	Bora Özarslan <borako.ozarslan@gmail.com>
Reviewed by:	oshogbo, cem (partial)
MFC after:	3 weeks
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19548
2019-04-17 16:02:57 +00:00
Ed Maste fc07a84f80 cap_fileargs.3: typo and markup corrections
Submitted by:	Bora Özarslan" <borako.ozarslan@gmail.com>
MFC after:	1 week
MFC with:	r346313
Sponsored by:	The FreeBSD Foundation
2019-04-17 16:00:33 +00:00
Ed Maste 731d06abf2 cap_fileargs.3: correct 'filerags' typo
Submitted by:	Bora Özarslan" <borako.ozarslan@gmail.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-04-17 15:48:33 +00:00
Jason A. Harmening f048354550 r341692 changed cap_syslog(3) to preserve the stdio descriptors inherited
from its parent so that LOG_PERROR would work.  However, this caused
dhclient(8)'s stdio streams to remain open across daemonization, breaking
the ability to capture its foreground output as done in netconfig_ipv4.

Fix this by reverting r341692 and instead passing the parent's stderr
descriptor as an argument to cap_openlog() only when LOG_PERROR is specified
in logopt.

PR:	234514
Suggested by:	markj
Reported by:	Shawn Webb
Reviewed by:	markj, oshogbo
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18989
2019-02-06 04:36:28 +00:00
Mariusz Zaborski 28f4385e45 libcasper: do not run registered exit functions
Casper library should not use exit(3) function because before setting it up
applications may register it. Casper doesn't depend on any registered exit
function, so it safe to change this.

Reported by:	jceel
MFC after:	2 weeks
2019-01-26 14:10:49 +00:00
Mark Johnston 08c4a937a6 Let the cap_syslog capability inherit stdio descriptors.
Otherwise cap_openlog(LOG_PERROR) doesn't work.

Reviewed by:	oshogbo
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18457
2018-12-07 15:52:50 +00:00
Mariusz Zaborski 77ebcc05ea libcasper: do not fail if Capsicum is not avilable
Casper service can be also used on the kernels without Capsicum support.

Reported by:	sbruno
Tested by:	sbruno
2018-11-30 19:27:14 +00:00
Mariusz Zaborski 2863fd2f27 libcasper: provide compatibility with the old version of service
Some external tools like tcpdump(1) have upstream the changes with old limits
name. Because of that provide compatibility with the old names.

Reported by:	emaste
2018-11-19 17:22:52 +00:00
Mariusz Zaborski fd253945ac Update the names in the LIMITS and EXAMPLES sections after r340363.
Reported by:	markj
2018-11-18 11:11:27 +00:00
Mariusz Zaborski 2607c01b66 Fix typo in the comparison.
This fix build with gcc.

Reported by:	jenkins
2018-11-12 18:37:31 +00:00
Mariusz Zaborski cdd6ea94b0 libcasper: introduce cap_fileargs service
cap_fileargs is a Casper service which helps to sandbox applications that need
access to the filesystem namespace. The main purpose of the service is to make
easy to capsicumize applications that works on multiple files passed in argv.

We have a couple example of using it but we still treat this service as an
experimental one.

Reviewed by:	emsate (previous version), jonathan (partially)
Discussed with:	many
Differential Revision:	https://reviews.freebsd.org/D14407
2018-11-12 17:40:47 +00:00
Mariusz Zaborski 752d135e0d libcasper: ange the name of limits in cap_dns so the intentions are obvious.
Reported by:	pjd
MFC after:	3 weeks
2018-11-12 15:52:45 +00:00
Mark Johnston 35b4d0f125 Document the fact that cap_limit_set() always frees the input nvlist.
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-11-05 21:01:45 +00:00
Mariusz Zaborski d9c2248dd5 libcasper: using explicit_bzero in cap_grp service
Please notice that we still don't clean information in nvlist structures.

Submitted by:	David CARLIER <devnexen@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D16777
2018-11-04 19:43:59 +00:00
Mariusz Zaborski 577dff6a8d libcasper: fix limitations in dns service
The getaddrinfo(3) and gethostbyname(3) are used to return the address for a
given hostname. The getnameinfo(3) and gethostbyaddr(3) are used to return
hostname for a given address. Right now in casper, we have two limitations:
- NAME which allows resolving DNS names.
- ADDR which allows to do revert DNS lookups.

Before this change the rights was mixed up:
NAME - getnameinfo(3) and gethostbyname(3)
ADDR - gethostbyaddr(3) and getaddrinfo(3)

Which no matters on limitation allowed us to resolve DNS names and do DNS
lookups basically by using a different set of functions.

Now the NAME type allows getaddrinfo(3) and gethostbyname (3)functions,
and the ADDR names allow to use gethostbyaddr(3) and getnameinfo(3) functions.

Reviewed by:	pjd, bcr
MFC after:	3 weeks
Discussed with:	hrs
Differential Revision:	https://reviews.freebsd.org/D16930
2018-11-04 19:38:54 +00:00
Mariusz Zaborski db9a6e4178 libcasper: Update example in man page to use cap_getnameinfo function.
Reviewed by:	hrs
Differential Revision:	https://reviews.freebsd.org/D16931
2018-11-04 19:31:44 +00:00
Mariusz Zaborski fe24949034 libcasper: Document the cap_getaddrinfo and cap_getnameinfo functions
Reviewed by:	hrs
Differential Revision:	https://reviews.freebsd.org/D16929
2018-11-04 19:29:19 +00:00
Mark Johnston e9b1dc32c9 Fix comments.
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-10-24 00:17:19 +00:00
Edward Tomasz Napierala 78b9f0095b Fix typo.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2018-08-16 14:46:49 +00:00
Mariusz Zaborski 2da0fcde21 With r335636 C++ program use libcasper.h and capsicum_helpers.h.
Add __BEGIN_DECLS and __END_DECLS to those headers.
2018-07-01 18:58:53 +00:00
Mariusz Zaborski 00e9473388 [libcasper] Use explicit_bzero instead of memset to clear pwd struct
Submitted by:	David Carlier <devnexen@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D16015
2018-06-26 19:57:47 +00:00
Eitan Adler bec6dc30e1 users(1): Use capsicum helpers for users
In doing so also fix the libcasper.h header to work in C++.
2018-06-25 11:44:41 +00:00
Mariusz Zaborski 9324388b0a Document libcasper_service.
Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D15766
2018-06-23 20:12:30 +00:00
Mariusz Zaborski 68b2ec19e1 Fix typo. 2018-06-19 22:19:42 +00:00
Mariusz Zaborski 4468cd1a73 The gids argument can be declared as const.
We don't modified it in this function.
2018-03-18 19:50:32 +00:00
Mariusz Zaborski 78d69bcbf4 Fix reference to man page in Makefile.
I broke it in r331120.
2018-03-18 17:27:37 +00:00
Mariusz Zaborski cba559e112 Fix similar typos to r331124. 2018-03-18 16:06:35 +00:00
Mariusz Zaborski d5219c1955 Fix typo.
Submitted by:	Trond Endrestøl <Trond.Endrestol@ximalas.info>
2018-03-18 16:02:41 +00:00
Mariusz Zaborski 2d649033ec Update libcasper references to all new man pages.
Remove obsolete example. All services has they own example.
This example also show old type of limiting method which is
not recommended to use.

Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D14607
2018-03-18 15:24:45 +00:00
Mariusz Zaborski edd09a2599 Document the sysctl Casper service.
PR:		226102
Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D14606
2018-03-18 15:16:47 +00:00
Mariusz Zaborski 54442b3cfa Document the pwd Casper service.
PR:		226102
Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D14605
2018-03-18 15:13:37 +00:00
Mariusz Zaborski 85ebe1f1cf nv was moved to the 9 section.
Fix reference to it.
2018-02-26 19:08:27 +00:00
Mariusz Zaborski 8763ae3526 Fix typo. 2018-02-26 18:06:15 +00:00
Mariusz Zaborski a241c14f9a Fix reference to nvlist in man pages.
Reviewed by:	@bcr @brueffer
Pointed out by:	@brueffer
Differential Revision:	https://reviews.freebsd.org/D14410
2018-02-24 16:31:26 +00:00
Mariusz Zaborski 4fc0a2791e Introduce channel flags in libcasper.
Instead of passing flags (which describe a type of nvlist)
every send/recv we remember them in channel.
It's enough for use to extract them only during unwrap.
This simplify use of Casper.

Reviewed by:	bruffer@, bcr@ (both man page)
Differential Revision:	https://reviews.freebsd.org/D14196 (man page)
2018-02-17 12:22:29 +00:00
Mark Johnston c0a2a830e2 Document the need for WITH_CASPER.
After r325062, consumers need to define WITH_CASPER for libcasper to
function as expected.
2018-02-05 17:33:16 +00:00
Mariusz Zaborski 5869a5d8ea The name of the library is exactly the same like one of name the name of the
functions.

We should not create MLINKS for that one, because it's break a build.

Submitted by:	lwhsu@
2018-01-29 05:29:28 +00:00
Mariusz Zaborski eca3793736 Document the syslog Casper service.
Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D14084
2018-01-29 04:38:11 +00:00
Mariusz Zaborski c1d2583d9d Add cap_random.3 to build system.
This should be done with r328494.
2018-01-27 22:57:06 +00:00
Mariusz Zaborski 90b809116a Fix caspermock - the cap_recv_nvlist should return nvlist. 2018-01-27 22:53:29 +00:00
Mariusz Zaborski f45de90e55 Document the random Casper service.
Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D14072
2018-01-27 22:49:34 +00:00
Mariusz Zaborski 28b6f7c86a Add SPDX tags for libcasper(3) and services.
MFC after:	2 weeks
2018-01-27 12:55:34 +00:00
Mariusz Zaborski 56a791046d Document the grp Casper service.
Reviewed by:	brueffer@, bcr@
Differential Revision:	https://reviews.freebsd.org/D13821
2018-01-27 11:54:51 +00:00
Mariusz Zaborski 280f3264a4 Fix markup. 2018-01-10 02:57:22 +00:00
Mariusz Zaborski d06b4cefed Document the DNS Casper service.
Reviewed by:	brueffer@, bcr@
Differential Revision:	https://reviews.freebsd.org/D13762
2018-01-08 09:20:08 +00:00
Mariusz Zaborski e1c30f7a07 Build service tests with Casper support. 2018-01-05 09:31:41 +00:00
Mariusz Zaborski 40905ec6bb cap_unwrap should return a descriptor but also free the structure. 2018-01-04 08:23:23 +00:00
Mariusz Zaborski bf2204a5ef Add missing macro in man page.
Reported by:	brueffer@
2018-01-04 04:04:29 +00:00
Mariusz Zaborski 6564c8d6ca Document services which we have in libcasper.
Reviewed by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D13734
2018-01-03 06:22:40 +00:00
Mariusz Zaborski 7b4fce76cc Introduce syslog service for Casper.
syslog in libc secretly reconnects to the daemon.
Another issue is that we don't have any information from openlog(3) if we
succeeded to open log or not so we don't know if we are ready
to enter cabability mode.
Because all of that we decided we need a syslog service for Caspser.

Reviewed by:	bapt@
Differential Revision:	https://reviews.freebsd.org/D12824
2017-11-12 08:34:25 +00:00
Mariusz Zaborski 8751b03b19 We return a pointer when we are using cap_init() or cap_service_open()
function, so check if cap_chanel_t is NULL is not enough.
Casper with a normal libc will still fail in capability mote so let's not
enter capability mode without casper support when we need to resolve DNS.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D12823
2017-11-12 07:18:10 +00:00
Glen Barber 0ff7d32714 Fix the 'casper' package, following r325062.
Submitted by:	woodsb02
Sponsored by:	The FreeBSD Foundation
2017-11-08 01:00:59 +00:00
Mariusz Zaborski 0dfac7ee08 The src.opts.mk sets default value for the SHLIBDIR, so our set was not
respected.

Please notice that libcasper is already in ObsoleteFiles so we don't add it
again.

Reported by:	Herbert J. Skuhra <herbert@mailbox.org>
Reviewed by:	bdrewery@
Differential Revision:	https://reviews.freebsd.org/D12918
2017-11-04 15:50:05 +00:00
Mariusz Zaborski 95844abe53 Casper work's only as shared library - disable building static ones.
Reviewed by:	bdrewery@
Differential Revision:	https://reviews.freebsd.org/D12917
2017-11-04 15:47:18 +00:00
Enji Cooper ca28b8ee5b Add static to cap_setgrent prototype in !WITH_CASPER case
This unbreaks the default powerpc/sparc64 build configuration after r325062.
2017-10-31 04:02:50 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery 3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Mariusz Zaborski c19b1a6a08 Fix information about nv.h include.
MFC after:	1 week
2017-10-29 09:50:20 +00:00
Mariusz Zaborski ceb36bc93a Introduce caspermocks.
The idea behinds mocks is that we don't need to ifdef a lot of code in
tools itself but those defines are hidden in the casper library.
Right now the mocks are implemented as define/inlines functions.
There was a very long discussion how this should be implemented.
This approach has some advantages like we don't need to link to any additional
libraries. Unfortunately there are also some disadvantages for example it is
easy to get library out of sync between two versions of functions or that we
need extra define to compile program with casper support.
This isn't an ideal solution but it's good enough for now and should simplify
capsicumizing programs. This also doesn't close us any other ways to do those
mocks and this should evolve in time.

Discussed with:	pjd, emaste, ed, rwatson, bapt, cem, bdrewery
Differential Revision:    https://reviews.freebsd.org/D8753
2017-10-28 19:23:57 +00:00
Enji Cooper 188e46ab03 Add supporting changes for Add limited sandbox capability to "make check"
Non-tests/... changes:
- Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration
  and propagate the appropriate environment down to *.test.mk.

tests/... changes:
- Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner,
  since tests/... is a special subdirectory tree compared to the others.

MFC after:	2 months
MFC with:	r322511
Reviewed by:	arch (silence), testing (silence)
Differential Revision:	D12014
2017-08-14 19:21:37 +00:00
Enji Cooper ac5ff11099 TESTSDIR isn't required; remove it
MFC after:	1 week
MFC with:	r322450
2017-08-13 01:08:37 +00:00
Enji Cooper 38dd175927 Integrate the tests moved in r305626 in to the FreeBSD test suite
The reachover Kyuafiles were never added, and thus the tests were installed
as standalone tests, and not integrated into the full suite.

MFC after:	1 week
MFC with:	r305626, 305629, r307863, r322447, r322448, r322449
2017-08-13 01:04:44 +00:00
Enji Cooper 191d976f61 Use hardcoded IPv4/IPv6 addresses for google-public-dns-a.google.com instead
of freefall.freebsd.org to unbreak the DNS tests

The address allocations for freefall.freebsd.org have changed in the past 4 years.
Use a more stable set of hardcoded addresses for now to make the tests succeed
reliably.

The hostname should be resolved dynamically instead of hardcoding the addresses in
the future. This is just a bandaid.

MFC after:	1 week
2017-08-13 00:56:43 +00:00
Enji Cooper 737fb907a7 Make root-privileges a requirement for the test
Some of the testcases try to manipulate sysctls that require root privileges,
e.g., "kern.sync_on_panic". Make root-privileges a hard requirement so the
tests don't raise false positives due to privilege issues when calling
sysctlbyname(3) on writable sysctls.

MFC after:	1 week
2017-08-13 00:14:08 +00:00
Enji Cooper ebe3e93cef Fix result printing
- Flushing stdout prevents the buffer from being printed twice, fixing
  issues with stdout printing out the testplan, etc, twice.
- Don't print out raw source/line numbers; hide them behind comments.

MFC after:	1 week
2017-08-13 00:04:50 +00:00
Enji Cooper d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper 4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Robert Watson 9612674f64 In libcasper, prefer to send a function index or service name over the IPC
channel to a zygote process, rather than sending a function pointer or
service pointer.  This avoids transfering pointers between address spaces,
which while robust in this case (due to the zygote being forked() from the
parent) is not generally a good idea, especially in the presence of
increasingly popular control-flow integrity and pointer protection
mitigation schemes.  With this change, ping(8) and other sandboxed tools
using libcasper for DNS resolution now work on architectures with tagged
memory again.

Reviewed by:	oshogbo
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2017-03-23 14:35:21 +00:00
Ed Maste aa09009340 Set SHLIBDIR before .including src.opts.mk in libcapser services
bsd.own.mk (included from src.opts.mk) sets SHLIBDIR?=${LIBDIR}, so
SHLIBDIR must be set before including either one of them.

MFC with:	305626
Sponsored by:	The FreeBSD Foundation
2016-10-24 14:37:18 +00:00
Mariusz Zaborski e7798d20c5 Fix naming in Casper man page. 2016-10-05 16:23:02 +00:00
Mariusz Zaborski d3bfc7250f Move libcasper tests from regression/capsicum/libcasper/ to
lib/libcasper/service/${service_name}/tests.

Reviewed by:	emaste, ngie
Differential Revision:	https://reviews.freebsd.org/D7759
2016-09-08 20:01:26 +00:00
Mariusz Zaborski 59cf368df4 Don't close fd if it's lower then stderr, otherwise we can close
one of the descriptor which we just set.

Pointed out by:		jilles
Approved by:		re (hrs)
2016-06-13 00:03:55 +00:00
Mariusz Zaborski 920be817aa Add flags to the Casper services.
CASPER_SERVICE_STDIO - Casper will not close the first three descriptors (stdin,
		       stdout and stderr) this can be helpful for debugging.
CASPER_SERVICE_FD - Capser will not close all other descriptors, this can
		    be useful for a filesystem service.
2016-06-08 02:03:53 +00:00
Ed Schouten 2ca9ffa9bb Don't call setgrent() in an unportable way.
For FreeBSD 12, I'm considering updating setgrent() to have a function
prototype that conforms to POSIX. FreeBSD seems to be the only operating
system that lets setgrent() return an integer. It's also inconsistent
with setpwent().

It looks like our libcasper depends on setgrent() returning an integer.
Get rid of that.

Reviewed by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D6659
2016-06-01 20:45:21 +00:00
Glen Barber 0edd2576c0 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-16 02:32:12 +00:00
Mariusz Zaborski 7f6a709bef Set NULL to the ai_next pointer which fix cap_getaddrinfo().
Add regression test case.

PR:		195551
Submitted by:	Mikhail <mp39590@gmail.com>
Approved by:	pjd (mentor)
2016-04-14 18:27:10 +00:00
Glen Barber 52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00