freebsd-nq/contrib
Pawel Jakub Dawidek 7008be5bd7 Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.

The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.

The structure definition looks like this:

	struct cap_rights {
		uint64_t	cr_rights[CAP_RIGHTS_VERSION + 2];
	};

The initial CAP_RIGHTS_VERSION is 0.

The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.

The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.

To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.

	#define	CAP_PDKILL	CAPRIGHT(1, 0x0000000000000800ULL)

We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:

	#define	CAP_LOOKUP	CAPRIGHT(0, 0x0000000000000400ULL)
	#define	CAP_FCHMOD	CAPRIGHT(0, 0x0000000000002000ULL)

	#define	CAP_FCHMODAT	(CAP_FCHMOD | CAP_LOOKUP)

There is new API to manage the new cap_rights_t structure:

	cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
	void cap_rights_set(cap_rights_t *rights, ...);
	void cap_rights_clear(cap_rights_t *rights, ...);
	bool cap_rights_is_set(const cap_rights_t *rights, ...);

	bool cap_rights_is_valid(const cap_rights_t *rights);
	void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
	void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
	bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);

Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:

	cap_rights_t rights;

	cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);

There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:

	#define	cap_rights_set(rights, ...)				\
		__cap_rights_set((rights), __VA_ARGS__, 0ULL)
	void __cap_rights_set(cap_rights_t *rights, ...);

Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:

	cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);

Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.

This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.

