On Tuesday, June 13, 2017 18:47 CEST, Jeremie Courreges-Anglas <j...@wxcvbn.org> wrote:
> > (adding openvpn-auth-ldap and libobjc2 maintainer to Cc) > > Stuart Henderson <s...@spacehopper.org> writes: > > > On 2016/10/18 21:29, Jeremie Courreges-Anglas wrote: > >> Pascal Stumpf <pas...@stumpf.co> writes: > >> > > >> > I don't claim to know much about objc, but I think the correct solution > >> > would be to either rename libobj from lang/gcc to libeobjc (and make the > >> > port use it) or go the fortran route and remove support from base. > >> > According to sqlports, openvpn-auth-ldap is the only port with objc in > >> > WANTLIB (GNUstep stuff uses clang + libobjc2). > >> > >> Same stance wrt objc, I think we should remove it from base. I took > >> a quick look at this openvpn plugin (last update from 2007...) and it > >> looks like just using gobjc from ports isn't enough. Debian has patches > >> to allow building with gcc 4.6+, those patches look interesting but > >> I did not dig further. There also are mentions of gnustep in their > >> package. > > > > So openvpn-auth-ldap is broken again because of the libobjc conflict; > > it picks up the higher-numbered version from /usr/local/lib ahead of > > the lower-numbered version in /usr/lib (i.e. higher version number > > trumps being earlier in the path). > > > > As this is now broken anyway, and other objc ports use libobjc2 instead, > > there's not really any disadvantage in removing libobjc from base. > > I think that just removing it makes sense. > > In the meantime... > > -r--r--r-- 1 root bin 470212 Jun 10 04:24 /usr/lib/libobjc.so.6.0 > -rw-r--r-- 1 root bin 632699 Jun 8 23:57 /usr/local/lib/libobjc.so.6.1 > > The two libraries aren't compatible, yet they had the same version. > Shouldn't we bump /usr/local/lib/libobjc.so.6.1 to > /usr/local/lib/libobjc.so.7.0 ? > > > Then openvpn-auth-ldap would need fixing to work with whichever of > > ports libobjc and libobjc2 is easiest.. > > Here are the patches I mentioned (debian/patches subdir) > > > http://http.debian.net/debian/pool/main/o/openvpn-auth-ldap/openvpn-auth-ldap_2.0.3-6.1.debian.tar.xz thanks for that pointer, with these patches, some additional changes to aclocal.m4, and making use of the gnustep ports module, I easily got it to build against libobjc2. Some remarks: The additional changes to aclocal.m4: - s/lobjc/lobjc2/ - with that configure then detects that all 3 tested runtimes work fine, and prefers apple runtime, I didn't bothered to check why that's the case, I just commented out the two preferred runtimes to end up with libobjc2 - there is a configure parameter --with-libobjc-runtime that can be set to modern, but then configure bailed out on me miserably. When building, there are first quite a few warnings, mostly about format strings. The last big bunch of warnings is about the tests it builds. I checked, and the reason is that for the modern runtime, it's basically declaring/building an empty TRObject class (See patches to TRobject.{hm}) and because of that the refCount method is not there. Make test doesn't work, I guess problem with a $SHELL, however, running 'gmake test' in the build directory runs 38 tests, 0 failures, 5 errors. The 5 errors are all related to the missing refCount from TRObject. Maybe the tests could be patched, or even just not built at all? Someone who uses it, might want to test it? I also have a LDAP server setup here, but no openvpn server around to test, so could take a while to set it up properly. Other comments patches cleanup etc. welcome as well, as this was just quickly hacked together so far ;) cheers, Sebastian Index: Makefile =================================================================== RCS file: /cvs/ports/net/openvpn-auth-ldap/Makefile,v retrieving revision 1.10 diff -u -r1.10 Makefile --- Makefile 12 Jun 2017 10:57:57 -0000 1.10 +++ Makefile 14 Jun 2017 21:25:43 -0000 @@ -3,7 +3,7 @@ COMMENT = LDAP authentication plugin for OpenVPN 2.x VERSION = 2.0.3 -REVISION = 4 +REVISION = 5 DISTNAME = auth-ldap-${VERSION} PKGNAME = openvpn-${DISTNAME} CATEGORIES = net security @@ -15,7 +15,9 @@ # BSD PERMIT_PACKAGE_CDROM = Yes -WANTLIB = lber ldap objc +MODULES = x11/gnustep +MODGNUSTEP_NEEDS_GUI = No +WANTLIB = lber ldap MASTER_SITES = ${MASTER_SITE_GOOGLECODE:=openvpn-auth-ldap/} @@ -27,7 +29,9 @@ SEPARATE_BUILD = Yes -CONFIGURE_STYLE = gnu +AUTOCONF_VERSION = 2.69 +CONFIGURE_STYLE = autoconf +MAKE_FILE = Makefile CONFIGURE_ARGS += --prefix=${LOCALBASE} \ --with-check=${LOCALBASE} \ Index: patches/patch-aclocal_m4 =================================================================== RCS file: patches/patch-aclocal_m4 diff -N patches/patch-aclocal_m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-aclocal_m4 14 Jun 2017 21:25:43 -0000 @@ -0,0 +1,135 @@ +$OpenBSD$ + +Index: aclocal.m4 +--- aclocal.m4.orig ++++ aclocal.m4 +@@ -1,4 +1,3 @@ +-builtin(include,objc.m4) + builtin(include,pthread.m4) + builtin(include,platform.m4) + builtin(include,check.m4) +@@ -23,7 +22,7 @@ builtin(include,check.m4) + # Result is cached. + # + # Defines one of the following preprocessor macros: +-# APPLE_RUNTIME GNU_RUNTIME ++# APPLE_RUNTIME GNU_RUNTIME MODERN_RUNTIME + # + # Substitutes the following variables: + # OBJC_RUNTIME OBJC_RUNTIME_FLAGS OBJC_LIBS +@@ -31,7 +30,7 @@ builtin(include,check.m4) + #------------------------------------------------------------------------ + AC_DEFUN([OD_OBJC_RUNTIME],[ + AC_REQUIRE([AC_PROG_OBJC]) +- AC_ARG_WITH(objc-runtime, AC_HELP_STRING([--with-objc-runtime], [Specify either "GNU" or "apple"]), [with_objc_runtime=${withval}]) ++ AC_ARG_WITH(objc-runtime, AC_HELP_STRING([--with-objc-runtime], [Specify either "GNU", "apple", or "modern"]), [with_objc_runtime=${withval}]) + + if test x"${with_objc_runtime}" != x; then + case "${with_objc_runtime}" in +@@ -39,8 +38,10 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ + ;; + apple) + ;; ++ modern) ++ ;; + *) +- AC_MSG_ERROR([${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either "GNU" or "apple"]) ++ AC_MSG_ERROR([${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either "GNU", "apple", or "modern"]) + ;; + esac + fi +@@ -57,7 +58,7 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ + OLD_OBJCFLAGS="${OBJCFLAGS}" + + # Add -lobjc. The following tests will ensure that the library exists and functions with the detected Objective C compiler +- LIBS="${LIBS} -lobjc" ++ LIBS="${LIBS} -lobjc2" + + # Test if pthreads are required to link against + # libobjc - this is the case on FreeBSD. +@@ -112,11 +113,11 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ + AC_MSG_RESULT(${od_cv_objc_req_pthread}) + + if test x"${od_cv_objc_req_pthread}" = x"no"; then +- OBJC_LIBS="-lobjc" ++ OBJC_LIBS="-lobjc2" + OBJC_PTHREAD_LIBS="${PTHREAD_LIBS}" + OBJC_PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" + elif test x"${od_cv_objc_req_pthread}" = x"yes"; then +- OBJC_LIBS="-lobjc ${PTHREAD_LIBS}" ++ OBJC_LIBS="-lobjc2 ${PTHREAD_LIBS}" + OBJCFLAGS="${OBJCFLAGS} ${PTHREAD_CFLAGS}" + fi + +@@ -174,17 +175,61 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ + od_cv_objc_runtime_gnu="no" + fi + ++ if test x"${with_objc_runtime}" = x || test x"${with_objc_runtime}" = x"modern"; then ++ AC_MSG_CHECKING([for Modern Objective C runtime]) ++ AC_CACHE_VAL(od_cv_objc_runtime_modern, [ ++ # The following uses quadrigraphs ++ # '@<:@' = '[' ++ # '@:>@' = ']' ++ AC_LINK_IFELSE([ ++ AC_LANG_PROGRAM([ ++ #include <objc/objc.h> ++ #include <objc/runtime.h> ++ ], [ ++ id class = objc_lookUpClass("NSObject"); ++ id obj = @<:@class alloc@:>@; ++ puts(@<:@obj name@:>@); ++ ]) ++ ], [ ++ od_cv_objc_runtime_modern="yes" ++ ], [ ++ od_cv_objc_runtime_modern="no" ++ ] ++ ) ++ ]) ++ AC_MSG_RESULT(${od_cv_objc_runtime_modern}) ++ else ++ od_cv_objc_runtime_modern="no" ++ fi ++ + # Apple runtime is prefered +- if test x"${od_cv_objc_runtime_apple}" = x"yes"; then +- OBJC_RUNTIME="APPLE_RUNTIME" +- OBJC_RUNTIME_FLAGS="-fnext-runtime" +- AC_MSG_NOTICE([Using Apple Objective-C runtime]) +- AC_DEFINE([APPLE_RUNTIME], 1, [Define if using the Apple Objective-C runtime and compiler.]) +- elif test x"${od_cv_objc_runtime_gnu}" = x"yes"; then +- OBJC_RUNTIME="GNU_RUNTIME" +- OBJC_RUNTIME_FLAGS="-fgnu-runtime" +- AC_MSG_NOTICE([Using GNU Objective-C runtime]) +- AC_DEFINE([GNU_RUNTIME], 1, [Define if using the GNU Objective-C runtime and compiler.]) ++ #if test x"${od_cv_objc_runtime_apple}" = x"yes"; then ++ # OBJC_RUNTIME="APPLE_RUNTIME" ++ # OBJC_RUNTIME_FLAGS="-fnext-runtime" ++ # AC_MSG_NOTICE([Using Apple Objective-C runtime]) ++ # AC_DEFINE([APPLE_RUNTIME], 1, [Define if using the Apple Objective-C runtime and compiler.]) ++ #elif test x"${od_cv_objc_runtime_gnu}" = x"yes"; then ++ # OBJC_RUNTIME="GNU_RUNTIME" ++ # OBJC_RUNTIME_FLAGS="-fgnu-runtime" ++ # AC_MSG_NOTICE([Using GNU Objective-C runtime]) ++ # AC_DEFINE([GNU_RUNTIME], 1, [Define if using the GNU Objective-C runtime and compiler.]) ++ if test x"${od_cv_objc_runtime_modern}" = x"yes"; then ++ OBJC_RUNTIME="MODERN_RUNTIME" ++ case "${target_os}" in ++ darwin*) OBJC_RUNTIME_FLAGS="-fnext-runtime" ++ LDFLAGS="-framework Foundation ${LDFLAGS}";; ++ *) AC_CHECK_PROG([have_gs_config], ++ [gnustep-config], [yes]) ++ if test x"$have_gs_config" != x"yes"; then ++ AC_MSG_ERROR([Cannot find gnustep-config.]) ++ else ++ OBJC_RUNTIME_FLAGS="`gnustep-config --objc-flags`" ++ OBJC_LIBS="`gnustep-config --base-libs`" ++ fi ++ ;; ++ esac ++ AC_MSG_NOTICE([Using Modern Objective-C runtime]) ++ AC_DEFINE([MODERN_RUNTIME], 1, [Define if using the Modern Objective-C runtime and compiler.]) + else + AC_MSG_FAILURE([Could not locate a working Objective-C runtime.]) + fi Index: patches/patch-src_Makefile_in =================================================================== RCS file: /cvs/ports/net/openvpn-auth-ldap/patches/patch-src_Makefile_in,v retrieving revision 1.1 diff -u -r1.1 patch-src_Makefile_in --- patches/patch-src_Makefile_in 12 Nov 2016 21:17:02 -0000 1.1 +++ patches/patch-src_Makefile_in 14 Jun 2017 21:25:43 -0000 @@ -1,12 +1,15 @@ -$OpenBSD: patch-src_Makefile_in,v 1.1 2016/11/12 21:17:02 jca Exp $ ---- src/Makefile.in.orig Fri Sep 15 04:45:57 2006 -+++ src/Makefile.in Tue Nov 1 17:52:06 2016 -@@ -37,7 +37,7 @@ TEST_OBJS= testplugin.o +$OpenBSD$ + +Index: src/Makefile.in +--- src/Makefile.in.orig ++++ src/Makefile.in +@@ -64,7 +64,8 @@ install:: $(PLUGIN_FILE) + $(INSTALL_PLUGIN) - CFLAGS+= -fPIC $(LDAP_CFLAGS) $(OPENVPN_CFLAGS) - OBJCFLAGS+= -fPIC $(LDAP_CFLAGS) $(OPENVPN_CFLAGS) --LIBS+= $(LDAP_LIBS) $(OBJC_LIBS) $(FLEX_LIBS) -+LIBS+= -L/usr/lib $(LDAP_LIBS) $(OBJC_LIBS) $(FLEX_LIBS) + clean:: +- rm -f $(TEST_OBJS) $(PLUGIN_OBJS) $(TEST_LIB) $(GEN_SRCS) testplugin ++ rm -f $(TEST_OBJS) $(PLUGIN_OBJS) $(PLUGIN_OBJS:.o=.d) $(TEST_LIB) \ ++ $(GEN_SRCS) testplugin + $(CLEAN_PLUGIN) - - INSTALL_LIB= $(INSTALL) -m 755 + distclean:: clean Index: patches/patch-src_TRObject_h =================================================================== RCS file: patches/patch-src_TRObject_h diff -N patches/patch-src_TRObject_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_TRObject_h 14 Jun 2017 21:25:43 -0000 @@ -0,0 +1,43 @@ +$OpenBSD$ + +Index: src/TRObject.h +--- src/TRObject.h.orig ++++ src/TRObject.h +@@ -40,20 +40,29 @@ + #endif + + #include <stdbool.h> ++#ifdef MODERN_RUNTIME ++#import <Foundation/NSObject.h> ++#else + #include <objc/Object.h> ++#endif + + #include "auth-ldap.h" + + @protocol TRObject ++#ifndef MODERN_RUNTIME + /* Reference counting */ + - (id) retain; + - (void) release; + + /* Equality */ + - (BOOL) isEqual: (id) anObject; ++#endif + @end + + ++#ifdef MODERN_RUNTIME ++@interface TRObject : NSObject <TRObject> ++#else + @interface TRObject : Object <TRObject> { + unsigned int _refCount; + } +@@ -66,6 +75,7 @@ + + - (void) dealloc; + ++#endif + @end + + #endif /* TROBJECT_H */ Index: patches/patch-src_TRObject_m =================================================================== RCS file: patches/patch-src_TRObject_m diff -N patches/patch-src_TRObject_m --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_TRObject_m 14 Jun 2017 21:25:43 -0000 @@ -0,0 +1,21 @@ +$OpenBSD$ + +Index: src/TRObject.m +--- src/TRObject.m.orig ++++ src/TRObject.m +@@ -53,6 +53,7 @@ + * Additionally, we implement brain-dead, non-thread-safe + * reference counting. + */ ++#ifndef MODERN_RUNTIME + @interface Object (AppleAddedAReallyStupidGCCWarning) + - (void) dealloc; + @end +@@ -102,4 +103,7 @@ + [self dealloc]; + } + ++#else ++@implementation TRObject ++#endif + @end Index: patches/patch-src_auth-ldap_m =================================================================== RCS file: patches/patch-src_auth-ldap_m diff -N patches/patch-src_auth-ldap_m --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_auth-ldap_m 14 Jun 2017 21:25:43 -0000 @@ -0,0 +1,47 @@ +$OpenBSD$ + +Index: src/auth-ldap.m +--- src/auth-ldap.m.orig ++++ src/auth-ldap.m +@@ -48,7 +48,12 @@ + #include <TRPacketFilter.h> + #include <TRPFAddress.h> + #include <TRLog.h> ++#ifdef MODERN_RUNTIME ++#import <Foundation/NSAutoreleasePool.h> + ++static NSAutoreleasePool *pool; ++#endif ++ + /* Plugin Context */ + typedef struct ldap_ctx { + LFAuthLDAPConfig *config; +@@ -166,7 +171,7 @@ static LFString *createSearchFilter(LFString *template + const char userFormat[] = "%u"; + + /* Copy the template */ +- templateString = [[LFString alloc] initWithString: template]; ++ templateString = [(LFString *)[LFString alloc] initWithString: template]; + + /* Initialize the result */ + result = [[LFString alloc] init]; +@@ -550,6 +555,10 @@ openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, + TRLDAPEntry *ldapUser = nil; + int ret = OPENVPN_PLUGIN_FUNC_ERROR; + ++#ifdef MODERN_RUNTIME ++ pool = [[NSAutoreleasePool alloc] init]; ++#endif ++ + username = get_env("username", envp); + password = get_env("password", envp); + remoteAddress = get_env("ifconfig_pool_remote_ip", envp); +@@ -613,5 +622,8 @@ cleanup: + [ldapUser release]; + if (ldap) + [ldap release]; ++#ifdef MODERN_RUNTIME ++ [pool release]; ++#endif + return (ret); + } Index: patches/patch-tests_Makefile_in =================================================================== RCS file: /cvs/ports/net/openvpn-auth-ldap/patches/patch-tests_Makefile_in,v retrieving revision 1.1 diff -u -r1.1 patch-tests_Makefile_in --- patches/patch-tests_Makefile_in 12 Nov 2016 21:17:02 -0000 1.1 +++ patches/patch-tests_Makefile_in 14 Jun 2017 21:25:43 -0000 @@ -1,12 +1,14 @@ -$OpenBSD: patch-tests_Makefile_in,v 1.1 2016/11/12 21:17:02 jca Exp $ ---- tests/Makefile.in.orig Tue Aug 1 05:51:52 2006 -+++ tests/Makefile.in Tue Nov 1 17:52:23 2016 +$OpenBSD$ + +Index: tests/Makefile.in +--- tests/Makefile.in.orig ++++ tests/Makefile.in @@ -26,7 +26,7 @@ TEST_OBJS= tests.o \ CFLAGS+= @CHECK_CFLAGS@ -DTEST_DATA=\"${srcdir}/data\" OBJCFLAGS+= @CHECK_CFLAGS@ -DTEST_DATA=\"${srcdir}/data\" LIBS+= -lauth-ldap-testing $(OBJC_LIBS) $(LDAP_LIBS) @CHECK_LIBS@ -LDFLAGS+= -L${top_builddir}src $(LIBS) -+LDFLAGS+= -L${top_builddir}/src -L/usr/lib $(LIBS) ++LDFLAGS+= -L${top_builddir}/src $(LIBS) # Recompile the tests every time all: tests > > -- > jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
openvpn-auth-ldap
Description: Binary data