Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

40.4. libcap-ng-0.9.6

Alternate POSIX capabilities library (required by openvpn 2.6+)

Version 0.9.6, release 1
Shelf base-libs — Low-level C libraries that the base system links
Phase 30_foundation (Build Foundation), 32 of 127 in build order
Licence LGPL-2.1-or-later AND GPL-2.0-or-later
Homepage https://github.com/stevegrubb/libcap-ng
Build time 0.2 SBU
Installed size 262.1 KiB in 45 files
Recipe ports/core/base-libs/libcap-ng/kpkgbuild

About

libcap-ng is a second library for POSIX capabilities, beside libcap, meant to make programming with them easier, with tools for finding programs that hold more privilege than they need: pscap reports the capabilities of running processes, netcap those of processes with listening sockets, and filecap the capabilities set on files. In KDOS it is linked by util-linux, whose setpriv is built with --with-cap-ng, by openvpn, which requires it, and by qemu, libvirt, virtiofsd, tcpdump, cifs-utils and smartmontools.

Sources

Dependencies

Depends on: autoconf, automake, libtool, pkgconf.

Required by (8): cifs-utils, libvirt, openvpn, qemu, smartmontools, tcpdump, util-linux, virtiofsd.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

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-ng'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base-libs/libcap-ng.

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-ng
echo '399040138e0ca62fa2bcabd63da9af4431a246ef7a654561a0ca3cb00010a539  libcap-ng-0.9.6.tar.gz' | 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-ng
SRC=$SRC_ROOT/libcap-ng-0.9.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libcap-ng-0.9.6.tar.gz -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:

./autogen.sh
./configure \
	--prefix=/usr \
	--sysconfdir=/etc \
	--libdir=/usr/lib \
	--without-python \
	--without-python3 \
	--disable-cap-audit \
	--disable-static
make
make DESTDIR=$PKG install

The switches, and why each is set:

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-ng, 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-ng-0.9.6-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-ng, and runs the triggers its paths call for.

Contents

Installed programs: filecap, netcap, pscap.

Installed libraries: libcap-ng.so, libdrop_ambient.so.

Installed directories: /usr/share/licenses/libcap-ng.

Short descriptions

filecap a program to see capabilities
netcap a program to review network capability posture
pscap a program to see capabilities
libcap-ng.pc An alternate POSIX capabilities library.

Notes

The source is a GitHub tag archive with no generated configure, so build.sh runs ./autogen.sh first; the recipe names autoconf, automake, libtool and pkgconf in depends for it.

The package installs libcap-ng.bash_completion in /usr/share/bash-completion/completions and links cap-audit, filecap, netcap and pscap to it there; the cap-audit link is installed although the program itself is not built.