Sponsored by:	The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
..
amd
apr Update subversion-1.8.0 -> 1.8.1. Update supporting 2013-07-28 06:02:40 +00:00
apr-util Update subversion-1.8.0 -> 1.8.1. Update supporting 2013-07-28 06:02:40 +00:00
atf Modify atf::fs::path::get_process_helpers_path API to properly 2013-05-29 19:41:36 +00:00
bind9 Update Bind to 9.9.3-P2 2013-08-22 08:15:03 +00:00
binutils Add support for the 'invpcid' instruction to binutils and DDB's 2013-09-03 21:21:47 +00:00
bmake Pay attention to errCheck! 2013-09-01 18:59:09 +00:00
bsnmp Register OID for HAST module. 2013-05-08 20:04:32 +00:00
byacc Update byacc to 20130304 2013-05-30 16:16:28 +00:00
bzip2
com_err
compiler-rt Don't use the pcs attribute on compilers that don't support it. We can 2013-01-19 02:24:14 +00:00
dialog Update dialog to 1.2-20130523 2013-06-17 10:28:55 +00:00
diff
dtc Clean up hardcoded ar(1) flags in the tree to use the global ARFLAGS in 2012-12-06 01:31:25 +00:00
ee Clean some 'svn:executable' properties in the tree. 2013-01-26 22:08:21 +00:00
expat Update base system libexpat to 2.1.0. 2013-02-26 00:58:44 +00:00
file Add support for Lua 5.2. 2013-01-11 17:34:30 +00:00
flex Enable GNU m4 compatibility mode. 2013-05-21 19:23:49 +00:00
gcc add support to gcc for AES and PCLMUL intrinsics... This addes the 2013-09-03 17:33:29 +00:00
gcclibs Add support for the GCC binary integer constants extension. 2013-08-31 20:33:37 +00:00
gdb Fold in frame-unwind patch 2013-06-17 18:34:34 +00:00
gdtoa Clean up hardcoded ar(1) flags in the tree to use the global ARFLAGS in 2012-12-06 01:31:25 +00:00
gperf Clean up hardcoded ar(1) flags in the tree to use the global ARFLAGS in 2012-12-06 01:31:25 +00:00
groff
ipfilter Retire struct sockaddr_inarp. 2013-01-31 08:55:21 +00:00
jemalloc Update jemalloc to version 3.4.0. 2013-06-03 14:36:28 +00:00
ldns Clean up the ntop / pton code. Part of a patch which has been submitted 2013-04-13 22:44:48 +00:00
less Revert files with no local changes to their vendor state to ease future 2013-05-31 00:31:45 +00:00
libarchive Fix return type of extattr_set_* and fix rmextattr(8) utility. 2013-04-02 05:30:41 +00:00
libbegemot
libc-pwcache
libc-vis Update to the latest (un)vis(3) sources from NetBSD. This adds 2013-03-14 23:51:47 +00:00
libc++ Import new libcxxrt / libc++. This brings some bug fixes, including a potential race condition for static initialisers. 2013-07-10 16:28:24 +00:00
libcxxrt Don't use _Unwind_Backtrace() on ARM as it's currently missing from our libgcc_s. andrew@ has patches to add it, so this can be reverted and sync'd with upstream later. 2013-08-31 08:56:33 +00:00
libexecinfo Add $FreeBSD$ tag for user-facing header 2013-09-03 13:36:23 +00:00
libgnuregex Fix build for FreeBSD. We do not have alloca.h. 2013-06-05 21:28:33 +00:00
libpcap MFV: libpcap 1.4.0. 2013-05-30 08:02:00 +00:00
libreadline
libstdc++ Add isnan() and isinf() to the global namespace in libstdc++'s <cmath>. 2013-07-23 10:23:43 +00:00
libyaml Import libyaml as libbsdyml (private brand name) 2013-03-04 11:27:41 +00:00
llvm Pull in r189672 from upstream llvm trunk: 2013-08-30 18:29:25 +00:00
lukemftpd
mdocml
mknod Add NetBSD's mtree to the tree and install it as nmtree as the first step 2012-12-21 21:00:00 +00:00
mtree Import a new version of NetBSD's mtree. 2013-04-09 06:50:11 +00:00
ncurses
netcat Reflect version update. 2013-04-15 18:35:09 +00:00
ngatm
ntp Clean some 'svn:executable' properties in the tree. 2013-01-26 22:08:21 +00:00
nvi Update nvi-1.79 to 2.1.1-4334a8297f 2013-08-11 20:03:12 +00:00
ofed - Fix compile errors from the clang conversion 2013-08-09 03:29:46 +00:00
one-true-awk MFV: one-true-awk 20121220. 2013-01-03 07:25:30 +00:00
openbsm Remove weirdly-named autofoo file. This is not needed for the (FreeBSD) 2013-07-22 08:46:15 +00:00
openpam Backport upstream r684 (OPENPAM_DEBUG enables debugging macros but does 2013-04-14 16:49:27 +00:00
openresolv
opie In contrib/opie/opiekey.c, use the correct length to zero the secret. 2013-02-16 12:45:57 +00:00
pam_modules/pam_passwdqc Make the PAM password strength checking module WARNS=2 safe. 2013-08-27 15:50:26 +00:00
pf
pnpinfo
sendmail Temporarily revert sendmail 8.14.7 change to getipnodebyname() flags to 2013-08-12 17:22:39 +00:00
serf Update serf 1.2.1 -> 1.3.0 for svn 2013-08-02 19:21:46 +00:00
smbfs - Trim an unused and bogus Makefile for mount_smbfs. 2013-06-28 21:00:08 +00:00
sqlite3 Introduce svnlite so that we can check out our source code again. 2013-06-18 02:53:45 +00:00
subversion Update subversion-1.8.0 -> 1.8.1. Update supporting 2013-07-28 06:02:40 +00:00
tcp_wrappers Clean up hardcoded ar(1) flags in the tree to use the global ARFLAGS in 2012-12-06 01:31:25 +00:00
tcpdump Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
tcsh
telnet Fix "automatic" login, broken by revision 69825 (12 years, 5 months ago). 2013-05-31 17:30:12 +00:00
texinfo
tnftp
top Bump MAX_COLS to 512 to take advantage of wider terminals. 2012-12-13 06:45:45 +00:00
traceroute
tzcode
tzdata MFV of tzdata2013d, 253008 2013-07-07 22:23:59 +00:00
unbound Upgrade to 1.4.20. 2013-04-05 09:51:31 +00:00
unvis Replace our (un)vis(1) commands with implementations from NetBSD to 2013-03-15 00:05:50 +00:00
vis Replace our (un)vis(1) commands with implementations from NetBSD to 2013-03-15 00:05:50 +00:00
wpa Fix previous commit: both flags must be set. 2013-08-07 15:55:12 +00:00
xz MFV r244559: 2012-12-22 21:32:12 +00:00