summarylogtreecommitdiffstats
path: root/auth-ldap-2.0.3-gnustep.patch
blob: 970060f993774c1d08db03400e4cf3644e7e390a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
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
+@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