Roundcubemail + PostfixAdmin - Troca de Senha com mais opções de segurança

Esse passo a passo foi utilizado em uma distribuição CentOS release 6.6 (Final)

Adicionamos um patch para o Roundcube permitir atualizar a senha com algumas restrições de segurança como:

- REQUER DIGITOS,
- REQUER CARACTERES ALFABETICOS
- REQUER CARACTERES PEQUENOS
- REQUER CARACTERES MAIUSCULOS
- REQUER NAO ALFABETICOS E NAO NUMERICOS
- NAO PODE REPETIR MAIS DE 3 VEZES SEGUIDAS O MESMO CARACTER

Opções do arquivo ../webmail_dir/plugins/password/config.inc.php

// Determine whether current password is required to change password.
$config['password_confirm_current'] = true;

// Require the new password to be a certain length.
$config['password_minimum_length'] = 6;


// Requirements for new password:
// Require digits - REQUER DIGITOS
$rcmail_config['password_require_digit'] = true;

// Require alphabetical - REQUER CARACTERES ALFABETICOS
$rcmail_config['password_require_alpha'] = true;

// Require lower - REQUER CARACTERES PEQUENOS
$rcmail_config['password_require_lower'] = true;

// Require capitals - REQUER CARACTERES MAIUSCULOS
$rcmail_config['password_require_upper'] = true;

// Require non-alphabetical and non-digit - REQUER NAO ALFABETICOS E NAO NUMERICOS
$rcmail_config['password_require_nonalpha'] = true;

// Require no repeat 3 times in a row  - NAO PODE REPETIR MAIS DE 3 VEZES SEGUIDAS O MESMO CARACTER
$rcmail_config['password_require_norepeat'] = true;





Existe um plugin para o Roundcubemail chamado password. Com ele é possível utilizar o próprio roundcube para modificar as senhas no banco de dados do POSTFIXADMIN.

Também é possível utilizar alguns parâmetros para reforçar a segurança na política de troca dessas senhas:

para isso configuramos o roundcubemail para usar o plugin "password" no arquivo de configuração do roundcubemail:

1- No arquivo de configuração do roundcubemail, trocar

$rcmail_config['plugins'] = array();

2- por

$rcmail_config['plugins'] = array(password);

3 – Tenha certeza que o diretório do plugin esteja com o caminho e nome corretos: ../webmail_dir/plugins/password

4 – Configurar o password do banco e configurar o plugin: .../webmail_dir/plugins/password/config.inc.php.

5 – Altere a opção de driver do plugin para:

$rcmail_config['password_driver'] = 'sql';

6 - Seguir o Diff abaixo e incluir as alterações nos arquivos do plugin password:

diff -ur password.old/config.inc.php.dist password/config.inc.php.dist
--- password.old/config.inc.php.dist    2011-11-15 14:50:30.000000000 +0400
+++ password/config.inc.php.dist        2012-01-23 14:18:05.372093621 +0400
@@ -14,9 +14,19 @@
 // set to blank to allow passwords of any length
 $rcmail_config['password_minimum_length'] = 0;

-// Require the new password to contain a letter and punctuation character
-// Change to false to remove this check.
+// Requrements for new password:
+// Require digits
+$rcmail_config['password_require_digit'] = false;
+// Require alphabetical
+$rcmail_config['password_require_alpha'] = false;
+// Require lower
+$rcmail_config['password_require_lower'] = false;
+// Require capitals
+$rcmail_config['password_require_upper'] = false;
+// Require non-alphabetical and non-digit
 $rcmail_config['password_require_nonalpha'] = false;
+// Require no repeat 3 times in a row
+$rcmail_config['password_require_norepeat'] = false;

 // Enables logging of password changes into logs/password
 $rcmail_config['password_log'] = false;
