Changeset 4546 in subversion


Ignore:
Timestamp:
Feb 15, 2011 7:26:26 AM (2 years ago)
Author:
alec
Message:
  • Virtualmin driver: Add option for setting username format (#1487781)
Location:
trunk/plugins/password
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/password/README

    r4165 r4546  
    202202 As in sasl driver this one allows to change password using shell 
    203203 utility called "virtualmin". See drivers/chgvirtualminpasswd.c for 
    204  installation instructions. 
     204 installation instructions. See also config.inc.php.dist file. 
    205205 
    206206 
  • trunk/plugins/password/config.inc.php.dist

    r4545 r4546  
    286286); 
    287287 
     288 
     289// Virtualmin Driver options 
     290// ------------------------- 
     291// Username format: 
     292// 0: username@domain 
     293// 1: username%domain 
     294// 2: username.domain 
     295// 3: domain.username 
     296// 4: username-domain 
     297// 5: domain-username 
     298// 6: username_domain 
     299// 7: domain_username 
     300$rcmail_config['password_virtualmin_format'] = 0; 
  • trunk/plugins/password/drivers/virtualmin.php

    r4199 r4546  
    1111 * and requires shell access and gcc in order to compile the binary. 
    1212 * 
    13  * @version 1.0 
     13 * @version 2.0 
    1414 * @author Martijn de Munnik 
    1515 */ 
     
    1717function password_save($currpass, $newpass) 
    1818{ 
    19     $curdir = realpath(dirname(__FILE__)); 
    20     $username = escapeshellcmd($_SESSION['username']); 
    21     $domain = substr(strrchr($username, "@"), 1); 
     19    $rcmail = rcmail::get_instance(); 
     20 
     21    $format   = $rcmail->config->get('password_virtualmin_format', 0); 
     22    $username = $_SESSION['username']; 
     23 
     24    switch ($format) { 
     25        case 1: // username%domain 
     26            $domain = substr(strrchr($username, "%"), 1); 
     27            break; 
     28        case 2: // username.domain (could be bogus) 
     29            $pieces = explode(".", $username); 
     30            $domain = $pieces[count($pieces)-2]. "." . end($pieces); 
     31            break; 
     32        case 3: // domain.username (could be bogus) 
     33            $pieces = explode(".", $username); 
     34            $domain = $pieces[0]. "." . $pieces[1]; 
     35            break; 
     36        case 4: // username-domain 
     37            $domain = substr(strrchr($username, "-"), 1); 
     38            break; 
     39        case 5: // domain-username 
     40            $domain = str_replace(strrchr($username, "-"), "", $username); 
     41            break; 
     42        case 6: // username_domain 
     43            $domain = substr(strrchr($username, "_"), 1); 
     44            break; 
     45        case 7: // domain_username 
     46            $pieces = explode("_", $username); 
     47            $domain = $pieces[0]; 
     48            break; 
     49        default: // username@domain 
     50            $domain = substr(strrchr($username, "@"), 1); 
     51    } 
     52                                                                                                                                                                                                                                                                                                             
     53    $username = escapeshellcmd($username); 
     54    $domain   = escapeshellcmd($domain); 
     55    $newpass  = escapeshellcmd($newpass); 
     56    $curdir   = realpath(dirname(__FILE__)); 
    2257 
    2358    exec("$curdir/chgvirtualminpasswd modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue); 
  • trunk/plugins/password/package.xml

    r4545 r4546  
    1616                <active>yes</active> 
    1717        </lead> 
    18         <date></date> 
    19         <time></time> 
     18        <date>2011-02-15</date> 
     19        <time>12:00</time> 
    2020        <version> 
    2121                <release>2.2</release> 
     
    3838- Fix double request when clicking on Password tab in Firefox 
    3939- Fix deprecated split() usage in xmail and directadmin drivers (#1487769) 
    40 - ldap/ldap_simple drivers: use password_ldap_samba_pwattr/password_ldap_samba_lchattr 
    41   instead of password_ldap_samba option 
    4240- Added option (password_log) for logging password changes 
     41- Virtualmin driver: Add option for setting username format (#1487781) 
    4342    </notes> 
    4443        <contents> 
Note: See TracChangeset for help on using the changeset viewer.