From 766fe023bfe46c2a2c09f7fdc4c42e4f534b512c Mon Sep 17 00:00:00 2001 From: David Beitey Date: Tue, 25 Jul 2017 12:42:40 +1000 Subject: [PATCH] Allow compiling on GCC < 5/CentOS 6 See #138. As per https://github.com/kvspb/nginx-auth-ldap/issues/138#issuecomment-317625746 the issue is that: * nginx compiles with `-Werror` (treating warnings as errors) * CentOS 6 has OpenSSL 1.0.1e and so the LDAP module has a warning on compile * CentOS 6 has GCC 4.4. GCC treats `#pragma GCC diagnostic warning "-Wcpp"` as itself an error and thus skips the statement, leading the the `#warning` still being an error. This adds version-checking to the warning options and the warning itself. This means that no warning is issued at compile time on this type of platform, but warnings are still emitted when starting Nginx without certificate verification, so it isn't as though the issue has been hidden. --- ngx_http_auth_ldap_module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ngx_http_auth_ldap_module.c b/ngx_http_auth_ldap_module.c index 18d359b..f8f4d60 100644 --- a/ngx_http_auth_ldap_module.c +++ b/ngx_http_auth_ldap_module.c @@ -41,9 +41,11 @@ #pragma clang diagnostic warning "-W#warnings" #else #ifdef __GNUC__ +#if GNUC > 4 #pragma GCC diagnostic warning "-Wcpp" #endif #endif +#endif // TODO: do the same stuff for MSVC and/or other compilers @@ -433,7 +435,9 @@ ngx_http_auth_ldap_ldap_server(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) #if OPENSSL_VERSION_NUMBER >= 0x10002000 server->ssl_check_cert = 1; #else + #if GNUC > 4 #warning "http_auth_ldap: Compiling with OpenSSL < 1.0.2, certificate verification will be unavailable. OPENSSL_VERSION_NUMBER == " XSTR(OPENSSL_VERSION_NUMBER) + #endif ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "http_auth_ldap: 'ssl_cert_check': cannot verify remote certificate's domain name because " "your version of OpenSSL is too old. "