Skip to content

Commit 87d2cb6

Browse files
author
Arun Kuruvila
committed
Bug #19953365 MY_PRINT_DEFAULTS DOES NOT MASK PASSWORDS
Description : "my_print_defaults" does not mask the password while printing it. Analysis : "my_print_defaults" does not mask the password value before printing while displaying all the config param values. Fix : In "my_print_defaults", the password arguments are masked by default while printing. An new option, "--show" has been introduced in this utility which is used to print passwords without masking. NOTE : mtr test case not added since '--password' option's value cannot be specified at the command line.
1 parent 44a901a commit 87d2cb6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

extra/my_print_defaults.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
3232

3333
const char *config_file="my"; /* Default config file */
3434
static char *my_login_path;
35+
static my_bool *show_passwords;
3536
uint verbose= 0, opt_defaults_file_used= 0;
3637
const char *default_dbug_option="d:t:o,/tmp/my_print_defaults.trace";
3738

@@ -87,6 +88,9 @@ static struct my_option my_long_options[] =
8788
{"login-path", 'l', "Path to be read from under the login file.",
8889
&my_login_path, &my_login_path, 0, GET_STR, REQUIRED_ARG,
8990
0, 0, 0, 0, 0, 0},
91+
{"show", 's', "Show passwords in plain text.",
92+
&show_passwords, &show_passwords, 0, GET_BOOL, NO_ARG,
93+
0, 0, 0, 0, 0, 0},
9094
{"help", '?', "Display this help message and exit.",
9195
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
9296
{"verbose", 'v', "Increase the output level",
@@ -203,7 +207,12 @@ int main(int argc, char **argv)
203207

204208
for (argument= arguments+1 ; *argument ; argument++)
205209
if (!my_getopt_is_args_separator(*argument)) /* skip arguments separator */
206-
puts(*argument);
210+
{
211+
if (!(show_passwords) && strncmp(*argument, "--password", 10) == 0)
212+
puts("--password=*****");
213+
else
214+
puts(*argument);
215+
}
207216
my_free(load_default_groups);
208217
free_defaults(arguments);
209218

0 commit comments

Comments
 (0)