Skip to content

Commit 510b141

Browse files
committed
fix: complaint about invalid password length on user plugins which have no fixed password length
Refs #1671
1 parent 3e4f562 commit 510b141

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

source/usermanager.pas

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ procedure TUserManagerForm.FormShow(Sender: TObject);
304304
tmp, PasswordExpr, IsRoleExpr, DefaultRoleExpr, PluginExpr: String;
305305
SkipNameResolve,
306306
HasPassword, HasAuthString: Boolean;
307-
PasswordLengthMatters: Boolean;
307+
PasswordLengthMatters, PasswordLengthValid: Boolean;
308308
UserTableColumns: TStringList;
309309

310310
function InitPrivList(Values: String): TStringList;
@@ -332,7 +332,6 @@ procedure TUserManagerForm.FormShow(Sender: TObject);
332332
FPrivsTable := InitPrivList('ALTER,CREATE,DELETE,DROP,GRANT,INDEX');
333333
FPrivsRoutine := InitPrivList('GRANT');
334334
FPrivsColumn := InitPrivList('INSERT,SELECT,UPDATE,REFERENCES');
335-
PasswordLengthMatters := True;
336335
FSQLPluginPrefix := IfThen(FConnection.Parameters.IsMariaDB, 'VIA', 'WITH');
337336
FSQLPluginPassPrefix := IfThen(FConnection.Parameters.IsMariaDB, 'USING', 'BY');
338337

@@ -367,11 +366,6 @@ procedure TUserManagerForm.FormShow(Sender: TObject);
367366
PrivsDb.Add('PROXY');
368367
end;
369368
}
370-
if Version >= 80000 then begin
371-
// MySQL 8 has predefined length of hashed passwords only with
372-
// mysql_native_password plugin enabled users
373-
PasswordLengthMatters := False;
374-
end;
375369
// See https://mariadb.com/kb/en/changes-improvements-in-mariadb-105/#privileges-made-more-granular
376370
if FConnection.Parameters.IsMariaDB then begin
377371
if Version > 100502 then begin
@@ -469,7 +463,9 @@ procedure TUserManagerForm.FormShow(Sender: TObject);
469463
if U.IsUser then begin
470464
if Length(U.Password) = 0 then
471465
U.Problem := upEmptyPassword;
472-
if PasswordLengthMatters and (not (Length(U.Password) in [0, 16, 41])) then
466+
PasswordLengthMatters := ExecRegExpr('(mysql_native_password|mysql_old_password)', U.Plugin) or (not FHasPlugin);
467+
PasswordLengthValid := Byte(Length(U.Password)) in [0, 16, 41];
468+
if PasswordLengthMatters and (not PasswordLengthValid) then
473469
U.Problem := upInvalidPasswordLen
474470
else if SkipNameResolve and U.HostRequiresNameResolve then
475471
U.Problem := upSkipNameResolve;

0 commit comments

Comments
 (0)