Сравнение openssl-1.0.2u-r1 с openssl-1.1.1u

/usr/portage/dev-libs/openssl/openssl-1.1.1u.ebuild 2023-10-09 14:52:29.752368357 +0300
1 1
# Copyright 1999-2023 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4
EAPI="7"
4
EAPI=8
5 5

  
6
inherit flag-o-matic toolchain-funcs multilib-minimal
7

  
8
# openssl-1.0.2-patches-1.6 contain additional CVE patches
9
# which got fixed with this release.
10
# Please use 1.7 version number when rolling a new tarball!
11
PATCH_SET="openssl-1.0.2-patches-1.5"
6
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/openssl.org.asc
7
inherit edo flag-o-matic toolchain-funcs multilib-minimal verify-sig
12 8

  
13 9
MY_P=${P/_/-}
14

  
15
# This patch set is based on the following files from Fedora 25,
16
# see https://src.fedoraproject.org/rpms/openssl/blob/25/f/openssl.spec
17
# for more details:
18
# - hobble-openssl (SOURCE1)
19
# - ec_curve.c (SOURCE12) -- MODIFIED
20
# - ectest.c (SOURCE13)
21
# - openssl-1.1.1-ec-curves.patch (PATCH37) -- MODIFIED
22
BINDIST_PATCH_SET="openssl-1.0.2t-bindist-1.0.tar.xz"
23

  
24
DESCRIPTION="full-strength general purpose cryptography library (including SSL and TLS)"
10
DESCRIPTION="Full-strength general purpose cryptography library (including SSL and TLS)"
25 11
HOMEPAGE="https://www.openssl.org/"
26 12
SRC_URI="mirror://openssl/source/${MY_P}.tar.gz
27
	bindist? (
28
		mirror://gentoo/${BINDIST_PATCH_SET}
29
		https://dev.gentoo.org/~whissi/dist/openssl/${BINDIST_PATCH_SET}
30
	)
31
	!vanilla? (
32
		mirror://gentoo/${PATCH_SET}.tar.xz
33
		https://dev.gentoo.org/~chutzpah/dist/${PN}/${PATCH_SET}.tar.xz
34
		https://dev.gentoo.org/~whissi/dist/${PN}/${PATCH_SET}.tar.xz
35
		https://dev.gentoo.org/~polynomial-c/dist/${PATCH_SET}.tar.xz
36
	)"
13
	verify-sig? ( mirror://openssl/source/${MY_P}.tar.gz.asc )"
14
S="${WORKDIR}/${MY_P}"
37 15

  
38 16
LICENSE="openssl"
39
SLOT="0"
40
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~x86-linux ~arm64-macos"
41
IUSE="+asm bindist gmp kerberos rfc3779 sctp cpu_flags_x86_sse2 sslv2 +sslv3 static-libs test tls-compression +tls-heartbeat vanilla"
42
RESTRICT="!bindist? ( bindist )
43
	!test? ( test )"
44

  
45
RDEPEND=">=app-misc/c_rehash-1.7-r1
46
	gmp? ( >=dev-libs/gmp-5.1.3-r1[static-libs(+)?,${MULTILIB_USEDEP}] )
47
	kerberos? ( >=app-crypt/mit-krb5-1.11.4[${MULTILIB_USEDEP}] )
17
SLOT="0/1.1" # .so version of libssl/libcrypto
18
if [[ ${PV} != *_pre* ]] ; then
19
	KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
20
fi
21
IUSE="+asm rfc3779 sctp cpu_flags_x86_sse2 sslv3 static-libs test tls-compression tls-heartbeat vanilla verify-sig weak-ssl-ciphers"
22
RESTRICT="!test? ( test )"
23

  
24
RDEPEND="
48 25
	tls-compression? ( >=sys-libs/zlib-1.2.8-r1[static-libs(+)?,${MULTILIB_USEDEP}] )"
49 26
DEPEND="${RDEPEND}"
50 27
BDEPEND="
......
53 30
	test? (
54 31
		sys-apps/diffutils
55 32
		sys-devel/bc
56
	)"
33
		kernel_linux? ( sys-process/procps )
34
	)
35
	verify-sig? ( >=sec-keys/openpgp-keys-openssl-20230207 )"
