Whamcloud - gitweb
LU-14929 gss: detect libkeyutils dependency
authorSebastien Buisson <sbuisson@ddn.com>
Wed, 11 Aug 2021 15:44:08 +0000 (17:44 +0200)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 10 Nov 2021 15:58:34 +0000 (15:58 +0000)
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.

Lustre-change: https://review.whamcloud.com/44597
Lustre-commit: 15998eb78e279f1bfa5059f0f65087f7851d40ff

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I9fa5750f4609250ecdc1c47f68b97bff9be13ace
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45484
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/ptlrpc/gss/lproc_gss.c
lustre/utils/Makefile.am
lustre/utils/gss/Makefile.am
lustre/utils/gss/sk_utils.h
lustre/utils/mount_utils.c

index 0161297..3c1c502 100644 (file)
@@ -229,7 +229,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], [], [
@@ -248,7 +250,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
 
@@ -341,7 +346,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"
 ])
index 6a319bf..3550820 100644 (file)
@@ -155,6 +155,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);
@@ -176,6 +177,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",
@@ -189,8 +191,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 }
 };
 
index 334fe86..6deba3f 100644 (file)
@@ -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 =
index dff542d..378e17d 100644 (file)
@@ -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
index d942e81..0f96176 100644 (file)
@@ -29,7 +29,9 @@
 #define SK_UTILS_H
 
 #include <gssapi/gssapi.h>
+#ifdef HAVE_LIBKEYUTILS
 #include <keyutils.h>
+#endif
 #include <linux/lustre/lustre_idl.h>
 #include <openssl/dh.h>
 #include <openssl/evp.h>
index 64547eb..357003e 100644 (file)
@@ -56,7 +56,9 @@
 #include <sys/xattr.h>
 
 #ifdef HAVE_GSS
+#ifdef HAVE_LIBKEYUTILS
 #include <keyutils.h>
+#endif
 #include <lustre/utils/gss/sk_utils.h>
 #endif