Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Dec 2011 08:34:22 +0800
From:      Jan Beich <jbeich@tormail.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/163550: [patch] ftp/vsftpd{, -ext}: respect CC/CFLAGS/STRIP uniformly
Message-ID:  <1Rdt5r-000GBs-A5@internal.tormail.net>
Resent-Message-ID: <201112230040.pBN0e5Ih081159@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         163550
>Category:       ports
>Synopsis:       [patch] ftp/vsftpd{,-ext}: respect CC/CFLAGS/STRIP uniformly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 23 00:40:04 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Jan Beich
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
# trap any attempt to not respect CC
$ export PATH=~/.bin:$PATH
$ for cc in CC cc c++ gcc g++ cpp; do ln -s /usr/bin/false ~/.bin/${cc}; done
>Description:
- respect CC (vsftpd-ext)
- respect CFLAGS[1], don't append -O2 as it breaks
  WITH_DEBUG/DEBUG_FLAGS/CFLAGS set in make.conf/Makefile.local
- don't strip unconditionally, rely INSTALL_PROGRAM respecting STRIP[2]
- remove -lwrap from LDFLAGS, rely on vsf_findlibs.sh adding it
- don't link against -lutil on FreeBSD, setproctitle() moved to libc
  more than 10 years ago, ports/ do not support FreeBSD < 7.
- unbreak ssl build by linking against -lssl (vsftpd-ext)

[1] superset of ports/163548
[2] apart from gdb it's also needed in case of system-wide profiling
    with pmcstat/dtrace
>How-To-Repeat:
# either vsftpd or vsftpd-ext
$ make install WITH_DEBUG=
$ command gdb -q /usr/local/libexec/vsftpd
(no debugging symbols found)...(gdb)

# vsftpd-ext
$ printf 'CC=clang\nCXX=clang++\nCPP=clang -E\n' >Makefile.local
$ __MAKE_CONF= make
gcc -c main.c -O2 -pipe -fno-strict-aliasing -O2 -pipe -march=prescott -fno-strict-aliasing -O2 -Wall -W -Wshadow -idirafter dummyinc
*** [main.o] Error code 1

