Skip to content

Commit

Permalink
ftp/wzdftpd: fix build with LLVM 15
Browse files Browse the repository at this point in the history
Seems like the compiler got a whole lot stricter with this release.
The biggest fix was changing the thread ID from unsigned long to
pthread_t, which will probably break compilation on Win32.

While we are at it, replace static uses of REINPLACE_CMD with patch
files as per policy.  This change is responsible for most of the
newly added patches.

The wzdftpd build scripts want to install plugins into ${PREFIX}/share
when they belong into ${PREFIX}/lib.  Instead of patching this in each
Makefile.am, set --datadir=${PREFIX}/lib and work around the one file
for which this is wrong.

Approved by:	eduardo (mentor)
Differential Revision: https://reviews.freebsd.org/D38523
  • Loading branch information
clausecker committed Feb 14, 2023
1 parent 81ce1e4 commit 2f04ed7
Show file tree
Hide file tree
Showing 19 changed files with 244 additions and 23 deletions.
25 changes: 6 additions & 19 deletions ftp/wzdftpd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ LICENSE_FILE= ${WRKSRC}/COPYING

USES= autoreconf:2.69 cpe gettext-tools libtool localbase pkgconfig
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --sysconfdir=${ETCDIR} --disable-bonjour --disable-static
CONFIGURE_ARGS= --sysconfdir=${ETCDIR} --datadir=${PREFIX}/lib \
--disable-bonjour --disable-static
INSTALL_TARGET= install-strip
USE_LDCONFIG= yes

Expand Down Expand Up @@ -62,26 +63,12 @@ AVAHI_LIB_DEPENDS= libdbus-1.so:devel/dbus \

post-patch:
@${TOUCH} ${WRKSRC}/config.rpath
@${ECHO_CMD} "ACLOCAL_AMFLAGS= -I ac-helpers" >> ${WRKSRC}/Makefile.am
@${REINPLACE_CMD} -e \
'/LDFLAGS/s|@PTHREAD_CFLAGS@|@LTLIBICONV@|' \
${WRKSRC}/libwzd-core/Makefile.am
@${REINPLACE_CMD} -e \
's|INSTALLDIRS=vendor|INSTALLPRIVLIB=$${prefix}/lib| ; \
/MAKE/s| install| pure_install|' \
${WRKSRC}/libwzd-perl/Makefile.am
.for i in backends modules
@${FIND} ${WRKSRC}/${i} -name "Makefile.am" | ${XARGS} \
${REINPLACE_CMD} -e \
'/^libdir/s|$${pkgdatadir}|$${prefix}/lib/wzdftpd|'
.endfor
@${FIND} ${WRKSRC} -name "*_tls.c" | ${XARGS} ${REINPLACE_CMD} -e \
'/<gcrypt\.h>/d ; /gcry_control/d'
@${REINPLACE_CMD} -e \
's|^wzd_sfv_config SfvConfig|extern &|' \
${WRKSRC}/modules/sfv/libwzd_sfv_main.h

# wzd.m4 gets installed into the wrong spot due to our --datadir hack
post-install:
${MKDIR} ${STAGEDIR}${PREFIX}/share/aclocal
${MV} ${STAGEDIR}${PREFIX}/lib/aclocal/wzd.m4 ${STAGEDIR}${PREFIX}/share/aclocal
${RMDIR} ${STAGEDIR}${PREFIX}/lib/aclocal
${INSTALL_DATA} ${WRKSRC}/*.pc ${STAGEDIR}${PREFIX}/libdata/pkgconfig

post-install-DOCS-on:
Expand Down
7 changes: 7 additions & 0 deletions ftp/wzdftpd/files/patch-Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--- Makefile.am.orig 2023-02-11 10:33:06 UTC
+++ Makefile.am
@@ -20,3 +20,4 @@ doxy:
doxygen doxygen.cfg


+ACLOCAL_AMFLAGS= -I ac-helpers
4 changes: 2 additions & 2 deletions ftp/wzdftpd/files/patch-ac-helpers__tls.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- ac-helpers/tls.m4.orig
--- ac-helpers/tls.m4.orig 2004-10-26 11:14:48 UTC
+++ ac-helpers/tls.m4
@@ -22,7 +22,7 @@
@@ -22,7 +22,7 @@ AC_DEFUN([WZD_TLS],
)

if test "$gnutls" = "yes"; then
Expand Down
11 changes: 11 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-auth_wzd__md5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libwzd-auth/wzd_md5.c.orig 2023-02-11 10:36:30 UTC
+++ libwzd-auth/wzd_md5.c
@@ -158,7 +158,7 @@ void MD5Name(MD5Final)(unsigned char digest[16], struc
MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ explicit_bzero(ctx, sizeof *ctx); /* In case it's sensitive */
}

