[Kolab-devel] Patch: Server Local Networks field

Stephan Buys list at codefusion.co.za
Tue Sep 9 12:46:27 CEST 2003


Hi all,

Here is a patch for the bug reported on the list a couple of days ago.
It attempts to enforce proper formatting on the list of networks provided to LDAP from
the Local Networks field.

Regards,
Stephan

Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/server/index.php,v
retrieving revision 1.6.2.1
diff -u -p -r1.6.2.1 index.php
--- index.php   18 Jul 2003 01:39:07 -0000      1.6.2.1
+++ index.php   9 Sep 2003 10:48:44 -0000
@@ -102,8 +102,18 @@ if (!$errors) {
                 ldap_free_result($result);
              }
          }
-         if ($mynetworks) $attrs['postfix-mynetworks'][0] = $mynetworks;
+         if ($mynetworks) {
+           #Do some basic sanity checks
+           preg_match_all ("/(\d+\.\d+\.\d+\.\d+\/\d+)/x",
+               $mynetworks, $networks);
+           for ($i = 0; $i < count($networks[0])-1; $i++) {
+               $parsednetworks = $parsednetworks.$networks[0][$i].", ";
+           }
+           $parsednetworks = $parsednetworks.$networks[0][count($networks[0])-1];

+           $attrs['postfix-mynetworks'][0] = $parsednetworks;
+
+        }
          if (!ldap_modify ($link,"k=kolab,".$_SESSION['base_dn'],$attrs))
             array_push($errors, "LDAP Error: failed to modify kolab config object ".ldap_error($link));
          break;
@@ -143,6 +153,7 @@ if (!$errors) {
 }

 print("</center></td></tr></table>\n");
+

 if ($errors) {
    print("<TABLE WIDTH=\"80%\" CELLSPACING=20 CELLPADDING=0 BORDER=0>\n");




More information about the devel mailing list