diff -ur password.old/localization/en_US.inc password/localization/en_US.inc
--- password.old/localization/en_US.inc 2010-02-25 13:56:01.000000000 +0300
+++ password/localization/en_US.inc     2012-01-23 14:14:41.191104442 +0400
@@ -15,7 +15,12 @@
 $messages['connecterror'] = 'Could not save new password. Connection error.';
 $messages['internalerror'] = 'Could not save new password.';
 $messages['passwordshort'] = 'Password must be at least $length characters long.';
-$messages['passwordweak'] = 'Password must include at least one number and one punctuation character.';
+$messages['passwordweak_digit'] = 'Password must include at least one number.';
+$messages['passwordweak_alpha'] = 'Password must include at least one latin character.';
+$messages['passwordweak_lower'] = 'Password must include at least one lower latin character.';
+$messages['passwordweak_upper'] = 'Password must include at least one upper latin character.';
+$messages['passwordweak_nonalpha'] = 'Password must include at least one special character.';
+$messages['passwordweak_norepeat'] = 'Password must not contain more than two identical characters in a row.';
 $messages['passwordforbidden'] = 'Password contains forbidden characters.';

 ?>
diff -ur password.old/localization/ru_RU.inc password/localization/ru_RU.inc
--- password.old/localization/ru_RU.inc 2011-01-12 21:32:31.000000000 +0300
+++ password/localization/ru_RU.inc     2012-01-23 14:14:53.799412527 +0400
@@ -29,7 +29,12 @@
 $messages['connecterror'] = 'Не ЌПгу сПхраМОть МПвый парПль. ОшОбка сПеЎОМеМОя.';
 $messages['internalerror'] = 'Не ЌПгу сПхраМОть МПвый парПль.';
 $messages['passwordshort'] = 'ПарПль ЎПлжеМ быть ЎлОМПй как ЌОМОЌуЌ $length сОЌвПлПв.';
-$messages['passwordweak'] = 'ПарПль ЎПлжеМ включать в себя как ЌОМОЌуЌ ПЎМу цОфру О ПЎОМ зМак пуМктуацОО.';
+$messages['passwordweak_digit'] = 'ПарПль ЎПлжеМ включать в себя как ЌОМОЌуЌ ПЎМу цОфру.';
+$messages['passwordweak_alpha'] = 'ПарПль ЎПлжеМ включать в себя как ЌОМОЌуЌ ПЎОМ латОМскОй сОЌвПл.';
+$messages['passwordweak_lower'] = 'ПарПль ЎПлжеМ включать в себя как ЌОМОЌуЌ ПЎОМ латОМскОй сОЌвПл в МОжМеЌ регОстре.';
+$messages['passwordweak_upper'] = 'ПарПль ЎПлжеМ включать в себя как ЌОМОЌуЌ ПЎОМ латОМскОй сОЌвПл в верхМеЌ регОстре.';
+$messages['passwordweak_nonalpha'] = 'ПарПль ЎПлжеМ включать в себя как ЌОМОЌуЌ ПЎОМ спецОальМый сОЌвПл.';
+$messages['passwordweak_norepeat'] = 'ПарПль Ме ЎПлжеМ сПЎержать пПвтПряющОхся бПлее Ўвух раз пПЎряЎ сОЌвПлПв.';
 $messages['passwordforbidden'] = 'ПарПль сПЎержОт МеЎПпустОЌые сОЌвПлы.';

 ?>
diff -ur password.old/password.php password/password.php
--- password.old/password.php   2011-11-15 14:50:30.000000000 +0400
+++ password/password.php       2011-11-18 16:31:23.000000000 +0400
@@ -81,7 +81,12 @@

         $confirm = $rcmail->config->get('password_confirm_current');
         $required_length = intval($rcmail->config->get('password_minimum_length'));
-        $check_strength = $rcmail->config->get('password_require_nonalpha');
+        $check_strength_digit = $rcmail->config->get('password_require_digit');
+        $check_strength_alpha = $rcmail->config->get('password_require_alpha');
+        $check_strength_lower = $rcmail->config->get('password_require_lower');
+        $check_strength_upper = $rcmail->config->get('password_require_upper');
+        $check_strength_nonalpha = $rcmail->config->get('password_require_nonalpha');
+        $check_strength_norepeat = $rcmail->config->get('password_require_norepeat');

         if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd'])) {
             $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
