Merge branch '__mysql_privileges_fix' into 'master'
__mysql_privileges: fix quoting See merge request ungleich-public/cdist!843
This commit is contained in:
commit
c4f085e739
3 changed files with 10 additions and 4 deletions
|
@ -30,7 +30,7 @@ host="$( cat "$__object/parameter/host" )"
|
||||||
|
|
||||||
check_privileges="$(
|
check_privileges="$(
|
||||||
mysql -B -N -e "show grants for '$user'@'$host'" \
|
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" ]
|
if [ -n "$check_privileges" ]
|
||||||
then
|
then
|
||||||
|
|
|
@ -37,13 +37,19 @@ user="$( cat "$__object/parameter/user" )"
|
||||||
|
|
||||||
host="$( cat "$__object/parameter/host" )"
|
host="$( cat "$__object/parameter/host" )"
|
||||||
|
|
||||||
|
if [ "$table" != '*' ]
|
||||||
|
then
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
table="$( printf '`%s`' "$table" )"
|
||||||
|
fi
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
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"
|
echo "grant $privileges on $database.$table to $user@$host" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
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"
|
echo "revoke $privileges on $database.$table from $user@$host" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -17,7 +17,7 @@ REQUIRED PARAMETERS
|
||||||
database
|
database
|
||||||
Name of database.
|
Name of database.
|
||||||
|
|
||||||
User
|
user
|
||||||
Name of user.
|
Name of user.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue