summaryrefslogtreecommitdiff
path: root/postgresql/postgresql-moz-ldap.patch
blob: ceb82567f798194953d084bba59c8262d7673894 (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
diff --recursive -u misc/build/postgresql-9.1.1/configure.in misc/build/postgresql-9.1.1.patched/configure.in
--- misc/build/postgresql-9.1.1/configure.in	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/configure.in	2011-12-14 13:10:11.000000000 +0100
@@ -662,6 +662,13 @@
 AC_MSG_RESULT([$with_ldap])
 AC_SUBST(with_ldap)
 
+AC_MSG_CHECKING([whether to use Mozilla C SDK for LDAP support])
+PGAC_ARG_BOOL(with, mozldap, no,
+              [build with Mozilla LDAP support],
+              [AC_DEFINE([USE_MOZLDAP], 1, [Define to 1 to use the Mozilla LDAP C SDK instead of platform default (OpenLDAP or Microsoft LDAP). (--with-mozldap)])])
+AC_MSG_RESULT([$with_mozldap])
+AC_SUBST(with_mozldap)
+
 
 #
 # Bonjour
@@ -1077,7 +1084,7 @@
 fi
 
 if test "$with_ldap" = yes ; then
-  if test "$PORTNAME" != "win32"; then
+  if test "$PORTNAME" != "win32" || test "$with_mozldap" = "yes"; then
      AC_CHECK_HEADERS(ldap.h, [],
                       [AC_MSG_ERROR([header file <ldap.h> is required for LDAP])])
   else
@@ -1086,6 +1093,7 @@
                       [AC_INCLUDES_DEFAULT
 #include <windows.h>
                       ])
+     AC_DEFINE([USE_MICROSOFT_LDAP], 1, [Defined when using Microsof LDAP])
   fi
 fi
 
@@ -1498,7 +1506,18 @@
 # We can test for libldap_r only after we know PTHREAD_LIBS
 if test "$with_ldap" = yes ; then
   _LIBS="$LIBS"
