git-compat-util: really support openssl as a source of entropy

05cd988dce5 (wrapper: add a helper to generate numbers from a CSPRNG, 2022-01-17), configure openssl as the source for entropy in NON-STOP but doesn't add the needed header or link options. Since the only system that is configured to use openssl as a source of entropy is NON-STOP, add the header unconditionally, and -lcrypto to the list of external libraries. An additional change is required to make sure a NO_OPENSSL=1 build will be able to work as well (tested on Linux with a modified value of CSPRNG_METHOD = openssl), and the more complex logic that allows for compatibility with APPLE_COMMON_CRYPTO or allowing for simpler ways to link (without libssl) has been punted for now. Reported-by: Randall Becker <rsbecker@nexbridge.com> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carlo Marcelo Arenas Belón committed Apr 4, 2022 at 21:28 UTC 5b52d9f15e311b82ee5f5c5ed9927c65b63731bf
3 files changed +6 -1
Makefile
+1
@@ -1940,6 +1940,7 @@ endif
1940
1941 ifneq ($(findstring openssl,$(CSPRNG_METHOD)),)
1942 BASIC_CFLAGS += -DHAVE_OPENSSL_CSPRNG
1943 + EXTLIBS += -lcrypto -lssl
1944 endif
1945
1946 ifneq ($(PROCFS_EXECUTABLE_PATH),)
git-compat-util.h
+4
@@ -521,6 +521,10 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
521 #include <openssl/x509v3.h>
522 #endif /* NO_OPENSSL */
523
524 +#ifdef HAVE_OPENSSL_CSPRNG
525 +#include <openssl/rand.h>
526 +#endif
527 +
528 /*
529 * Let callers be aware of the constant return value; this can help
530 * gcc with -Wuninitialized analysis. We restrict this trick to gcc, though,
imap-send.c
+1 -1
@@ -27,7 +27,7 @@
27 #include "exec-cmd.h"
28 #include "run-command.h"
29 #include "parse-options.h"
30 -#ifdef NO_OPENSSL
30 +#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
31 typedef void *SSL;
32 #endif
33 #ifdef USE_CURL_FOR_IMAP_SEND