]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-compat-util: really support openssl as a source of entropy
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>
Tue, 5 Apr 2022 04:28:26 +0000 (21:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2022 16:04:50 +0000 (09:04 -0700)
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>
Makefile
git-compat-util.h
imap-send.c

index 198b759e760f649737764758b8b702e96f5c839d..e106728194b070f8c32583b99e7c399c956ee9c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1940,6 +1940,7 @@ endif
 
 ifneq ($(findstring openssl,$(CSPRNG_METHOD)),)
        BASIC_CFLAGS += -DHAVE_OPENSSL_CSPRNG
+       EXTLIBS += -lcrypto -lssl
 endif
 
 ifneq ($(PROCFS_EXECUTABLE_PATH),)
index 50597c76be2d49a320b0d0a619b53152141272a2..f439f2691d9e9af2617681b745399701e3467e89 100644 (file)
@@ -521,6 +521,10 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 #include <openssl/x509v3.h>
 #endif /* NO_OPENSSL */
 
+#ifdef HAVE_OPENSSL_CSPRNG
+#include <openssl/rand.h>
+#endif
+
 /*
  * Let callers be aware of the constant return value; this can help
  * gcc with -Wuninitialized analysis. We restrict this trick to gcc, though,
index e6090a0346ad4947791a04ffce71ba1d0a8e8e28..c091b4e94b1ba29dac26bdfa812b4988cf5cce7e 100644 (file)
@@ -27,7 +27,7 @@
 #include "exec-cmd.h"
 #include "run-command.h"
 #include "parse-options.h"
-#ifdef NO_OPENSSL
+#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
 typedef void *SSL;
 #endif
 #ifdef USE_CURL_FOR_IMAP_SEND