Skip to content

Commit ecb9b5a

Browse files
committed
Merge branch 'mysql-5.5' into mysql-5.6
2 parents e84b8e6 + 1079066 commit ecb9b5a

File tree

1 file changed

+48
-19
lines changed

1 file changed

+48
-19
lines changed

scripts/mysql_secure_installation.sh

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2002, 2016, 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
@@ -33,6 +33,20 @@ set_echo_compat() {
3333
esac
3434
}
3535

36+
validate_reply () {
37+
ret=0
38+
if [ -z "$1" ]; then
39+
reply=y
40+
return $ret
41+
fi
42+
case $1 in
43+
y|Y|yes|Yes|YES) reply=y ;;
44+
n|N|no|No|NO) reply=n ;;
45+
*) ret=1 ;;
46+
esac
47+
return $ret
48+
}
49+
3650
prepare() {
3751
touch $config $command
3852
chmod 600 $config $command
@@ -284,15 +298,18 @@ echo "Setting the root password ensures that nobody can log into the MySQL"
284298
echo "root user without the proper authorisation."
285299
echo
286300

287-
if [ $hadpass -eq 0 ]; then
288-
echo $echo_n "Set root password? [Y/n] $echo_c"
289-
else
290-
echo "You already have a root password set, so you can safely answer 'n'."
291-
echo
292-
echo $echo_n "Change the root password? [Y/n] $echo_c"
293-
fi
301+
while true ; do
302+
if [ $hadpass -eq 0 ]; then
303+
echo $echo_n "Set root password? [Y/n] $echo_c"
304+
else
305+
echo "You already have a root password set, so you can safely answer 'n'."
306+
echo
307+
echo $echo_n "Change the root password? [Y/n] $echo_c"
308+
fi
309+
read reply
310+
validate_reply $reply && break
311+
done
294312

295-
read reply
296313
if [ "$reply" = "n" ]; then
297314
echo " ... skipping."
298315
else
@@ -316,9 +333,11 @@ echo "go a bit smoother. You should remove them before moving into a"
316333
echo "production environment."
317334
echo
318335

319-
echo $echo_n "Remove anonymous users? [Y/n] $echo_c"
320-
321-
read reply
336+
while true ; do
337+
echo $echo_n "Remove anonymous users? [Y/n] $echo_c"
338+
read reply
339+
validate_reply $reply && break
340+
done
322341
if [ "$reply" = "n" ]; then
323342
echo " ... skipping."
324343
else
@@ -334,9 +353,11 @@ echo
334353
echo "Normally, root should only be allowed to connect from 'localhost'. This"
335354
echo "ensures that someone cannot guess at the root password from the network."
336355
echo
337-
338-
echo $echo_n "Disallow root login remotely? [Y/n] $echo_c"
339-
read reply
356+
while true ; do
357+
echo $echo_n "Disallow root login remotely? [Y/n] $echo_c"
358+
read reply
359+
validate_reply $reply && break
360+
done
340361
if [ "$reply" = "n" ]; then
341362
echo " ... skipping."
342363
else
@@ -354,8 +375,12 @@ echo "access. This is also intended only for testing, and should be removed"
354375
echo "before moving into a production environment."
355376
echo
356377

357-
echo $echo_n "Remove test database and access to it? [Y/n] $echo_c"
358-
read reply
378+
while true ; do
379+
echo $echo_n "Remove test database and access to it? [Y/n] $echo_c"
380+
read reply
381+
validate_reply $reply && break
382+
done
383+
359384
if [ "$reply" = "n" ]; then
360385
echo " ... skipping."
361386
else
@@ -372,8 +397,12 @@ echo "Reloading the privilege tables will ensure that all changes made so far"
372397
echo "will take effect immediately."
373398
echo
374399

375-
echo $echo_n "Reload privilege tables now? [Y/n] $echo_c"
376-
read reply
400+
while true ; do
401+
echo $echo_n "Reload privilege tables now? [Y/n] $echo_c"
402+
read reply
403+
validate_reply $reply && break
404+
done
405+
377406
if [ "$reply" = "n" ]; then
378407
echo " ... skipping."
379408
else

0 commit comments

Comments
 (0)