[LTP] [PATCH v3 01/36] lapi/keyctl.h: Add fallback definitions for extended ops
Petr Vorel
pvorel@suse.cz
Wed Sep 16 16:03:27 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
Add fallback definitions for KEYCTL_LINK, KEYCTL_RESTRICT_KEYRING,
KEYCTL_MOVE, and KEYCTL_MOVE_EXCL, as well as fallback definitions
for struct keyctl_dh_params and struct keyctl_kdf_params when built
without linux/keyctl.h.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
[ pvorel
* Remove <keyutils.h> usage - use only <linux/keyctl.h>
* Add check for struct keyctl_dh_params.priv for Leap 42.2 ]
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/keyctl.h | 36 +++++++++++++++++++++++++++++++++++-
m4/ltp-keyutils.m4 | 7 +++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index 83fa09303c..1c6627f555 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -8,6 +8,8 @@
#include "config.h"
+#include <stdint.h>
+
#if defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS)
# include <keyutils.h>
#else
@@ -16,7 +18,6 @@
# endif /* HAVE_LINUX_KEYCTL_H */
# include <stdarg.h>
-# include <stdint.h>
# include "lapi/syscalls.h"
typedef int32_t key_serial_t;
@@ -60,6 +61,23 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
#endif /* defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS) */
+#ifndef HAVE_STRUCT_KEYCTL_DH_PARAMS
+struct keyctl_dh_params {
+ int32_t priv;
+ int32_t prime;
+ int32_t base;
+};
+#endif
+
+#ifndef HAVE_STRUCT_KEYCTL_KDF_PARAMS
+struct keyctl_kdf_params {
+ char *hashname;
+ char *otherinfo;
+ uint32_t otherinfolen;
+ uint32_t __spare[8];
+};
+#endif
+
/* special process keyring shortcut IDs */
#ifndef KEY_SPEC_THREAD_KEYRING
# define KEY_SPEC_THREAD_KEYRING -1
@@ -124,6 +142,10 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
# define KEYCTL_CLEAR 7
#endif
+#ifndef KEYCTL_LINK
+# define KEYCTL_LINK 8
+#endif
+
#ifndef KEYCTL_UNLINK
# define KEYCTL_UNLINK 9
#endif
@@ -168,6 +190,18 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
# define KEYCTL_WATCH_KEY 32
#endif
+#ifndef KEYCTL_RESTRICT_KEYRING
+# define KEYCTL_RESTRICT_KEYRING 29
+#endif
+
+#ifndef KEYCTL_MOVE
+# define KEYCTL_MOVE 30
+#endif
+
+#ifndef KEYCTL_MOVE_EXCL
+# define KEYCTL_MOVE_EXCL 0x00000001 /* do not displace from the to-keyring */
+#endif
+
/* key permissions */
#ifndef KEY_POS_VIEW
# define KEY_POS_VIEW 0x01000000
diff --git a/m4/ltp-keyutils.m4 b/m4/ltp-keyutils.m4
index 451c549f38..35bad783e5 100644
--- a/m4/ltp-keyutils.m4
+++ b/m4/ltp-keyutils.m4
@@ -1,10 +1,17 @@
dnl SPDX-License-Identifier: GPL-2.0-or-later
dnl Copyright (c) 2016 Fujitsu Ltd.
dnl Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+dnl Copyright (c) Linux Test Project, 2019-2026
dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [
AC_CHECK_LIB([keyutils], [add_key],
[AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have libkeyutils installed.])
AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")])
+
+ AC_CHECK_TYPES([struct keyctl_dh_params, struct keyctl_kdf_params,
+ struct keyctl_pkey_query, struct keyctl_pkey_params],,,
+ [#include <linux/keyctl.h>])
+
+ AC_CHECK_MEMBERS([struct keyctl_dh_params.priv],,,[#include <linux/keyctl.h>])
])
--
2.55.0
More information about the ltp
mailing list