[openvpn-auth-ldap: 1/3] Use gnustep runtime
Orion Poplawski
orion at fedoraproject.org
Tue Jul 23 17:29:55 UTC 2013
commit e145d29e9bf37b47e801ed155b2377d884ad2f32
Author: Orion Poplawski <orion at nwra.com>
Date: Wed May 29 12:16:22 2013 -0600
Use gnustep runtime
auth-ldap-2.0.3-objc-include.patch | 42 --------
auth-ldap-gnustep.patch | 201 ++++++++++++++++++++++++++++++++++++
openvpn-auth-ldap.spec | 11 ++-
3 files changed, 208 insertions(+), 46 deletions(-)
---
diff --git a/auth-ldap-gnustep.patch b/auth-ldap-gnustep.patch
new file mode 100644
index 0000000..970060f
--- /dev/null
+++ b/auth-ldap-gnustep.patch
@@ -0,0 +1,201 @@
+Index: aclocal.m4
+===================================================================
+--- aclocal.m4 (revision 1378)
++++ aclocal.m4 (working copy)
+@@ -1,4 +1,3 @@
+-builtin(include,objc.m4)
+ builtin(include,pthread.m4)
+ builtin(include,platform.m4)
+ builtin(include,check.m4)
+@@ -23,7 +22,7 @@
+ # 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 @@
+ #------------------------------------------------------------------------
+ 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 @@
+ ;;
+ 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
+@@ -174,6 +175,33 @@
+ 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"
+@@ -185,6 +213,16 @@
+ 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.])
++ elif test x"${od_cv_objc_runtime_modern}" = x"yes"; then
++ OBJC_RUNTIME="MODERN_RUNTIME"
++ case "${target_os}" in
++ linux*) OBJC_RUNTIME_FLAGS="-fgnu-runtime"
++ OBJC_LIBS="-lgnustep-base ${OBJC_LIBS}";;
++ darwin*) OBJC_RUNTIME_FLAGS="-fnext-runtime"
++ LDFLAGS="-framework Foundation ${LDFLAGS}";;
++ 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: src/TRObject.h
+===================================================================
+--- src/TRObject.h (revision 1378)
++++ src/TRObject.h (working copy)
+@@ -40,7 +40,11 @@
+ #endif
+
+ #include <stdbool.h>
++#ifdef MODERN_RUNTIME
++#include <Foundation/NSObject.h>
++#else
+ #include <objc/Object.h>
++#endif
+
+ #include "auth-ldap.h"
+
+@@ -54,7 +58,11 @@
+ @end
+
+
++#ifdef MODERN_RUNTIME
++ at interface TRObject : NSObject <TRObject> {
++#else
+ @interface TRObject : Object <TRObject> {
++#endif
+ unsigned int _refCount;
+ }
+
+Index: src/TRObject.m
+===================================================================
+--- src/TRObject.m (revision 1378)
++++ src/TRObject.m (working copy)
+@@ -53,9 +53,11 @@
+ * Additionally, we implement brain-dead, non-thread-safe
+ * reference counting.
+ */
++#ifndef MODERN_RUNTIME
+ @interface Object (AppleAddedAReallyStupidGCCWarning)
+ - (void) dealloc;
+ @end
++#endif
+
+ @implementation TRObject
+
+@@ -69,7 +71,11 @@
+ }
+
+ - (void) dealloc {
++#ifdef MODERN_RUNTIME
++ [super dealloc];
++#else
+ [super free];
++#endif
+
+ /* Make Apple's objc compiler be quiet */
+ if (false)
+Index: src/auth-ldap.m
+===================================================================
+--- src/auth-ldap.m (revision 1378)
++++ src/auth-ldap.m (working copy)
+@@ -48,6 +48,9 @@
+ #include <TRPacketFilter.h>
+ #include <TRPFAddress.h>
+ #include <TRLog.h>
++#ifdef MODERN_RUNTIME
++#include <Foundation/NSAutoreleasePool.h>
++#endif
+
+ /* Plugin Context */
+ typedef struct ldap_ctx {
+@@ -267,7 +270,6 @@
+ }
+ #endif
+
+-
+ *type = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY) |
+ OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT) |
+ OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_DISCONNECT);
+@@ -550,6 +552,10 @@
+ TRLDAPEntry *ldapUser = nil;
+ int ret = OPENVPN_PLUGIN_FUNC_ERROR;
+
++#ifdef MODERN_RUNTIME
++ NSAutoreleasePool *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 +619,8 @@
+ [ldapUser release];
+ if (ldap)
+ [ldap release];
++#ifdef MODERN_RUNTIME
++ [pool drain];
++#endif
+ return (ret);
+ }
+Index: tests/Makefile.in
+===================================================================
+--- tests/Makefile.in (revision 1378)
++++ tests/Makefile.in (working copy)
+@@ -26,7 +26,7 @@
+ 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 $(LIBS)
+
+ # Recompile the tests every time
+ all: tests
diff --git a/openvpn-auth-ldap.spec b/openvpn-auth-ldap.spec
index 0efc770..9a2475b 100644
--- a/openvpn-auth-ldap.spec
+++ b/openvpn-auth-ldap.spec
@@ -10,7 +10,7 @@ Source1: openvpn-plugin.h
Patch0: auth-ldap-2.0.3-top_builddir.patch
Patch1: auth-ldap-2.0.3-README.patch
Patch2: auth-ldap-2.0.3-tools-CFLAGS.patch
-Patch3: auth-ldap-2.0.3-objc-include.patch
+Patch3: auth-ldap-gnustep.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# This is a plugin not linked against a lib, so hardcode the requirement
# since we require the parent configuration and plugin directories
@@ -20,6 +20,8 @@ Buildrequires: doxygen
Buildrequires: openldap-devel
BuildRequires: check-devel
BuildRequires: gcc-objc
+BuildRequires: gnustep-base-devel
+BuildRequires: autoconf
%description
The OpenVPN Auth-LDAP Plugin implements username/password authentication via
@@ -28,21 +30,22 @@ LDAP for OpenVPN 2.x.
%prep
%setup -q -n auth-ldap-%{version}
-%patch0 -p1 -b .top_builddir
%patch1 -p1 -b .README
%patch2 -p1 -b .tools-CFLAGS
-%patch3 -p1 -b .objc-include
+%patch3 -p0 -b .gnustep
# Fix plugin from the instructions in the included README
sed -i 's|^plugin .*| plugin %{_libdir}/openvpn/plugin/lib/openvpn-auth-ldap.so "/etc/openvpn/auth/ldap.conf"|g' README
# Install the one required OpenVPN plugin header
install -p -m 0644 %{SOURCE1} .
+autoconf
+autoheader
%build
# Fix undefined objc_msgSend reference (nope, the with-objc-runtime is enough)
#export OBJCFLAGS=-fobjc-abi-version=2
%configure \
- --with-objc-runtime=GNU \
+ --with-objc-runtime=modern \
--libdir=%{_libdir}/openvpn/plugin/lib \
--with-openvpn="`pwd`"
make %{?_smp_mflags}
More information about the scm-commits
mailing list