Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 May 2005 09:00:16 +0300
From:      Vasil Dimov <vd@datamax.bg>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/81289: Options for ucontext/pthread/fork in security/stunnel (ucontext is broken)
Message-ID:  <20050520060016.GA12225@sinanica.bg.datamax>
Resent-Message-ID: <200505200600.j4K60PIP063936@freefall.freebsd.org>

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

>Number:         81289
>Category:       ports
>Synopsis:       Options for ucontext/pthread/fork in security/stunnel (ucontext is broken)
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 20 06:00:24 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Vasil Dimov
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
DataMax
>Environment:

System: FreeBSD sinanica.bg.datamax 5.4-STABLE FreeBSD 5.4-STABLE #6: Tue May 10 12:46:25 EEST 2005     root@sinanica.bg.datamax:/usr/obj/usr/src/sys/SINANICA-SMP  i386

>Description:

There are known problems with stunnel's new threading model - ucontext(3),
some of which were reported to ports@ and ports-bugs@ they include
unexpected exits (without errors) and build faulures on sparc64.
See ports@ mailing list, ports/81162 and
http://pointyhat.freebsd.org/errorlogs/sparc64-errorlogs/e.5.2005042909/stunnel-4.10.log

Following is a patch to the port that lets the user choose ucontext,
pthread or fork model. It currently defaults to pthread.

This should eliminate the problems as it seems that ucontext is broken,
not 4.10. At first glance I saw that pthread code was not touched
between 4.09-4.10 and it works fine for me with pthreading.

>How-To-Repeat:

>Fix:

--- stunnel.diff begins here ---
diff -urN stunnel.orig/Makefile stunnel/Makefile
--- stunnel.orig/Makefile	Fri May 13 02:23:55 2005
+++ stunnel/Makefile	Fri May 20 08:34:08 2005
@@ -7,6 +7,7 @@
 
 PORTNAME=	stunnel
 PORTVERSION=	4.10
+PORTREVISION=	1
 CATEGORIES=	security
 MASTER_SITES=	http://www.stunnel.org/download/stunnel/src/ \
 		ftp://stunnel.mirt.net/stunnel/OBSOLETE/ \
@@ -35,6 +36,22 @@
 CONFIGURE_ARGS+=	--enable-ipv6
 .endif
 
+.if defined(WITH_UCONTEXT)
+EXTRA_PATCHES+=	${FILESDIR}/common.h-ucontext.patch
+.elif defined(WITH_FORK)
+EXTRA_PATCHES+=	${FILESDIR}/common.h-fork.patch
+.else
+EXTRA_PATCHES+=	${FILESDIR}/common.h-pthread.patch
+.endif
+
+pre-everything::
+	@${ECHO}
+	@${ECHO} "You can build ${PORTNAME} with the following options:"
+	@${ECHO} "WITH_UCONTEXT   use ucontext(3) model. Currently has known problems"
+	@${ECHO} "WITH_FORK       use fork(2) model"
+	@${ECHO} "default is to use pthread(3) model"
+	@${ECHO}
+
 post-patch:
 # place files under /var/tmp so that this can be run by an unprivileged user
 # user stunnel and group stunnel
@@ -83,7 +100,7 @@
 
 .if ${OSVERSION} > 500000
 .if !defined(WITH_STUNNEL_SSL_ENGINE)
-EXTRA_PATCHES=	${FILESDIR}/ssl-noengine.patch
+EXTRA_PATCHES+=	${FILESDIR}/ssl-noengine.patch
 pre-patch:
 	@${ECHO} "*************************************************************************"
 	@${ECHO} "Note: you have to explicitly define WITH_STUNNEL_SSL_ENGINE to activate"
diff -urN stunnel.orig/files/common.h-fork.patch stunnel/files/common.h-fork.patch
--- stunnel.orig/files/common.h-fork.patch	Thu Jan  1 02:00:00 1970
+++ stunnel/files/common.h-fork.patch	Mon May 16 19:53:09 2005
@@ -0,0 +1,21 @@
+--- src/common.h.orig	Mon May 16 19:50:46 2005
++++ src/common.h	Mon May 16 19:53:05 2005
+@@ -38,18 +38,7 @@
+ #endif
+ 
+ /* threads model */
+-#if HAVE_UCONTEXT_H && HAVE_GETCONTEXT && HAVE_POLL
+-#define USE_UCONTEXT
+-#include <ucontext.h>
+-#elif HAVE_PTHREAD_H && HAVE_LIBPTHREAD
+-#define USE_PTHREAD
+-#include <pthread.h>
+-#define THREADS
+-#define _REENTRANT
+-#define _THREAD_SAFE
+-#else
+ #define USE_FORK
+-#endif
+ 
+ /* TCP wrapper */
+ #if HAVE_TCPD_H && HAVE_LIBWRAP
diff -urN stunnel.orig/files/common.h-pthread.patch stunnel/files/common.h-pthread.patch
--- stunnel.orig/files/common.h-pthread.patch	Thu Jan  1 02:00:00 1970
+++ stunnel/files/common.h-pthread.patch	Mon May 16 19:52:51 2005
@@ -0,0 +1,21 @@
+--- src/common.h.orig	Mon May 16 19:50:46 2005
++++ src/common.h	Mon May 16 19:52:45 2005
+@@ -38,18 +38,11 @@
+ #endif
+ 
+ /* threads model */
+-#if HAVE_UCONTEXT_H && HAVE_GETCONTEXT && HAVE_POLL
+-#define USE_UCONTEXT
+-#include <ucontext.h>
+-#elif HAVE_PTHREAD_H && HAVE_LIBPTHREAD
+ #define USE_PTHREAD
+ #include <pthread.h>
+ #define THREADS
+ #define _REENTRANT
+ #define _THREAD_SAFE
+-#else
+-#define USE_FORK
+-#endif
+ 
+ /* TCP wrapper */
+ #if HAVE_TCPD_H && HAVE_LIBWRAP
diff -urN stunnel.orig/files/common.h-ucontext.patch stunnel/files/common.h-ucontext.patch
--- stunnel.orig/files/common.h-ucontext.patch	Thu Jan  1 02:00:00 1970
+++ stunnel/files/common.h-ucontext.patch	Mon May 16 19:52:19 2005
@@ -0,0 +1,21 @@
+--- src/common.h.orig	Mon May 16 19:50:46 2005
++++ src/common.h	Mon May 16 19:51:49 2005
+@@ -38,18 +38,8 @@
+ #endif
+ 
+ /* threads model */
+-#if HAVE_UCONTEXT_H && HAVE_GETCONTEXT && HAVE_POLL
+ #define USE_UCONTEXT
+ #include <ucontext.h>
+-#elif HAVE_PTHREAD_H && HAVE_LIBPTHREAD
+-#define USE_PTHREAD
+-#include <pthread.h>
+-#define THREADS
+-#define _REENTRANT
+-#define _THREAD_SAFE
+-#else
+-#define USE_FORK
+-#endif
+ 
+ /* TCP wrapper */
+ #if HAVE_TCPD_H && HAVE_LIBWRAP
--- stunnel.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?20050520060016.GA12225>