Skip to content

length check for usernames should take mysql version into consideration #722

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

Merged
merged 1 commit into from
Jun 25, 2015
Merged

Conversation

igalic
Copy link
Contributor

@igalic igalic commented May 28, 2015

Starting MariaDB 10.0.0, usernames are now 80 long.
Our mysql_user and mysql_grant types now take that into consideration.

@igalic
Copy link
Contributor Author

igalic commented May 28, 2015

rspec testing puppet types: let(:facts) {{ :foo => 'bar' }}

rspec testing puppet providers: Facter.stubs(:value).with(:foo).returns('bar')

— The Wrath of PB™ (@hirojin) May 29, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

everything is normal.

nothing to see here.

— The Wrath of PB™ (@hirojin) May 29, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

@@ -78,7 +78,11 @@ def initialize(*args)
raise(ArgumentError, "Invalid database user #{value}")
end

raise(ArgumentError, 'MySQL usernames are limited to a maximum of 16 characters') unless user_part.size <= 16
if Puppet::Util::Package.versioncmp(Facter.value(:mysql_version), '10.0.0') < 0 and user_part.size >= 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If mysql is not installed and mysql_version is unset, what happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then versioncmp's first argument will be nil, and it will return

NoMethodError: undefined method `scan' for nil:NilClass

Starting MariaDB 10.0.0, usernames are now 80 long.
Our mysql_user and mysql_grant types now take that into consideration.

This check is *opportunistic*. It will only take place if the
mysql_version fact is available. If that is not the case, it will be
skipped, leaving the database itself to deal with it, and returning its
error verbatim to our users, if it does fail.

Our fixed and extended tests assume this isn't the first run, and the
fact is already in place.
@igalic
Copy link
Contributor Author

igalic commented May 29, 2015

FAQ: Why aren't we trying harder to determine the version on/before the first run?
Answer: Why aren't we checking the length of the database?

underscorgan pushed a commit that referenced this pull request Jun 25, 2015
length check for usernames should take mysql version into consideration
@underscorgan underscorgan merged commit c6afa11 into puppetlabs:master Jun 25, 2015
@underscorgan
Copy link
Contributor

👍 thanks @igalic

@igalic igalic deleted the lenght_check branch June 25, 2015 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants