SOURCES: imp-quota_hook.patch (NEW) - working _imp_quota_hook with example

baggins baggins at pld-linux.org
Tue Oct 14 20:10:45 CEST 2008


Author: baggins                      Date: Tue Oct 14 18:10:45 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- working _imp_quota_hook with example

---- Files affected:
SOURCES:
   imp-quota_hook.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/imp-quota_hook.patch
diff -u /dev/null SOURCES/imp-quota_hook.patch:1.1
--- /dev/null	Tue Oct 14 20:10:46 2008
+++ SOURCES/imp-quota_hook.patch	Tue Oct 14 20:10:40 2008
@@ -0,0 +1,48 @@
+diff -ur imp-h3-4.3/config/hooks.php.dist imp-h3-4.3-quota_hook/config/hooks.php.dist
+--- imp-h3-4.3/config/hooks.php.dist	2008-06-05 11:04:14.000000000 +0200
++++ imp-h3-4.3-quota_hook/config/hooks.php.dist	2008-10-12 01:35:41.000000000 +0200
+@@ -505,12 +505,12 @@
+ //               second: maximum disk space (in bytes)
+ //               In case of an error, return PEAR::raiseError()
+ if (!function_exists('_imp_hook_quota')) {
+-    function _imp_hook_quota($params = null)
++    function _imp_hook_quota($command = null, $fs = null)
+     {
+         $host = $_SESSION['imp']['server'];
+         $user = $_SESSION['imp']['user'];
+         $pass = Auth::getCredential('password');
+-        $command = $params[0];
++	$quota = array(0, 0, 0);
+ 
+         $session = ssh2_connect($host);
+         if (!$session) {
+@@ -524,7 +524,13 @@
+         $stream = ssh2_exec($session, $command, false);
+         stream_set_blocking($stream, true);
+ 
+-        $quota = preg_split('/\s+/', trim(stream_get_contents($stream)), 2);
++	$patt = '/.*'.preg_quote($fs, '/').'.*/';
++	foreach (preg_split('/\n/', stream_get_contents($stream)) as $line) {
++		if (preg_match($patt, $line)) {
++			$quota = preg_split('/\s+/', trim($line));
++			break;
++		}
++	}
+         return array($quota[1] * 1024, $quota[2] * 1024);
+     }
+ }
+diff -ur imp-h3-4.3/config/servers.php.dist imp-h3-4.3-quota_hook/config/servers.php.dist
+--- imp-h3-4.3/config/servers.php.dist	2008-07-03 15:06:15.000000000 +0200
++++ imp-h3-4.3-quota_hook/config/servers.php.dist	2008-10-12 03:19:36.000000000 +0200
+@@ -237,6 +237,11 @@
+     'smtpport' => 25,
+     'realm' => '',
+     'preferred' => '',
++//    'quota' => array(
++//        'driver' => 'hook',
++//	'params' => array('command' => '/usr/bin/quota',
++//       			  'fs' => '/dev/hdv2'),
++//    ),
+ );
+ 
+ $servers['cyrus'] = array(
================================================================


More information about the pld-cvs-commit mailing list