-  if test "$PORTNAME" != "win32"; then
+  if test "$with_mozldap" = "yes"; then
+    if test "$PORTNAME" != "win32"; then
+      mozlibname=ldap50
+    else
+      mozlibname=nsldap32v50
+    fi
+    AC_CHECK_LIB($mozlibname, ldap_bind, [],
+		 [AC_MSG_ERROR([library "$mozlibname" is required for Mozilla LDAP])],
+		 [$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
+    LDAP_LIBS_FE="-l$mozlibname $EXTRA_LDAP_LIBS"
+    LDAP_LIBS_BE="-l$mozlibname $EXTRA_LDAP_LIBS"
+  elif test "$PORTNAME" != "win32"; then
     AC_CHECK_LIB(ldap, ldap_bind, [],
 		 [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
 		 [$EXTRA_LDAP_LIBS])
diff --recursive -u misc/build/postgresql-9.1.1/src/backend/libpq/auth.c misc/build/postgresql-9.1.1.patched/src/backend/libpq/auth.c
--- misc/build/postgresql-9.1.1/src/backend/libpq/auth.c	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/src/backend/libpq/auth.c	2011-12-14 13:10:11.000000000 +0100
@@ -93,11 +93,7 @@
  *----------------------------------------------------------------
  */
 #ifdef USE_LDAP
-#ifndef WIN32
-/* We use a deprecated function to keep the codepath the same as win32. */
-#define LDAP_DEPRECATED 1
-#include <ldap.h>
-#else
+#ifdef USE_MICROSOFT_LDAP
 #include <winldap.h>
 
 /* Correct header from the Platform SDK */
@@ -109,6 +105,10 @@
 										   IN PLDAPControlA * ServerControls,
 											IN PLDAPControlA * ClientControls
 );
+#else
+/* We use a deprecated function to keep the codepath the same as win32. */
+#define LDAP_DEPRECATED 1
+#include <ldap.h>
 #endif
 
 static int	CheckLDAPAuth(Port *port);
@@ -2043,7 +2043,7 @@
 	*ldap = ldap_init(port->hba->ldapserver, port->hba->ldapport);
 	if (!*ldap)
 	{
-#ifndef WIN32
+#ifndef USE_MICROSOFT_LDAP
 		ereport(LOG,
 				(errmsg("could not initialize LDAP: error code %d",
 						errno)));
@@ -2065,7 +2065,7 @@
 
 	if (port->hba->ldaptls)
 	{
-#ifndef WIN32
+#ifndef USE_MICROSOFT_LDAP
 		if ((r = ldap_start_tls_s(*ldap, NULL, NULL)) != LDAP_SUCCESS)
 #else
 		static __ldap_start_tls_sA _ldap_start_tls_sA = NULL;
diff --recursive -u misc/build/postgresql-9.1.1/src/interfaces/libpq/fe-connect.c misc/build/postgresql-9.1.1.patched/src/interfaces/libpq/fe-connect.c
--- misc/build/postgresql-9.1.1/src/interfaces/libpq/fe-connect.c	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/src/interfaces/libpq/fe-connect.c	2011-12-14 13:10:11.000000000 +0100
@@ -60,7 +60,7 @@
 #endif
 
 #ifdef USE_LDAP
-#ifdef WIN32
+#ifdef USE_MICROSOFT_LDAP
 #include <winldap.h>
 #else
 /* OpenLDAP deprecates RFC 1823, but we want standard conformance */
diff --recursive -u misc/build/postgresql-9.1.1/src/interfaces/libpq/win32.mak misc/build/postgresql-9.1.1.patched/src/interfaces/libpq/win32.mak
--- misc/build/postgresql-9.1.1/src/interfaces/libpq/win32.mak	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/src/interfaces/libpq/win32.mak	2011-12-14 13:11:25.000000000 +0100
@@ -4,6 +4,8 @@
 #        and a dynamic library libpq(d).dll with import library libpq(d)dll.lib
 # USE_SSL=1 will compile with OpenSSL
 # USE_KFW=1 will compile with kfw(kerberos for Windows)
+# USE_LDAP=1 will compile with LDAP support
+# USE_MOZLDAP=1 when LDAP is enabled, use Mozilla LDAP C SDK instead of Microsoft LDAP
 # DEBUG=1 compiles with debugging symbols
 # ENABLE_THREAD_SAFETY=1 compiles with threading enabled
 
@@ -58,6 +60,16 @@
 !MESSAGE Using default Kerberos Library directory: $(KFW_LIB_PATH)
 !ENDIF
 
+!IF "$(MOZLDAP_INC)" == ""
+MOZLDAP_INC=C:\ldapcsdk-6.0.7\include
+!MESSAGE Using default Mozilla LDAP Include directory: $(MOZLDAP_INC)
+!ENDIF
+
+!IF "$(MOZLDAP_LIB_PATH)" == ""
+MOZLDAP_PATH=C:\ldapcsdk-6.0.7\lib
+!MESSAGE Using default Mozilla LDAP Library directory: $(MOZLDAP_LIB_PATH)
+!ENDIF
+
 !IF "$(OS)" == "Windows_NT"
 NULL=
 !ELSE
@@ -178,7 +190,9 @@
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
-CPP_PROJ=/nologo /W3 /EHsc $(OPT) /I "..\..\include" /I "..\..\include\port\win32" /I "..\..\include\port\win32_msvc" /I "..\..\port" /I. /I "$(SSL_INC)" \
+CPP_PROJ=/nologo /W3 /EHsc $(OPT) \
+ /I "..\..\include" /I "..\..\include\port\win32" /I "..\..\include\port\win32_msvc" \
+ /I "..\..\port" /I. /I "$(SSL_INC)" /I "$(KFW_INC)" /I "$(MOZLDAP_INC)" \
  /D "FRONTEND" $(DEBUGDEF) \
  /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" \
  /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c  \
@@ -189,6 +203,17 @@
 SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
 !ENDIF
 
+!IFDEF USE_LDAP
+CPP_PROJ=$(CPP_PROJ) /D USE_LDAP
+!IFDEF USE_MOZLDAP
+CPP_PROJ=$(CPP_PROJ) /D USE_MOZLDAP
+LDAP_LIBS=nsldap32v50.lib
+!ELSE
+CPP_PROJ=$(CPP_PROJ) /D USE_MICROSOFT_LDAP
+LDAP_LIBS=wldap32.lib
+!ENDIF
+!ENDIF # DEFINED(USE_LDAP)
+
 !IFDEF USE_KFW
 CPP_PROJ=$(CPP_PROJ) /D KRB5
 KFW_LIBS=krb5_32.lib comerr32.lib gssapi32.lib
@@ -203,12 +228,12 @@
 RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
 
 LINK32=link.exe
-LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib ws2_32.lib secur32.lib $(SSL_LIBS)  $(KFW_LIB) $(ADD_SECLIB) \
+LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib ws2_32.lib secur32.lib $(SSL_LIBS) $(LDAP_LIBS) $(KFW_LIBS) $(ADD_SECLIB) \
  /nologo /subsystem:windows /dll $(LOPT) /incremental:no \
  /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:$(CPU) \
  /out:"$(OUTDIR)\$(OUTFILENAME).dll"\
  /implib:"$(OUTDIR)\$(OUTFILENAME)dll.lib"  \
- /libpath:"$(SSL_LIB_PATH)" /libpath:"$(KFW_LIB_PATH)" \
+ /libpath:"$(SSL_LIB_PATH)" /libpath:"$(KFW_LIB_PATH)" /libpath:"$(MOZLDAP_LIB_PATH)" \
  /def:$(OUTFILENAME)dll.def
 LINK32_OBJS= \
 	"$(OUTDIR)\$(OUTFILENAME).lib" \
diff --recursive -u misc/build/postgresql-9.1.1/src/tools/msvc/config_default.pl misc/build/postgresql-9.1.1.patched/src/tools/msvc/config_default.pl
--- misc/build/postgresql-9.1.1/src/tools/msvc/config_default.pl	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/src/tools/msvc/config_default.pl	2011-12-14 13:10:11.000000000 +0100
@@ -11,6 +11,7 @@
     # wal_blocksize => 8,     # --with-wal-blocksize, 8kB by default
     # wal_segsize => 16,      # --with-wal-segsize, 16MB by default
     ldap=>1,				# --with-ldap
+    # mozldap=>1,			# --with-mozldap, off by default
     nls=>undef,				# --enable-nls=<path>
     tcl=>undef,				# --with-tls=<path>
     perl=>undef, 			# --with-perl
diff --recursive -u misc/build/postgresql-9.1.1/src/tools/msvc/Mkvcbuild.pm misc/build/postgresql-9.1.1.patched/src/tools/msvc/Mkvcbuild.pm
--- misc/build/postgresql-9.1.1/src/tools/msvc/Mkvcbuild.pm	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/src/tools/msvc/Mkvcbuild.pm	2011-12-14 13:10:11.000000000 +0100
@@ -78,7 +78,8 @@
     $postgres->AddLibrary('wsock32.lib');
     $postgres->AddLibrary('ws2_32.lib');
     $postgres->AddLibrary('secur32.lib');
-    $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
+    $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap} && ! $solution->{options}->{mozldap});
+    $postgres->AddLibrary('nsldap32v50.lib') if ($solution->{options}->{ldap} && $solution->{options}->{mozldap});
     $postgres->FullExportDLL('postgres.lib');
 
     my $snowball = $solution->AddProject('dict_snowball','dll','','src\backend\snowball');
diff --recursive -u misc/build/postgresql-9.1.1/src/tools/msvc/Solution.pm misc/build/postgresql-9.1.1.patched/src/tools/msvc/Solution.pm
--- misc/build/postgresql-9.1.1/src/tools/msvc/Solution.pm	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1.patched/src/tools/msvc/Solution.pm	2011-12-14 13:10:11.000000000 +0100
@@ -174,6 +174,8 @@
         print O "#define USE_ASSERT_CHECKING 1\n" if ($self->{options}->{asserts});
         print O "#define USE_INTEGER_DATETIMES 1\n" if ($self->{options}->{integer_datetimes});
         print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap});
+        print O "#define USE_MICROSOFT_LDAP 1\n" if ( ! $self->{options}->{mozldap});
+        print O "#define USE_MOZLDAP 1\n" if ($self->{options}->{mozldap});
         print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib});
         print O "#define USE_SSL 1\n" if ($self->{options}->{openssl});
         print O "#define ENABLE_NLS 1\n" if ($self->{options}->{nls});
@@ -559,6 +561,7 @@
     $cfg .= ' --enable-integer-datetimes' if ($self->{options}->{integer_datetimes});
     $cfg .= ' --enable-nls' if ($self->{options}->{nls});
     $cfg .= ' --with-ldap' if ($self->{options}->{ldap});
+    $cfg .= ' --with-mozldap' if ($self->{options}->{mozldap});
     $cfg .= ' --without-zlib' unless ($self->{options}->{zlib});
     $cfg .= ' --with-openssl' if ($self->{options}->{ssl});
     $cfg .= ' --with-ossp-uuid' if ($self->{options}->{uuid});