Posible bug related to quotas and user edit

Discussion in 'General' started by SrTango, Oct 22, 2009.

  1. SrTango

    SrTango New Member

    Hi,
    I am experiencing the following behavior.
    If I log in as a client and try to edit an user autoresponse. I get the same error as I'd get if I had not enough quota for the mailbox.
    That is:
    The max space for mailboxes is reached. The max. available space in MB is: 400
    but I am in fact under quota (as the error also suggest) and I'm not touching the user quota which is, in this case, 50 MB.
    So it seems that when I change tabs to get to the autoresponder tab the value in the quota field is... somewhat lost and mail_user_edit.php can't see it and believes that I want to change the quota to 0 or something like that thus giving me the error message.
    I didn't really have the time to properly debug the problem but I hope that the description helps you to understand what I mean and how to reproduce.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The error means that you assigned too much quota to your mail users as ispconfig calculates the sum of all mailusers assigned to a client. Set the mail quota of the client and / or the reseller to a higher limit.
     
  3. SrTango

    SrTango New Member

    Maybe I did not explain it correctly
    I am not over quota
    I am not changing the quota the user has already assigned
    as the error message says I still have 400MB to assign if I wanted to.
    Problem is, when I *only* try to change the autoresponder I get the error even when I am not changing the quota.

    If I were over quota the message would say something like The max available space is 0
    (or even minus something)
    So since I still have 400MB to spare and since I am not changing the 50 mb that the user already have assigned, no error quota related should pop up.
     
  4. damir

    damir New Member

    Im experiencing same problem, i have 500mb quota on my email plan. 100mb is assign to my account and 400 free.

    When i move from autoresponder to mailfilter i get the error message. Im not even messing with quota.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    This does not matter as quota is tested on every operation that is done on the mailbox.

    Which quota settings have you set in the reseller, which have you set in the client and which setting do you have in every mailbox that belongs to the same client and same reseller?
     
  6. SrTango

    SrTango New Member

    That is actually the problem, the code is checking for the quota but for some reason the value is lost somewhere (I think)

    My quota setting for this particular example are about 4000MB for the client with a max of around 80 mailboxes.
    there are like 72 mailboxes created each of which have 50mb quota.
    That leaves me with like 400mb free.
    I am not changing the user quota, just changing tabs and trying to set an autoresponder as the client. (it obviously works as admin)
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    You can test it yourself but I doubt that the mysql sum function is broken. Get the record of this mailbox, what we need is the sys_groupid and the mailuser_id. Then execute the following sql statement in the ispconfig database to get the quota of all mailboxes of this client:

    SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != [MAILUSER_ID] AND sys_groupid = [SYS_GROUPID]

    replace [MAILUSER_ID] and [SYS_GROUPID] with the ID's from the mailbox record.

    What you get is the mailbox size in bytes, you have to divide it twice by 1024 to get The size in mbyte.

    You will get a quota error if the size of all mailboxes + the size of the current mailbox is > the limit of the client.

    This does not matter as I posted above. the limits are chcekd on every operation that you do on the mailbox and not only if you change quota.
     
  8. SrTango

    SrTango New Member

    You miss the point.
    The point is, if the quota works and I can change it without any problem, for example changing it from 50 to 40 or 60. it should work when I am *not* changing the quota and just creating an autoresponse. So there should be something wrong with the check, cause it works when I'm using the first tab on the mailbox edit, but it doesn't when I'm using the autoresponse tab.

    Then again.
    If I take that very same mailbox and I edit the quota, raising it to 80 or lowering to 40 and I save the changes it works ok.
    If, on the other hand, I edit the mailbox, change to the autoresponse tab, check the checkbox, set up a message and save the change I get the error message.
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok. Added it to the bugtracker.
     
  10. chengkinhung

    chengkinhung New Member

    I try to fix the mail/mail_user_edit.php

    the original code:

    // Check the quota and adjust
    if($client["limit_mailquota"] >= 0) {
    $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != ".intval($this->id)." AND sys_groupid = $client_group_id");
    $mailquota = $tmp["mailquota"] / 1024 / 1024;
    $new_mailbox_quota = intval($this->dataRecord["quota"]);
    if(($mailquota + $new_mailbox_quota > $client["limit_mailquota"]) || ($new_mailbox_quota == 0 && $client["limit_mailquota"] != -1)) {
    $max_free_quota = $client["limit_mailquota"] - $mailquota;
    $app->tform->errorMessage .= $app->tform->lng("limit_mailquota_txt").": ".$max_free_quota."<br>";
    // Set the quota field to the max free space
    $this->dataRecord["quota"] = $max_free_quota;
    }
    unset($tmp);
    unset($tmp_quota);
    }

    I change to:

    // Check the quota and adjust
    if($client["limit_mailquota"] >= 0) {
    $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != ".intval($this->id)." AND sys_groupid = $client_group_id");
    $mailquota = $tmp["mailquota"] / 1024 / 1024;
    $new_mailbox_quota = intval($this->dataRecord["quota"]);
    if($mailquota + $new_mailbox_quota > $client["limit_mailquota"]) {
    $max_free_quota = $client["limit_mailquota"] - $mailquota;
    $app->tform->errorMessage .= $app->tform->lng("limit_mailquota_txt").": ".$max_free_quota."<br>";
    // Set the quota field to the max free space
    $this->dataRecord["quota"] = $max_free_quota;
    }
    unset($tmp);
    unset($tmp_quota);
    }
     
  11. vistree

    vistree Member HowtoForge Supporter

    Hi, I am running in the the problem.
    What does the mailbox-warning mean for customers? Is this an error, which can be ignored, or is also the real quota set to reached??? So, I client tries to change autoresponder, will this effect his quota to be reached - or is it only a wrong message.
    Also: does this fix helps?



     
  12. ArnOS

    ArnOS New Member

    The fix works, but I'm not sure if there are any side-effects.
     
    Last edited: Jul 29, 2010

Share This Page