Ok
vacation:
I created a new driver, based on the customsql driver found in horde/vacation/lib/Driver.
Here the "patch -u":
Code:
/vacation/lib/Driver# diff -u customsql.php ispcp.php
--- customsql.php 2009-01-29 17:02:55.000000000 +0100
+++ ispcp.php 2009-06-19 01:04:57.000000000 +0200
@@ -13,7 +13,7 @@
* @since Vacation 3.1
* @package Vacation
*/
-class Vacation_Driver_customsql extends Vacation_Driver {
+class Vacation_Driver_ispcp extends Vacation_Driver {
/**
* SQL connection object.
@@ -35,7 +35,7 @@
* @param string $user A user name.
* @param array $params Configuration parameters for the backend.
*/
- function Vacation_Driver_customsql($user, $params = array())
+ function Vacation_Driver_ispcp($user, $params = array())
{
$params = Horde::getDriverConfig('server', 'sql');
parent::Vacation_Driver($user, $params);
@@ -91,6 +91,8 @@
if ($result !== DB_OK) {
return PEAR::raiseError(_("An unknown error occured while enabling the vacation notice."));
}
+ # ispCP Update...
+ $this->send_request();
}
/**
@@ -135,6 +137,9 @@
if ($result !== DB_OK) {
return PEAR::raiseError(_("An unknown error occured while enabling the vacation notice."));
}
+
+ # ispCP Update...
+ $this->send_request();
}
/**
@@ -230,7 +235,12 @@
{
if ($this->_realm === 'default' ||
$this->_realm === '') {
- return $this->_user;
+ $userid = Auth::getAuth();
+ return $userid;
} else {
return $this->_user . '@' . $this->_realm;
}
@@ -308,4 +318,83 @@
$this->_connected = true;
}
+# ispcp Funktionen
+function read_line(&$socket) {
+ $ch = '';
+ $line = '';
+ do {
+ $ch = socket_read($socket,1);
+ $line = $line . $ch;
+ } while($ch != "\r" && $ch != "\n");
+ return $line;
+}
+
+function send_request() {
+
+# global $Version;
+ $Version = 'ispCP-Horde-Passwd';
+
+ $code = 999;
+
+ @$socket = socket_create (AF_INET, SOCK_STREAM, 0);
+ if ($socket < 0) {
+ $errno = "socket_create() failed.\n";
+ return $errno;
+ }
+
+ @$result = socket_connect ($socket, '127.0.0.1', 9876);
+ if ($result == FALSE) {
+ $errno = "socket_connect() failed.\n";
+ return $errno;
+ }
+
+ /* read one line with welcome string */
+ $out = $this->read_line($socket);
+
+ list($code) = explode(' ', $out);
+ if ($code == 999) {
+ return $out;
+ }
+
+ /* send hello query */
+ $query = "helo $Version\r\n";
+ socket_write ($socket, $query, strlen ($query));
+
+ /* read one line with helo answer */
+ $out = $this->read_line($socket);
+
+ list($code) = explode(' ', $out);
+ if ($code == 999) {
+ return $out;
+ }
+
+ /* send reg check query */
+ $query = "execute query\r\n";
+ socket_write ($socket, $query, strlen ($query));
+ /* read one line key replay */
+ $execute_reply = $this->read_line($socket);
+
+ list($code) = explode(' ', $execute_reply);
+ if ($code == 999) {
+ return $out;
+ }
+
+ /* send quit query */
+ $quit_query = "bye\r\n";
+ socket_write ($socket, $quit_query, strlen ($quit_query));
+ /* read quit answer */
+ $quit_reply = $this->read_line($socket);
+
+ list($code) = explode(' ', $quit_reply);
+ if ($code == 999) {
+ return $out;
+ }
+
+ list($answer) = explode(' ', $execute_reply);
+
+ socket_close ($socket);
+
+ return $answer;
+}
+
}
the configuration (config/conf.php) is simple, but you need a sql users who have access to some fields in the ispcp db (table mail_users) - in my case I gave the needed permissions to the horde mysql user (select and update to the table - or only the needes fields - depends on you).
part of the config:
Code:
$conf['server']['params']['default']['query_set'] = 'UPDATE `ispcp`.`mail_users` SET `mail_auto_respond_text` = \M, `mail_auto_respond` = 1, `status` = \'change\' WHERE mail_addr = \U AND `mail_pass` = \P';
$conf['server']['params']['default']['query_unset'] = 'UPDATE `ispcp`.`mail_users` SET `mail_auto_respond` = 0, `status` = \'change\' WHERE mail_addr = \U AND `mail_pass` = \P';
$conf['server']['params']['default']['query_get'] = "SELECT IF(`mail_auto_respond`=1,'Y', 'N') AS `vacation`, `mail_auto_respond_text` AS `message`, '' AS `subject` FROM `ispcp`.`mail_users` WHERE mail_addr = \U AND `mail_pass` = \P";
$conf['server']['params']['default']['driverconfig'] = 'horde';
$conf['server']['params']['default']['hordeauth'] = false;
$conf['server']['params']['encryption'] = 'plain';
$conf['server']['params']['show_encryption'] = false;
$conf['server']['driver'] = 'ispcp';
***
Passwd:
very similar the password module.
a new Driver, based on the sql.php:
Code:
/passwd/lib/Driver# diff -u sql.php ispcp.php
--- sql.php 2009-01-06 16:25:23.000000000 +0100
+++ ispcp.php 2009-06-19 00:57:50.000000000 +0200
@@ -17,7 +17,7 @@
* @author Eric Jon Rostetter <eric.rostetter@physics.utexas.edu>
* @package Passwd
*/
-class Passwd_Driver_sql extends Passwd_Driver {
+class Passwd_Driver_ispcp extends Passwd_Driver {
/**
* SQL connection object.
@@ -38,7 +38,7 @@
*
* @param array $params A hash containing connection parameters.
*/
- function Passwd_Driver_sql($params = array())
+ function Passwd_Driver_ispcp($params = array())
{
if (isset($params['phptype'])) {
$this->_params['phptype'] = $params['phptype'];
@@ -172,6 +172,9 @@
return $result;
}
+ # ispCP Update...
+ $this->send_request();
+
return true;
}
@@ -255,4 +258,85 @@
return $this->_modify($username, $new_password);
}
+
+# ispcp Funktionen
+function read_line(&$socket) {
+ $ch = '';
+ $line = '';
+ do {
+ $ch = socket_read($socket,1);
+ $line = $line . $ch;
+ } while($ch != "\r" && $ch != "\n");
+ return $line;
+}
+
+function send_request() {
+
+# global $Version;
+ $Version = 'ispCP-Horde-Passwd';
+
+ $code = 999;
+
+ @$socket = socket_create (AF_INET, SOCK_STREAM, 0);
+ if ($socket < 0) {
+ $errno = "socket_create() failed.\n";
+ return $errno;
+ }
+
+ @$result = socket_connect ($socket, '127.0.0.1', 9876);
+ if ($result == FALSE) {
+ $errno = "socket_connect() failed.\n";
+ return $errno;
+ }
+
+ /* read one line with welcome string */
+ $out = $this->read_line($socket);
+
+ list($code) = explode(' ', $out);
+ if ($code == 999) {
+ return $out;
+ }
+
+ /* send hello query */
+ $query = "helo $Version\r\n";
+ socket_write ($socket, $query, strlen ($query));
+
+ /* read one line with helo answer */
+ $out = $this->read_line($socket);
+
+ list($code) = explode(' ', $out);
+ if ($code == 999) {
+ return $out;
+ }
+
+ /* send reg check query */
+ $query = "execute query\r\n";
+ socket_write ($socket, $query, strlen ($query));
+ /* read one line key replay */
+ $execute_reply = $this->read_line($socket);
+
+ list($code) = explode(' ', $execute_reply);
+ if ($code == 999) {
+ return $out;
+ }
+
+ /* send quit query */
+ $quit_query = "bye\r\n";
+ socket_write ($socket, $quit_query, strlen ($quit_query));
+ /* read quit answer */
+ $quit_reply = $this->read_line($socket);
+
+ list($code) = explode(' ', $quit_reply);
+ if ($code == 999) {
+ return $out;
+ }
+
+ list($answer) = explode(' ', $execute_reply);
+
+ socket_close ($socket);
+
+ return $answer;
+}
+
+
}
and the backends-config:
Code:
$backends['ispcp'] = array (
'name' => 'ispCP Authentication',
'preferred' => '',
'password policy' => array(
'minLength' => 6,
'maxLength' => 16,
'maxSpace' => 0,
'minUpper' => 0,
'minLower' => 1,
'minNumeric' => 1,
'minSymbols' => 0
),
'driver' => 'ispcp',
'params' => array_merge($conf['sql'],
array('database' => 'ispcp',
'table' => 'mail_users',
'user_col' => 'mail_addr',
'pass_col' => 'mail_pass',
'show_encryption' => false,
'encryption' => 'plain',
'query_modify' => "UPDATE `mail_users` SET `mail_pass` = %p, `status` = 'change' WHERE mail_addr = %u",
)),
);
Of cource: the horde mysql user needs update permission on the mail_pass field :-)
There you go.
Biggest difference to the (custom)sql drivers is: run the request manager after changing the database.
/J