8000 Make finding openssl program a configure or meson option · postgrespro/postgres@c8e4030 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8e4030

Browse files
committed
Make finding openssl program a configure or meson option
Various test suites use the "openssl" program as part of their setup. There isn't a way to override which openssl program is to be used, other than by fiddling with the path, perhaps. This has gotten increasingly problematic because different versions of openssl have different capabilities and do different things by default. This patch checks for an openssl binary in configure and meson setup, with appropriate ways to override it. This is similar to how "lz4" and "zstd" are handled, for example. The meson build system actually already did this, but the result was only used in some places. This is now applied more uniformly. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/dc638b75-a16a-007d-9e1c-d16ed6cf0ad2%40enterprisedb.com
1 parent 40c7fcb commit c8e4030

File tree

16 files changed

+107
-29
lines changed

16 files changed

+107
-29
lines changed

configure

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ PG_CRC32C_OBJS
648648
CFLAGS_ARMV8_CRC32C
649649
CFLAGS_SSE42
650650
LIBOBJS
651+
OPENSSL
651652
ZSTD
652653
LZ4
653654
UUID_LIBS
@@ -14112,6 +14113,60 @@ done
1411214113

1411314114
fi
1411414115

14116+
if test -z "$OPENSSL"; then
14117+
for ac_prog in openssl
14118+
do
14119+
# Extract the first word of "$ac_prog", so it can be a program name with args.
14120+
set dummy $ac_prog; ac_word=$2
14121+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
14122+
$as_echo_n "checking for $ac_word... " >&6; }
14123+
if ${ac_cv_path_OPENSSL+:} false; then :
14124+
$as_echo_n "(cached) " >&6
14125+
else
14126+
case $OPENSSL in
14127+
[\\/]* | ?:[\\/]*)
14128+
ac_cv_path_OPENSSL="$OPENSSL" # Let the user override the test with a path.
14129+
;;
14130+
*)
14131+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14132+
for as_dir in $PATH
14133+
do
14134+
IFS=$as_save_IFS
14135+
test -z "$as_dir" && as_dir=.
14136+
for ac_exec_ext in '' $ac_executable_extensions; do
14137+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
14138+
ac_cv_path_OPENSSL="$as_dir/$ac_word$ac_exec_ext"
14139+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
14140+
break 2
14141+
fi
14142+
done
14143+
done
14144+
IFS=$as_save_IFS
14145+
14146+
;;
14147+
esac
14148+
fi
14149+
OPENSSL=$ac_cv_path_OPENSSL
14150+
if test -n "$OPENSSL"; then
14151+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENSSL" >&5
14152+
$as_echo "$OPENSSL" >&6; }
14153+
else
14154+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14155+
$as_echo "no" >&6; }
14156+
fi
14157+
14158+
14159+
test -n "$OPENSSL" && break
14160+
done
14161+
14162+
else
14163+
# Report the value of OPENSSL in configure's output in all cases.
14164+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5
14165+
$as_echo_n "checking for OPENSSL... " >&6; }
14166+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENSSL" >&5
14167+
$as_echo "$OPENSSL" >&6; }
14168+
fi
14169+
1411514170
if test "$with_ssl" = openssl ; then
1411614171
ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default"
1411714172
if test "x$ac_cv_header_openssl_ssl_h" = xyes; then :

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,7 @@ if test "$with_gssapi" = yes ; then
15421542
[AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
15431543
fi
15441544

1545+
PGAC_PATH_PROGS(OPENSSL, openssl)
15451546
if test "$with_ssl" = openssl ; then
15461547
AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
15471548
AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])

doc/src/sgml/install-windows.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,15 @@ $ENV{PROVE_TESTS}='t/020*.pl t/010*.pl'
541541
</para></listitem>
542542
</varlistentry>
543543

