Subject: Compiling Pine 4.44 with LDAP on MacOS 10.2.2

From: Josh Larios <[email-masked]>
Date: Tue, 19 Nov 2002 17:42:30 -0800 (PST)

I doubt this works on 10.1, and I've only tested it on 10.2.2, but I think
it ought to work on any 10.2.

OS X comes with OpenLDAP 2.1.x. Between OpenLDAP 2.0 and 2.1, a number of
functions were removed, notably the ldap_url_* functions. Pine 4.44 uses
ldap_url_search_st in adrbkcmd.c, so if you try to compile it against the
system libraries as-is, you'll get a link error.

This patch changes the call from 2.0-style to 2.1-style:

diff -Naur pine4.44-orig/pine/adrbkcmd.c pine4.44/pine/adrbkcmd.c
--- pine4.44-orig/pine/adrbkcmd.c       Tue Sep 11 10:44:17 2001
+++ pine4.44/pine/adrbkcmd.c    Tue Nov 19 17:18:37 2002
@@ -7281,6 +7281,7 @@
     LDAP_SERV_S     *info;
     LDAP_SERV_RES_S *serv_res = NULL;
     WP_ERR_S wp_err;
+    LDAPURLDesc *ldapurl;

     dprint(2, (debugfile, "url_local_ldap(%s)\n", url));

@@ -7304,7 +7305,16 @@
       our_ldap_set_option(ld, LDAP_OPT_RESTART, LDAP_OPT_ON);

       t.tv_sec = 30; t.tv_usec = 0;
-      if((ld_err = ldap_url_search_st(ld,url,0,&t,&result)) != LDAP_SUCCESS){
+
+      ld_err = ldap_url_parse_ext(url, ldapurl);
+      if ( ld_err == 0 ) {
+       ld_err = ldap_search_st(ld, ldapurl->lud_dn, ldapurl->lud_scope,
+                               ldapurl->lud_filter, ldapurl->lud_attrs,
+                               0, &t, &result);
+       ldap_free_urldesc(ldapurl);
+      }
+
+      if(ld_err != LDAP_SUCCESS){
        sprintf(ebuf, "LDAP search failed: %.200s", ldap_err2string(ld_err));
        q_status_message(SM_ORDER, 3, 5, ebuf);
        ldap_unbind(ld);

You'll probably also have to modify contrib/ldap-setup to make sure it
exits with a return value of 3. My simple expedient is to replace the
entire script with this one:

#!/bin/sh
exit 3

I'm sure there's a better way to do that, though. Then, in the pine4.44
directory, do this:

mkdir ldap
ln -s /usr/include ldap/
ln -s /usr/lib ldap/libraries

(If you haven't already edited pico/osdep/os-osx.h to comment out the line
near the end which reads:
extern int   sys_nerr;
now would be a good time to do that, or the build will fail.)

To build pine, run the build script like so:

./build osx EXTRALDFLAGS=-lncurses

Standard disclaimers apply. I'm not a very good programmer, so someone
might want to take a closer look at my patch to make sure it doesn't do
Bad Things. I just saw a similar patch for another project and modified it
to fit Pine.

--
Josh Larios                   Computing & Communications Client Services
University of Washington      Box 352830, Mary Gates Hall 011A
[email-masked]   Seattle, WA 98195-2830

-- 
-----------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/pine/pine-info/
-----------------------------------------------------------------