Skip to content

Commit 3bb398c

Browse files
authored
resolve,import: always use openssl (systemd#36937)
2 parents b8fd3f7 + 99cc106 commit 3bb398c

30 files changed

+122
-969
lines changed

.github/workflows/build_test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fatal() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; }
1010
success() { echo >&2 -e "\033[32;1m$1\033[0m"; }
1111

1212
ARGS=(
13-
"--optimization=0 -Dopenssl=disabled -Dcryptolib=gcrypt -Ddns-over-tls=gnutls -Dtpm=true -Dtpm2=enabled"
13+
"--optimization=0 -Dopenssl=disabled -Dtpm=true -Dtpm2=enabled"
1414
"--optimization=s -Dutmp=false"
1515
"--optimization=2 -Dc_args=-Wmaybe-uninitialized -Ddns-over-tls=openssl"
1616
"--optimization=3 -Db_lto=true -Ddns-over-tls=false"
@@ -67,7 +67,6 @@ PACKAGES=(
6767
COMPILER="${COMPILER:?}"
6868
COMPILER_VERSION="${COMPILER_VERSION:?}"
6969
LINKER="${LINKER:?}"
70-
CRYPTOLIB="${CRYPTOLIB:?}"
7170
RELEASE="$(lsb_release -cs)"
7271

7372
# Note: As we use postfixed clang/gcc binaries, we need to override $AR
@@ -150,7 +149,7 @@ for args in "${ARGS[@]}"; do
150149
CXX="$CXX" CXX_LD="$LINKER" CXXFLAGS="$CXXFLAGS" \
151150
meson setup \
152151
-Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror \
153-
-Dnobody-group=nogroup -Dcryptolib="${CRYPTOLIB:?}" -Ddebug=false \
152+
-Dnobody-group=nogroup -Ddebug=false \
154153
$args build; then
155154

156155
cat build/meson-logs/meson-log.txt

.github/workflows/build_test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
env:
28-
- { COMPILER: "gcc", COMPILER_VERSION: "11", LINKER: "bfd", CRYPTOLIB: "gcrypt" }
29-
- { COMPILER: "gcc", COMPILER_VERSION: "13", LINKER: "mold", CRYPTOLIB: "openssl" }
30-
- { COMPILER: "clang", COMPILER_VERSION: "14", LINKER: "mold", CRYPTOLIB: "gcrypt" }
31-
- { COMPILER: "clang", COMPILER_VERSION: "16", LINKER: "bfd", CRYPTOLIB: "openssl" }
32-
- { COMPILER: "clang", COMPILER_VERSION: "18", LINKER: "lld", CRYPTOLIB: "auto" }
28+
- { COMPILER: "gcc", COMPILER_VERSION: "11", LINKER: "bfd" }
29+
- { COMPILER: "gcc", COMPILER_VERSION: "13", LINKER: "mold" }
30+
- { COMPILER: "clang", COMPILER_VERSION: "14", LINKER: "mold" }
31+
- { COMPILER: "clang", COMPILER_VERSION: "16", LINKER: "bfd" }
32+
- { COMPILER: "clang", COMPILER_VERSION: "18", LINKER: "lld" }
3333
env: ${{ matrix.env }}
3434
steps:
3535
- name: Repository checkout

.github/workflows/unit_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function run_meson() {
4141

4242
set -ex
4343

44-
MESON_ARGS=(-Dcryptolib=${CRYPTOLIB:-auto})
44+
MESON_ARGS=()
4545

4646
# (Re)set the current oom-{score-}adj. For some reason root on GH actions is able to _decrease_
4747
# its oom-score even after dropping all capabilities (including CAP_SYS_RESOURCE), until the

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ jobs:
1616
build:
1717
runs-on: ubuntu-24.04
1818
concurrency:
19-
group: ${{ github.workflow }}-${{ matrix.run_phase }}-${{ matrix.cryptolib }}-${{ github.ref }}
19+
group: ${{ github.workflow }}-${{ matrix.run_phase }}-${{ github.ref }}
2020
cancel-in-progress: true
2121
strategy:
2222
fail-fast: false
2323
matrix:
2424
run_phase: [GCC, GCC_ASAN_UBSAN, CLANG, CLANG_RELEASE, CLANG_ASAN_UBSAN, CLANG_ASAN_UBSAN_NO_DEPS]
25-
cryptolib: [auto]
2625
include:
2726
- run_phase: GCC
28-
cryptolib: openssl
2927
- run_phase: CLANG
30-
cryptolib: gcrypt
3128
steps:
3229
- name: Repository checkout
3330
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -38,8 +35,6 @@ jobs:
3835
sudo sed -i '/^XDG_/d' /etc/environment
3936
# Pass only specific env variables through sudo, to avoid having
4037
# the already existing XDG_* stuff on the "other side"
41-
sudo --preserve-env=CRYPTOLIB,GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh SETUP
38+
sudo --preserve-env=GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh SETUP
4239
- name: Build & test
43-
run: sudo --preserve-env=CRYPTOLIB,GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh RUN_${{ matrix.run_phase }}
44-
env:
45-
CRYPTOLIB: ${{ matrix.cryptolib }}
40+
run: sudo --preserve-env=GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh RUN_${{ matrix.run_phase }}

NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ CHANGES WITH 258 in spe:
6767
in v255), 'default-hierarchy' (v256), and 'nscd' (v257) have been
6868
removed.
6969

70+
* OpenSSL is the only crypto backend for systemd-resolved and
71+
systemd-importd, and support for gnutls and gcrypt has been removed.
72+
Hence, support for 'dns-over-tls=gnutls' meson option has been
73+
removed. Also, 'cryptolib' meson option has been deprecated, and will
74+
be removed in a future release.
75+
7076
Announcements of Future Feature Removals:
7177

7278
* The D-Bus method org.freedesktop.systemd1.StartAuxiliaryScope() is

README

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ REQUIREMENTS:
240240
libcurl >= 7.32.0 (optional)
241241
libidn2 or libidn (optional)
242242
gnutls >= 3.1.4 (optional)
243-
>= 3.6.0 is required to support DNS-over-TLS with gnutls
244-
openssl >= 1.1.0 (optional, required to support DNS-over-TLS with openssl)
243+
openssl >= 1.1.0 (optional, required to support DNS-over-TLS)
245244
p11-kit >= 0.23.3 (optional)
246245
libfido2 (optional)
247246
tpm2-tss (optional)

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,6 @@ Features:
17911791
with matches, then activate app through that passing socket over
17921792

17931793
* unify on openssl:
1794-
- kill gnutls support in resolved
17951794
- figure out what to do about libmicrohttpd, which has a hard dependency on
17961795
gnutls
17971796
- port fsprg over to a dlopen lib, then switch it to openssl

meson.build

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,50 +1482,18 @@ endif
14821482
dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'loongarch64', 'mips', 'riscv64']
14831483
conf.set10('HAVE_DMI', host_machine.cpu_family() in dmi_arches)
14841484

1485-
# We support one or the other. If gcrypt is available, we assume it's there to
1486-
# be used, and use it in preference.
1487-
opt = get_option('cryptolib')
1488-
if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1489-
error('openssl requested as the default cryptolib, but not available')
1490-
endif
1491-
conf.set10('PREFER_OPENSSL',
1492-
opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1493-
conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1494-
conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1495-
lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1496-
14971485
dns_over_tls = get_option('dns-over-tls')
1498-
if dns_over_tls != 'false'
1499-
if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1500-
error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1501-
endif
1502-
1503-
if dns_over_tls == 'gnutls'
1504-
have_openssl = false
1505-
else
1506-
have_openssl = conf.get('HAVE_OPENSSL') == 1
1507-
if dns_over_tls == 'openssl' and not have_openssl
1508-
error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1509-
endif
1510-
endif
1511-
if dns_over_tls == 'openssl' or have_openssl
1512-
have_gnutls = false
1513-
else
1514-
have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1515-
if dns_over_tls != 'auto' and not have_gnutls
1516-
str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1517-
error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1518-
endif
1519-
endif
1520-
have = have_gnutls or have_openssl
1521-
else
1486+
have_openssl = conf.get('HAVE_OPENSSL') == 1
1487+
if dns_over_tls == 'false'
15221488
have = false
1523-
have_gnutls = false
1524-
have_openssl = false
1489+
elif dns_over_tls == 'auto'
1490+
have = have_openssl
1491+
elif have_openssl
1492+
have = true
1493+
else
1494+
error('DNS-over-TLS support was requested, but OpenSSL support is disabled.')
15251495
endif
15261496
conf.set10('ENABLE_DNS_OVER_TLS', have)
1527-
conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1528-
conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
15291497

15301498
default_dns_over_tls = get_option('default-dns-over-tls')
15311499
if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
@@ -1552,8 +1520,8 @@ have = get_option('repart').require(
15521520
conf.set10('ENABLE_REPART', have)
15531521

15541522
default_dnssec = get_option('default-dnssec')
1555-
if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1556-
message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1523+
if default_dnssec != 'no' and conf.get('HAVE_OPENSSL') == 0
1524+
message('default-dnssec cannot be set to yes or allow-downgrade when openssl is disabled. Setting default-dnssec to no.')
15571525
default_dnssec = 'no'
15581526
endif
15591527
conf.set('DEFAULT_DNSSEC_MODE',
@@ -1584,7 +1552,7 @@ conf.set10('ENABLE_STORAGETM', get_option('storagetm'))
15841552

15851553
have = get_option('importd').require(
15861554
conf.get('HAVE_LIBCURL') == 1 and
1587-
conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1555+
conf.get('HAVE_OPENSSL') == 1 and
15881556
conf.get('HAVE_ZLIB') == 1 and
15891557
conf.get('HAVE_XZ') == 1,
15901558
error_message : 'curl, openssl/grypt, zlib and xz required').allowed()
@@ -3097,6 +3065,7 @@ foreach tuple : [
30973065

30983066
# optional features
30993067
['dmi'],
3068+
['DNS-over-TLS'],
31003069
['idn'],
31013070
['polkit'],
31023071
['legacy-pkla', install_polkit_pkla],
@@ -3161,22 +3130,6 @@ else
31613130
found += 'static-libudev(@0@)'.format(static_libudev)
31623131
endif
31633132

3164-
if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
3165-
found += 'cryptolib(openssl)'
3166-
elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
3167-
found += 'cryptolib(gcrypt)'
3168-
else
3169-
missing += 'cryptolib'
3170-
endif
3171-
3172-
if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
3173-
found += 'DNS-over-TLS(gnutls)'
3174-
elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
3175-
found += 'DNS-over-TLS(openssl)'
3176-
else
3177-
missing += 'DNS-over-TLS'
3178-
endif
3179-
31803133
summary({
31813134
'enabled' : ', '.join(found),
31823135
'disabled' : ', '.join(missing)},

meson_options.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ option('default-llmnr', type : 'combo',
358358
choices : ['yes', 'resolve', 'no'],
359359
description : 'default LLMNR mode',
360360
value : 'yes')
361-
option('dns-over-tls', type : 'combo', choices : ['auto', 'gnutls', 'openssl', 'true', 'false'],
361+
option('dns-over-tls', type : 'combo', choices : ['auto', 'openssl', 'true', 'false'],
362362
description : 'DNS-over-TLS support')
363363
option('dns-servers', type : 'string',
364364
description : 'space-separated list of default DNS servers',
@@ -434,8 +434,8 @@ option('gnutls', type : 'feature', deprecated : { 'true' : 'enabled', 'false' :
434434
description : 'gnutls support')
435435
option('openssl', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },
436436
description : 'openssl support')
437-
option('cryptolib', type : 'combo', choices : ['auto', 'openssl', 'gcrypt'],
438-
description : 'whether to use openssl or gcrypt where both are supported')
437+
option('cryptolib', type : 'combo', choices : ['auto', 'openssl'],
438+
description : 'This option is deprecated and will be removed in a future release')
439439
option('p11kit', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },
440440
description : 'p11kit support')
441441
option('libfido2', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },

src/basic/gcrypt-util.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -106,39 +106,4 @@ int initialize_libgcrypt(bool secmem) {
106106

107107
return 0;
108108
}
109-
110-
# if !PREFER_OPENSSL
111-
int string_hashsum(const char *s, size_t len, int md_algorithm, char **out) {
112-
_cleanup_(sym_gcry_md_closep) gcry_md_hd_t md = NULL;
113-
gcry_error_t err;
114-
size_t hash_size;
115-
void *hash;
116-
char *enc;
117-
int r;
118-
119-
r = initialize_libgcrypt(false);
120-
if (r < 0)
121-
return r;
122-
123-
hash_size = sym_gcry_md_get_algo_dlen(md_algorithm);
124-
assert(hash_size > 0);
125-
126-
err = sym_gcry_md_open(&md, md_algorithm, 0);
127-
if (gcry_err_code(err) != GPG_ERR_NO_ERROR || !md)
128-
return -EIO;
129-
130-
sym_gcry_md_write(md, s, len);
131-
132-
hash = sym_gcry_md_read(md, 0);
133-
if (!hash)
134-
return -EIO;
135-
136-
enc = hexmem(hash, hash_size);
137-
if (!enc)
138-
return -ENOMEM;
139-
140-
*out = enc;
141-
return 0;
142-
}
143-
# endif
144109
#endif

0 commit comments

Comments
 (0)