Created
September 24, 2016 21:28
-
-
Save tarqd/faed25aa2c7bdcfd3309773f228364dd to your computer and use it in GitHub Desktop.
MySQL Vulnerability Security Checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Try and find where my.cnf are loaded from, otherwise guess | |
MYSQLD_OUT=$(mysqld --help --verbose 2>/dev/null) | |
DATADIR=$(echo "$MYSQLD_OUT" | grep "datadir " | tr -s ' ' | cut -d' ' -f 2) | |
DATADIR=${DATADIR:=/var/lib/mysql} | |
FILES=$(echo "$MYSQLD_OUT" | awk 'f{print;f=0} /Default options are read/{f=1}') | |
FILES=${FILES:=/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf} | |
FILES="$FILES $DATADIR/my.cnf $DATADIR/.my.cnf" | |
DIRS=$(dirname $FILES | sort | uniq) | |
COMMON_INCLUDE_DIRS="/etc/mysql /etc/my.cnf.d /usr/etc/mysql /usr/etc/my.cnf.d /usr/local/etc/my.cnf.d /usr/local/etc/mysql $DATADIR" | |
echo 'Writable Configuration Files:' | |
(cd / ; sudo -u mysql find $FILES -type f -writable ; sudo -u mysql find $COMMON_INCLUDE_DIRS -type f -name "*.cnf" -writable ) 2>/dev/null | |
echo | |
echo "Missing Configuration Files: " | |
for file in $FILES; do if [ ! -e "$file" ]; then echo $file; fi; done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 11,
DIRS=$(dirname $FILES | sort | uniq)
, gives an error, becausedirname
only takes a single name as argument, whereas$FILES
contains multiple names.But in any case, the value of
$DIRS
does not appear to be used anywhere later in the script!