1
1
/*
2
- Copyright (c) 2015, 2017 , Oracle and/or its affiliates. All rights reserved.
2
+ Copyright (c) 2015, 2018 , Oracle and/or its affiliates. All rights reserved.
3
3
4
4
This program is free software; you can redistribute it and/or modify
5
5
it under the terms of the GNU General Public License, version 2.0,
@@ -273,17 +273,19 @@ static bool execute_query(const char **query, size_t length) {
273
273
}
274
274
275
275
/* *
276
- Checks if the validate_password plugin is installed and returns true if it is.
276
+ Checks if the validate_password component is installed and returns true
277
+ if it is.
277
278
*/
278
279
static bool validate_password_exists () {
279
280
MYSQL_ROW row;
280
281
bool res = true ;
281
282
const char *query =
282
- " SELECT NAME FROM mysql.plugin WHERE NAME "
283
- " = \' validate_password \' " ;
283
+ " SELECT component_urn FROM mysql.component WHERE component_urn "
284
+ " = \' file://component_validate_password \' " ;
284
285
if (!execute_query (&query, strlen (query)))
285
286
DBUG_PRINT (" info" , (" query success!" ));
286
287
MYSQL_RES *result = mysql_store_result (&mysql);
288
+ if (!result) return false ;
287
289
row = mysql_fetch_row (result);
288
290
if (!row) res = false ;
289
291
@@ -292,40 +294,29 @@ static bool validate_password_exists() {
292
294
}
293
295
294
296
/* *
295
- Installs validate_password plugin and sets the password validation policy.
297
+ Installs validate_password component and sets the password validation policy.
296
298
297
- @return Returns 1 on successfully setting the plugin and 0 in case of
299
+ @return Returns 1 on successfully setting the component and 0 in case of
298
300
of any error.
299
301
*/
300
- static int install_password_validation_plugin () {
302
+ static int install_password_validation_component () {
301
303
int reply;
302
- int plugin_set = 0 ;
304
+ int component_set = 0 ;
303
305
char *strength = NULL ;
304
306
bool option_read = false ;
305
- reply= get_response ((const char *) " \n VALIDATE PASSWORD PLUGIN can be used "
306
- " to test passwords\n and improve security. "
307
- " It checks the strength of password \n and "
308
- " allows the users to set only those "
309
- " passwords which are\n secure enough. "
310
- " Would you like to setup VALIDATE "
311
- " PASSWORD plugin ?\n\n Press y|Y for Yes, "
312
- " any other key for No: " , ' y' );
307
+ reply= get_response ((const char *) " \n VALIDATE PASSWORD COMPONENT can be "
308
+ " used to test passwords\n and improve "
309
+ " security. It checks the strength of "
310
+ " password \n and allows the users to set "
311
+ " only those passwords which are\n secure "
312
+ " enough. Would you like to setup VALIDATE "
313
+ " PASSWORD component ?\n\n Press y|Y for Yes,"
314
+ " any other key for No: " , ' y' );
313
315
if (reply == (int )' y' || reply == (int )' Y' ) {
314
- #ifdef _WIN32
315
- const char *query_tmp;
316
- query_tmp =
317
- " INSTALL PLUGIN validate_password SONAME "
318
- " 'validate_password.dll'" ;
319
- if (!execute_query (&query_tmp, strlen (query_tmp)))
320
- #else
321
316
const char *query_tmp;
322
- query_tmp =
323
- " INSTALL PLUGIN validate_password SONAME "
324
- " 'validate_password.so'" ;
325
- if (!execute_query (&query_tmp, strlen (query_tmp)))
326
- #endif
327
- {
328
- plugin_set = 1 ;
317
+ query_tmp = " INSTALL COMPONENT 'file://component_validate_password'" ;
318
+ if (!execute_query (&query_tmp, strlen (query_tmp))) {
319
+ component_set = 1 ;
329
320
while (!option_read) {
330
321
reply= get_response ((const char *) " \n There are three levels of "
331
322
" password validation policy:\n\n "
@@ -352,7 +343,7 @@ static int install_password_validation_plugin() {
352
343
}
353
344
}
354
345
char *query, *end;
355
- int tmp = sizeof (" SET GLOBAL validate_password_policy = " ) + 3 ;
346
+ int tmp = sizeof (" SET GLOBAL validate_password.policy = " ) + 3 ;
356
347
size_t strength_length = strlen (strength);
357
348
/*
358
349
query string needs memory which is atleast the length of initial part
@@ -361,7 +352,7 @@ static int install_password_validation_plugin() {
361
352
query = (char *)my_malloc (PSI_NOT_INSTRUMENTED,
362
353
(strength_length * 2 + tmp) * sizeof (char ),
363
354
MYF (MY_WME));
364
- end = my_stpcpy (query, " SET GLOBAL validate_password_policy = " );
355
+ end = my_stpcpy (query, " SET GLOBAL validate_password.policy = " );
365
356
*end++ = ' \' ' ;
366
357
end += mysql_real_escape_string_quote (&mysql, end, strength,
367
358
(ulong)strength_length, ' \' ' );
@@ -371,10 +362,10 @@ static int install_password_validation_plugin() {
371
362
my_free (query);
372
363
} else
373
364
fprintf (stdout,
374
- " The password validation plugin is not available. "
375
- " Proceeding with the further steps without the plugin .\n " );
365
+ " The password validation component is not available. "
366
+ " Proceeding with the further steps without the component .\n " );
376
367
}
377
- return (plugin_set );
368
+ return (component_set );
378
369
}
379
370
380
371
/* *
@@ -474,11 +465,11 @@ static bool mysql_expire_password(MYSQL *mysql) {
474
465
if he wants to continue with the password, or provide a new one,
475
466
depending on the strength displayed.
476
467
477
- @param plugin_set 1 if validate_password plugin is set and
468
+ @param component_set 1 if validate_password component is set and
478
469
0 if it is not.
479
470
*/
480
471
481
- static void set_opt_user_password (int plugin_set ) {
472
+ static void set_opt_user_password (int component_set ) {
482
473
char *password1 = 0 , *password2 = 0 ;
483
474
int reply = 0 ;
484
475
@@ -506,7 +497,7 @@ static void set_opt_user_password(int plugin_set) {
506
497
continue ;
507
498
}
508
499
509
- if (plugin_set == 1 ) {
500
+ if (component_set == 1 ) {
510
501
estimate_password_strength (password1);
511
502
reply = get_response ((
512
503
const char *)" Do you wish to continue with the "
@@ -516,7 +507,7 @@ static void set_opt_user_password(int plugin_set) {
516
507
517
508
size_t pass_length = strlen (password1);
518
509
519
- if ((!plugin_set ) || (reply == (int )' y' || reply == (int )' Y' )) {
510
+ if ((!component_set ) || (reply == (int )' y' || reply == (int )' Y' )) {
520
511
char *query = NULL , *end;
521
512
int tmp = sizeof (" SET PASSWORD=" ) + 3 ;
522
513
/*
@@ -834,7 +825,7 @@ bool find_temporary_password(char **p) {
834
825
int main (int argc, char *argv[]) {
835
826
int reply;
836
827
int rc;
837
- int hadpass, plugin_set = 0 ;
828
+ int hadpass, component_set = 0 ;
838
829
839
830
MY_INIT (argv[0 ]);
840
831
DBUG_ENTER (" main" );
@@ -870,23 +861,23 @@ int main(int argc, char *argv[]) {
870
861
hadpass = get_opt_user_password ();
871
862
872
863
if (!validate_password_exists ())
873
- plugin_set = install_password_validation_plugin ();
864
+ component_set = install_password_validation_component ();
874
865
else {
875
866
fprintf (stdout,
876
- " The 'validate_password' plugin is installed on the server.\n "
867
+ " The 'validate_password' component is installed on the server.\n "
877
868
" The subsequent steps will run with the existing "
878
- " configuration\n of the plugin .\n " );
879
- plugin_set = 1 ;
869
+ " configuration\n of the component .\n " );
870
+ component_set = 1 ;
880
871
}
881
872
882
873
if (!hadpass) {
883
874
fprintf (stdout, " Please set the password for %s here.\n " , opt_user);
884
- set_opt_user_password (plugin_set );
875
+ set_opt_user_password (component_set );
885
876
} else if (opt_use_default == false ) {
886
877
char prompt[256 ];
887
878
fprintf (stdout, " Using existing password for %s.\n " , opt_user);
888
879
889
- if (plugin_set == 1 ) estimate_password_strength (password);
880
+ if (component_set == 1 ) estimate_password_strength (password);
890
881
891
882
snprintf (prompt, sizeof (prompt) - 1 ,
892
883
" Change the password for %s ? ((Press y|Y "
@@ -895,7 +886,7 @@ int main(int argc, char *argv[]) {
895
886
reply = get_response (prompt, ' n' );
896
887
897
888
if (reply == (int )' y' || reply == (int )' Y' )
898
- set_opt_user_password (plugin_set );
889
+ set_opt_user_password (component_set );
899
890
else
900
891
fprintf (stdout, " \n ... skipping.\n " );
901
892
}
0 commit comments