[imp] Question about IMAP Quota on Redhat 7.3 using sudo
Santiesteban Sifontes
alietss@yahoo.com
Sun, 2 Jun 2002 15:41:46 -0700 (PDT)
Hi all:
I'm testing the imp_show_quota , I've already added
the entry to sudo to permit apache execute quota
command but all I receive is "Quota not available" I
test the variables they're ok the function exec is
receiving all parameters ok, but it's not returning
nothing I think the problem is my integration of
apache - sudo- quota.
Any ideas??
Bye Aliet
>
> // See the 'imp_show_quota' function below for an
> example.
> $conf['hooks']['quota'] = 'imp_show_quota';
>
> /* Gets the quota usage for a user. */
> /* This requires a modified "quota" command that
> allows the httpd server */
> /* account to get quotas for other users... It also
> requires that your */
> /* web server and imap server be the same server or
> at least have shared */
> /* authentication and file servers (e.g. via
> NIS/NFS) */
> if (!function_exists('imp_show_quota')) {
> function imp_show_quota ($imp) {
> $imap_admin = $imp['user'];
> $passwd_array = posix_getpwnam($imap_admin);
> $homedir = split("/", $passwd_array['dir']);
> $realname = split(",",
> $passwd_array['gecos']);
>
> $quota_html = '<table width="100%"
> border="0" cellpadding="0" cellspacing="0"><tr><td
> class="item"><table border="0" cellspacing="0"
> cellpadding="0" width="100%"><tr>';
> $quota_html .= '<td align="left"
> class="header">Login: ' . $realname[0] . " (" .
> $imap_admin . ")" . '</td>';
>
> $junk = exec("sudo /usr/bin/quota -u
> $imap_admin | grep /dev/md1",
> $quota_data,$return_code);
> if ($return_code == 0 && count($quota_data)
> == 1) {
> $splitted = split("[[:blank:]]+",
> trim($quota_data[0]));
> $taken = $splitted[1] / 1000 ; $total =
> $splitted[2] / 1000 ;
> $percent = $taken * 100 / $total ;
> if ($percent >= 90) {
> $color = '#FF0000';
> } elseif ($percent >= 80) {
> $color = '#FCE30D';
> } else {
> $color = '#339933';
> }
> $quota_html .= '<td align="center"
> class="header">';
> $quota_html .= sprintf("<font
> size=-2>Quota on /%s: %.1fMB/%.1fMB
> (%.1f%%)</font>", $homedir[1], $taken, $total,
> $percent);
> } else {
> $quota_html .= '<td align="center"
> class="header">';
> $quota_html .= "Quota not available";
> }
> $quota_html .= '</td><td width="30"
> class="header" align="right"><font
> size="-3">0%</font></td><td width="200"
> class="header">';
> $quota_html .= '<table width="100%"><tr><td
> bgcolor="#ccccff"><div style="height:6px; width:'.
> sprintf("%.1f%%", $percent). '; font-size:3px;
> background-color:'.$color.'">';
> $quota_html .=
> '</div></td></tr></table></td><td width="30"
> class="header" align="left"><font
>
size="-3">100%</font></td></tr></table></td></tr></table>';
> return $quota_html;
> }
> }
>
>
> Arie Kraak jr.
>
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com