Skip to content

Commit 51bd650

Browse files
authored
Merge pull request #1075 from disappear89/master
Allow empty user passwords
2 parents ea75ad5 + 033d5fe commit 51bd650

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ mysql::db { 'mydb':
170170
}
171171
```
172172

173+
If required, the password can also be an empty string to allow connections without an password.
174+
173175
### Install Percona server on CentOS
174176

175177
This example shows how to do a minimal installation of a Percona server on a

lib/puppet/provider/mysql_user/mysql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def password_hash=(string)
126126
# default ... if mysqld_version does not work
127127
self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system')
128128
elsif newer_than('mysql' => '5.7.6', 'percona' => '5.7.6')
129-
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) hashes are supported.') unless string =~ %r{^\*}
129+
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) hashes are supported.') unless string =~ %r{^\*|^$}
130130
self.class.mysql_caller("ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'", 'system')
131131
else
132132
self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system')

spec/unit/puppet/type/mysql_user_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
user[:password_hash] = 'foo'
4444
expect(user[:password_hash]).to eq('foo')
4545
end
46+
47+
it 'accepts an empty password' do
48+
user[:password_hash] = ''
49+
expect(user[:password_hash]).to eq('')
50+
end
4651
end
4752

4853
context 'using foo@LocalHost' do

0 commit comments

Comments
 (0)