bugPhamm (PHP LDAP Virtual Hosting Manager) - Bugs: bug #15103, empty ldap values will lead to a...

 
 

bug #15103: empty ldap values will lead to a failed update

Submitted by:  matteo brancaleoni <mbrancaleoni>
Submitted on:  Wed 30 Nov 2005 10:01:59 AM UTC  
 
Category: mail-pluginSeverity: 3 - Normal
Item Group: NoneStatus: Wont Fix
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 16 May 2006 03:43:52 PM UTC, comment #4:

in phamm05 module you can find purge_empty_values function, it is very easy but works fine, take a look, I use it to purge all array before use ldap functions to insert or update entry

function purge_empty_values ($data)
{
// Empty array
$res = array();

foreach ($data as $key => $val)
if ($val)
$res[$key] = $val;

return $res;
}

anyway a similar problem is try to update not existing attribute, using related DB this is not a problem, but with LDAP whis produce error

I think will be important use a way to create "on fly" not existing attributes if wanted

Alessandro De Zorzi <lotabi>
Project Administrator
Sun 09 Apr 2006 01:55:39 PM UTC, comment #3:

Please always report phamm version and step to reproduce bug. Also ldiff extract if useful.

Alessandro De Zorzi <lotabi>
Project Administrator
Sat 08 Apr 2006 08:13:58 PM UTC, comment #2:

I have the same problems when adding aliases. Under some cirtumstances, adding the alias fails because of empty ldap attributes.

I have hacked the add_alias.php a little:

for ($i=0; $i < count($maildrop); $i++)
{
- $info["maildrop"][$i] = "$maildrop[$i]";
+ if ( !empty($maildrop[$i]) ) // only non-empty maildrops are useful
+ $info["maildrop"][$i] = "$maildrop[$i]";
}

this works for me.

The best solution would be a function which kills empty attributes out of the update array.

Jan Dankert <dankert>
Thu 08 Dec 2005 07:52:31 PM UTC, comment #1:

Your patch do not solve the problem ;-P

Amavi schema provide 3 attributes:

amavisSpamTagLevel
amavisSpamTag2Level
amavisSpamKillLevel

Only if manager are logged phamm provide a form with the 3 select,
in the other cases phamm show only one generic select "Spam kill level" and choose the 3 values as defined in configuration file.

Maybe the mail/config.inc.php file is not contains this values:

$spamTagLevels
$spamTag2Levels
$spamKillLevels

or a bug in those lines

// Value Reference
$refValue = $amavis["amavisspamkilllevel"];
$level = $spamKillLevels["$refValue"];

//
$info["amavisSpamTagLevel"] = array_search($level,$spamTagLevels);
$info["amavisSpamTag2Level"] = array_search($level,$spamTag2Levels);

Alessandro De Zorzi <lotabi>
Project Administrator
Wed 30 Nov 2005 10:01:59 AM UTC, original submission:

seems that under certain circumstances, when logged as user
and spamcheck is enabled, phamm fails to update the records
because the array passed to ldap modify contains empty values
(amavisSpamTagLevel and amavisSpamTag2Level).
this little hack simply deletes empty tags from the ldap array and so the update is successful.

btw, I think that the correct method is not having these values at all, when logged as user....

--- phamm-0.4.6/plugins/mail/functions/modify_mail.php 2005-05-18 17:29:43.000000000 +0200
+++ phamm/plugins/mail/functions/modify_mail.php 2005-11-21 20:38:48.000000000 +0100
@@ -92,7 +92,16 @@
$info["amavisSpamTag2Level"] = array_search($level,$spamTag2Levels);
}

- $r = ldap_modify($connect, "mail=$mail,vd=$domain,$LDAP_BASE", $info);
+ reset($info);
+ while (list($key, $val) = each($info)) {
+ if($val)
+ $info_clean[$key] = $val;
+ }
+ //print_r($info);
+ //print_r($info_clean);
+
+ error_log("$connect, mail=$mail,vd=$domain,$LDAP_BASE, $info_clean");
+ $r = ldap_modify($connect, "mail=$mail,vd=$domain,$LDAP_BASE", $info_clean);

return $r;
}

matteo brancaleoni <mbrancaleoni>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 16 May 2006 03:45:02 PM UTClotabiOpen/ClosedOpen=>Closed
Tue 16 May 2006 03:44:41 PM UTClotabiStatusNone=>Wont Fix

Back to the top


Powered by Savane 3.1-cleanup1