Commit 710e99f2 authored by Ander Punnar's avatar Ander Punnar

__mysql_privileges: fix quoting

parent bcefeb24
......@@ -30,7 +30,7 @@ host="$( cat "$__object/parameter/host" )"
check_privileges="$(
mysql -B -N -e "show grants for '$user'@'$host'" \
| grep -Ei "^grant $privileges on .$database.\..$table. to " || true )"
| grep -Ei "^grant $privileges on .$database.\..?$table.? to " || true )"
if [ -n "$check_privileges" ]
then
......
......@@ -37,13 +37,18 @@ user="$( cat "$__object/parameter/user" )"
host="$( cat "$__object/parameter/host" )"
if [ "$table" != '*' ]
then
table="$( printf '`%s`' "$table" )"
fi
case "$state_should" in
present)
echo "mysql -e 'grant $privileges on \`$database\`.\`$table\` to \`$user\`@\`$host\`'"
echo "mysql -e 'grant $privileges on \`$database\`.$table to \`$user\`@\`$host\`'"
echo "grant $privileges on $database.$table to $user@$host" >> "$__messages_out"
;;
absent)
echo "mysql -e 'revoke $privileges on \`$database\`.\`$table\` from \`$user\`@\`$host\`'"
echo "mysql -e 'revoke $privileges on \`$database\`.$table from \`$user\`@\`$host\`'"
echo "revoke $privileges on $database.$table from $user@$host" >> "$__messages_out"
;;
esac
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment