Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jul 2006 13:25:27 +0200
From:      Matthias Fechner <idefix@fechner.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/101050: New port net/asterisk-app-ldap Asterisk can lookup names and numbers in LDAP-directory
Message-ID:  <E1G79QF-0004rN-2X@server.idefix.loc>
Resent-Message-ID: <200607301250.k6UCoHeO024624@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         101050
>Category:       ports
>Synopsis:       New port net/asterisk-app-ldap Asterisk can lookup names and numbers in LDAP-directory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 30 12:50:17 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Fechner
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD server.idefix.loc 6.1-STABLE FreeBSD 6.1-STABLE #15: Tue Jul 11 20:10:47 CEST 2006 root@server.idefix.loc:/usr/obj/usr/src/sys/SERVER2 i386


>Description:
	Adds a new function LDAPget to asterisk to lookup numbers in LDAP directory and set CALLERNAME accordingly. Created a patch to compile with FreeBSD and openldap 2.3.
>How-To-Repeat:
	
>Fix:

--- port-asterisk-app-ldap begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	net/asterisk-app-ldap
#	net/asterisk-app-ldap/distinfo
#	net/asterisk-app-ldap/Makefile
#	net/asterisk-app-ldap/pkg-descr
#	net/asterisk-app-ldap/pkg-plist
#	net/asterisk-app-ldap/files
#	net/asterisk-app-ldap/files/patch-cflags.sh
#	net/asterisk-app-ldap/files/patch-app_ldap.c
#	net/asterisk-app-ldap/files/patch-Makefile
#
echo c - net/asterisk-app-ldap
mkdir -p net/asterisk-app-ldap > /dev/null 2>&1
echo x - net/asterisk-app-ldap/distinfo
sed 's/^X//' >net/asterisk-app-ldap/distinfo << 'END-of-net/asterisk-app-ldap/distinfo'
XMD5 (app_ldap-1.0rc6.tgz) = 031470fc962a82dbc987261fd16c6344
XSHA256 (app_ldap-1.0rc6.tgz) = f0a80aa3f63da0204fda18d5b98e61b59c4071519359efa7e1ce9c7c9fa434d0
XSIZE (app_ldap-1.0rc6.tgz) = 6288
END-of-net/asterisk-app-ldap/distinfo
echo x - net/asterisk-app-ldap/Makefile
sed 's/^X//' >net/asterisk-app-ldap/Makefile << 'END-of-net/asterisk-app-ldap/Makefile'
X# New ports collection makefile for: app-ldap
X# Date created:		30 July 2006
X# Whom:			Matthias Fechner <idefix@fechner.net>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	app_ldap
XDISTVERSION=	1.0rc6
XPORTREVISION=	1
XCATEGORIES=	net
XMASTER_SITES=	http://www.mezzo.net/asterisk/
XEXTRACT_SUFX=	.tgz
X
XMAINTAINER=	idefix@fechner.net
XCOMMENT=	LDAPget application module for the Asterisk PBX
X
XBUILD_DEPENDS=	asterisk:${PORTSDIR}/net/asterisk\
X		${LOCALBASE}/lib/libldap.so:${PORTSDIR}/net/openldap23-client\
X		${LOCALBASE}/lib/libiconv.so:${PORTSDIR}/converters/libiconv
X
XUSE_GMAKE=	yes
X
X.include <bsd.port.mk>
END-of-net/asterisk-app-ldap/Makefile
echo x - net/asterisk-app-ldap/pkg-descr
sed 's/^X//' >net/asterisk-app-ldap/pkg-descr << 'END-of-net/asterisk-app-ldap/pkg-descr'
XLDAPget is an Asterisk application for data retrieval from LDAP
Xdirectories (e.g. OpenLDAP or ActiveDirectory).
X
XWWW: http://www.mezzo.net/asterisk/app_ldap.html
END-of-net/asterisk-app-ldap/pkg-descr
echo x - net/asterisk-app-ldap/pkg-plist
sed 's/^X//' >net/asterisk-app-ldap/pkg-plist << 'END-of-net/asterisk-app-ldap/pkg-plist'
Xlib/asterisk/modules/app_ldap.so
Xetc/asterisk/ldap.conf.sample
X
END-of-net/asterisk-app-ldap/pkg-plist
echo c - net/asterisk-app-ldap/files
mkdir -p net/asterisk-app-ldap/files > /dev/null 2>&1
echo x - net/asterisk-app-ldap/files/patch-cflags.sh
sed 's/^X//' >net/asterisk-app-ldap/files/patch-cflags.sh << 'END-of-net/asterisk-app-ldap/files/patch-cflags.sh'
X--- cflags.sh.orig	Sun Jul 30 12:23:23 2006
X+++ cflags.sh	Wed Jul 19 10:09:51 2006
X@@ -1,13 +1,13 @@
X #!/bin/sh
X 
X-CFLAGS="-g -Wall -D_REENTRANT -D_GNU_SOURCE -fPIC"
X+CFLAGS="-g -Wall -D_REENTRANT -D_GNU_SOURCE -fPIC -I/usr/local/include -L/usr/local/lib"
X 
X-CHANNEL_H=/usr/include/asterisk/channel.h
X+CHANNEL_H=/usr/local/include/asterisk/channel.h
X if [ "`grep 'struct ast_callerid cid' ${CHANNEL_H}`" != "" ]; then
X     CFLAGS="${CFLAGS} -DCHANNEL_HAS_CID"
X fi
X 
X-CONFIG_H=/usr/include/asterisk/config.h
X+CONFIG_H=/usr/local/include/asterisk/config.h
X if [ "`grep 'ast_config_load' ${CONFIG_H}`" != "" ]; then
X     CFLAGS="${CFLAGS} -DNEW_CONFIG"
X fi
END-of-net/asterisk-app-ldap/files/patch-cflags.sh
echo x - net/asterisk-app-ldap/files/patch-app_ldap.c
sed 's/^X//' >net/asterisk-app-ldap/files/patch-app_ldap.c << 'END-of-net/asterisk-app-ldap/files/patch-app_ldap.c'
X--- app_ldap.c.orig	Sun Jul 30 12:22:29 2006
X+++ app_ldap.c	Thu Jul 27 18:42:54 2006
X@@ -9,6 +9,8 @@
X  *
X  */
X 
X+/*#define LDAP_DEPRECATED 1*/
X+
X #include <stdlib.h>
X #include <stdio.h>
X #include <string.h>
X@@ -27,19 +29,24 @@
X #include <asterisk/utils.h>
X #include <asterisk/callerid.h>
X 
X+#include <sasl/sasl.h>
X #include <ctype.h>
X #include <errno.h>
X #include <iconv.h>
X #include <ldap.h>
X 
X #define LDAP_CONFIG "ldap.conf"
X+#define SIZELIMIT 2048
X 
X char *replace_ast_vars(struct ast_channel *chan, const char *string);
X+LDAP* ldap_open_connection(char *host, int port, int version);
X+int ldap_bind_connection(LDAP *ld, char *user, char *pass);
X+int ldap_search_in_connection(LDAP *ld, char *base, char *scope, char *filter, char *attribute, char *result);
X int ldap_lookup(char *host, int port, int version, int timeout, char *user, char *pass, char *base, char *scope, char *filter, char *attribute, char *result);
X int strconvert(const char *incharset, const char *outcharset, char *in, char *out);
X char *strtrim (char *string);
X 
X-static char *tdesc = "LDAP directory lookup function for Asterisk extension logic.";
X+static char *tdesc = "LDAP directory lookup function for Asterisk extension logic(Version: $version$).";
X 
X static char *g_descrip =
X "  LDAPget(varname=config-file-section/key): Retrieves a value from an LDAP\n"
X@@ -58,11 +65,11 @@
X   int arglen;
X   struct localuser *u;
X   char *argv, *varname, *config, *keys = NULL, *key = NULL, *tail = NULL;
X-  char result[2048];
X+  char result[SIZELIMIT+1];
X   char *result_conv;
X   struct ast_config *cfg;
X 
X-  int port = LDAP_PORT, version = LDAP_VERSION2, timeout = 10;
X+  int port = LDAP_PORT, version = LDAP_VERSION3, timeout = 10;
X   char *temp, *host, *user, *pass, *base, *scope, *filter, *_filter, *attribute,
X     *convert_from = NULL, *convert_to = NULL;
X 
X@@ -145,9 +152,11 @@
X   if(option_verbose > 3)
X     ast_verbose (VERBOSE_PREFIX_4 "LDAPget: ldap://%s/%s?%s?%s?%s\n", host, base, attribute, scope, _filter);
X 
X+//  ast_log(LOG_WARNING, "LDAPget: filter: before replace_ast_vars in main: -%s-\n", filter);
X   filter = replace_ast_vars(chan, _filter);
X+//  ast_log(LOG_WARNING, "LDAPget: filter: after replace_ast_vars in main: -%s-\n", filter);
X   if(option_verbose > 3)
X-    ast_verbose (VERBOSE_PREFIX_4 "LDAPget: %s\n", filter);
X+    ast_verbose (VERBOSE_PREFIX_4 "LDAPget: replaced string: %s\n", filter);
X 
X   if(keys && strstr(filter, "%s") != NULL) {
X     filter = (char *)realloc(filter, (strlen(filter)+strlen(keys)+1)*sizeof(char));
X@@ -163,6 +172,7 @@
X   if(option_verbose > 2)
X     ast_verbose (VERBOSE_PREFIX_3 "LDAPget: ldap://%s/%s?%s?%s?%s\n", host, base, attribute, scope, filter);
X 
X+//  ast_log(LOG_WARNING, "LDAPget: filter before ldap_lookup: -%s-\n", filter);
X   if(ldap_lookup(host, port, version, timeout, user, pass, base, scope, filter, attribute, result)) {
X 
X     if(convert_from) {
X@@ -176,11 +186,17 @@
X 		
X     if(strcmp("CALLERIDNAME", varname)==0) {
X #ifdef CHANNEL_HAS_CID
X+       if(option_verbose > 2)
X+	  ast_verbose(VERBOSE_PREFIX_3 "LDAPget: set callerid with HAS_CID ast_set_callerid\n");
X+      result_conv = malloc(strlen(result) * 2);
X+//      ast_set_callerid(chan, chan->cid.cid_num, result, NULL);
X       ast_set_callerid(chan, NULL, result, NULL);
X #else
X       char *cidnum, *cidname, newcid[512] = "";
X       ast_callerid_parse(chan->callerid, &cidname, &cidnum);
X       snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", result, cidnum);
X+      if(option_verbose > 2)
X+	 ast_verbose(VERBOSE_PREFIX_3 "LDAPget: set callerid with NO HAS_CID ast_set_callerid\n");
X       ast_set_callerid(chan, newcid, 0);
X #endif
X       if(option_verbose > 2)
X@@ -237,37 +253,95 @@
X   return ASTERISK_GPL_KEY;
X }
X 
X-int ldap_lookup(char *host, int port, int version, int timeout, char *user, char *pass, 
X-		char *base, char *scope, char *filter, char *attribute, char *result) {
X-  char *attrs[] = { NULL };
X-  char **values;
X-  LDAP *ld;
X-  LDAPMessage *res, *entry;
X-  int ret, ldap_scope = LDAP_SCOPE_SUBTREE;
X-
X-  //ast_verbose(VERBOSE_PREFIX_3 "LDAPget: %s\n", filter);
X-  ld = ldap_init(host, port);
X-  if(!ld) {
X-    ast_log(LOG_WARNING, "LDAPget: unable to initialize ldap connection to %s:%d\n", host, port);
X+LDAP* ldap_open_connection(char *host, int port, int version)
X+{
X+   LDAP *ld=NULL;
X+   LDAPURLDesc url;
X+   char *ldapuri=NULL;
X+   int ret;
X+//   int ldap_debug=0xffff;
X+   int ldap_debug=0;
X+   
X+   // Open connection to the LDAP server
X+   memset(&url, 0, sizeof(url));
X+   url.lud_host=host;
X+   url.lud_port=port;
X+   url.lud_scope=LDAP_SCOPE_DEFAULT;
X+   url.lud_scheme="ldap";
X+   
X+   ldapuri=ldap_url_desc2str(&url);
X+   (void) ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldap_debug);
X+   
X+   if(option_verbose > 2)
X+      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: open connection to %s with version: %d\n", ldapuri, version);
X+   ret = ldap_initialize(&ld, ldapuri);
X+  if(ret != LDAP_SUCCESS) {
X+    ast_log(LOG_WARNING, "LDAPget: unable to initialize ldap connection to %s(%d)\n", ldap_err2string(ret),ret);
X     return 0;
X   }
X-  ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &timeout);
X-  ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version);
X-  if(user) {
X-    if (option_verbose > 2)
X-      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: bind to %s as %s\n", host, user);
X-    ret = ldap_simple_bind_s(ld, user, pass);
X-  } else {
X-    if (option_verbose > 2)
X-      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: bind to %s anonymously\n", host);
X-    ret = ldap_simple_bind_s(ld, NULL, NULL);
X-  }
X-  if(ret) {
X-    ast_log(LOG_WARNING, "LDAPget: bind failed: %s\n", ldap_err2string(ret));
X-    ldap_unbind(ld);
X-    return 0;
X+  
X+  // Disable option referrals
X+  if(ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF) != LDAP_OPT_SUCCESS)
X+  {
X+     ast_log(LOG_WARNING, "LDAPget: unable to disable LDAP_OPT_REFERRALS\n");
X+     return 0;
X   }
X 
X+  // set protocol to version
X+  if(ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version)!= LDAP_OPT_SUCCESS)
X+  {
X+     ast_log(LOG_WARNING, "LDAPget: unable to set LDAP_OPT_PROTOCOL_VERSION %d\n",version);
X+     return 0;
X+  }
X+  return ld;
X+}
X+
X+int ldap_bind_connection(LDAP *ld, char *user, char *pass)
X+{
X+   int rc;
X+   char *sasl_secprops=NULL;
X+   
X+   if( sasl_secprops != NULL)
X+   {
X+      rc= ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS, (void *) sasl_secprops);
X+      if(rc != LDAP_OPT_SUCCESS)
X+      {
X+	 ast_log(LOG_WARNING, "LDAPget: Could not set LDAP_OPT_X_SASL_SECPROPS: %s\n", sasl_secprops);
X+	 return 0;
X+      }
X+   }
X+   if(option_verbose > 2)
X+      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: bind as %s\n", user);
X+
X+   struct berval passwd= {0, NULL};
X+   passwd.bv_val=ber_strdup(pass);
X+   passwd.bv_len=strlen(passwd.bv_val);
X+   
X+   rc=ldap_sasl_bind_s(ld, user, NULL, &passwd, NULL, NULL, NULL);
X+   
X+   if(rc != LDAP_SUCCESS)
X+   {
X+	 ast_log(LOG_WARNING, "LDAPget: ldap_sasl_interactive_bind_s failed: %s (%d)\n", ldap_err2string(rc),rc);
X+	 return 0;
X+   }
X+   
X+   return 1;
X+}
X+
X+
X+int ldap_search_in_connection(LDAP *ld, char *base, char *scope, char *filter, char *attribute, char *result)
X+{
X+  char *attrs[] = { NULL };
X+  int ret, ldap_scope = LDAP_SCOPE_SUBTREE;
X+  LDAPMessage *msg, *res;
X+  int num_entries=0;
X+  int msgtype;
X+  char *dn, *a;
X+  BerElement *ber=NULL;
X+  struct berval **vals;
X+  struct berval val;
X+
X+//  ast_log(LOG_WARNING, "LDAPget: filter start of ldap_search_in_connections: -%s-\n", filter);
X   if(strncmp(scope,"sub",3)==0) {
X     ldap_scope = LDAP_SCOPE_SUBTREE;
X   } else if(strncmp(scope,"base",4)==0) {
X@@ -276,48 +350,126 @@
X     ldap_scope = LDAP_SCOPE_ONELEVEL;
X   }
X 
X-  ret = ldap_search_s(ld, base, ldap_scope, filter, attrs, 0, &res);
X-  if(ret) {
X-    ast_log(LOG_DEBUG, "LDAPget: search failed: %s\n", ldap_err2string(ret));
X+  if(option_verbose > 2)
X+     ast_verbose(VERBOSE_PREFIX_3 "LDAPget: send search command to LDAP server\n");
X+  ret = ldap_search_ext_s(ld, base, ldap_scope, filter, attrs, 0, NULL, NULL, NULL, SIZELIMIT, &res);
X+  if(ret != LDAP_SUCCESS) {
X+    ast_log(LOG_WARNING, "LDAPget: search failed: %s (%d)\n", ldap_err2string(ret),ret);
X+    ast_log(LOG_WARNING, "LDAPget: filter: %s\n", filter);
X+// XXXX need to check
X     ldap_msgfree(res);
X-    ldap_unbind(ld);
X+    ldap_unbind_ext_s(ld,NULL,NULL);
X+    ast_log(LOG_WARNING, "LDAPget: search failed resourceses released, cancel search\n");
X     return 0;
X   }
X+  num_entries=ldap_count_entries(ld, res);
X+  msg=ldap_first_message(ld, res);
X+  msgtype=ldap_msgtype(msg);
X 
X-  entry = ldap_first_entry(ld, res);
X-  if(!entry) {
X-    if (option_verbose > 2)
X-      ast_verbose (VERBOSE_PREFIX_3 "LDAPget: Value not found in directory.\n");
X-    ldap_msgfree(res);
X-    ldap_unbind(ld);
X-    return 0;
X-  }
X+  if(option_verbose > 2)
X+     ast_verbose(VERBOSE_PREFIX_3 "LDAPget: found %d entry in LDAP server\n", num_entries);
X 
X-  values = ldap_get_values(ld, entry, attribute);
X-  if(values && values[0]) {
X-    memset(result, 0, strlen(values[0]));
X-    strncpy(result, values[0], strlen(values[0]));
X-    result[strlen(values[0])] = '\0';
X-    if (option_verbose > 2)
X-      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: %s=%s\n", attribute, result);
X-  } else {
X-    if (option_verbose > 2)
X-      ast_verbose (VERBOSE_PREFIX_3 "LDAPget: %s not found.\n", attribute);
X-    ldap_msgfree(res);
X-    ldap_unbind(ld);
X-    return 0;
X+  for ( msg = ldap_first_message( ld, res ); msg != NULL; msg = ldap_next_message( ld, msg ) ) {
X+     /* Determine what type of message was sent from the server. */
X+     
X+     msgtype = ldap_msgtype( msg );
X+     switch( msgtype ) {
X+	/* If the result was an entry found by the search, get and print the
X+	   attributes and values of the entry. */
X+	case LDAP_RES_SEARCH_ENTRY:
X+	   /* Get and print the DN of the entry. */
X+	   if(option_verbose > 2)
X+	      ast_verbose(VERBOSE_PREFIX_3 "Found a LDAP_RES_SEARCH_ENTRY\n");
X+	   ret=ldap_get_dn_ber(ld,msg,&ber,&val);
X+	   
X+	   if (( dn = ldap_get_dn( ld, res )) != NULL ) {
X+	      ldap_memfree( dn );
X+	   }
X+	   /* Iterate through each attribute in the entry. */
X+	   for ( a = ldap_first_attribute( ld, res, &ber );
X+		 a != NULL; a = ldap_next_attribute( ld, res, ber ) ) {
X+	      /* Get the searched attribute and value */
X+	      if(!strcmp(a,attribute))
X+	      {
X+		 
X+		 if (( vals = ldap_get_values_len( ld, res, a )) != NULL ) {
X+		    val=*vals[0];
X+		    // remove space at end of string
X+		    if(val.bv_val[val.bv_len-1]==' ')
X+		    {
X+		       val.bv_len--;
X+//		       val.bv_val[val.bv_len]=NULL;
X+		    }
X+		    if(option_verbose > 2)
X+		       ast_verbose(VERBOSE_PREFIX_3 "Found <%s>: <%s>\n", a, val.bv_val);
X+		    memcpy(result,val.bv_val,val.bv_len);
X+		    ldap_value_free_len( vals );
X+		    ldap_memfree(a);
X+		    break;
X+		 }
X+	      }
X+	      ldap_memfree( a );
X+	   }
X+	   if ( ber != NULL ) {
X+	      ber_free( ber, 0 );
X+	   }
X+	   break;
X+	case LDAP_RES_SEARCH_REFERENCE:
X+	   if(option_verbose > 2)
X+	      ast_verbose(VERBOSE_PREFIX_3 "LDAP_RES_SEARCH_REFERENCE\n");
X+	   break;
X+	case LDAP_RES_SEARCH_RESULT:
X+	   if(option_verbose > 2)
X+	      ast_verbose(VERBOSE_PREFIX_3 "LDAPRES_SERCH_RESULT\n");
X+	   break;
X+	default:
X+	   break;
X+     }
X   }
X-  ldap_value_free(values);
X-  ldap_msgfree(res);
X-  ldap_unbind_s(ld);
X   return 1;
X }
X 
X+int ldap_lookup(char *host, int port, int version, int timeout, char *user, char *pass, 
X+		char *base, char *scope, char *filter, char *attribute, char *result) {
X+   LDAP *ld=NULL;
X+   
X+//   ast_log(LOG_WARNING, "LDAPget: filter in ldap_lookup: -%s-\n", filter);
X+   // open connection to LDAP server
X+   if(option_verbose > 2)
X+      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: Initialize connection to LDAP server\n");
X+   ld=ldap_open_connection(host, port, version);
X+   if(ld==0)
X+      return 0;
X+   
X+   // authenticate to the LDAP-Server
X+   if(option_verbose > 2)
X+      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: bind to LDAP server\n");
X+   if(ldap_bind_connection(ld, user, pass) == 0)
X+      return 0;
X+   
X+   // Search in the LDAP directory
X+   if(option_verbose > 2)
X+      ast_verbose(VERBOSE_PREFIX_3 "LDAPget: search attribute %s in LDAP directory\n", attribute);
X+   if(ldap_search_in_connection(ld, base, scope, filter, attribute, result)==0)
X+      return 0;
X+   
X+   // Close connection to the LDAP server
X+   int err = ldap_set_option(ld, LDAP_OPT_SERVER_CONTROLS, NULL);
X+   if(err != LDAP_OPT_SUCCESS)
X+   {
X+      ast_log(LOG_WARNING, "LDAPget: Could not unset controls\n");
X+   }
X+   
X+   ldap_unbind_ext_s(ld, NULL, NULL);
X+   return 1;
X+}
X+
X 
X char *replace_ast_vars(struct ast_channel *chan, const char *_string)
X {
X   char *var_start, *var_end, *key, *value, *string;
X   int begin, end;
X+
X   if(!_string) return "";
X   string = (char *)malloc((strlen(_string)+1)*sizeof(char));
X   memcpy(string, _string, strlen(_string)+1);
X@@ -328,19 +480,35 @@
X     key = (char *)alloca((end-begin-1)*sizeof(char));
X     memcpy(key, var_start+2, end-begin-2);
X     key[end-begin-2] = '\0';
X-    value = pbx_builtin_getvar_helper(chan, key);
X-    if(value) { 
X-      //ast_verbose (VERBOSE_PREFIX_3 "LDAPget: %s=%s\n", key, value);
X+    if(!strcmp(key,"CALLERIDNUM"))
X+    {
X+       value=chan->cid.cid_num;
X+    }else
X+    {
X+       value = pbx_builtin_getvar_helper(chan, key);
X+//    ast_log(LOG_WARNING, "LDAPget: key=-%s-, value=-%s-\n",key,value);
X+    }
X+    
X+    if(option_verbose > 2)
X+    {
X+       ast_verbose (VERBOSE_PREFIX_3 "LDAPget: key=%s\n", key);
X+       ast_verbose (VERBOSE_PREFIX_3 "LDAPget: value=%s\n", value);
X+    }
X+    if(strcmp(value,"")) { 
X       string = (char *)realloc(string, (strlen(string)-(end-begin+1)+strlen(value)+1)*sizeof(char));
X+
X       memmove(var_start+strlen(value), var_end+1, strlen(var_end+1)+1);
X       memcpy(var_start, value, strlen(value));
X     } else {
X-      memmove(var_start, var_end+1, strlen(var_end+1)+1);
X+       memmove(var_start, var_end+1, strlen(var_end+1)+1);
X     }
X-    //ast_verbose (VERBOSE_PREFIX_3 "LDAPget: filter:%s\n", string);
X+    if(option_verbose > 2)
X+       ast_verbose (VERBOSE_PREFIX_3 "LDAPget: filter:%s\n", string);
X   }
X   return string;
X }
X+
X+
X 
X int strconvert(const char *incharset, const char *outcharset, char *in, char *out) 
X {
END-of-net/asterisk-app-ldap/files/patch-app_ldap.c
echo x - net/asterisk-app-ldap/files/patch-Makefile
sed 's/^X//' >net/asterisk-app-ldap/files/patch-Makefile << 'END-of-net/asterisk-app-ldap/files/patch-Makefile'
X--- Makefile.orig	Sun Jul 30 12:20:19 2006
X+++ Makefile	Sun Jul 30 12:29:12 2006
X@@ -10,16 +10,16 @@
X CONF=ldap.conf
X 
X CFLAGS=$(shell ./cflags.sh)
X-LIBS=-llber -lldap
X-RES=$(shell if [ -f /usr/include/asterisk/channel.h ]; then echo "$(NAME).so"; fi)
X+LIBS=-llber -lldap -liconv
X+RES=$(shell if [ -f /usr/local/include/asterisk/channel.h ]; then echo "$(NAME).so"; fi)
X 
X ifeq (${OSARCH},Darwin)
X SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
X else
X-SOLINK=-shared -Xlinker -x
X+SOLINK=-shared -Xlinker -x -L/usr/local/lib
X endif
X 
X-MODULES_DIR=/usr/lib/asterisk/modules
X+MODULES_DIR=/usr/local/lib/asterisk/modules
X 
X %.so : %.o
X 	$(CC) $(SOLINK) -o $@ $(LIBS) $<
X@@ -30,8 +30,8 @@
X 	rm -f $(NAME).o $(NAME).so
X 
X install: all
X-	if ! [ -f /etc/asterisk/$(CONF) ]; then \
X-		install -m 644 $(CONF).sample /etc/asterisk/$(CONF) ; \
X+	if ! [ -f /usr/local/etc/asterisk/$(CONF).sample ]; then \
X+		install -m 644 $(CONF).sample /usr/local/etc/asterisk/$(CONF).sample ; \
X 	fi
X 	if [ -f $(NAME).so ]; then \
X 		install -m 755 $(NAME).so $(MODULES_DIR) ; \
END-of-net/asterisk-app-ldap/files/patch-Makefile
exit
--- port-asterisk-app-ldap ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1G79QF-0004rN-2X>