Bug 214660 - security/trousers: miscompiles with libressl
Summary: security/trousers: miscompiles with libressl
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Ben Woods
URL: https://sourceforge.net/p/trousers/bu...
Keywords:
: 214782 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-11-19 07:41 UTC by Walter Schwarzenfeld
Modified: 2016-11-23 14:29 UTC (History)
4 users (show)

See Also:


Attachments
poudrere-gnutls-3.4.16.log.bz2 (44.63 KB, application/x-bzip)
2016-11-19 08:01 UTC, Walter Schwarzenfeld
no flags Details
gnutls-config.log.bz2 (63.21 KB, application/x-bzip)
2016-11-19 13:59 UTC, Walter Schwarzenfeld
no flags Details
Patch to support LibreSSL (355 bytes, patch)
2016-11-21 03:42 UTC, David Z.
daz: maintainer-approval? (hrs)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Schwarzenfeld freebsd_triage 2016-11-19 07:41:49 UTC
gnutls fails on 10.3 with poudriere with

=======================<phase: package        >============================
===>  Building package for gnutls-3.4.16
pkg-static: Unable to access file /wrkdirs/usr/ports/security/gnutls/work/stage/usr/local/bin/tpmtool: No such file or directory
*** Error code 1

Stop.
make: stopped in /usr/ports/security/gnutls
====>> Cleaning up wrkdir
===>  Cleaning for gnutls-3.4.16
build of security/gnutls ended at Sat Nov 19 08:37:16 CET 2016
build time: 00:05:12
!!! build failure encountered !!!
Comment 1 Walter Schwarzenfeld freebsd_triage 2016-11-19 08:01:36 UTC
Created attachment 177173 [details]
poudrere-gnutls-3.4.16.log.bz2
Comment 2 Walter Schwarzenfeld freebsd_triage 2016-11-19 08:12:31 UTC
The error does not appear with the port.
Comment 3 Walter Schwarzenfeld freebsd_triage 2016-11-19 09:01:03 UTC
On my system poudriere has an own portstree, I updated it two hours ago. Now I updated
the system portstree (with the update of security/trousers). Now I have the same error in 
the port.
Comment 4 Tijl Coosemans freebsd_committer freebsd_triage 2016-11-19 11:41:24 UTC
Please attach config.log from the gnutls work directory.
Comment 5 Walter Schwarzenfeld freebsd_triage 2016-11-19 13:59:14 UTC
Created attachment 177183 [details]
gnutls-config.log.bz2
Comment 6 Tijl Coosemans freebsd_committer freebsd_triage 2016-11-19 16:17:37 UTC
configure:47914: checking for tss library
configure:47931: /usr/local/libexec/ccache/world/cc -o conftest -O2 -pipe  -DLIBICONV_PLUG -fstack-protector -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include -I/usr/local/include  -fstack-protector conftest.c -L/usr/local/lib -ltspi >&5
/usr/local/lib/libtspi.so: undefined reference to `RSA_set0_key'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

RSA_set0_key is provided by libcrypto.so.10 which is provided by security/openssl-devel.  If you install security/openssl-devel you must also add DEFAULT_VERSIONS+=ssl=openssl-devel to /etc/make.conf.  Make sure that is the case.
Comment 7 Walter Schwarzenfeld freebsd_triage 2016-11-19 16:35:18 UTC
I use libressl.
Comment 8 Walter Schwarzenfeld freebsd_triage 2016-11-19 16:41:52 UTC
locate  libcrypto.so.10
/compat/linux/usr/lib/.libcrypto.so.10.hmac
/compat/linux/usr/lib/libcrypto.so.10
/compat/linux/usr/lib64/.libcrypto.so.10.hmac
/compat/linux/usr/lib64/libcrypto.so.10
Comment 9 Tijl Coosemans freebsd_committer freebsd_triage 2016-11-19 17:06:42 UTC
(In reply to w.schwarzenfeld from comment #7)
Then you must put DEFAULT_VERSIONS=ssl=libressl in /etc/make.conf.

What is the output of 'objdump -p /usr/local/lib/libtspi.so | grep NEEDED'?
Comment 10 Tijl Coosemans freebsd_committer freebsd_triage 2016-11-19 17:12:50 UTC
I see that you have ssl=libressl already so it must be something in trousers that doesn't like libressl.  Maybe it depends on OPENSSL_VERSION_NUMBER which is something different in libressl.  Over to trousers maintainer.
Comment 11 Walter Schwarzenfeld freebsd_triage 2016-11-19 17:14:42 UTC
objdump -p /usr/local/lib/libtspi.so | grep NEEDED
  NEEDED      libthr.so.3
  NEEDED      libcrypto.so.38
  NEEDED      libc.so.7

----
DEFAULT_VERSIONS+=ssl=libressl is in /erc/make.conf
Comment 12 Ben Woods freebsd_committer freebsd_triage 2016-11-20 05:21:44 UTC
Me too... I am also using libressl with DEFAULT_VERSIONS+=ssl=libressl
Comment 13 David Z. 2016-11-21 03:42:01 UTC
Created attachment 177221 [details]
Patch to support LibreSSL

I've attached a patch to security/trousers that should fix the LibreSSL problem.  With the patch, security/gnutls now builds successfully for me.  Please test.
Comment 14 Walter Schwarzenfeld freebsd_triage 2016-11-21 04:27:00 UTC
Thanks, this is working.
Comment 15 Ben Woods freebsd_committer freebsd_triage 2016-11-22 22:02:43 UTC
I have also raised this as a bug upstream:
https://sourceforge.net/p/trousers/bugs/197/
Comment 16 commit-hook freebsd_committer freebsd_triage 2016-11-23 13:17:01 UTC
A commit references this bug:

Author: woodsb02
Date: Wed Nov 23 13:16:54 UTC 2016
New revision: 426920
URL: https://svnweb.freebsd.org/changeset/ports/426920

Log:
  security/trousers: Fix compilation with LibreSSL

  This was causing the build of security/gnutls to fail when the
  TPM option was enabled and make.conf contained
  DEFAULT_VERSIONS+=ssl=libressl. The gnutls configure script failed to
  successfully link against the libtspi.so library, and therefore
  determined the tss library was not suitable and disabled TPM.
  /usr/local/lib/libtspi.so: undefined reference to `RSA_set0_key'
  This caused the gnutls build to fail during staging due to an incorrect
  PLIST (missing bin/tpmtool).

  As of version 0.3.14, TrouSerS utilises the new OpenSSL function
  RSA_set0_key, which was only introduced in OpenSSL 1.1.0 and is not in
  LibreSSL (yet).

  The TrouSerS code utilises the OPENSSL_VERSION_NUMBER preprocessor macro
  to determine the version of OpenSSL which is it compiling against,
  and defines the RSA_set0_key function if the version of OpenSSL is older
  than 1.1.0. This causes an issue with LibreSSL, because it sets the
  OPENSSL_VERSION_NUMBER preprocessor macro to impersonate OpenSSL 2.0.0.

  The new patch-src_trspi_crypto_openssl_rsa.c causes TrouSerS to define
  the RSA_set0_key function on LibreSSL also.

  PR:		214660
  Submitted by:	David Z <daz@hyperchronos.org>
  Reported by:	Walter Schwarzenfeld <w.schwarzenfeld@utanet.at>
  Approved by:	adamw (mentor, implicit)
  Approved by:	portmgr (just-fix-it blanket)

Changes:
  head/security/trousers/Makefile
  head/security/trousers/files/patch-src_trspi_crypto_openssl_rsa.c
Comment 17 Ben Woods freebsd_committer freebsd_triage 2016-11-23 13:17:36 UTC
Committed. Thanks for the patch daz, and to everyone else for reporting / debugging the issue.
Comment 18 Tijl Coosemans freebsd_committer freebsd_triage 2016-11-23 14:29:50 UTC
*** Bug 214782 has been marked as a duplicate of this bug. ***