Archive

Archive for August, 2009

PostfixAdmin + Roundcube = Postcube – UPDATE

August 3rd, 2009 HeXagon No comments

After the Postfix developers said F*@&  you to anyone who wants user management and the new ability to add plugins. Here is what I have come up with. Donations are welcome!

This installation assumes a few things:

1. You have PostfixAdmin already installed somewhere.  (While it is not required. It is nice to have since this doesn’t do domain admin.)
2. You are using the default database structure that comes with PostfixAdmin
3. You know what you are doing.  (You have to modify the postfix database.)
4. You are using the latest subversion release of RoundCube that supports plugins.

It also does have some limitations:

1. It only allows for add/removal/editing of  accounts under a single domain. The accounts that are being edited must match the domain of the logged in user.
2. I am not an excellent programmer. This version is a complete mess of code and may or may not break on you. If it does, please tell me how, when, where, and why and I will do my best to fix it.
3. You must manually edit the database to create the superuser that cannot be deleted.
4. This must be done perfectly or stuff will break.
5. It does not remove account data.
6. This also currently must be installed on the same server as the e-mail.


Installation Steps:

Altering the database structure + configs.

  1. Add a field to the mailbox table
    ALTER TABLE `mailbox` ADD `is_admin` TINYINT NOT NULL AFTER `active`;
  2. Create a table called quotacron
    CREATE TABLE IF NOT EXISTS `quotacron` ( `path` varchar(255) NOT NULL, `bytes` varchar(255) NOT NULL, `time` datetime NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  3. Modify dovecot and postfix configuation (Make sure to do this for ANY query that checks the database for a virtual user.
  4. Change the SQL string to use WHERE username = ‘%u’ AND active > 0′ instead of ‘WHERE username = ‘%u’ AND active = 1′
  5. Okay, now reload postfix and dovecot. The reason we did this is because a normal user will be active = 1 and is_admin = 1. The super user will have a value of 2 for both fields. This is so that we can make sure that if we grant another user admin, they cannot steal it.

Installing the Plug-in

  1. Download the Plugin
    http://hexhost.net/files/roundcube_plugin-manage_users.zip
  2. Unzip the plugin in the roundcube plugins directory
    unzip roundcube_plugin-manage_users.zip
  3. Edit roundcube configuration file (/path/to/roundcube/config/main.inc.php)
    $rcmail_config['plugins'] = Array('manage_users');
  4. Edit Plugin configuration file (/path/to/roundcube/plugins/config.inc.php)
    $rcmail_config['postfixadmin_user'] = 'postfix'; // Username to access the postfix database$rcmail_config['postfixadmin_pass'] = 'password'; // Password to access the postfix database$rcmail_config['postfixadmin_db'] = 'postfix'; // Name for the postfix database$rcmail_config['postfixadmin_host'] = 'localhost'; // Host for the postfix database$rcmail_config['physical_mail_path'] = '/path/to/virtual/mail/root/';  //Path to virtual Mailboxes (MUST HAVE BEGINNINGAND TRAILING SLASHES!
  5. If you want quota’s to work, Create a cron for the user that is owner of the virtual mailboxes. In it add the following line (editing it appropriately):
    */5 * * * * cd /path/to/roundcube/plugins/manage_users/; php quota_cron.php

Configuring the superuser

  1. Using SQL administrator change the is_admin and active field for your superuser to a value of 2 in the MySQL database. This will make the superuser irremovable and nobody can deactivate it without manually editing the database.

Using the plugin

  1. Log into RounCube interface as super-administrator
  2. Go to User Preferences
  3. Click on User Admin
  4. You can now edit users.

In the end

  • This probably will break. It might or might not work. Remember you HAVE to know what your doing. And, this is VERY alpha, and you are charged with knowing what you are doing!
VN:F [1.9.3_1094]
Rating: 9.6/10 (5 votes cast)
VN:F [1.9.3_1094]
Rating: +5 (from 5 votes)