544+
<varlistentry>
545+
<term><varname>OPENSSL</varname></term>
546+
<listitem><para>
547+
Path to a <application>openssl</application> command. The default is
548+
<literal>openssl</literal>, which will search for a command by that
549+
name in the configured <envar>PATH</envar>.
550+
</para></listitem>
551+
</varlistentry>
552+
544553
<varlistentry>
545554
<term><varname>TAR</varname></term>
546555
<listitem><para>

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ tar = find_program(get_option('TAR'), native: true)
328328
gzip = find_program(get_option('GZIP'), native: true)
329329
program_lz4 = find_program(get_option('LZ4'), native: true, required: false)
330330
touch = find_program('touch', native: true)
331+
openssl = find_program(get_option('OPENSSL'), native: true, required: false)
331332
program_zstd = find_program(get_option('ZSTD'), native: true, required: false)
332333
dtrace = find_program(get_option('DTRACE'), native: true, required: get_option('dtrace'))
333334
missing = find_program('config/missing', native: true)

meson_options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ option('GZIP', type : 'string', value: 'gzip',
157157
option('LZ4', type : 'string', value: 'lz4',
158158
description: 'path to lz4 binary')
159159

160+
option('OPENSSL', type : 'string', value: 'openssl',
161+
description: 'path to openssl binary')
162+
160163
option('PERL', type : 'string', value: 'perl',
161164
description: 'path to perl binary')
162165

src/Makefile.global.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ LN_S = @LN_S@
343343
MSGFMT = @MSGFMT@
344344
MSGFMT_FLAGS = @MSGFMT_FLAGS@
345345
MSGMERGE = @MSGMERGE@
346+
OPENSSL = @OPENSSL@
346347
PYTHON = @PYTHON@
347348
TAR = @TAR@
348349
XGETTEXT = @XGETTEXT@

src/test/ldap/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ top_builddir = ../../..
1414
include $(top_builddir)/src/Makefile.global
1515

1616
export with_ldap
17+
export OPENSSL
1718

1819
check:
1920
$(prove_check)

src/test/ldap/meson.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ tests += {
66
'tests': [
77
't/001_auth.pl',
88
],
9-
'env': {'with_ldap': ldap.found() ? 'yes' : 'no'},
9+
'env': {
10+
'with_ldap': ldap.found() ? 'yes' : 'no',
11+
'OPENSSL': openssl.path(),
12+
},
1013
},
1114
}

src/test/ldap/t/001_auth.pl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,15 @@
113113
mkdir $ldap_datadir or die;
114114
mkdir $slapd_certs or die;
115115

116-
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout",
116+
my $openssl = $ENV{OPENSSL};
117+
118+
system_or_bail $openssl, "req", "-new", "-nodes", "-keyout",
117119
"$slapd_certs/ca.key", "-x509", "-out", "$slapd_certs/ca.crt", "-subj",
118120
"/CN=CA";
119-
system_or_bail "openssl", "req", "-new", "-nodes", "-keyout",
121+
system_or_bail $openssl, "req", "-new", "-nodes", "-keyout",
120122
"$slapd_certs/server.key", "-out", "$slapd_certs/server.csr", "-subj",
121123
"/CN=server";
122-
system_or_bail "openssl", "x509", "-req", "-in", "$slapd_certs/server.csr",
124+
system_or_bail $openssl, "x509", "-req", "-in", "$slapd_certs/server.csr",
123125
"-CA", "$slapd_certs/ca.crt", "-CAkey", "$slapd_certs/ca.key",
124126
"-CAcreateserial", "-out", "$slapd_certs/server.crt";
125127

src/test/modules/ssl_passphrase_callback/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ PASS = FooBaR1
3131
.PHONY: ssl-files ssl-files-clean
3232

3333
ssl-files:
34-
openssl req -new -x509 -days 10000 -nodes -out server.crt \
34+
$(OPENSSL) req -new -x509 -days 10000 -nodes -out server.crt \
3535
-keyout server.ckey -subj "/CN=localhost"
36-
openssl rsa -aes256 -in server.ckey -out server.key -passout pass:$(PASS)
36+
$(OPENSSL) rsa -aes256 -in server.ckey -out server.key -passout pass:$(PASS)
3737
rm server.ckey
3838

3939
ssl-files-clean:

0 commit comments

Comments
 (0)
0