Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty user passwords #1075

Merged
merged 4 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ mysql::db { 'mydb':
}
```

If required, the password can also be an empty string to allow connections without an password.

### Install Percona server on CentOS

This example shows how to do a minimal installation of a Percona server on a
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/mysql_user/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def password_hash=(string)
# default ... if mysqld_version does not work
self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system')
elsif newer_than('mysql' => '5.7.6', 'percona' => '5.7.6')
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) hashes are supported.') unless string =~ %r{^\*}
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) hashes are supported.') unless string =~ %r{^\*|^$}
self.class.mysql_caller("ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'", 'system')
else
self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system')
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/puppet/type/mysql_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
user[:password_hash] = 'foo'
expect(user[:password_hash]).to eq('foo')
end

it 'accepts an empty password' do
user[:password_hash] = ''
expect(user[:password_hash]).to eq('')
end
end

context 'using foo@LocalHost' do
Expand Down