Escape mysql passwords in alternc install

This commit is contained in:
Kienan Stewart 2018-06-13 18:01:43 -04:00
parent 71ed8bf5f4
commit eca8d7ccdf
1 changed files with 4 additions and 2 deletions

View File

@ -155,7 +155,8 @@ if [ -r /etc/alternc/my.cnf ]; then
# * add a right quote operator at the end of line (;s)
# * convert mysql variables into our MYSQL_ naming convention (;s)
# * print the result (;p)
eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf`
MYSQL_PASS_ESC=$(echo "$MYSQL_PASS" | sed -e 's/[\/&^$]/\\&/g')
eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS_ESC/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf`
chown root:alterncpanel /etc/alternc/my.cnf
chmod 640 /etc/alternc/my.cnf
fi
@ -168,7 +169,8 @@ if [ -r /etc/alternc/my_mail.cnf ]; then
# * add a right quote operator at the end of line (;s)
# * convert mysql variables into our MYSQL_ naming convention (;s)
# * print the result (;p)
eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_MAIL_USER/;s/password/MYSQL_MAIL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my_mail.cnf`
MYSQL_MAIL_PASS_ESC=$(echo "$MYSQL_MAIL_PASS" | sed -e 's/[\/&^$]/\\&/g')
eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_MAIL_USER/;s/password/MYSQL_MAIL_PASS_ESC/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my_mail.cnf`
chown root:alterncpanel /etc/alternc/my_mail.cnf
chmod 640 /etc/alternc/my_mail.cnf
fi