@@ -123,8 +128,23 @@
                 $rcmail->output->command('display_message', $this->gettext(
                        array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error');
             }
-            else if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) {
-                $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error');
+            else if ($check_strength_digit && !preg_match("/[0-9]/", $newpwd)) {
+                $rcmail->output->command('display_message', $this->gettext('passwordweak_digit'), 'error');
+            }
+            else if ($check_strength_alpha && !preg_match("/[a-zA-Z]/", $newpwd)) {
+                $rcmail->output->command('display_message', $this->gettext('passwordweak_alpha'), 'error');
+            }
+            else if ($check_strength_lower && !preg_match("/[a-z]/", $newpwd)) {
+                $rcmail->output->command('display_message', $this->gettext('passwordweak_lower'), 'error');
+            }
+            else if ($check_strength_upper && !preg_match("/[A-Z]/", $newpwd)) {
+                $rcmail->output->command('display_message', $this->gettext('passwordweak_upper'), 'error');
+            }
+            else if ($check_strength_nonalpha && !preg_match("/[^0-9a-zA-Z]/", $newpwd)) {
+                $rcmail->output->command('display_message', $this->gettext('passwordweak_nonalpha'), 'error');
+            }
+            else if ($check_strength_norepeat && preg_match("/(.)\\1\\1/", $newpwd)) {
+                $rcmail->output->command('display_message', $this->gettext('passwordweak_norepeat'), 'error');
             }
             // password is the same as the old one, do nothing, return success
             else if ($sespwd == $newpwd) {



7 - A grande sacada para funcionar com SCHEMA postfixadmin de banco de dados MySQL é alterar a function que é criada no banco:
Use a function abaixo ao invés da descrita na README:

DELIMITER $$
CREATE FUNCTION update_passwd (oldpass text, cryptpass text, user text) RETURNS text
        MODIFIES SQL DATA
    BEGIN
        DECLARE currentsalt varchar(20);
        DECLARE error text;
        SET error = '';
        SELECT substring_index(substr(password,4),_latin1'$',1) INTO currentsalt FROM postfixadmin.mailbox WHERE username=user;
        SET currentsalt=concat('$1$',currentsalt);
        SELECT '' INTO error FROM postfixadmin.mailbox WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
        UPDATE postfixadmin.mailbox SET password=cryptpass WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
        RETURN error;
    END;
$$
DELIMITER ;



8 - Na opção de parâmetros deve-se incluir a opção de trazer a senha antiga para ser enviada a FUNCTION SQL que tratará de alterar a senha na tabela mailbox do DATABASE postfixadmin  no banco de dados MYSQL.

Alterar de
// Default: "SELECT update_passwd(%c, %u)"
$config['password_query'] = 'SELECT update_passwd(%c, %u)';

Para:
// Default: "SELECT update_passwd(%c, %u)"
     90 $config['password_query'] = 'SELECT update_passwd(%o, %c, %u)';


9 - A configuração do DSN só foi necessária para o roundcube achar a função update_passwd no banco de dados do postfixadmin, para isso alteramos a string abaixo:
$config['password_db_dsn'] = 'mysql://usuario:senha@localhost/postfixadmin_db';

10 - A configuração de criptografia utilizada é:
$config['password_crypt_hash'] = 'md5';


Abaixo: segue o arquivo de configuração utilizado no plugin do password:
###################################################################
<?php

// Password Plugin options
// -----------------------
// A driver to use for password change. Default: "sql".
// See README file for list of supported driver names.
$config['password_driver'] = 'sql';

// Determine whether current password is required to change password.
// Default: false.
$config['password_confirm_current'] = true;

// Require the new password to be a certain length.
$config['password_minimum_length'] = 6;


// Requirements for new password:
// Require digits
$rcmail_config['password_require_digit'] = true;

// Require alphabetical
$rcmail_config['password_require_alpha'] = true;
// Require lower
$rcmail_config['password_require_lower'] = true;
// Require capitals
$rcmail_config['password_require_upper'] = true;
// Require non-alphabetical and non-digit
$rcmail_config['password_require_nonalpha'] = true;
// Require no repeat 3 times in a row
$rcmail_config['password_require_norepeat'] = true;



// Require the new password to contain a letter and punctuation character
// Change to false to remove this check.
$config['password_require_nonalpha'] = false;


// Enables logging of password changes into logs/password
$config['password_log'] = false;

// Comma-separated list of login exceptions for which password change
// will be not available (no Password tab in Settings)
$config['password_login_exceptions'] = null;

// Array of hosts that support password changing. Default is NULL.
// Listed hosts will feature a Password option in Settings; others will not.
// Example:
//$config['password_hosts'] = array('mail.example.com', 'mail2.example.org');
$config['password_hosts'] = null;

// Enables saving the new password even if it matches the old password. Useful
// for upgrading the stored passwords after the encryption scheme has changed.
$config['password_force_save'] = false;


// SQL Driver options
// ------------------
// PEAR database DSN for performing the query. By default
// Roundcube DB settings are used.
$config['password_db_dsn'] = 'mysql://usuario:senha@localhost/postfixadmin_db';




// The SQL query used to change the password.
// The query can contain the following macros that will be expanded as follows:
//      %p is replaced with the plaintext new password
//      %c is replaced with the crypt version of the new password, MD5 if available
//         otherwise DES. More hash function can be enabled using the password_crypt_hash
//         configuration parameter.
//      %D is replaced with the dovecotpw-crypted version of the new password
//      %o is replaced with the password before the change
//      %n is replaced with the hashed version of the new password
//      %q is replaced with the hashed password before the change
//      %h is replaced with the imap host (from the session info)
//      %u is replaced with the username (from the session info)
//      %l is replaced with the local part of the username
//         (in case the username is an email address)
//      %d is replaced with the domain part of the username
//         (in case the username is an email address)
// Escaping of macros is handled by this module.
// Default: "SELECT update_passwd(%c, %u)"
$config['password_query'] = 'SELECT update_passwd(%o, %c, %u)';

// By default the crypt() function which is used to create the '%c'
// parameter uses the md5 algorithm. To use different algorithms
// you can choose between: des, md5, blowfish, sha256, sha512.
// Before using other hash functions than des or md5 please make sure
// your operating system supports the other hash functions.
$config['password_crypt_hash'] = 'md5';

// By default domains in variables are using unicode.
// Enable this option to use punycoded names
$config['password_idn_ascii'] = false;

// Path for dovecotpw (if not in $PATH)
// $config['password_dovecotpw'] = '/usr/local/sbin/dovecotpw';

// Dovecot method (dovecotpw -s 'method')
$config['password_dovecotpw_method'] = 'CRAM-MD5';

// Enables use of password with crypt method prefix in %D, e.g. {MD5}$1$LUiMYWqx$fEkg/ggr/L6Mb2X7be4i1/
$config['password_dovecotpw_with_method'] = false;

// Using a password hash for %n and %q variables.
// Determine which hashing algorithm should be used to generate
// the hashed new and current password for using them within the
// SQL query. Requires PHP's 'hash' extension.
$config['password_hash_algorithm'] = 'sha1';

// You can also decide whether the hash should be provided
// as hex string or in base64 encoded format.
$config['password_hash_base64'] = false;

// Iteration count parameter for Blowfish-based hashing algo.
// It must be between 4 and 31. Default: 12.
// Be aware, the higher the value, the longer it takes to generate the password hashes.
$config['password_blowfish_cost'] = 12;


// Poppassd Driver options
// -----------------------
// The host which changes the password
$config['password_pop_host'] = 'localhost';

// TCP port used for poppassd connections
$config['password_pop_port'] = 106;


// SASL Driver options
// -------------------
// Additional arguments for the saslpasswd2 call
$config['password_saslpasswd_args'] = '';


// LDAP and LDAP_SIMPLE Driver options
// -----------------------------------
// LDAP server name to connect to.
// You can provide one or several hosts in an array in which case the hosts are tried from left to right.
// Exemple: array('ldap1.exemple.com', 'ldap2.exemple.com');
// Default: 'localhost'
$config['password_ldap_host'] = 'localhost';

// LDAP server port to connect to
// Default: '389'
$config['password_ldap_port'] = '389';

// TLS is started after connecting
// Using TLS for password modification is recommanded.
// Default: false
$config['password_ldap_starttls'] = false;

// LDAP version
// Default: '3'
$config['password_ldap_version'] = '3';

// LDAP base name (root directory)
// Exemple: 'dc=exemple,dc=com'
$config['password_ldap_basedn'] = 'dc=exemple,dc=com';

// LDAP connection method
// There is two connection method for changing a user's LDAP password.
// 'user': use user credential (recommanded, require password_confirm_current=true)
// 'admin': use admin credential (this mode require password_ldap_adminDN and password_ldap_adminPW)
// Default: 'user'
$config['password_ldap_method'] = 'user';

// LDAP Admin DN
// Used only in admin connection mode
// Default: null
$config['password_ldap_adminDN'] = null;

// LDAP Admin Password
// Used only in admin connection mode
// Default: null
$config['password_ldap_adminPW'] = null;

// LDAP user DN mask
// The user's DN is mandatory and as we only have his login,
// we need to re-create his DN using a mask
// '%login' will be replaced by the current roundcube user's login
// '%name' will be replaced by the current roundcube user's name part
// '%domain' will be replaced by the current roundcube user's domain part
// '%dc' will be replaced by domain name hierarchal string e.g. "dc=test,dc=domain,dc=com"
// Exemple: 'uid=%login,ou=people,dc=exemple,dc=com'
$config['password_ldap_userDN_mask'] = 'uid=%login,ou=people,dc=exemple,dc=com';

// LDAP search DN
// The DN roundcube should bind with to find out user's DN
// based on his login. Note that you should comment out the default
// password_ldap_userDN_mask setting for this to take effect.
// Use this if you cannot specify a general template for user DN with
// password_ldap_userDN_mask. You need to perform a search based on
// users login to find his DN instead. A common reason might be that
// your users are placed under different ou's like engineering or
// sales which cannot be derived from their login only.
$config['password_ldap_searchDN'] = 'cn=roundcube,ou=services,dc=example,dc=com';

// LDAP search password
// If password_ldap_searchDN is set, the password to use for
// binding to search for user's DN. Note that you should comment out the default
// password_ldap_userDN_mask setting for this to take effect.
// Warning: Be sure to set approperiate permissions on this file so this password
// is only accesible to roundcube and don't forget to restrict roundcube's access to
// your directory as much as possible using ACLs. Should this password be compromised
// you want to minimize the damage.
$config['password_ldap_searchPW'] = 'secret';

// LDAP search base
// If password_ldap_searchDN is set, the base to search in using the filter below.
// Note that you should comment out the default password_ldap_userDN_mask setting
// for this to take effect.
$config['password_ldap_search_base'] = 'ou=people,dc=example,dc=com';

// LDAP search filter
// If password_ldap_searchDN is set, the filter to use when
// searching for user's DN. Note that you should comment out the default
// password_ldap_userDN_mask setting for this to take effect.
// '%login' will be replaced by the current roundcube user's login
// '%name' will be replaced by the current roundcube user's name part
// '%domain' will be replaced by the current roundcube user's domain part
// '%dc' will be replaced by domain name hierarchal string e.g. "dc=test,dc=domain,dc=com"
// Example: '(uid=%login)'
// Example: '(&(objectClass=posixAccount)(uid=%login))'
$config['password_ldap_search_filter'] = '(uid=%login)';

// LDAP password hash type
// Standard LDAP encryption type which must be one of: crypt,
// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, ad or clear.
// Please note that most encodage types require external libraries
// to be included in your PHP installation, see function hashPassword in drivers/ldap.php for more info.
// Default: 'crypt'
$config['password_ldap_encodage'] = 'crypt';

// LDAP password attribute
// Name of the ldap's attribute used for storing user password
// Default: 'userPassword'
$config['password_ldap_pwattr'] = 'userPassword';

// LDAP password force replace
// Force LDAP replace in cases where ACL allows only replace not read
// See http://pear.php.net/package/Net_LDAP2/docs/latest/Net_LDAP2/Net_LDAP2_Entry.html#methodreplace
// Default: true
$config['password_ldap_force_replace'] = true;

// LDAP Password Last Change Date
// Some places use an attribute to store the date of the last password change
// The date is meassured in "days since epoch" (an integer value)
// Whenever the password is changed, the attribute will be updated if set (e.g. shadowLastChange)
$config['password_ldap_lchattr'] = '';

// LDAP Samba password attribute, e.g. sambaNTPassword
// Name of the LDAP's Samba attribute used for storing user password
$config['password_ldap_samba_pwattr'] = '';

// LDAP Samba Password Last Change Date attribute, e.g. sambaPwdLastSet
// Some places use an attribute to store the date of the last password change
// The date is meassured in "seconds since epoch" (an integer value)
// Whenever the password is changed, the attribute will be updated if set
$config['password_ldap_samba_lchattr'] = '';


// DirectAdmin Driver options
// --------------------------
// The host which changes the password
// Use 'ssl://host' instead of 'tcp://host' when running DirectAdmin over SSL.
// The host can contain the following macros that will be expanded as follows:
//     %h is replaced with the imap host (from the session info)
//     %d is replaced with the domain part of the username (if the username is an email)
$config['password_directadmin_host'] = 'tcp://localhost';

// TCP port used for DirectAdmin connections
$config['password_directadmin_port'] = 2222;


// vpopmaild Driver options
// -----------------------
// The host which changes the password
$config['password_vpopmaild_host'] = 'localhost';

// TCP port used for vpopmaild connections
$config['password_vpopmaild_port'] = 89;


// cPanel Driver options
// --------------------------
// The cPanel Host name
$config['password_cpanel_host'] = 'host.domain.com';

// The cPanel admin username
$config['password_cpanel_username'] = 'username';

// The cPanel admin password
$config['password_cpanel_password'] = 'password';

// The cPanel port to use
$config['password_cpanel_port'] = 2087;


// XIMSS (Communigate server) Driver options
// -----------------------------------------
// Host name of the Communigate server
$config['password_ximss_host'] = 'mail.example.com';

// XIMSS port on Communigate server
$config['password_ximss_port'] = 11024;


// chpasswd Driver options
// ---------------------
// Command to use
$config['password_chpasswd_cmd'] = 'sudo /usr/sbin/chpasswd 2> /dev/null';


// XMail Driver options
// ---------------------
$config['xmail_host'] = 'localhost';
$config['xmail_user'] = 'YourXmailControlUser';
$config['xmail_pass'] = 'YourXmailControlPass';
$config['xmail_port'] = 6017;


// hMail Driver options
// -----------------------
// Remote hMailServer configuration
// true:  HMailserver is on a remote box (php.ini: com.allow_dcom = true)
// false: Hmailserver is on same box as PHP
$config['hmailserver_remote_dcom'] = false;
// Windows credentials
$config['hmailserver_server'] = array(
    'Server' => 'localhost', // hostname or ip address
    'Username' => 'administrator', // windows username
    'Password' => 'password' // windows user password
);


// Virtualmin Driver options
// -------------------------
// Username format:
// 0: username@domain
// 1: username%domain
// 2: username.domain
// 3: domain.username
// 4: username-domain
// 5: domain-username
// 6: username_domain
// 7: domain_username
$config['password_virtualmin_format'] = 0;


// pw_usermod Driver options
// --------------------------
// Use comma delimited exlist to disable password change for users
// Add the following line to visudo to tighten security:
// www  ALL=NOPASSWORD: /usr/sbin/pw
$config['password_pw_usermod_cmd'] = 'sudo /usr/sbin/pw usermod -h 0 -n';


// DBMail Driver options
// -------------------
// Additional arguments for the dbmail-users call
$config['password_dbmail_args'] = '-p sha512';


// Expect Driver options
// ---------------------
// Location of expect binary
$config['password_expect_bin'] = '/usr/bin/expect';

// Location of expect script (see helpers/passwd-expect)
$config['password_expect_script'] = '';

// Arguments for the expect script. See the helpers/passwd-expect file for details.
// This is probably a good starting default:
//   -telent -host localhost -output /tmp/passwd.log -log /tmp/passwd.log
$config['password_expect_params'] = '';


// smb Driver options
// ---------------------
// Samba host (default: localhost)
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
$config['password_smb_host'] = 'localhost';
// Location of smbpasswd binary
$config['password_smb_cmd'] = '/usr/bin/smbpasswd';







################################################################
diff de todas as modificações na pasta /usr/share/roundcubemail/ para facilitar o patch
################################################################
diff -r roundcubemail.orig/plugins/password/config.inc.php roundcubemail.mod/plugins/password/config.inc.php
7c7
< $config['password_driver'] = 'directadmin';
---
> $config['password_driver'] = 'sql';
14,15c14,39
< // set to blank to allow passwords of any length
< $config['password_minimum_length'] = 0;
---
> $config['password_minimum_length'] = 6;
>
>
> // Requirements for new password:
> // Require digits
> $rcmail_config['password_require_digit'] = true;
>
> // Require alphabetical
> $rcmail_config['password_require_alpha'] = true;
>
> // Require lower
> $rcmail_config['password_require_lower'] = true;
> $config['password_require_lower'] = true;
>
> // Require capitals
> $rcmail_config['password_require_upper'] = true;
> $config['password_require_upper'] = true;
>
> // Require non-alphabetical and non-digit
> $rcmail_config['password_require_nonalpha'] = true;
>
> // Require no repeat 3 times in a row
> $rcmail_config['password_require_norepeat'] = true;
>
>
>
20a45,46
>
>
43c69,72
< $config['password_db_dsn'] = '';
---
> $config['password_db_dsn'] = 'mysql://postfix:postfix@localhost/postfixadmin';
>
>
>
62,63c91,97
< // Default: "SELECT update_passwd(%c, %u)"
< $config['password_query'] = 'SELECT update_passwd(%c, %u)';
---
> // Default: "SELECT update_passwd(%c, %u)"a
>
> ######### MODIFICADO QUIRINO - START
>
> $config['password_query'] = 'SELECT update_passwd(%o, %c, %u)';
>
> ######### MODIFICADO QUIRINO - END
diff -r roundcubemail.orig/plugins/password/localization/en_US.inc roundcubemail.mod/plugins/password/localization/en_US.inc
34a35,46
>
>
>
> $messages['passwordweak_digit'] = 'Password must include at least one number.';
> $messages['passwordweak_alpha'] = 'Password must include at least one latin character.';
> $messages['passwordweak_lower'] = 'Password must include at least one lower latin character.';
> $messages['passwordweak_upper'] = 'Password must include at least one upper latin character.';
> $messages['passwordweak_nonalpha'] = 'Password must include at least one special character.';
> $messages['passwordweak_norepeat'] = 'Password must not contain more than two identical characters in a row.';
>
>
>
diff -r roundcubemail.orig/plugins/password/localization/pt_BR.inc roundcubemail.mod/plugins/password/localization/pt_BR.inc
30c30,42
< $messages['passwordweak'] = 'A senha precisa conter ao menos um número e um caractere de pontuação.';
---
> $messages['passwordweak'] = 'A senha precisa conter ao menos um número e um caractere especial (!@#$%¨&*?) ou pontuação.';
>
> ######### MODIFICADO QUIRINO - START
>
> $messages['passwordweak_digit'] = 'A senha precisa ter ao mínimo um número.';
> $messages['passwordweak_alpha'] = 'A senha precisa ter no mínimo um caracter do alfabeto.';
> $messages['passwordweak_lower'] = 'A senha precisa ter no mínimo um caracter minúsculo.';
> $messages['passwordweak_upper'] = 'A senha deve ter no mínimo uma letra em maiúsculo.';
> $messages['passwordweak_nonalpha'] = 'A senha deve ter no mínimo um caracter especial.';
> $messages['passwordweak_norepeat'] = 'A senha não pode conter mais de 2 caracteres seguidos.';
>
> ######### MODIFICADO QUIRINO - END
>
diff -r roundcubemail.orig/plugins/password/password.php roundcubemail.mod/plugins/password/password.php
106a107,121
>
> ######### MODIFICADO QUIRINO - START
>
>         $check_strength_digit = $rcmail->config->get('password_require_digit');
>         $check_strength_alpha = $rcmail->config->get('password_require_alpha');
>         $check_strength_lower = $rcmail->config->get('password_require_lower');
>         $check_strength_upper = $rcmail->config->get('password_require_upper');
>         $check_strength_nonalpha = $rcmail->config->get('password_require_nonalpha');
>         $check_strength_norepeat = $rcmail->config->get('password_require_norepeat');
>
> ######### MODIFICADO QUIRINO - END
>
>
>
>
148a164,192
>
>
>
>
> ######### MODIFICADO QUIRINO - START
>
>           else if ($check_strength_digit && !preg_match("/[0-9]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_digit'), 'error');
>             }
>             else if ($check_strength_alpha && !preg_match("/[a-zA-Z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_alpha'), 'error');
>             }
>             else if ($check_strength_lower && !preg_match("/[a-z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_lower'), 'error');
>             }
>             else if ($check_strength_upper && !preg_match("/[A-Z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_upper'), 'error');
>             }
>             else if ($check_strength_nonalpha && !preg_match("/[^0-9a-zA-Z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_nonalpha'), 'error');
>
>         $check_strength_digit = $rcmail->config->get('password_require_digit');
>         $check_strength_alpha = $rcmail->config->get('password_require_alpha');
>         $check_strength_lower = $rcmail->config->get('password_require_lower');
>         $check_strength_upper = $rcmail->config->get('password_require_upper');
>         $check_strength_nonalpha = $rcmail->config->get('password_require_nonalpha');
>         $check_strength_norepeat = $rcmail->config->get('password_require_norepeat');
>
> ######### MODIFICADO QUIRINO - END
>
>
>
>
148a164,192
>
>
>
>
> ######### MODIFICADO QUIRINO - START
>
>           else if ($check_strength_digit && !preg_match("/[0-9]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_digit'), 'error');
>             }
>             else if ($check_strength_alpha && !preg_match("/[a-zA-Z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_alpha'), 'error');
>             }
>             else if ($check_strength_lower && !preg_match("/[a-z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_lower'), 'error');
>             }
>             else if ($check_strength_upper && !preg_match("/[A-Z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_upper'), 'error');
>             }
>             else if ($check_strength_nonalpha && !preg_match("/[^0-9a-zA-Z]/", $newpwd)) {
>                 $rcmail->output->command('display_message', $this->gettext('passwordweak_nonalpha'), 'error');
>             }
>             else if ($check_strength_norepeat && preg_match("/(.)\\1\\1/", $newpwd)) {
>                $rcmail->output->command('display_message', $this->gettext('passwordweak_norepeat'), 'error');
>             }
>
> ######### MODIFICADO QUIRINO - END
>
>
>

Comentários

Postagens mais visitadas