From 15998eb78e279f1bfa5059f0f65087f7851d40ff Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 11 Aug 2021 17:44:08 +0200 Subject: [PATCH] LU-14929 gss: detect libkeyutils dependency When building GSS support, gss_keyring requires libkeyutils. So make sure this dependency is properly detected at configure time, and include keyutils.h only when required. Signed-off-by: Sebastien Buisson Change-Id: I9fa5750f4609250ecdc1c47f68b97bff9be13ace Reviewed-on: https://review.whamcloud.com/44597 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 11 +++++++++-- lustre/ptlrpc/gss/lproc_gss.c | 4 ++++ lustre/utils/Makefile.am | 6 +++++- lustre/utils/gss/Makefile.am | 4 ++-- lustre/utils/gss/sk_utils.h | 2 ++ lustre/utils/mount_utils.c | 2 ++ 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 026f650..acfb007 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -268,7 +268,9 @@ AC_MSG_CHECKING([whether to enable gss keyring backend]) AC_ARG_ENABLE([gss_keyring], [AC_HELP_STRING([--disable-gss-keyring], [disable gss keyring backend])], - [], [enable_gss_keyring="auto"]) + [], [AS_IF([test "x$enable_gss" != xno], [ + enable_gss_keyring="yes"], [ + enable_gss_keyring="auto"])]) AC_MSG_RESULT([$enable_gss_keyring]) AS_IF([test "x$enable_gss_keyring" != xno], [ LB_CHECK_CONFIG_IM([KEYS], [], [ @@ -287,7 +289,10 @@ AS_IF([test "x$enable_gss_keyring" != xno], [ AS_IF([test "x$enable_gss_keyring" = xyes], [ AC_MSG_ERROR([Cannot enable gss_keyring. See above for details.]) ]) + enable_ssk="no" ]) +], [ + enable_ssk="no" ]) ]) # LC_CONFIG_GSS_KEYRING @@ -380,7 +385,9 @@ AS_IF([test "x$enable_gss" != xno], [ enable_gss="no" ]) - enable_ssk=$enable_gss + AS_IF([test "x$enable_ssk" != xno], [ + enable_ssk=$enable_gss + ]) ], [ enable_gss_keyring="no" ]) diff --git a/lustre/ptlrpc/gss/lproc_gss.c b/lustre/ptlrpc/gss/lproc_gss.c index c60043c..e401985 100644 --- a/lustre/ptlrpc/gss/lproc_gss.c +++ b/lustre/ptlrpc/gss/lproc_gss.c @@ -154,6 +154,7 @@ ssize_t sptlrpc_krb5_allow_old_client_csum_seq_write(struct file *file, } LPROC_SEQ_FOPS(sptlrpc_krb5_allow_old_client_csum); +#ifdef HAVE_GSS_KEYRING int sptlrpc_gss_check_upcall_ns_seq_show(struct seq_file *m, void *data) { seq_printf(m, "%u\n", gss_check_upcall_ns); @@ -175,6 +176,7 @@ ssize_t sptlrpc_gss_check_upcall_ns_seq_write(struct file *file, return count; } LPROC_SEQ_FOPS(sptlrpc_gss_check_upcall_ns); +#endif /* HAVE_GSS_KEYRING */ static struct ldebugfs_vars gss_debugfs_vars[] = { { .name = "replays", @@ -188,8 +190,10 @@ static struct ldebugfs_vars gss_debugfs_vars[] = { static struct lprocfs_vars gss_lprocfs_vars[] = { { .name = "krb5_allow_old_client_csum", .fops = &sptlrpc_krb5_allow_old_client_csum_fops }, +#ifdef HAVE_GSS_KEYRING { .name = "gss_check_upcall_ns", .fops = &sptlrpc_gss_check_upcall_ns_fops }, +#endif { NULL } }; diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index 72e7143..4509db2 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -13,10 +13,14 @@ if UTILS if GSS SUBDIRS = . gss GSSSRC = gss/err_util.c gss/err_util.h +GSSLIB = -lcrypto -lssl -lm if GSS_SSK GSSSRC += gss/sk_utils.c gss/sk_utils.h +GSSLIB += -lkeyutils +endif +if GSS_KEYRING +GSSLIB += -lkeyutils endif -GSSLIB = -lcrypto -lssl -lkeyutils -lm else GSSSRC = GSSLIB = diff --git a/lustre/utils/gss/Makefile.am b/lustre/utils/gss/Makefile.am index dff542d..378e17d 100644 --- a/lustre/utils/gss/Makefile.am +++ b/lustre/utils/gss/Makefile.am @@ -4,10 +4,10 @@ AM_CFLAGS := -fPIC \ -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS=1 \ -D_GNU_SOURCE -sbin_PROGRAMS = lsvcgssd l_idmap +sbin_PROGRAMS = l_idmap if GSS_KEYRING -sbin_PROGRAMS += lgss_keyring +sbin_PROGRAMS += lsvcgssd lgss_keyring if GSS_SSK sbin_PROGRAMS += lgss_sk endif diff --git a/lustre/utils/gss/sk_utils.h b/lustre/utils/gss/sk_utils.h index d942e81..0f96176 100644 --- a/lustre/utils/gss/sk_utils.h +++ b/lustre/utils/gss/sk_utils.h @@ -29,7 +29,9 @@ #define SK_UTILS_H #include +#ifdef HAVE_LIBKEYUTILS #include +#endif #include #include #include diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index 37f292f..b341df8 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -55,7 +55,9 @@ #include #ifdef HAVE_GSS +#ifdef HAVE_LIBKEYUTILS #include +#endif #include #endif -- 1.8.3.1