#ifndef ASM_MD5
11 changes: 11 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libwzd-core/Makefile.am.orig 2007-04-14 10:02:19 UTC
+++ libwzd-core/Makefile.am
@@ -101,7 +101,7 @@ libwzd_core_la_SOURCES = \


libwzd_core_la_LIBADD = ../libwzd-base/libwzd_base.la ../libwzd-auth/libwzd_auth.la
-libwzd_core_la_LDFLAGS = @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ -version-info $(LT_VERSION_INFO) -export-dynamic -no-undefined
+libwzd_core_la_LDFLAGS = @LTLIBICONV@ @PTHREAD_LIBS@ -version-info $(LT_VERSION_INFO) -export-dynamic -no-undefined

AM_CPPFLAGS = -I$(top_srcdir) $(WZD_SSL_INCLUDES) -DWZD_MULTITHREAD -D_REENTRANT @PTHREAD_CFLAGS@

11 changes: 11 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__cookie__lex.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libwzd-core/wzd_cookie_lex.l.orig 2023-02-11 11:26:34 UTC
+++ libwzd-core/wzd_cookie_lex.l
@@ -1731,7 +1731,7 @@ out_err(LEVEL_HIGH,"char: %d [%c]\n", c, c);
{
/* check FLAG_SITEOP for self */
if (me && me->flags && strchr(me->flags,FLAG_SITEOP))
- snprintf(internalbuffer,IBUFSIZE,"%lu",current_context->pid_child);
+ snprintf(internalbuffer,IBUFSIZE,"%lu",(unsigned long)current_context->pid_child);
else
snprintf(internalbuffer,IBUFSIZE,"some id");
}
11 changes: 11 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libwzd-core/wzd_debug.c.orig 2023-02-11 11:21:12 UTC
+++ libwzd-core/wzd_debug.c
@@ -318,7 +318,7 @@ int check_context(wzd_context_t * context)
out_err(LEVEL_CRITICAL,"CRITICAL context %p\n",context);
return 1;
}
- if (!context->magic == CONTEXT_MAGIC)
+ if (context->magic != CONTEXT_MAGIC)
{
out_err(LEVEL_CRITICAL,"CRITICAL context->magic is invalid, context may be corrupted\n");
return 1;
10 changes: 10 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__libmain.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- libwzd-core/wzd_libmain.c.orig 2023-02-11 10:43:55 UTC
+++ libwzd-core/wzd_libmain.c
@@ -285,7 +285,6 @@ void context_init(wzd_context_t * context)
context->datafd = -1;
context->pasvsock = -1;
context->userid = (unsigned int)-1;
- context->thread_id = (unsigned long)-1;
context->state = STATE_UNKNOWN;
context->datamode = DATA_PORT;
context->current_action.current_file = -1;
11 changes: 11 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__list.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libwzd-core/wzd_list.c.orig 2023-02-11 11:22:20 UTC
+++ libwzd-core/wzd_list.c
@@ -277,7 +277,7 @@ char * mlst_single_file(const char *filename, wzd_cont

ptr = strrchr(filename,'/');
if (!ptr) return NULL;
- if (ptr+1 != '\0') ptr++;
+ if (ptr[1] != '\0') ptr++;

/** \bug this kills VFS */
/* if (fs_file_lstat(filename,&s)) return -1;*/
20 changes: 20 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__misc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- libwzd-core/wzd_misc.c.orig 2023-02-11 11:23:37 UTC
+++ libwzd-core/wzd_misc.c
@@ -990,7 +990,7 @@ void win_normalize(char * s, unsigned int length, unsi


/* \return 0 if ok, -1 if error, 1 if trying to kill myself */
-int kill_child_signal(unsigned long pid, wzd_context_t * context)
+int kill_child_signal(pthread_t pid, wzd_context_t * context)
{
ListElmt * elmnt;
wzd_context_t * loop_context;
@@ -1022,7 +1022,7 @@ int kill_child_signal(unsigned long pid, wzd_context_t
}

/* \return 0 if ok, -1 if error, 1 if trying to kill myself */
-int kill_child_new(unsigned long pid, wzd_context_t * context)
+int kill_child_new(pthread_t pid, wzd_context_t * context)
{
ListElmt * elmnt;
int found=0;
20 changes: 20 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__misc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- libwzd-core/wzd_misc.h.orig 2023-02-11 11:24:33 UTC
+++ libwzd-core/wzd_misc.h
@@ -52,7 +52,7 @@ int split_filename(const char *filename, char *path, c
* If the client is inside a function, it is stopped immediatly,
* maybe creating some problems.
*/
-int kill_child_signal(unsigned long pid, wzd_context_t * context);
+int kill_child_signal(pthread_t pid, wzd_context_t * context);

/** \brief Kill child
*
@@ -61,7 +61,7 @@ int kill_child_signal(unsigned long pid, wzd_context_t
* If the client is inside a function, it will exit after the function
* is finished.
*/
-int kill_child_new(unsigned long pid, wzd_context_t * context);
+int kill_child_new(pthread_t pid, wzd_context_t * context);

/* returns system ip on specifed interface (e.g eth0) */
int get_system_ip(const char * itface, struct in_addr * ina);
14 changes: 14 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__site__user.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- libwzd-core/wzd_site_user.c.orig 2023-02-11 11:29:18 UTC
+++ libwzd-core/wzd_site_user.c
@@ -1224,9 +1224,9 @@ int do_site_kill(UNUSED wzd_string_t *ignored, wzd_str
{
char *ptr;
int ret;
- unsigned long pid;
+ pthread_t pid;

- pid = strtoul(str_tochar(param),&ptr,0);
+ pid = (pthread_t)strtoul(str_tochar(param),&ptr,0);
if (*ptr!='\0') {
ret = send_message_with_args(501,context,"Usage: site kill <pid>");
return 0;
13 changes: 13 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-core_wzd__structs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- libwzd-core/wzd_structs.h.orig 2007-05-17 09:54:38 UTC
+++ libwzd-core/wzd_structs.h
@@ -366,8 +366,8 @@ struct wzd_context_t {
data_mode_t datamode;
tls_data_mode_t tls_data_mode;
net_family_t datafamily; /**< \brief IPv4 or IPv6 */
- unsigned long pid_child;
- unsigned long thread_id;
+ pthread_t pid_child;
+ pthread_t thread_id;

union wzd_thread_t * transfer_thread;
u8_t is_transferring;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@
}

SSL_CTX_set_session_cache_mode(tls_ctx, SSL_SESS_CACHE_CLIENT);
@@ -946,19 +946,13 @@ int tls_exit(void)
@@ -779,7 +779,6 @@ void * ssl_get_obj(wzd_context_t * context)
#include <stdio.h>

#include <gnutls/gnutls.h>
-#include <gcrypt.h>
#include <errno.h>
#include <pthread.h>
GCRY_THREAD_OPTION_PTHREAD_IMPL;
@@ -892,7 +891,6 @@ int tls_init(void)

/* The order matters.
*/
- gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
gnutls_global_init();

/** \todo TODO XXX move this code to global init ? */
@@ -946,19 +944,13 @@ int tls_exit(void)

static gnutls_session initialize_tls_session(gnutls_connection_end con_end)
{
Expand All @@ -31,7 +47,7 @@

gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);

@@ -1001,27 +995,6 @@ int tls_auth (const char *type, wzd_context_t * contex
@@ -1001,27 +993,6 @@ int tls_auth (const char *type, wzd_context_t * contex
}

/** \todo XXX parse TLS cipher names */
Expand Down
19 changes: 19 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd-perl_Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- libwzd-perl/Makefile.am.orig 2006-06-13 07:34:54 UTC
+++ libwzd-perl/Makefile.am
@@ -7,14 +7,14 @@ ext: ext/Makefile ext/wzdftpd.pm ../libwzd/libwzd.la
cd ext && $(MAKE) LD_RUN_PATH=""

ext/Makefile: ext/Makefile.PL ext/wzdftpd.pm ext/wzdftpd.xs
- cd ext && $(PERL) Makefile.PL $(PERLFLAGS) $(PERL_MAKE_OPTIONS) INSTALLDIRS=vendor
+ cd ext && $(PERL) Makefile.PL $(PERLFLAGS) $(PERL_MAKE_OPTIONS) INSTALLPRIVLIB=${prefix}/lib


all-local: ext

install-data-local: all-local
echo "Installing wzdftpd.pm"; \
- cd ext && $(MAKE) install
+ cd ext && $(MAKE) pure_install

clean-local:
cd ext && test -f Makefile && $(MAKE) clean || true \
10 changes: 10 additions & 0 deletions ftp/wzdftpd/files/patch-libwzd_libwzd__tls.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- libwzd/libwzd_tls.c.orig 2006-09-19 13:28:28 UTC
+++ libwzd/libwzd_tls.c
@@ -153,7 +153,6 @@ int tls_write(const char *buffer, int length)
#elif HAVE_GNUTLS

#include <gnutls/gnutls.h>
-#include <gcrypt.h>

#define DH_BITS 1024

11 changes: 11 additions & 0 deletions ftp/wzdftpd/files/patch-modules_sfv_libwzd__sfv__main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- modules/sfv/libwzd_sfv_main.h.orig 2006-05-29 16:45:55 UTC
+++ modules/sfv/libwzd_sfv_main.h
@@ -15,7 +15,7 @@ typedef struct {
double size_total;
} wzd_release_stats;

-wzd_sfv_config SfvConfig; /*Our main SFV config */
+extern wzd_sfv_config SfvConfig; /*Our main SFV config */
char * create_filepath(const char *dir, const char * file);


25 changes: 25 additions & 0 deletions ftp/wzdftpd/files/patch-wzdftpd_wzd__ServerThread.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- wzdftpd/wzd_ServerThread.c.orig 2023-02-11 11:33:03 UTC
+++ wzdftpd/wzd_ServerThread.c
@@ -934,7 +934,7 @@ static void server_login_accept(wzd_context_t * contex
out_err(LEVEL_CRITICAL,"Unable to create thread\n");
return;
}
- context->pid_child = (unsigned long)WZD_THREAD_VOID(&thread);
+ context->pid_child = (pthread_t)WZD_THREAD_VOID(&thread);
wzd_thread_attr_destroy(&thread_attr); /* not needed anymore */
}

@@ -1624,10 +1624,12 @@ void serverMainThreadCleanup(int retcode)
{
ListElmt * elmnt;
wzd_context_t * loop_context;
+ wzd_thread_t child;
for (elmnt=list_head(context_list); elmnt!=NULL; elmnt=list_next(elmnt))
{
if ((loop_context = list_data(elmnt))) {
- wzd_thread_cancel(loop_context->pid_child);
+ child._t = loop_context->pid_child;
+ wzd_thread_cancel(&child);
#ifdef WIN32
/** \todo remove this when wzd_thread_cancel is implemented on windows */
loop_context->exitclient = 1;
14 changes: 14 additions & 0 deletions ftp/wzdftpd/files/patch-wzdftpd_wzd__opts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- wzdftpd/wzd_opts.h.orig 2023-02-11 11:32:00 UTC
+++ wzdftpd/wzd_opts.h
@@ -24,11 +24,7 @@ struct option
#define optional_argument 2

#if __STDC__
-#if defined(__GNU_LIBRARY__)
extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char
*shortopts, const struct option *longopts, int
*longind); extern int getopt_long_only (int argc, char *const *argv,

0 comments on commit 2f04ed7

Please sign in to comment.