Opened 4 years ago

Closed 4 years ago

#61005 closed defect (fixed)

lftp fails to build with libressl after upgrade to 4.9.2

Reported by: bK4gYuRo Owned by: Schamschula (Marius Schamschula)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: bK4gYuRo
Port: lftp

Description

The error that I can see in the log:

:info:build lftp_ssl.cc:1164:10: error: use of undeclared identifier 'X509_STORE_CTX_get_by_subject'; did you mean 'X509_STORE_get_by_subject'?
:info:build     rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
:info:build          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:info:build          X509_STORE_get_by_subject
:info:build /opt/local/include/openssl/x509_vfy.h:479:5: note: 'X509_STORE_get_by_subject' declared here
:info:build int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
:info:build     ^
:info:build lftp_ssl.cc:1204:10: error: use of undeclared identifier 'X509_STORE_CTX_get_by_subject'; did you mean 'X509_STORE_get_by_subject'?
:info:build     rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
:info:build          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:info:build          X509_STORE_get_by_subject
:info:build /opt/local/include/openssl/x509_vfy.h:479:5: note: 'X509_STORE_get_by_subject' declared here
:info:build int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
:info:build     ^
:info:build 2 errors generated.

libressl port that I have is:

libressl @2.8.3_0 (active)

Attachments (3)

main.log (431.5 KB) - added by bK4gYuRo 4 years ago.
build log with error
main.2.log (432.0 KB) - added by bK4gYuRo 4 years ago.
log of 4.9.2_2
patch-lftp-libressl.diff (1011 bytes) - added by bK4gYuRo 4 years ago.
corrected patch-lftp-libressl.diff

Download all attachments as: .zip

Change History (19)

Changed 4 years ago by bK4gYuRo

Attachment: main.log added

build log with error

comment:1 Changed 4 years ago by bK4gYuRo

Cc: bK4gYuRo added

comment:2 Changed 4 years ago by mf2k (Frank Schima)

Cc: Schamschula removed
Keywords: lftp removed
Owner: set to Schamschula
Status: newassigned

comment:3 Changed 4 years ago by Schamschula (Marius Schamschula)

Unfortunately, I can't build lftp against all branches of *ssl.I build and test against openssl.

comment:4 Changed 4 years ago by bK4gYuRo

FreeBSD has this patch https://bugs.freebsd.org/bugzilla/attachment.cgi?id=217368&action=diff which fixes the problem. Would it be possible to appy it here?

comment:5 Changed 4 years ago by Schamschula (Marius Schamschula)

In c3d13078259a38da6861ca6ea56cb05da11c7895/macports-ports (master):

lftp: add patch to fix libressl build

See: #61005

comment:6 Changed 4 years ago by Schamschula (Marius Schamschula)

Let me know if this works for you.

Changed 4 years ago by bK4gYuRo

Attachment: main.2.log added

log of 4.9.2_2

comment:7 Changed 4 years ago by bK4gYuRo

Thank you for applying the patch. Unfortunately, it looks like patchfiles-append command is ignored in the port file. I have port base 2.6.3.

comment:8 Changed 4 years ago by bK4gYuRo

The diff file does not look right to me:

$ pwd
/opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/net/lftp
$ cat files/patch-lftp-libressl.diff
Index: ftp/lftp/files/patch-src_lftp__ssl.cc
===================================================================
--- ftp/lftp/files/patch-src_lftp__ssl.cc	(nonexistent)
+++ ftp/lftp/files/patch-src_lftp__ssl.cc	(working copy)
@@ -0,0 +1,29 @@
+--- src/lftp_ssl.cc.orig	2020-01-29 20:36:37 UTC
++++ src/lftp_ssl.cc
+@@ -34,7 +34,7 @@
+ #include "misc.h"
+ #include "network.h"
+ #include "buffer.h"
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER
+ #define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
+ #endif
+ extern "C" {
+@@ -840,7 +840,7 @@ lftp_ssl_openssl_instance::lftp_ssl_openssl_instance()
+    ssl_ctx=SSL_CTX_new();
+    X509_set_default_verify_paths(ssl_ctx->cert);
+ #else
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER
+    SSLeay_add_ssl_algorithms();
+ #endif
+    ssl_ctx=SSL_CTX_new(SSLv23_client_method());
+@@ -1080,7 +1080,7 @@ void lftp_ssl_openssl::copy_sid(const lftp_ssl_openssl
+ 
+ const char *lftp_ssl_openssl::strerror()
+ {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER
+    SSL_load_error_strings();
+ #endif
+    int error=ERR_get_error();

Property changes on: ftp/lftp/files/patch-src_lftp__ssl.cc
___________________________________________________________________
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property

comment:9 Changed 4 years ago by bK4gYuRo

I cleaned the diff file from extra stuff, and now I am able to build. I am attaching correct diff.

Changed 4 years ago by bK4gYuRo

Attachment: patch-lftp-libressl.diff added

corrected patch-lftp-libressl.diff

comment:10 Changed 4 years ago by bK4gYuRo

Can you please commit it?

comment:11 Changed 4 years ago by Schamschula (Marius Schamschula)

The FreeBSD patch cleanly applied on my machine (otherwise I wouldn't have committed it), and on all instances of MacPorts CI.

The patch utility will ignore the extra stuff.

comment:12 Changed 4 years ago by bK4gYuRo

If you look closer at the FreeBSD patch, you can see that it actually creates a diff file ftp/lftp/files/patch-src_lftp__ssl.cc, but it does not apply it to src/lftp_ssl.cc. If MacPorts CI builds with openssl (and not with libressl), you won't notice. I had to remove the first 5 lines and last 15 lines, and also extra plus character at the beginning of each line. Only then it patched src/lftp_ssl.cc as intended. I think FreeBSD ports works differently than MacPorts, hence extra stuff in their diff.

comment:13 Changed 4 years ago by Schamschula (Marius Schamschula)

It looks like this a patch to create the actual patch. We sometimes see the same thing in GitHub.

comment:14 Changed 4 years ago by Schamschula (Marius Schamschula)

In 897d5733b00e40a11e8ea4188b2cb19c8307a96f/macports-ports (master):

lftp: replace meta-patch with actual patch

See: #61005

comment:15 Changed 4 years ago by bK4gYuRo

Thank you!

comment:16 Changed 4 years ago by Schamschula (Marius Schamschula)

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.