Ticket #169: mail_crypt.diff

File mail_crypt.diff, 6.5 kB (added by DPR, 1 year ago)

patch file for Omega 1.0 RC1

  • vhcs-omega-1.0.0-rc1/gui/client/add_mail_acc.php

    old new  
    198198  global $cfg; 
    199199 
    200200  $domain_id = $dmn_id; 
     201  $enc_secret = 0; 
    201202 
    202203  // standard whithout encoding 
    203204  //$mail_acc = $_POST['username']; 
     
    221222  $mail_auto_respond = '_no_'; 
    222223 
    223224  if ($_POST['mail_type'] === 'normal') { 
     225    $enc_secret = 1; 
     226 
    224227    if ($_POST['dmn_type'] === 'dmn') { 
    225228      $mail_pass = $_POST['pass']; 
    226229      $mail_forward = '_no_'; 
     
    339342    return; 
    340343  } 
    341344 
     345  // create crypted password if necessary 
     346  if ($enc_secret == 1) { 
     347    if (isset($cfg['ENCRYPT_MAIL_PASS'])) 
     348    { 
     349      // use MD5 if available, otherwise fallback to standard crypt method 
     350      if (CRYPT_MD5 == 1) { 
     351        srand(); 
     352        $salt = substr(md5(rand()), 0,8); 
     353        $secret = crypt($mail_pass, '$1$' . $salt . '$'); 
     354      } else { 
     355        $secret = crypt($mail_pass); 
     356      } 
     357      $mail_pass = '_no_'; 
     358    } else { 
     359      $secret = '_no_'; 
     360    } 
     361  } 
     362 
    342363  check_for_lock_file(); 
    343364 
    344365  $query = <<<SQL_QUERY 
     
    350371             mail_type, 
    351372             sub_id, 
    352373             status, 
    353              mail_auto_respond) 
     374             mail_auto_respond, 
     375             mail_crypt) 
    354376        VALUES 
    355             (?, ?, ?, ?, ?, ?, ?, ?
     377            (?, ?, ?, ?, ?, ?, ?, ?, ?
    356378SQL_QUERY; 
    357379 
    358380  $rs = exec_query($sql, $query, array($mail_acc, 
     
    362384                                       $mail_type, 
    363385                                       $sub_id, 
    364386                                       $status, 
    365                                        $mail_auto_respond)); 
     387                                       $mail_auto_respond, 
     388                                       $secret)); 
    366389 
    367390  write_log($_SESSION['user_logged'].": add new mail account: ".$mail_acc."@".$dmn_name); 
    368391  set_page_message(tr('Mail account scheduled for addition!')); 
  • vhcs-omega-1.0.0-rc1/gui/client/create_catchall.php

    old new  
    282282                         mail_type, 
    283283                         sub_id, 
    284284                         status, 
    285                          mail_auto_respond) 
     285                         mail_auto_respond, 
     286                         mail_crypt) 
    286287                    values 
    287                         (?, ?, ?, ?, ?, ?, ?, ?
     288                        (?, ?, ?, ?, ?, ?, ?, ?, ?
    288289SQL_QUERY; 
    289290 
    290         $rs = exec_query($sql, $query, array($mail_acc, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, '_no_')); 
     291        $rs = exec_query($sql, $query, array($mail_acc, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, '_no_', '_no_')); 
    291292 
    292293        send_request(); 
    293294        write_log($_SESSION['user_logged'].": add new email catch all"); 
     
    342343                         mail_type, 
    343344                         sub_id, 
    344345                         status, 
    345                          mail_auto_respond) 
     346                         mail_auto_respond, 
     347                         mail_crypt) 
    346348                    values 
    347                         (?, ?, ?, ?, ?, ?, ?, ?
     349                        (?, ?, ?, ?, ?, ?, ?, ?, ?
    348350SQL_QUERY; 
    349351 
    350         $rs = exec_query($sql, $query, array($mail_acc, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, '_no_')); 
     352        $rs = exec_query($sql, $query, array($mail_acc, '_no_', '_no_', $domain_id, $mail_type, $sub_id, $status, '_no_', '_no_')); 
    351353 
    352354        send_request(); 
    353355        write_log($_SESSION['user_logged'].": add new email catch all "); 
  • vhcs-omega-1.0.0-rc1/gui/client/edit_mail_acc.php

    old new  
    132132 
    133133function update_email_pass($sql) 
    134134{ 
     135  global $cfg; 
     136 
    135137  if (!isset($_POST['uaction'])) { 
    136138    return; 
    137139  } 
     
    159161    global $cfg; 
    160162    $status = $cfg['ITEM_CHANGE_STATUS']; 
    161163 
     164    if (isset($cfg['ENCRYPT_MAIL_PASS'])) { 
     165      if (CRYPT_MD5 == 1) { 
     166        srand(); 
     167        $salt = substr(md5(rand()), 0,8); 
     168        $secret = crypt($pass, '$1$' . $salt . '$'); 
     169      } else { 
     170        $secret = crypt($pass); 
     171      } 
     172      $pass = '_no_'; 
     173    } else { 
     174      $secret = '_no_'; 
     175    } 
     176 
    162177    check_for_lock_file(); 
    163178 
    164179    $query = <<<SQL_QUERY 
     
    166181              mail_users 
    167182          set 
    168183              mail_pass = ?, 
     184              mail_crypt = ?, 
    169185              status = ? 
    170186          where 
    171187              mail_id = ? 
    172188SQL_QUERY; 
    173189 
    174     $rs = exec_query($sql, $query, array($pass, $status, $mail_id)); 
     190    $rs = exec_query($sql, $query, array($pass, $secret, $status, $mail_id)); 
    175191 
    176192    send_request(); 
    177193    set_page_message(tr("Mail were updated successfully!")); 
  • vhcs-omega-1.0.0-rc1/gui/include/admin-functions.php

    old new  
    18841884                return; 
    18851885        } 
    18861886 
     1887        if (isset($cfg['ENCRYPT_MAIL_PASS'])) { 
     1888                $pass_field = 'mail_crypt'; 
     1889        } else { 
     1890                $pass_field = 'mail_pass'; 
     1891        } 
     1892 
     1893 
    18871894$query = <<<SQL_QUERY 
    18881895          SELECT 
    18891896                  mail_id, 
    1890                   mail_pass 
     1897                  $pass_field 
    18911898          FROM 
    18921899                  mail_users 
    18931900          WHERE 
    18941901                  domain_id = ? 
    18951902                AND 
    1896                   mail_pass != '_no_' 
     1903                  $pass_field != '_no_' 
    18971904SQL_QUERY; 
    18981905 
    18991906        $rs = exec_query($sql, $query, array($domain_id)); 
     
    19081915                                $mail_id = $rs -> fields['mail_id']; 
    19091916                                $timestamp = time(); 
    19101917                                $pass_prefix = substr(md5($timestamp),0,4); 
    1911                                 $mail_pass = $pass_prefix.$rs -> fields['mail_pass']; 
     1918                                $mail_pass = $pass_prefix.$rs -> fields[$pass_field]; 
    19121919 
    19131920                        } else if ($action == 'enable') { 
    19141921 
    19151922                                $mail_id = $rs -> fields['mail_id']; 
    1916                                 $mail_pass = substr($rs -> fields['mail_pass'],4,50); 
     1923                                $mail_pass = substr($rs -> fields[$pass_field],4,50); 
    19171924 
    19181925                        } else { 
    19191926                                return; 
     
    19271934                        UPDATE 
    19281935                                 mail_users 
    19291936                        SET 
    1930                                 mail_pass = ?, 
     1937                                $pass_field = ?, 
    19311938                                status = ? 
    19321939                        WHERE 
    19331940                                mail_id = ?