40.6. libcap-2.78
Implements the user-space interfaces to the POSIX 1003.1e capabilities
| Version | 2.78, release 1 |
| Shelf | base-libs — Low-level C libraries that the base system links |
| Phase | 30_foundation (Build Foundation), 64 of 127 in build order |
| Licence | BSD-3-Clause OR GPL-2.0-only |
| Homepage | https://sites.google.com/site/fullycapable/ |
| Build time | 0.1 SBU |
| Installed size | 371.0 KiB in 98 files |
| Recipe | ports/core/base-libs/libcap/kpkgbuild |
About
libcap is the library for POSIX capabilities, the pieces root’s power is split into, on processes and on files, with setcap, getcap, getpcaps and capsh; libpsx beside it lets a threaded program change the capabilities of all its threads at once. In KDOS it is linked by coreutils, whose ls shows a file’s capabilities, by iproute2, iputils, bubblewrap, crun and basu, and by others.
libcap has no configure script: build.sh is a single make install whose variables decide the build.
Sources
libcap-2.78.tar.xz(196.3 KiB)
sha2560d621e562fd932ccf67b9660fb018e468a683d7b827541df27813228c996bb11
upstream: https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.78.tar.xz
archive copy: sources-1/base-libs--libcap-2.78.tar.xz
Dependencies
Depends on: gperf.
Required by (24): ardour, avahi, basu, bpftool, brltty, bubblewrap, chromium, coreutils, crun, elogind, gpsd, gvfs, htop, iproute2, iputils, kodi, kwin, libwebsockets, mtr, mumble, nfs-utils, samba, slirp4netns, wireshark.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install libcap'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base-libs/libcap.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/base-libs/libcap
echo '0d621e562fd932ccf67b9660fb018e468a683d7b827541df27813228c996bb11 libcap-2.78.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/libcap
SRC=$SRC_ROOT/libcap-2.78
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libcap-2.78.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
make GOLANG=no PAM_CAP=no USE_GPERF=yes RAISE_SETFCAP=no lib=lib prefix=/usr DESTDIR=$PKG install
The switches, and why each is set:
GOLANG=no— Do not build the Go packages (capandpsx). Left unset, the makefiles build them whenevergo versionruns; go is a port of31_compilers, so a rebuild after it would change the package.PAM_CAP=no— Do not buildpam_cap.so, the PAM module that grants inheritable capabilities at login. Left unset, it is built whenever/usr/include/security/pam_modules.hexists; pam is a port of41_system, so the same applies.USE_GPERF=yes— Generate the table that turns a capability’s name into its number with gperf, a perfect hash, instead of a linear search. Left unset, it is used whenevergperfis onPATH; the recipe depends on gperf and makes it unconditional.RAISE_SETFCAP=no— Installsetcapwithout the file capabilitycap_setfcapin its inheritable set. Withyes, any user whose own inheritable set holdscap_setfcap, as some distributions give every user, can runsetcapto put any capability on any file.nois also upstream’s default, and thesetcaprun thatyesadds to the install would be lost in the package anyway (see below).lib=lib— The library directory under the prefix. Left unset, the makefiles guess it from the dynamic loader’s path, taking the line ofldd /usr/bin/ldthat matchesld-linuxorld.so.prefix=/usr— Install under/usr. Without a prefix the makefiles put the tools in/sbinand the libraries in/lib.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libcap, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf libcap-2.78-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libcap, and runs the triggers its paths call for.
Contents
Installed programs: capsh, getcap, getpcaps, setcap.
Installed libraries: libcap.a, libcap.so, libpsx.a, libpsx.so.
Installed directories: /usr/share/licenses/libcap.
Short descriptions
capsh |
capability shell wrapper |
getcap |
examine file capabilities |
getpcaps |
display process capabilities |
setcap |
set file capabilities |
libcap.pc |
libcap - linux capabilities library |
libpsx.pc |
libpsx - linux posix syscall API for threads |
Notes
No program on the image is given a file capability by its package. A capability is an extended attribute, and the package archive is written without --xattrs, so it would not survive; KDOS uses setuid bits instead. setcap sets one by hand on a running system, as the security model suggests for packet capture tools (see setuid binaries).