Skip to content

Commit db93a48

Browse files
authored
Revert "Add support for REQUIRE SSL|X509 option"
1 parent ccea304 commit db93a48

File tree

4 files changed

+11
-98
lines changed

4 files changed

+11
-98
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ Maximum updates per hour for the user. Must be an integer value. A value of '0'
902902
```
903903
mysql_grant { 'root@localhost/*.*':
904904
ensure => 'present',
905-
options => ['REQUIRE SSL', 'GRANT'],
905+
options => ['GRANT'],
906906
privileges => ['ALL'],
907907
table => '*.*',
908908
user => 'root@localhost',
@@ -944,8 +944,7 @@ User to whom privileges are granted.
944944

945945
##### `options`
946946

947-
Array of MySQL options to grant. Optional.
948-
Supported options are 'REQUIRE SSL', 'REQUIRE X509', 'GRANT'.
947+
MySQL options to grant. Optional.
949948

950949
#### mysql_plugin
951950

lib/puppet/provider/mysql.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ def self.cmd_privs(privileges)
104104
# Take in potential options and build up a query string with them.
105105
def self.cmd_options(options)
106106
option_string = ''
107-
options.sort.reverse_each do |opt|
108-
if op = opt.match(/^REQUIRE\s(SSL|X509)$/)
109-
option_string << " #{op[0]}"
110-
elsif opt == 'GRANT'
107+
options.each do |opt|
108+
if opt == 'GRANT'
111109
option_string << ' WITH GRANT OPTION'
112110
end
113111
end

lib/puppet/provider/mysql_grant/mysql.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def self.instances
4646
end
4747
end
4848
# Same here, but to remove OPTION leaving just GRANT.
49-
options = []
50-
req_opt = rest.match(/REQUIRE\s(SSL|X509)/)
51-
options << req_opt[0] if req_opt
52-
options << 'GRANT' if rest.match(/WITH\sGRANT\sOPTION/)
53-
options << 'NONE' if options.empty?
49+
if rest.match(/WITH\sGRANT\sOPTION/)
50+
options = ['GRANT']
51+
else
52+
options = ['NONE']
53+
end
5454
# fix double backslash that MySQL prints, so resources match
5555
table.gsub!("\\\\", "\\")
5656
# We need to return an array of instances so capture these

spec/acceptance/types/mysql_grant_spec.rb

+2-86
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class { 'mysql::server':
1717
describe 'missing privileges for user' do
1818
it 'should fail' do
1919
pp = <<-EOS
20-
mysql_user { 'test1@tester':
20+
mysql_user { 'test1@tester':
2121
ensure => present,
2222
}
2323
mysql_grant { 'test1@tester/test.*':
@@ -129,35 +129,7 @@ class { 'mysql::server':
129129
end
130130
end
131131

132-
describe 'adding REQUIRE SSL option' do
133-
it 'should work without errors' do
134-
pp = <<-EOS
135-
mysql_user { 'test3@tester':
136-
ensure => present,
137-
}
138-
mysql_grant { 'test3@tester/test.*':
139-
ensure => 'present',
140-
table => 'test.*',
141-
user => 'test3@tester',
142-
options => ['REQUIRE SSL'],
143-
privileges => ['SELECT', 'UPDATE'],
144-
require => Mysql_user['test3@tester'],
145-
}
146-
EOS
147-
148-
apply_manifest(pp, :catch_failures => true)
149-
end
150-
151-
it 'should find the user' do
152-
shell("mysql -NBe \"SHOW GRANTS FOR test3@tester\"") do |r|
153-
expect(r.stdout).to match(/GRANT USAGE ON *.* TO 'test3'@'tester' REQUIRE SSL$/)
154-
expect(r.stdout).to match(/GRANT SELECT, UPDATE ON `test`.* TO 'test3'@'tester'$/)
155-
expect(r.stderr).to be_empty
156-
end
157-
end
158-
end
159-
160-
describe 'adding GRANT option' do
132+
describe 'adding option' do
161133
it 'should work without errors' do
162134
pp = <<-EOS
163135
mysql_user { 'test3@tester':
@@ -184,62 +156,6 @@ class { 'mysql::server':
184156
end
185157
end
186158

187-
describe 'adding REQUIRE X509 and GRANT option' do
188-
it 'should work without errors' do
189-
pp = <<-EOS
190-
mysql_user { 'test3@tester':
191-
ensure => present,
192-
}
193-
mysql_grant { 'test3@tester/test.*':
194-
ensure => 'present',
195-
table => 'test.*',
196-
user => 'test3@tester',
197-
options => ['REQUIRE X509', 'GRANT'],
198-
privileges => ['SELECT', 'UPDATE'],
199-
require => Mysql_user['test3@tester'],
200-
}
201-
EOS
202-
203-
apply_manifest(pp, :catch_failures => true)
204-
end
205-
206-
it 'should find the user' do
207-
shell("mysql -NBe \"SHOW GRANTS FOR test3@tester\"") do |r|
208-
expect(r.stdout).to match(/GRANT USAGE ON *.* TO 'test3'@'tester' REQUIRE X509$/)
209-
expect(r.stdout).to match(/GRANT SELECT, UPDATE ON `test`.* TO 'test3'@'tester' WITH GRANT OPTION$/)
210-
expect(r.stderr).to be_empty
211-
end
212-
end
213-
end
214-
215-
describe 'adding GRANT and REQUIRE X509 option' do
216-
it 'should work without errors' do
217-
pp = <<-EOS
218-
mysql_user { 'test3@tester':
219-
ensure => present,
220-
}
221-
mysql_grant { 'test3@tester/test.*':
222-
ensure => 'present',
223-
table => 'test.*',
224-
user => 'test3@tester',
225-
options => ['GRANT', 'REQUIRE X509'],
226-
privileges => ['SELECT', 'UPDATE'],
227-
require => Mysql_user['test3@tester'],
228-
}
229-
EOS
230-
231-
apply_manifest(pp, :catch_failures => true)
232-
end
233-
234-
it 'should find the user' do
235-
shell("mysql -NBe \"SHOW GRANTS FOR test3@tester\"") do |r|
236-
expect(r.stdout).to match(/GRANT USAGE ON *.* TO 'test3'@'tester' REQUIRE X509$/)
237-
expect(r.stdout).to match(/GRANT SELECT, UPDATE ON `test`.* TO 'test3'@'tester' WITH GRANT OPTION$/)
238-
expect(r.stderr).to be_empty
239-
end
240-
end
241-
end
242-
243159
describe 'adding all privileges without table' do
244160
it 'should fail' do
245161
pp = <<-EOS

0 commit comments

Comments
 (0)