Skip to content

Commit 5b52d9f

Browse files
carenasgitster
authored andcommitted
git-compat-util: really support openssl as a source of entropy
05cd988 (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 <[email protected]> Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47efda9 commit 5b52d9f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,7 @@ endif
19401940

19411941
ifneq ($(findstring openssl,$(CSPRNG_METHOD)),)
19421942
BASIC_CFLAGS += -DHAVE_OPENSSL_CSPRNG
1943+
EXTLIBS += -lcrypto -lssl
19431944
endif
19441945

19451946
ifneq ($(PROCFS_EXECUTABLE_PATH),)

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
521521
#include <openssl/x509v3.h>
522522
#endif /* NO_OPENSSL */
523523

524+
#ifdef HAVE_OPENSSL_CSPRNG
525+
#include <openssl/rand.h>
526+
#endif
527+
524528
/*
525529
* Let callers be aware of the constant return value; this can help
526530
* gcc with -Wuninitialized analysis. We restrict this trick to gcc, though,

imap-send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "exec-cmd.h"
2828
#include "run-command.h"
2929
#include "parse-options.h"
30-
#ifdef NO_OPENSSL
30+
#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
3131
typedef void *SSL;
3232
#endif
3333
#ifdef USE_CURL_FOR_IMAP_SEND

0 commit comments

Comments
 (0)