Просмотр исходного кода

Merge pull request #262 from dougnazar/fix_openssl_1_1_1

Fix compiling with OpenSSL below 3.0
Sebastian Wolf 3 лет назад
Родитель
Сommit
1adc010549
6 измененных файлов с 20 добавлено и 13 удалено
  1. 7 1
      configure
  2. 4 0
      include/common.h.in
  3. 1 0
      include/config.h.in
  4. 3 1
      macros/ax_nagios_get_ssl
  5. 4 5
      src/nrpe.c
  6. 1 6
      src/print_c_code.c

+ 7 - 1
configure

@@ -7758,7 +7758,13 @@ fi
 
 				test -d include || mkdir include
 				if test "x$nagios_ssl_major_version" = "x3"; then
-					$CC src/print_c_code.c -o src/print_c_code
+
+cat >>confdefs.h <<_ACEOF
+#define OPENSSL_V3 1
+_ACEOF
+
+					test -d src || mkdir src
+					$CC ${srcdir}/src/print_c_code.c -o src/print_c_code
 					$sslbin dhparam -text 2048 | ./src/print_c_code > include/dh.h
 				else
 					# awk to strip off meta data at bottom of dhparam output

+ 4 - 0
include/common.h.in

@@ -29,6 +29,10 @@
 #define SSL_TYPE_@SSL_TYPE@
 
 #ifdef HAVE_SSL
+#ifdef OPENSSL_V3
+# define OPENSSL_API_COMPAT 10002
+# define OPENSSL_NO_DEPRECATED
+#endif
 #include <@SSL_INC_PREFIX@@SSL_HDR@>
 # ifdef SSL_TYPE_openssl
 #  include <@SSL_INC_PREFIX@err.h>

+ 1 - 0
include/config.h.in

@@ -324,6 +324,7 @@ typedef int int32_t;
 
 /* Have SSL support */
 #undef HAVE_SSL
+#undef OPENSSL_V3
 
 /* Have the krb5.h header file */
 #undef HAVE_KRB5_H

+ 3 - 1
macros/ax_nagios_get_ssl

@@ -300,7 +300,9 @@ if test x$SSL_TYPE != xNONE; then
 
 				test -d include || mkdir include
 				if test "x$nagios_ssl_major_version" = "x3"; then
-					$CC src/print_c_code.c -o src/print_c_code
+					AC_DEFINE_UNQUOTED(OPENSSL_V3,[1],[Have OpenSSL v3])
+					test -d src || mkdir src
+					$CC ${srcdir}/src/print_c_code.c -o src/print_c_code
 					$sslbin dhparam -text 2048 | ./src/print_c_code > include/dh.h
 				else
 					# awk to strip off meta data at bottom of dhparam output

+ 4 - 5
src/nrpe.c

@@ -35,6 +35,10 @@
  ****************************************************************************/
 
 #include "config.h"
+#include "common.h"
+#include "nrpe.h"
+#include "utils.h"
+#include "acl.h"
 
 #ifdef HAVE_SSL
 # ifdef USE_SSL_DH
@@ -42,11 +46,6 @@
 # endif
 #endif
 
-#include "common.h"
-#include "nrpe.h"
-#include "utils.h"
-#include "acl.h"
-
 #ifndef HAVE_ASPRINTF
 extern int asprintf(char **ptr, const char *format, ...);
 #endif

+ 1 - 6
src/print_c_code.c

@@ -130,12 +130,7 @@ int main() {
 
 	// Print the first part of the C code:
 
-	printf("#ifndef HEADER_DH_H\n"
-		"#define OPENSSL_API_COMPAT 10002\n"
-		"#define OPENSSL_NO_DEPRECATED\n"
-		"#include <openssl/dh.h>\n"
-		"#endif\n"
-		"DH *get_dh2048()\n"
+	printf("DH *get_dh2048()\n"
 		"{\n"
 		"\tstatic unsigned char dh2048_p[]={");