# vsfptd-ext + VSFTPD_SSL option
$ make
===>  Building for vsftpd-ext-ssl-2.3.4.2
[...]
gcc -c ssl.c -O2 -pipe -fno-strict-aliasing -I/usr/include -O2 -pipe -fno-strict-aliasing       -O2 -Wall -W -Wshadow -idirafter dummyinc
[...]
gcc -o vsftpd main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o  tunables.o ftpdataio.o secbuf.o ls.o  postprivparent.o logging.o str.o netstr.o sysstr.o strlist.o  banner.o filestr.o parseconf.o secutil.o  ascii.o oneprocess.o twoprocess.o privops.o standalone.o hash.o  tcpwrap.o ipaddrparse.o access.o features.o readwrite.o opts.o  ssl.o sslslave.o ptracesandbox.o ftppolicy.o sysutil.o sysdeputil.o  charconv.o pasvrules.o usersip.o http.o http_msg.o http_str.o -Wl,-s -lpam  -lwrap  -L/usr/lib
ssl.o: In function `ssl_init':
WRKSRC/ssl.c:62: undefined reference to `SSL_library_init'
WRKSRC/ssl.c:63: undefined reference to `SSLv23_server_method'
WRKSRC/ssl.c:63: undefined reference to `SSL_CTX_new'
WRKSRC/ssl.c:81: undefined reference to `SSL_CTX_ctrl'
WRKSRC/ssl.c:89: undefined reference to `SSL_CTX_use_certificate_chain_file'
WRKSRC/ssl.c:93: undefined reference to `SSL_CTX_use_PrivateKey_file'
WRKSRC/ssl.c:105: undefined reference to `SSL_CTX_use_certificate_chain_file'
WRKSRC/ssl.c:109: undefined reference to `SSL_CTX_use_PrivateKey_file'
WRKSRC/ssl.c:115: undefined reference to `SSL_CTX_set_cipher_list'
WRKSRC/ssl.c:119: undefined reference to `RAND_status'
WRKSRC/ssl.c:133: undefined reference to `SSL_CTX_set_verify'
WRKSRC/ssl.c:137: undefined reference to `SSL_CTX_load_verify_locations'
WRKSRC/ssl.c:141: undefined reference to `SSL_load_client_CA_file'
WRKSRC/ssl.c:146: undefined reference to `SSL_CTX_set_client_CA_list'
WRKSRC/ssl.c:152: undefined reference to `SSL_CTX_set_session_id_context'
WRKSRC/ssl.c:157: undefined reference to `SSL_CTX_set_timeout'
ssl.o: In function `setup_bio_callbacks':
WRKSRC/ssl.c:646: undefined reference to `SSL_get_rbio'
WRKSRC/ssl.c:647: undefined reference to `BIO_set_callback'
WRKSRC/ssl.c:648: undefined reference to `SSL_get_wbio'
WRKSRC/ssl.c:649: undefined reference to `BIO_set_callback'
ssl.o: In function `get_ssl_error':
WRKSRC/ssl.c:640: undefined reference to `SSL_load_error_strings'
WRKSRC/ssl.c:641: undefined reference to `ERR_get_error'
WRKSRC/ssl.c:641: undefined reference to `ERR_error_string'
ssl.o: In function `ssl_read_common':
WRKSRC/ssl.c:268: undefined reference to `SSL_read'
WRKSRC/ssl.c:269: undefined reference to `SSL_get_error'
WRKSRC/ssl.c:276: undefined reference to `SSL_get_shutdown'
WRKSRC/ssl.c:268: undefined reference to `SSL_peek'
WRKSRC/ssl.c:269: undefined reference to `SSL_get_error'
WRKSRC/ssl.c:276: undefined reference to `SSL_get_shutdown'
ssl.o: In function `ssl_write':
WRKSRC/ssl.c:296: undefined reference to `SSL_write'
WRKSRC/ssl.c:297: undefined reference to `SSL_get_error'
ssl.o: In function `ssl_write_str':
WRKSRC/ssl.c:308: undefined reference to `SSL_write'
ssl.o: In function `ssl_data_close':
WRKSRC/ssl.c:392: undefined reference to `SSL_shutdown'
WRKSRC/ssl.c:396: undefined reference to `SSL_shutdown'
WRKSRC/ssl.c:416: undefined reference to `SSL_free'
ssl.o: In function `maybe_log_shutdown_state':
WRKSRC/ssl.c:337: undefined reference to `SSL_get_shutdown'
ssl.o: In function `get_ssl_error':
WRKSRC/ssl.c:640: undefined reference to `SSL_load_error_strings'
WRKSRC/ssl.c:641: undefined reference to `ERR_get_error'
WRKSRC/ssl.c:641: undefined reference to `ERR_error_string'
ssl.o: In function `setup_bio_callbacks':
WRKSRC/ssl.c:646: undefined reference to `SSL_get_rbio'
WRKSRC/ssl.c:647: undefined reference to `BIO_set_callback'
WRKSRC/ssl.c:648: undefined reference to `SSL_get_wbio'
WRKSRC/ssl.c:649: undefined reference to `BIO_set_callback'
ssl.o: In function `ssl_accept':
WRKSRC/ssl.c:442: undefined reference to `SSL_ctrl'
ssl.o: In function `get_ssl':
WRKSRC/ssl.c:518: undefined reference to `SSL_new'
WRKSRC/ssl.c:528: undefined reference to `SSL_set_fd'
WRKSRC/ssl.c:535: undefined reference to `SSL_free'
WRKSRC/ssl.c:538: undefined reference to `SSL_accept'
ssl.o: In function `get_ssl_error':
WRKSRC/ssl.c:640: undefined reference to `SSL_load_error_strings'
WRKSRC/ssl.c:641: undefined reference to `ERR_get_error'
WRKSRC/ssl.c:641: undefined reference to `ERR_error_string'
ssl.o: In function `get_ssl':
WRKSRC/ssl.c:554: undefined reference to `SSL_get_current_cipher'
WRKSRC/ssl.c:554: undefined reference to `SSL_CIPHER_get_version'
WRKSRC/ssl.c:556: undefined reference to `SSL_get_current_cipher'
WRKSRC/ssl.c:560: undefined reference to `SSL_CIPHER_get_name'
WRKSRC/ssl.c:561: undefined reference to `SSL_get_peer_certificate'
WRKSRC/ssl.c:562: undefined reference to `SSL_ctrl'
WRKSRC/ssl.c:578: undefined reference to `X509_free'
ssl.o: In function `ssl_cert_digest':
WRKSRC/ssl.c:606: undefined reference to `SSL_get_peer_certificate'
WRKSRC/ssl.c:615: undefined reference to `EVP_sha256'
WRKSRC/ssl.c:615: undefined reference to `X509_digest'
WRKSRC/ssl.c:620: undefined reference to `X509_free'
ssl.o: In function `ssl_add_entropy':
WRKSRC/ssl.c:689: undefined reference to `RAND_load_file'
ssl.o: In function `bio_callback':
WRKSRC/ssl.c:665: undefined reference to `BIO_ctrl'
gcc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [vsftpd] Error code 1
>Fix:
--- cc_cflags_strip.diff begins here ---
Index: ftp/vsftpd/Makefile
===================================================================
RCS file: /a/.csup/ports/ftp/vsftpd/Makefile,v
retrieving revision 1.48
diff -u -p -r1.48 Makefile
--- ftp/vsftpd/Makefile	23 Sep 2011 22:22:32 -0000	1.48
+++ ftp/vsftpd/Makefile	23 Dec 2011 00:19:51 -0000
@@ -23,8 +23,6 @@ DOCFILES=	AUDIT BENCHMARKS BUGS Changelo
 		README README.security README.ssl REFS REWARD \
 		SIZE SPEED TODO TUNING
 
-LDFLAGS+=	-lwrap
-
 OPTIONS=	RC_NG		"install RC_NG script"		off \
 		VSFTPD_SSL	"Include support for SSL"	off \
 		PIDFILE		"unofficial support for pidfile"	off
@@ -50,10 +48,11 @@ do-configure:
 	${REINPLACE_CMD} -e "s|/etc/vsftpd.conf|${PREFIX}/etc/vsftpd.conf|" \
 		${WRKSRC}/defs.h ${WRKSRC}/vsftpd.conf
 	${REINPLACE_CMD} \
-		-e "s|^CC 	=	gcc|CC	= ${CC}|" \
-		-e "s|^CFLAGS	=|CFLAGS	= ${CFLAGS}|" \
-		-e "s|	-Wl,-s| -Wl,-s ${LDFLAGS}|" \
+		-e '/^CC/s/=/?=/' \
+		-e '/^CFLAGS/{s/=/+=/;s/-O[0-9]//;}' \
+		-e '/^LINK/s/=.*/=/' \
 		${WRKSRC}/Makefile
+	${REINPLACE_CMD} -e '/-lutil/d' ${WRKSRC}/vsf_findlibs.sh
 	${REINPLACE_CMD} -e \
 		"s|#undef VSF_BUILD_TCPWRAPPERS|#define VSF_BUILD_TCPWRAPPERS 1|" \
 		${WRKSRC}/builddefs.h
Index: ftp/vsftpd-ext/Makefile
===================================================================
RCS file: /a/.csup/ports/ftp/vsftpd-ext/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- ftp/vsftpd-ext/Makefile	21 Dec 2011 13:18:23 -0000	1.5
+++ ftp/vsftpd-ext/Makefile	23 Dec 2011 00:20:22 -0000
@@ -28,8 +28,6 @@ DOCFILES=	AUDIT BENCHMARKS BUGS Changelo
 		README README.security README.ssl REFS REWARD \
 		SIZE SPEED TODO TUNING
 
-LDFLAGS+=	-lwrap
-
 OPTIONS=	RC_SCRIPT	"install RC_SCRIPT"		on \
 		VSFTPD_SSL	"Include support for SSL"	off
 
@@ -53,10 +51,12 @@ do-configure:
 	${REINPLACE_CMD} -e "s|/etc/vsftpd.conf|${PREFIX}/etc/vsftpd.conf|" \
 		${WRKSRC}/defs.h ${WRKSRC}/vsftpd.conf
 	${REINPLACE_CMD} \
-		-e "s|^CC 	=	gcc|CC	= ${CC}|" \
-		-e "s|^CFLAGS	=|CFLAGS	= ${CFLAGS}|" \
-		-e "s|	-Wl,-s| -Wl,-s ${LDFLAGS}|" \
+		-e '/^CC/s/=/?=/' \
+		-e '/^CFLAGS/{s/=/+=/;s/-O[0-9]//;}' \
+		-e '/^LIBS/s|=.*|= `./vsf_findlibs.sh`|' \
+		-e '/^LINK/s/=.*/=/' \
 		${WRKSRC}/Makefile
+	${REINPLACE_CMD} -e '/-lutil/d' ${WRKSRC}/vsf_findlibs.sh
 	${REINPLACE_CMD} -e \
 		"s|#undef VSF_BUILD_TCPWRAPPERS|#define VSF_BUILD_TCPWRAPPERS 1|" \
 		${WRKSRC}/builddefs.h
Index: ftp/vsftpd-ext/files/patch-Makefile
===================================================================
RCS file: ftp/vsftpd-ext/files/patch-Makefile
diff -N ftp/vsftpd-ext/files/patch-Makefile
--- ftp/vsftpd-ext/files/patch-Makefile	21 Dec 2011 13:19:37 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
---- ./Makefile.orig	2011-12-13 10:14:07.000000000 +0200
-+++ ./Makefile	2011-12-13 10:15:30.000000000 +0200
-@@ -3,9 +3,9 @@
- INSTALL	=       install
- IFLAGS  = -idirafter dummyinc
- #CFLAGS = -g
--CFLAGS	=       -O2 -Wall -W -Wshadow #-pedantic -Werror -Wconversion
-+CFLAGS	= -O2 -pipe -march=prescott -fno-strict-aliasing       -O2 -Wall -W -Wshadow #-pedantic -Werror -Wconversion
- 
--LIBS	=       -lcap -ldl -lcrypt    -lpam    -lwrap -lnsl    -lssl -lcrypto
-+LIBS=	-lpam
- #                                     |        |               + VSF_BUILD_SSL
- #                                     |        + VSF_BUILD_TCPWRAPPERS
- #                                     + VSF_BUILD_PAM
--- cc_cflags_strip.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1Rdt5r-000GBs-A5>