Blame SOURCES/vim-crypto-warning.patch

0cebd2
diff --git a/src/config.h.in b/src/config.h.in
0cebd2
index 7d61220..ca0b1a8 100644
0cebd2
--- a/src/config.h.in
0cebd2
+++ b/src/config.h.in
0cebd2
@@ -478,3 +478,12 @@
0cebd2
 
0cebd2
 /* Define to inline symbol or empty */
0cebd2
 #undef inline
0cebd2
+
0cebd2
+/* Do we need FIPS warning? */
0cebd2
+#undef HAVE_FIPS_WARNING
0cebd2
+
0cebd2
+/* Link to system-fips file */
0cebd2
+#undef SYSTEM_FIPS_FILE_LINK
0cebd2
+
0cebd2
+/* Link to fips_enabled file */
0cebd2
+#undef FIPS_ENABLED_FILE_LINK
0cebd2
diff --git a/src/configure.ac b/src/configure.ac
0cebd2
index 1e7d444..5e45762 100644
0cebd2
--- a/src/configure.ac
0cebd2
+++ b/src/configure.ac
0cebd2
@@ -525,6 +525,38 @@ else
0cebd2
   AC_MSG_RESULT(yes)
0cebd2
 fi
0cebd2
 
0cebd2
+dnl Checking if we want FIPS warning
0cebd2
+
0cebd2
+AC_MSG_CHECKING(--enable-fips-warning)
0cebd2
+AC_ARG_ENABLE([fips-warning],
0cebd2
+              AS_HELP_STRING([--enable-fips-warning], [Enable FIPS warning]),
0cebd2
+              ,[enable_fips_warning="no"])
0cebd2
+
0cebd2
+if test "$enable_fips_warning" = "yes"; then
0cebd2
+  AC_MSG_RESULT(yes)
0cebd2
+  AC_DEFINE([HAVE_FIPS_WARNING])
0cebd2
+
0cebd2
+  dnl Setting path for system-fips file
0cebd2
+
0cebd2
+  AC_MSG_CHECKING(--with-system-fips-file argument)
0cebd2
+  AC_ARG_WITH([system-fips-file], [  --with-system-fips-file=PATH       Link to system-fips file (default: /etc/system-fips)],
0cebd2
+	with_system_fips_file=$withval,
0cebd2
+       with_system_fips_file="/etc/system-fips")
0cebd2
+  AC_MSG_RESULT([$with_system_fips_file])
0cebd2
+  AC_DEFINE_UNQUOTED([SYSTEM_FIPS_FILE_LINK], ["$with_system_fips_file"])
0cebd2
+
0cebd2
+  dnl Setting link to fips_enabled file
0cebd2
+
0cebd2
+  AC_MSG_CHECKING(--with-fips-enabled-file argument)
0cebd2
+  AC_ARG_WITH([fips-enabled-file], [  --with-fips-enabled-file=PATH       Link to fibs_enabled file (default: /proc/sys/crypto/fips_enabled)],
0cebd2
+	with_fips_enabled_file=$withval,
0cebd2
+       with_fips_enabled_file="/proc/sys/crypto/fips_enabled")
0cebd2
+  AC_MSG_RESULT([$with_fips_enabled_file])
0cebd2
+  AC_DEFINE_UNQUOTED([FIPS_ENABLED_FILE_LINK], ["$with_fips_enabled_file"])
0cebd2
+else
0cebd2
+  AC_MSG_RESULT(no)
0cebd2
+fi
0cebd2
+
0cebd2
 dnl Check for Lua feature.
0cebd2
 AC_MSG_CHECKING(--enable-luainterp argument)
0cebd2
 AC_ARG_ENABLE(luainterp,
0cebd2
diff --git a/src/crypt.c b/src/crypt.c
0cebd2
index dfbf02c..c935bc0 100644
0cebd2
--- a/src/crypt.c
0cebd2
+++ b/src/crypt.c
0cebd2
@@ -501,6 +501,21 @@ crypt_check_method(int method)
0cebd2
 	msg_scroll = TRUE;
0cebd2
 	MSG(_("Warning: Using a weak encryption method; see :help 'cm'"));
0cebd2
     }
0cebd2
+#ifdef HAVE_FIPS_WARNING
0cebd2
+    FILE *fips_enable_fd = fopen(FIPS_ENABLED_FILE_LINK, "r");
0cebd2
+    if (fips_enable_fd == NULL)
0cebd2
+      return;
0cebd2
+
0cebd2
+    int enabled = fgetc(fips_enable_fd);
0cebd2
+
0cebd2
+    if ( access(SYSTEM_FIPS_FILE_LINK, F_OK) != -1 && enabled == '1')
0cebd2
+    {
0cebd2
+	msg_scroll = TRUE;
0cebd2
+	MSG(_("Warning: This cryptography is not FIPS 140-2 compliant."));
0cebd2
+    }
0cebd2
+
0cebd2
+    fclose(fips_enable_fd);
0cebd2
+#endif
0cebd2
 }
0cebd2
 
0cebd2
     void