steffen: server/postfix postfix-ldap-leafonly.patch, NONE, 1.1 Makefile, 1.9, 1.10 kolab.patch, 1.1, 1.2

cvs at intevation.de cvs at intevation.de
Thu May 19 13:13:57 CEST 2005


Author: steffen

Update of /kolabrepository/server/postfix
In directory doto:/tmp/cvs-serv30505

Modified Files:
	Makefile kolab.patch 
Added Files:
	postfix-ldap-leafonly.patch 
Log Message:
patch for postfix to support "our" kind of recursive ldap lookup

--- NEW FILE: postfix-ldap-leafonly.patch ---
diff -upr ../postfix-2.1.5.orig/src/global/dict_ldap.c ./src/global/dict_ldap.c
--- ../postfix-2.1.5.orig/src/global/dict_ldap.c	2004-01-04 19:43:18.000000000 +0100
+++ ./src/global/dict_ldap.c	2005-05-19 11:31:39.000000000 +0200
@@ -58,6 +58,10 @@
 /* .IP special_result_attribute
 /*	The attribute(s) of directory entries that can contain DNs or URLs.
 /*	If found, a recursive subsequent search is done using their values.
+/* .IP exclude_internal
+/*      Used in conjunction with \fIspecial_result_attribute\fR. If set to 
+/*      yes, only matching objects without \fIspecial_result_attribute\fR
+/*      attributes are included in the result. The default is no.
 /* .IP scope
 /*	LDAP search scope: sub, base, or one.
 /* .IP bind
@@ -223,6 +227,7 @@ typedef struct {
     char   *result_filter;
     ARGV   *result_attributes;
     int     num_attributes;		/* rest of list is DN's. */
+    int     exclude_internal;
     int     bind;
     char   *bind_dn;
     char   *bind_pw;
@@ -719,6 +724,7 @@ static void dict_ldap_get_values(DICT_LD
     char   *myname = "dict_ldap_get_values";
     struct timeval tv;
     LDAPURLDesc *url;
+    int     is_leaf;
 
     tv.tv_sec = dict_ldap->timeout;
     tv.tv_usec = 0;
@@ -744,6 +750,27 @@ static void dict_ldap_get_values(DICT_LD
 		   recursion, dict_ldap->ldapsource, dict_ldap->size_limit);
 	    dict_errno = DICT_ERR_RETRY;
 	}
