sys-apps/keyutils: Sync with Gentoo

It's from Gentoo commit 0e727a3a16bc2abfd39386f10821d3e5ce89c45a.
This commit is contained in:
Krzesimir Nowak 2025-04-03 15:19:14 +02:00
parent b677163275
commit 327f06ecde
4 changed files with 114 additions and 44 deletions

View File

@ -1,3 +0,0 @@
We keep this package in overlay, because we install the keyutils
config file in /usr instead of /etc, and then establish some symlinks
during installation and with systemd's tmpfiles.d utility.

View File

@ -0,0 +1,76 @@
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/commit/?id=c076dff259e99d84d3822b4d2ad7f3f66532f411
From c076dff259e99d84d3822b4d2ad7f3f66532f411 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Tue, 20 Dec 2022 14:13:29 +0100
Subject: test: Fix test expectation based on kernel config
Some test results are dependent on the kernel configuration option
CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE.
Check the kernel configuration file for its presence and expect appropriate
test results.
Function has_kernel_config is based on its xfstsests counterpart.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
--- a/tests/features/builtin_trusted/runtest.sh
+++ b/tests/features/builtin_trusted/runtest.sh
@@ -33,7 +33,11 @@ expect_error EACCES
create_key --fail user a a $stk
expect_error EOPNOTSUPP
create_key --fail user a a $blk
-expect_error EACCES
+if has_kernel_config "CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE"; then
+ expect_error EOPNOTSUPP
+else
+ expect_error EACCES
+fi
# Try adding a key to the keyrings
marker "TRY ADDING ASYMMETRIC KEYS"
@@ -89,7 +93,11 @@ expect_error EACCES
create_key --fail -x asymmetric "" "$x509" $stk
expect_error ENOKEY
create_key --fail -x asymmetric "" "$x509" $blk
-expect_error EACCES
+if has_kernel_config "CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE"; then
+ expect_error EOPNOTSUPP
+else
+ expect_error EACCES
+fi
echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE
--- a/tests/prepare.inc.sh
+++ b/tests/prepare.inc.sh
@@ -4,6 +4,26 @@
includes=${BASH_SOURCE[0]}
includes=${includes%/*}/
+# Check if currently running kernel has option set
+function has_kernel_config()
+{
+ local option=$1
+ local uname=$(uname -r)
+ local config_list="$KCONFIG_PATH
+ /lib/modules/$uname/build/.config
+ /boot/config-$uname
+ /lib/kernel/config-$uname"
+
+ for config in $config_list; do
+ [ ! -f $config ] && continue
+ grep -qE "^${option}=[my]" $config
+ return
+ done
+
+ echo "Failed to find kernel configuration file"
+ return false
+}
+
# --- need to run in own session keyring
watch_fd=0
if [ "$1" != "--inside-test-session" ]
--
cgit 1.2.3-korg

View File

@ -1,3 +0,0 @@
L /etc/request-key.conf - - - - ../usr/share/keyutils/request-key.conf
d /etc/request-key.d - - - - -
d /etc/keyutils - - - - -

View File

@ -1,10 +1,9 @@
# Copyright 1999-2023 Gentoo Authors
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
TMPFILES_OPTIONAL=1
inherit toolchain-funcs linux-info multilib-minimal usr-ldscript systemd tmpfiles
inherit toolchain-funcs linux-info multilib-minimal
DESCRIPTION="Linux Key Management Utilities"
HOMEPAGE="https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git"
@ -12,7 +11,7 @@ SRC_URI="https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/s
LICENSE="GPL-2 LGPL-2.1"
SLOT="0/1.9"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ~ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux"
KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ~ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux"
IUSE="static static-libs test"
RESTRICT="!test? ( test )"
@ -24,10 +23,9 @@ PATCHES=(
"${FILESDIR}"/${PN}-1.5.10-disable-tests.patch #519062 #522050
"${FILESDIR}"/${PN}-1.5.9-header-extern-c.patch
"${FILESDIR}"/${PN}-1.6.3-fix-rpmspec-check.patch
"${FILESDIR}"/${P}-tests.patch
)
MAKEOPTS+=" ETCDIR=/usr/share/keyutils"
pkg_setup() {
# To prevent a failure in test phase and false positive bug reports
# we are enforcing the following options because testsuite expects
@ -72,30 +70,38 @@ src_prepare() {
multilib_copy_sources
}
multilib_src_compile() {
tc-export AR CC CXX
sed -i \
-e "1iRPATH = $(usex static -static '')" \
-e '/^C.*FLAGS/s|:=|+=|' \
-e 's:-Werror::' \
-e '/^BUILDFOR/s:=.*:=:' \
-e "/^LIBDIR/s:=.*:= /usr/$(get_libdir):" \
-e '/^USRLIBDIR/s:=.*:=$(LIBDIR):' \
-e "s: /: ${EPREFIX}/:g" \
-e '/^NO_ARLIB/d' \
Makefile || die
# We need the static lib in order to statically link programs.
if use static ; then
export NO_ARLIB=0
# Hack the progs to depend on the static lib instead.
sed -i \
-e '/^.*:.*[$](DEVELLIB)$/s:$(DEVELLIB):$(ARLIB) $(SONAME):' \
Makefile || die
else
export NO_ARLIB=$(usex static-libs 0 1)
mymake() {
local args=(
PREFIX="${EPREFIX}/usr"
ETCDIR="${EPREFIX}/etc"
BINDIR="${EPREFIX}/bin"
SBINDIR="${EPREFIX}/sbin"
SHAREDIR="${EPREFIX}/usr/share/keyutils"
MANDIR="${EPREFIX}/usr/share/man"
INCLUDEDIR="${EPREFIX}/usr/include"
LIBDIR="${EPREFIX}/usr/$(get_libdir)"
USRLIBDIR="${EPREFIX}/usr/$(get_libdir)"
CFLAGS="${CFLAGS}"
CXXFLAGS="${CXXFLAGS}"
RPATH=$(usex static -static '')
BUILDFOR=
NO_ARLIB="${NO_ARLIB}"
)
if use static; then
args+=( LIB_DEPENDENCY='$(ARLIB)' )
fi
emake
emake "${args[@]}" "$@"
}
multilib_src_compile() {
local NO_ARLIB
if use static; then
NO_ARLIB=0
else
NO_ARLIB=$(usex static-libs 0 1)
fi
tc-export AR CC CXX
mymake
}
multilib_src_test() {
@ -103,19 +109,13 @@ multilib_src_test() {
# older versions already installed in the system.
LD_LIBRARY_PATH=${BUILD_DIR} \
PATH="${BUILD_DIR}:${PATH}" \
emake test
mymake test
}
multilib_src_install() {
dotmpfiles "${FILESDIR}/tmpfiles.d/keyutils.conf"
# Possibly undo the setting for USE=static (see src_compile).
export NO_ARLIB=$(usex static-libs 0 1)
default
use static || gen_usr_ldscript -a keyutils
dosym ../usr/share/keyutils/request-key.conf /etc/request-key.conf
dodir /etc/request-key.d
dodir /etc/keyutils
local NO_ARLIB=$(usex static-libs 0 1)
mymake DESTDIR="${D}" install
}
multilib_src_install_all() {