[imp] wu-imap quotas on Redhat 8 or 9 with imp 3.2.2

AJ aj at mindcrash.com
Fri Sep 19 10:47:16 PDT 2003


Well, in answering my own post, I came up with this.. Can someone let me know if
this looks ok?  It seems to work.. if a user has no quota, it sets $quota to 0
and will then print out the NO LIMIT message, but if there is a problem (tested
by changing the quota_path to something invalid) it will print the Unable to
retrieve quota message.

Thanks.
AJ

imp/lib/Quota/command.php

    function quotaHTML()
    {
        global $imp;

        $imap_user = strtolower($imp['user']);
        $passwd_array = posix_getpwnam($imap_user);
        $homedir = "/dev/hda2";
        $cmdline = $this->_params['quota_path'] . " -u $imap_user | " .
                   $this->_params['grep_path'] . " $homedir";

        $junk = exec($cmdline, $quota_data, $return_code);
        if (($return_code == 0) && (count($quota_data) == 1)) {
           $quota = split("[[:blank:]]+", trim($quota_data[0]));
           return $this->_quotaHTML($quota[1] * 1024, $quota[2] * 1024);
        }

        $cmdline2 = $this->_params['quota_path'] . " -u $imap_user | " .
                    $this->_params['grep_path'] . " none";
        $junk2 = exec($cmdline2, $quota_data, $return_code);
        if (($return_code == 0)) {
           $quota = 0;
           return $this->_quotaHTML($quota);
        }

        return $this->_quotaError(_("Unable to retrieve quota"));
    }

}





Quoting AJ <aj at mindcrash.com>:

> Well, in playing with this, I made this change.. keeping in mind I have no
> idea
> what I am doing w/ PHP.  :)
>
> This is to lib/Quota/command.php
>
>     function quotaHTML()
>     {
>         global $imp;
>
>         $imap_user = strtolower($imp['user']);
>         $passwd_array = posix_getpwnam($imap_user);
>         $homedir = "/dev/hda2";
>         $cmdline = $this->_params['quota_path'] . " -u $imap_user | " .
>                    $this->_params['grep_path'] . " $homedir";
>         $junk = exec($cmdline, $quota_data, $return_code);
>         if (($return_code == 0) && (count($quota_data) == 1)) {
>            $quota = split("[[:blank:]]+", trim($quota_data[0]));
>            return $this->_quotaHTML($quota[1] * 1024, $quota[2] * 1024);
>         }
>         return $this->_quotaError(_("Unable to retrieve quota"));
>     }
>
> }
>
>
> Basically, I just hard coded in the filesystem where my /home folder is.
> This seems to now work, except that people who do not have quotas get the:
> "Unable to retrieve quota" messeage, where they should get the "NO LIMIT"
> message..  What would be the best way to fix this, but at the same time keep
> the quota error message enabled in case something goes wrong?
>




More information about the imp mailing list