+
+	/*
+	 * The number of ordinary attributes is "num_attributes". We run through
+	 * the "special" attributes and check if any of them are present in the
+	 * object. If yes, then is_leaf = 0, else is_leaf = 1
+	 */
+	is_leaf = 1;
+	if (dict_ldap->exclude_internal) {
+	    for (i = dict_ldap->num_attributes; dict_ldap->result_attributes->argv[i]; i++) {
+		attr = dict_ldap->result_attributes->argv[i];
+		vals = ldap_get_values(dict_ldap->ld, entry, attr);
+		if (vals) {
+		    if (ldap_count_values(vals) > 0) {
+			is_leaf = 0;
+			ldap_value_free(vals);
+			break;
+		    }
+		    ldap_value_free(vals);	    
+		}
+	    }
+	}
 	for (attr = ldap_first_attribute(dict_ldap->ld, entry, &ber);
 	     attr != NULL;
 	     ldap_memfree(attr), attr = ldap_next_attribute(dict_ldap->ld,
@@ -791,6 +818,7 @@ static void dict_ldap_get_values(DICT_LD
 	     */
 	    if (i < dict_ldap->num_attributes) {
 		/* Ordinary result attribute */
+	        if(is_leaf) {
 		for (i = 0; vals[i] != NULL; i++) {
 		    if (++expansion > dict_ldap->expansion_limit &&
 			dict_ldap->expansion_limit) {
@@ -815,6 +843,7 @@ static void dict_ldap_get_values(DICT_LD
 		    msg_info("%s[%d]: search returned %ld value(s) for"
 			     " requested result attribute %s",
 			     myname, recursion, i, attr);
+		}
 	    } else if (recursion < dict_ldap->recursion_limit
 		       && dict_ldap->result_attributes->argv[i]) {
 		/* Special result attribute */
@@ -1363,6 +1392,11 @@ DICT   *dict_ldap_open(const char *ldaps
     myfree(attr);
 
     /*
+     * get configured value of "exclude_internal", default to no
+     */
+    dict_ldap->exclude_internal = cfg_get_bool(dict_ldap->parser, "exclude_internal", 0);    
+
+    /*
      * get configured value of "bind"; default to true
      */
     dict_ldap->bind = cfg_get_bool(dict_ldap->parser, "bind", 1);
Only in ./src/global: dict_ldap.c~

Index: Makefile
===================================================================
RCS file: /kolabrepository/server/postfix/Makefile,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Makefile	16 Dec 2004 13:26:06 -0000	1.9
+++ Makefile	19 May 2005 11:13:55 -0000	1.10
@@ -17,6 +17,7 @@
 	$(RPM) -ihv postfix-$(VERSION)-$(RELEASE).src.rpm
 
 	cp $(KOLABCVSDIR)/postfix-pipe.patch $(KOLABRPMSRC)/postfix/
+	cp $(KOLABCVSDIR)/postfix-ldap-leafonly.patch $(KOLABRPMSRC)/postfix/
 	cp $(KOLABCVSDIR)/kolab.patch $(KOLABRPMSRC)/postfix/           # Patch for postfix.spec
 
 	cd $(KOLABRPMSRC)/postfix && patch < $(KOLABCVSDIR)/kolab.patch && $(RPM) -ba postfix.spec --define 'with_ldap yes' --define 'with_sasl yes' --define 'with_ssl yes'

Index: kolab.patch
===================================================================
RCS file: /kolabrepository/server/postfix/kolab.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- kolab.patch	16 Dec 2004 13:26:06 -0000	1.1
+++ kolab.patch	19 May 2005 11:13:55 -0000	1.2
@@ -1,27 +1,29 @@
---- ../postfix.orig/postfix.spec	2004-10-11 20:49:19.000000000 +0200
-+++ postfix.spec	2004-12-15 17:14:49.000000000 +0100
+--- postfix.spec.orig	2005-05-19 04:56:45.000000000 +0200
++++ postfix.spec	2005-05-19 05:13:43.000000000 +0200
 @@ -42,7 +42,7 @@ Class:        BASE
  Group:        Mail
  License:      IPL
  Version:      %{V_postfix}
 -Release:      2.2.0
-+Release:      2.2.0_kolab
++Release:      2.2.0_kolab2
  
  #   package options
  %option       with_fsl       yes
-@@ -67,6 +67,7 @@ Patch1:       postfix.patch.pfls
+@@ -67,6 +67,8 @@ Patch1:       postfix.patch.pfls
  Patch2:       ftp://ftp.openpkg.org/sources/CPY/postfix/postfix-%{V_whoson}-whoson.patch
  Patch3:       http://www.ipnet6.org/postfix/download/postfix-libspf2-%{V_spf}.patch
  Patch4:       http://www.libsrs2.org/patch/postfix-libsrs2-%{V_srs}.patch
 +Patch5:	      postfix-pipe.patch
++Patch6:       postfix-ldap-leafonly.patch
  
  #   build information
  Prefix:       %{l_prefix}
-@@ -195,6 +196,7 @@ Conflicts:    exim, sendmail, ssmtp
+@@ -195,6 +197,8 @@ Conflicts:    exim, sendmail, ssmtp
  %if "%{with_whoson}" == "yes"
      %patch -p0 -P 2
  %endif
 +    %patch -p0 -P 5
++    %patch -p0 -P 6
  
  %build
      #   configure Postfix (hard-core part I)





More information about the commits mailing list