Merge pull request #391 from vicinus/mysql_grant_fixes
Mysql grant fixes
This commit is contained in:
commit
50f0ef8477
2 changed files with 7 additions and 2 deletions
|
@ -22,7 +22,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql, :parent => Puppet::Provider::Mys
|
||||||
priv == 'ALL PRIVILEGES' ? 'ALL' : priv.lstrip.rstrip
|
priv == 'ALL PRIVILEGES' ? 'ALL' : priv.lstrip.rstrip
|
||||||
end
|
end
|
||||||
# Same here, but to remove OPTION leaving just GRANT.
|
# Same here, but to remove OPTION leaving just GRANT.
|
||||||
options = rest.match(/WITH\s(.*)\sOPTION$/).captures if rest.include?('WITH')
|
options = ['GRANT'] if rest.match(/WITH\sGRANT\sOPTION/)
|
||||||
# We need to return an array of instances so capture these
|
# We need to return an array of instances so capture these
|
||||||
instances << new(
|
instances << new(
|
||||||
:name => "#{user}@#{host}/#{table}",
|
:name => "#{user}@#{host}/#{table}",
|
||||||
|
@ -76,6 +76,11 @@ Puppet::Type.type(:mysql_grant).provide(:mysql, :parent => Puppet::Provider::Mys
|
||||||
|
|
||||||
query = "REVOKE ALL ON #{table_string} FROM #{user_string}"
|
query = "REVOKE ALL ON #{table_string} FROM #{user_string}"
|
||||||
mysql([defaults_file, '-e', query].compact)
|
mysql([defaults_file, '-e', query].compact)
|
||||||
|
# revoke grant option needs to be a extra query, because
|
||||||
|
# "REVOKE ALL PRIVILEGES, GRANT OPTION [..]" is only valid mysql syntax
|
||||||
|
# if no ON clause is used.
|
||||||
|
query = "REVOKE GRANT OPTION ON #{table_string} FROM #{user_string}"
|
||||||
|
mysql([defaults_file, '-e', query].compact)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -17,7 +17,7 @@ Puppet::Type.newtype(:mysql_grant) do
|
||||||
# Sort the privileges array in order to ensure the comparision in the provider
|
# Sort the privileges array in order to ensure the comparision in the provider
|
||||||
# self.instances method match. Otherwise this causes it to keep resetting the
|
# self.instances method match. Otherwise this causes it to keep resetting the
|
||||||
# privileges.
|
# privileges.
|
||||||
self[:privileges] = Array(self[:privileges]).sort!
|
self[:privileges] = Array(self[:privileges]).map(&:upcase).uniq.reject{|k| k == 'GRANT' or k == 'GRANT OPTION'}.sort!
|
||||||
end
|
end
|
||||||
|
|
||||||
validate do
|
validate do
|
||||||
|
|
Loading…
Reference in a new issue