Commit graph

167 commits

Author SHA1 Message Date
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
Bryan Drewery 3055a28d44 Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-02-26 22:14:15 +00:00
Bryan Drewery e6f17963a8 Remove unneeded lines.
- WARNS can be inherited from lib/Makefile.inc
- CFLAGS referred to a non-existent directory and this shouldn't be needed
  anyhow due to the build picking up includes from WORLDTMP.

Sponsored by:	EMC / Isilon Storage Division
2016-02-26 22:14:08 +00:00
Bryan Drewery 88ad7d508a These can build in parallel.
Sponsored by:	EMC / Isilon Storage Division
2016-02-26 22:14:04 +00:00
Mariusz Zaborski c501d73c7e Convert casperd(8) daemon to the libcasper.
After calling the cap_init(3) function Casper will fork from it's original
process, using pdfork(2). Forking from a process has a lot of advantages:
1. We have the same cwd as the original process.
2. The same uid, gid and groups.
3. The same MAC labels.
4. The same descriptor table.
5. The same routing table.
6. The same umask.
7. The same cpuset(1).
From now services are also in form of libraries.
We also removed libcapsicum at all and converts existing program using Casper
to new architecture.

Discussed with:		pjd, jonathan, ed, drysdale@google.com, emaste
Partially reviewed by:	drysdale@google.com, bdrewery
Approved by:		pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D4277
2016-02-25 18:23:40 +00:00
Glen Barber a70cba9582 First pass through library packaging.
Sponsored by:	The FreeBSD Foundation
2016-02-04 21:16:35 +00:00
Bryan Drewery b1f92fa229 META MODE: Update dependencies with 'the-lot' and add missing directories.
This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so.  A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR.  These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package.  The current implementation of targets/ is
very unmaintainable.

Currently rescue/rescue and sys/modules are still not connected.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:23:19 +00:00
Mariusz Zaborski c36e54bb32 Let the nv.h and dnv.h includes be only in sys directory.
Change consumers to include those files from sys.
Add duplicated files to ObsoleteFiles.

Approved by:	pjd (mentor)
2015-07-02 21:58:10 +00:00
Baptiste Daroussin 18b2ee82db Revert r284417 it is not necessary anymore 2015-06-15 19:28:07 +00:00
Baptiste Daroussin 4232f82668 Enforce overwritting SHLIBDIR
Since METAMODE has been added, sys.mk loads bsd.mkopt.mk which ends load loading
bsd.own.mk which then defines SHLIBDIR before all the Makefile.inc everywhere.

This makes /lib being populated again.

Reported by:	many
2015-06-15 15:34:20 +00:00
Mariusz Zaborski bd1da0a002 Approved, oprócz użycie RESTORE_ERRNO() do ustawiania errno.
Change the nvlist_recv() function to take additional argument that
specifies flags expected on the received nvlist. Receiving a nvlist with
different set of flags than the ones we expect might lead to undefined
behaviour, which might be potentially dangerous.

Update consumers of this and related functions and update the tests.

Approved by:	pjd (mentor)

Update man page for nvlist_unpack, nvlist_recv, nvlist_xfer, cap_recv_nvlist
and cap_xfer_nvlist.

Reviewed by:	AllanJude
Approved by:	pjd (mentor)
2015-05-02 17:45:52 +00:00
Baptiste Daroussin 6b129086dc Convert libraries to use LIBADD
While here reduce a bit overlinking
2014-11-25 11:07:26 +00:00
Robert Watson b881b8be1d Update most userspace consumers of capability.h to use capsicum.h instead.
auditdistd is not updated as I will make the change upstream and then do a
vendor import sometime in the next week or two.

MFC after:	3 weeks
2014-03-16 11:04:44 +00:00
Pawel Jakub Dawidek 5564ef953a Fix descriptor leak. 2014-02-09 21:47:46 +00:00
Pawel Jakub Dawidek 93b3fdba4a MFp4 @1189741:
- Add missing nvlist_destroy().
- Don't override nvlout.

Submitted by:	Mariusz Zaborski <oshogbo@FreeBSD.org>
MFC after:	3 days
2014-01-03 09:10:04 +00:00
Pawel Jakub Dawidek fecba05b97 Fix comparisons in assertions.
Reported by:	Coverity
Coverity CID:	1130048
2013-12-03 13:26:37 +00:00
Pawel Jakub Dawidek 0f984a9260 Both libcasper and libcapsicum libraries have to be installed in /lib/,
as they are used by /sbin/casperd.
2013-12-02 17:07:22 +00:00
Pawel Jakub Dawidek 05af64096c Forgot to 'svn add' lib/libcasper/ directory.
Reported by:	glebius
2013-12-02 10:18:25 +00:00