57 36
PDEPEND="app-misc/ca-certificates"
58 37

  
59
S="${WORKDIR}/${MY_P}"
38
# force upgrade to prevent broken login, bug #696950
39
RDEPEND+=" !<net-misc/openssh-8.0_p1-r3"
60 40

  
61 41
MULTILIB_WRAPPED_HEADERS=(
62 42
	usr/include/openssl/opensslconf.h
63 43
)
64 44

  
65
src_prepare() {
66
	if use bindist; then
67
		mv "${WORKDIR}"/bindist-patches/hobble-openssl "${WORKDIR}" || die
68
		bash "${WORKDIR}"/hobble-openssl || die
69

  
70
		cp -f "${WORKDIR}"/bindist-patches/ec_curve.c "${S}"/crypto/ec/ || die
71
		cp -f "${WORKDIR}"/bindist-patches/ectest.c "${S}"/crypto/ec/ || die
72

  
73
		eapply "${WORKDIR}"/bindist-patches/ec-curves.patch
74

  
75
		# Also see the configure parts below:
76
		# enable-ec \
77
		# $(use_ssl !bindist ec2m) \
78
		# $(use_ssl !bindist srp) \
45
PATCHES=(
46
	# General patches which are suitable to always apply
47
	# If they're Gentoo specific, add to USE=-vanilla logic in src_prepare!
48
	"${FILESDIR}"/${PN}-1.1.0j-parallel_install_fix.patch # bug #671602
49
	"${FILESDIR}"/${PN}-1.1.1i-riscv32.patch
50
)
51

  
52
pkg_setup() {
53
	[[ ${MERGE_TYPE} == binary ]] && return
54

  
55
	# must check in pkg_setup; sysctl doesn't work with userpriv!
56
	if use test && use sctp; then
57
		# test_ssl_new will fail with "Ensure SCTP AUTH chunks are enabled in kernel"
58
		# if sctp.auth_enable is not enabled.
59
		local sctp_auth_status=$(sysctl -n net.sctp.auth_enable 2>/dev/null)
60
		if [[ -z "${sctp_auth_status}" ]] || [[ ${sctp_auth_status} != 1 ]]; then
61
			die "FEATURES=test with USE=sctp requires net.sctp.auth_enable=1!"
62
		fi
79 63
	fi
64
}
80 65

  
81
	# keep this in sync with app-misc/c_rehash
82
	SSL_CNF_DIR="/etc/ssl"
66
src_unpack() {
67
	# Can delete this once test fix patch is dropped
68
	if use verify-sig ; then
69
		# Needed for downloaded patch (which is unsigned, which is fine)
70
		verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.gz{,.asc}
71
	fi
83 72

  
73
	default
74
}
75

  
76
src_prepare() {
84 77
	# Make sure we only ever touch Makefile.org and avoid patching a file
85 78
	# that gets blown away anyways by the Configure script in src_configure
86 79
	rm -f Makefile
87 80

  
88 81
	if ! use vanilla ; then
89
		eapply "${WORKDIR}"/patch/*.patch
82
		PATCHES+=(
83
			# Add patches which are Gentoo-specific customisations here
84
		)
90 85
	fi
91 86

  
92
	eapply_user
87
	default
93 88

  
94
	# disable fips in the build
95
	# make sure the man pages are suffixed #302165
96
	# don't bother building man pages if they're disabled
97
	sed -i \
98
		-e '/DIRS/s: fips : :g' \
99
		-e '/^MANSUFFIX/s:=.*:=ssl:' \
100
		-e '/^MAKEDEPPROG/s:=.*:=$(CC):' \
101
		-e $(has noman FEATURES \
102
			&& echo '/^install:/s:install_docs::' \
103
			|| echo '/^MANDIR=/s:=.*:='${EPREFIX}'/usr/share/man:') \
104
		Makefile.org \
105
		|| die
106
	# show the actual commands in the log
107
	sed -i '/^SET_X/s:=.*:=set -x:' Makefile.shared
108

  
109
	# since we're forcing $(CC) as makedep anyway, just fix
110
	# the conditional as always-on
111
	# helps clang (#417795), and versioned gcc (#499818)
112
	# this breaks build with 1.0.2p, not sure if it is needed anymore
113
	#sed -i 's/expr.*MAKEDEPEND.*;/true;/' util/domd || die
89
	if use test && use sctp && has network-sandbox ${FEATURES}; then
90
		einfo "Disabling test '80-test_ssl_new.t' which is known to fail with FEATURES=network-sandbox ..."
91
		rm test/recipes/80-test_ssl_new.t || die
92
	fi
114 93

  
115
	# quiet out unknown driver argument warnings since openssl
116
	# doesn't have well-split CFLAGS and we're making it even worse
117
	# and 'make depend' uses -Werror for added fun (#417795 again)
118
	[[ ${CC} == *clang* ]] && append-flags -Qunused-arguments
94
	# Test fails depending on kernel configuration, bug #699134
95
	rm test/recipes/30-test_afalg.t || die
119 96

  
120
	# allow openssl to be cross-compiled
121
	cp "${FILESDIR}"/gentoo.config-1.0.2 gentoo.config || die
122
	chmod a+rx gentoo.config || die
97
	# Remove test target when FEATURES=test isn't set
98
	if ! use test ; then
99
		sed \
100
			-e '/^$config{dirs}/s@ "test",@@' \
101
			-i Configure || die
102
	fi
123 103

  
124
	append-flags -fno-strict-aliasing
125
	append-flags $(test-flags-CC -Wa,--noexecstack)
126
	append-cppflags -DOPENSSL_NO_BUF_FREELISTS
104
	if use prefix && [[ ${CHOST} == *-solaris* ]] ; then
105
		# use GNU ld full option, not to confuse it on Solaris
106
		sed -i \
107
			-e 's/-Wl,-M,/-Wl,--version-script=/' \
108
			-e 's/-Wl,-h,/-Wl,--soname=/' \
109
			Configurations/10-main.conf || die
110
	fi
127 111

  
128
	sed -i '1s,^:$,#!'${EPREFIX}'/usr/bin/perl,' Configure #141906
129 112
	# The config script does stupid stuff to prompt the user.  Kill it.
130 113
	sed -i '/stty -icanon min 0 time 50; read waste/d' config || die
131
	./config --test-sanity || die "I AM NOT SANE"
114
}
115

  
116
src_configure() {
117
	# Keep this in sync with app-misc/c_rehash
118
	SSL_CNF_DIR="/etc/ssl"
119

  
120
	# Quiet out unknown driver argument warnings since openssl
121
	# doesn't have well-split CFLAGS and we're making it even worse
122
	# and 'make depend' uses -Werror for added fun (bug #417795 again)
123
	tc-is-clang && append-flags -Qunused-arguments
124

  
125
	# We really, really need to build OpenSSL w/ strict aliasing disabled.
126
	# It's filled with violations and it *will* result in miscompiled
127
	# code. This has been in the ebuild for > 10 years but even in 2022,
128
	# it's still relevant:
129
	# - https://github.com/llvm/llvm-project/issues/55255
130
	# - https://github.com/openssl/openssl/issues/18225
131
	# - https://github.com/openssl/openssl/issues/18663#issuecomment-1181478057
132
	# Don't remove the no strict aliasing bits below!
133
	filter-flags -fstrict-aliasing
134
	append-flags -fno-strict-aliasing
135
	# The OpenSSL developers don't test with LTO right now, it leads to various
136
	# warnings/errors (which may or may not be false positives), it's considered
137
	# unsupported, and it's not tested in CI: https://github.com/openssl/openssl/issues/18663.
138
	filter-lto
132 139

  
133
	multilib_copy_sources
140
	append-cppflags -DOPENSSL_NO_BUF_FREELISTS
141

  
142
	append-flags $(test-flags-CC -Wa,--noexecstack)
143

  
144
	# bug #197996
145
	unset APPS
146
	# bug #312551
147
	unset SCRIPTS
148
	# bug #311473
149
	unset CROSS_COMPILE
150

  
151
	tc-export AR CC CXX RANLIB RC
152

  
153
	multilib-minimal_src_configure
134 154
}
135 155

  
136 156
multilib_src_configure() {
137
	unset APPS #197996
138
	unset SCRIPTS #312551
139
	unset CROSS_COMPILE #311473
140

  
141
	tc-export CC AR RANLIB RC
142

  
143
	# Clean out patent-or-otherwise-encumbered code
144
	# Camellia: Royalty Free            https://en.wikipedia.org/wiki/Camellia_(cipher)
145
	# IDEA:     Expired                 https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
146
	# EC:       ????????? ??/??/2015    https://en.wikipedia.org/wiki/Elliptic_Curve_Cryptography
147
	# MDC2:     Expired                 https://en.wikipedia.org/wiki/MDC-2
148
	# RC5:      Expired                 https://en.wikipedia.org/wiki/RC5
149

  
150 157
	use_ssl() { usex $1 "enable-${2:-$1}" "no-${2:-$1}" " ${*:3}" ; }
151
	echoit() { echo "$@" ; "$@" ; }
152 158

  
153 159
	local krb5=$(has_version app-crypt/mit-krb5 && echo "MIT" || echo "Heimdal")
154 160

  
......
161 167
	#
162 168
	#echo "__uint128_t i;" > "${T}"/128.c
163 169
	#if ${CC} ${CFLAGS} -c "${T}"/128.c -o /dev/null >&/dev/null ; then
164
	#       ec_nistp_64_gcc_128="enable-ec_nistp_64_gcc_128"
170
	#	ec_nistp_64_gcc_128="enable-ec_nistp_64_gcc_128"
165 171
	#fi
166 172

  
167
	# https://github.com/openssl/openssl/issues/2286
168
	if use ia64 ; then
169
		replace-flags -g3 -g2
170
		replace-flags -ggdb3 -ggdb2
171
	fi
172

  
173
	local sslout=$(./gentoo.config)
173
	local sslout=$(bash "${FILESDIR}/gentoo.config-1.0.4")
174 174
	einfo "Use configuration ${sslout:-(openssl knows best)}"
175
	local config="Configure"
176
	[[ -z ${sslout} ]] && config="config"
175
	local config=( perl "${S}/Configure" )
176
	[[ -z ${sslout} ]] && config=( sh "${S}/config" -v )
177 177

  
178
	# Fedora hobbled-EC needs 'no-ec2m', 'no-srp'
178
	# "disable-deprecated" option breaks too many consumers.
179
	# Don't set it without thorough revdeps testing.
179 180
	# Make sure user flags don't get added *yet* to avoid duplicated
180 181
	# flags.
181
	CFLAGS= LDFLAGS= echoit \
182
	./${config} \
183
		${sslout} \
184
		$(use cpu_flags_x86_sse2 || echo "no-sse2") \
185
		enable-camellia \
186
		enable-ec \
187
		$(use_ssl !bindist ec2m) \
188
		$(use_ssl !bindist srp) \
189
		${ec_nistp_64_gcc_128} \
190
		enable-idea \
191
		enable-mdc2 \
192
		enable-rc5 \
193
		enable-tlsext \
194
		$(use_ssl asm) \
195
		$(use_ssl gmp gmp -lgmp) \
196
		$(use_ssl kerberos krb5 --with-krb5-flavor=${krb5}) \
197
		$(use_ssl rfc3779) \
198
		$(use_ssl sctp) \
199
		$(use_ssl sslv2 ssl2) \
200
		$(use_ssl sslv3 ssl3) \
201
		$(use_ssl tls-compression zlib) \
202
		$(use_ssl tls-heartbeat heartbeats) \
203
		--prefix="${EPREFIX}"/usr \
204
		--openssldir="${EPREFIX}"${SSL_CNF_DIR} \
205
		--libdir=$(get_libdir) \
206
		shared threads \
207
		|| die
208

  
209
	# Clean out hardcoded flags that openssl uses
210
	local DEFAULT_CFLAGS=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
211
		-e 's:^CFLAG=::' \
212
		-e 's:\(^\| \)-fomit-frame-pointer::g' \
213
		-e 's:\(^\| \)-O[^ ]*::g' \
214
		-e 's:\(^\| \)-march=[^ ]*::g' \
215
		-e 's:\(^\| \)-mcpu=[^ ]*::g' \
216
		-e 's:\(^\| \)-m[^ ]*::g' \
217
		-e 's:^ *::' \
218
		-e 's: *$::' \
219
		-e 's: \+: :g' \
220
		-e 's:\\:\\\\:g'
182
	local myeconfargs=(
183
		${sslout}
184

  
185
		$(use cpu_flags_x86_sse2 || echo "no-sse2")
186
		enable-camellia
187
		enable-ec
188
		enable-ec2m
189
		enable-sm2
190
		enable-srp
191
		$(use elibc_musl && echo "no-async")
192
		${ec_nistp_64_gcc_128}
193
		enable-idea
194
		enable-mdc2
195
		enable-rc5
196
		$(use_ssl sslv3 ssl3)
197
		$(use_ssl sslv3 ssl3-method)
198
		$(use_ssl asm)
199
		$(use_ssl rfc3779)
200
		$(use_ssl sctp)
201
		$(use test || echo "no-tests")
202
		$(use_ssl tls-compression zlib)
203
		$(use_ssl tls-heartbeat heartbeats)
204
		$(use_ssl weak-ssl-ciphers)
205

  
206
		--prefix="${EPREFIX}"/usr
207
		--openssldir="${EPREFIX}"${SSL_CNF_DIR}
208
		--libdir=$(get_libdir)
209

  
210
		shared
211
		threads
221 212
	)
222 213

  
223
	# Now insert clean default flags with user flags
224
	sed -i \
225
		-e "/^CFLAG/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
226
		-e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \
227
		Makefile || die
214
	edo "${config[@]}" "${myeconfargs[@]}"
228 215
}
229 216

  
230 217
multilib_src_compile() {
231
	# depend is needed to use $confopts; it also doesn't matter
232
	# that it's -j1 as the code itself serializes subdirs
233
	emake -j1 V=1 depend
234 218
	emake all
235
	# rehash is needed to prep the certs/ dir; do this
236
	# separately to avoid parallel build issues.
237
	emake rehash
238 219
}
239 220

  
240 221
multilib_src_test() {
......
242 223
}
243 224

  
244 225
multilib_src_install() {
245
	# We need to create $ED/usr on our own to avoid a race condition #665130
246
	if [[ ! -d "${ED}/usr" ]]; then
247
		# We can only create this directory once
248
		mkdir "${ED}"/usr || die
249
	fi
226
	emake DESTDIR="${D}" install_sw
250 227

  
251
	emake INSTALL_PREFIX="${D}" install
228
	if multilib_is_native_abi; then
229
		emake DESTDIR="${D}" install_ssldirs
230
		emake DESTDIR="${D}" DOCDIR='$(INSTALLTOP)'/share/doc/${PF} MANSUFFIX=ssl install_docs
231
	fi
252 232

  
253 233
	# This is crappy in that the static archives are still built even
254
	# when USE=static-libs.  But this is due to a failing in the openssl
234
	# when USE=static-libs. But this is due to a failing in the openssl
255 235
	# build system: the static archives are built as PIC all the time.
256 236
	# Only way around this would be to manually configure+compile openssl
257 237
	# twice; once with shared lib support enabled and once without.
......
265 245
	# we provide a shell version via app-misc/c_rehash
266 246
	rm "${ED}"/usr/bin/c_rehash || die
267 247

  
268
	local -a DOCS=( CHANGES* FAQ NEWS README doc/*.txt doc/c-indentation.el )
269
	einstalldocs
270

  
271
	use rfc3779 && dodoc engines/ccgost/README.gost
248
	dodoc CHANGES* FAQ NEWS README doc/*.txt doc/${PN}-c-indent.el
272 249

  
273
	# create the certs directory
274
	dodir ${SSL_CNF_DIR}/certs
275
	cp -RP certs/* "${ED}"${SSL_CNF_DIR}/certs/ || die
276
	rm -r "${ED}"${SSL_CNF_DIR}/certs/{demo,expired}
277

  
278
	# Namespace openssl programs to prevent conflicts with other man pages
279
	cd "${ED}"/usr/share/man
280
	local m d s
281
	for m in $(find . -type f | xargs grep -L '#include') ; do
282
		d=${m%/*} ; d=${d#./} ; m=${m##*/}
283
		[[ ${m} == openssl.1* ]] && continue
284
		[[ -n $(find -L ${d} -type l) ]] && die "erp, broken links already!"
285
		mv ${d}/{,ssl-}${m}
286
		# fix up references to renamed man pages
287
		sed -i '/^[.]SH "SEE ALSO"/,/^[.]/s:\([^(, ]*(1)\):ssl-\1:g' ${d}/ssl-${m}
288
		ln -s ssl-${m} ${d}/openssl-${m}
289
		# locate any symlinks that point to this man page ... we assume
290
		# that any broken links are due to the above renaming
291
		for s in $(find -L ${d} -type l) ; do
292
			s=${s##*/}
293
			rm -f ${d}/${s}
294
			ln -s ssl-${m} ${d}/ssl-${s}
295
			ln -s ssl-${s} ${d}/openssl-${s}
296
		done
297
	done
298
	[[ -n $(find -L ${d} -type l) ]] && die "broken manpage links found :("
250
	# Create the certs directory
251
	keepdir ${SSL_CNF_DIR}/certs
299 252

  
300
	dodir /etc/sandbox.d #254521
253
	# bug #254521
254
	dodir /etc/sandbox.d
301 255
	echo 'SANDBOX_PREDICT="/dev/crypto"' > "${ED}"/etc/sandbox.d/10openssl
302 256

  
303 257
	diropts -m0700
......
305 259
}
306 260

  
307 261
pkg_postinst() {
308
	ebegin "Running 'c_rehash ${EROOT}${SSL_CNF_DIR}/certs/' to rebuild hashes #333069"
309
	c_rehash "${EROOT}${SSL_CNF_DIR}/certs" >/dev/null
262
	ebegin "Running 'openssl rehash ${EROOT}${SSL_CNF_DIR}/certs' to rebuild hashes (bug #333069)"
263
	openssl rehash "${EROOT}${SSL_CNF_DIR}/certs"
310 264
	eend $?
311 265
}
Спасибо!