Skip to content

Commit c614f1b

Browse files
committed
Fixed: FS#1741 - Password after update
1 parent e55c5bf commit c614f1b

File tree

4 files changed

+15
-35
lines changed

4 files changed

+15
-35
lines changed

interface/lib/classes/auth.inc.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ public function get_random_password($length = 8) {
132132
}
133133
return $password;
134134
}
135+
136+
public function crypt_password($cleartext_password) {
137+
$salt="$1$";
138+
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
139+
for ($n=0;$n<8;$n++) {
140+
$salt.=$base64_alphabet[mt_rand(0,63)];
141+
}
142+
$salt.="$";
143+
return crypt($cleartext_password,$salt);
144+
}
135145

136146
}
137147

interface/lib/classes/tform.inc.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -903,15 +903,7 @@ function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_whe
903903
if($field['formtype'] == 'PASSWORD') {
904904
$sql_insert_key .= "`$key`, ";
905905
if($field['encryption'] == 'CRYPT') {
906-
$salt="$1$";
907-
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
908-
for ($n=0;$n<8;$n++) {
909-
//$salt.=chr(mt_rand(64,126));
910-
$salt.=$base64_alphabet[mt_rand(0,63)];
911-
}
912-
$salt.="$";
913-
// $salt = substr(md5(time()),0,2);
914-
$record[$key] = crypt(stripslashes($record[$key]),$salt);
906+
$record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
915907
$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
916908
} elseif ($field['encryption'] == 'MYSQL') {
917909
$sql_insert_val .= "PASSWORD('".$app->db->quote($record[$key])."'), ";
@@ -938,15 +930,7 @@ function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_whe
938930
} else {
939931
if($field['formtype'] == 'PASSWORD') {
940932
if(isset($field['encryption']) && $field['encryption'] == 'CRYPT') {
941-
$salt="$1$";
942-
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
943-
for ($n=0;$n<8;$n++) {
944-
//$salt.=chr(mt_rand(64,126));
945-
$salt.=$base64_alphabet[mt_rand(0,63)];
946-
}
947-
$salt.="$";
948-
// $salt = substr(md5(time()),0,2);
949-
$record[$key] = crypt(stripslashes($record[$key]),$salt);
933+
$record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
950934
$sql_update .= "`$key` = '".$app->db->quote($record[$key])."', ";
951935
} elseif (isset($field['encryption']) && $field['encryption'] == 'MYSQL') {
952936
$sql_update .= "`$key` = PASSWORD('".$app->db->quote($record[$key])."'), ";

interface/web/client/client_edit.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,7 @@ function onAfterInsert() {
149149
$type = 'user';
150150
$active = 1;
151151
$language = $app->db->quote($this->dataRecord["language"]);
152-
153-
$salt="$1$";
154-
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
155-
for ($n=0;$n<8;$n++) {
156-
$salt.=$base64_alphabet[mt_rand(0,63)];
157-
}
158-
$salt.="$";
159-
$password = crypt(stripslashes($password),$salt);
152+
$password = $app->auth->crypt_password($password);
160153

161154
// Create the controlpaneluser for the client
162155
//Generate ssh-rsa-keys

interface/web/login/password_reset.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,8 @@
5252
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' AND email = '$email'");
5353

5454
if($client['client_id'] > 0) {
55-
$new_password = md5 (uniqid (rand()));
56-
$salt="$1$";
57-
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
58-
for ($n=0;$n<8;$n++) {
59-
//$salt.=chr(mt_rand(64,126));
60-
$salt.=$base64_alphabet[mt_rand(0,63)];
61-
}
62-
$salt.="$";
63-
$new_password_encrypted = crypt($new_password,$salt);
55+
$new_password = $app->auth->get_random_password();
56+
$new_password_encrypted = $app->auth->crypt_password($new_password);
6457
$new_password_encrypted = $app->db->quote($new_password_encrypted);
6558

6659
$username = $app->db->quote($client['username']);

0 commit comments

Comments
 (0)