#Packager: George Vlahavas <vlahavas~at~gmail~dot~com>
# Included in Slint by Didier Spaier didieratslintdotfr
pkgname=bubblewrap
pkgver=0.8.0
pkgrel=1slint
source=("https://github.com/containers/bubblewrap/archive/refs/tags/v$pkgver.tar.gz")
docs=("readme.md" "security.md" "code-of-conduct.md" "install" "copying" "changelog" "authors" "news" "todo")
url=https://github.com/containers/bubblewrap
options=('noautodotnew')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"bubblewrap (Unprivileged sandboxing tool)"
"There is an effort in the Linux kernel called user namespaces which"
"attempts to allow unprivileged users to use container features. While"
"significant progress has been made, there are still concerns about it,"
"and it is not available to unprivileged users in several production"
"distributions. Bubblewrap could be viewed as setuid implementation of"
"a subset of user namespaces. Emphasis on subset - specifically"
"relevant to the above CVE, bubblewrap does not allow control over"
"iptables."
)

doinst() {
	# Mitigate the risks of privilege escalation as the binary /usr/bin/bwrap is
	# installed setuid in Slint
	if [ ! -f /etc/sysctl.d/max_usernamespaces.conf ]; then
		echo "user.max_user_namespaces=0" > /etc/sysctl.d/max_user_namespaces.conf
		sysctl -p/etc/sysctl.d/max_user_namespaces.conf
	fi
}
build() {
	cd $startdir/src/$pkgname-$pkgver
	NOCONFIGURE=1 ./autogen.sh
	./configure --prefix=/usr \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--with-priv-mode=setuid \
		--with-bash-completion-dir=/etc/bash_completion.d \
		--build=$arch-slackware-linux
	make -j $numjobs || return 1
	make install DESTDIR=$startdir/pkg
} 
