Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[COOK-1709] Add 'grant_option' parameter. #14

Closed
wants to merge 1 commit into from

6 participants

@realloc

Need it to create remote root or give grant privileges to users.

Stanislav Bogatyrev Add 'grant_option' parameter.
Need it to create remote root or give grant privileges to users.
3317094
@stevendanna
Owner

Thank you for taking the time to help make Chef better! We require a Contributor License Agreement (CLA) from contributors to help protect all Chef users. It is easy to complete one online. Instructions to do so are on our wiki, which is linked below. Once your account is updated, you will have access to 'resolve' tickets that indicates to the code review team that your contribution is ready for review.

http://wiki.opscode.com/display/chef/How+to+Contribute

@tf
tf commented

I would really like to see this get merged.

@bigwhoop

bump

@jesseadams

@tf @bigwhoop - @realloc still needs to sign the CLA and create a ticket for this at http://tickets.opscode.com. If you would like to see this get merged, you could follow this procedure and submit a new pull request.

http://wiki.opscode.com/display/chef/How+to+Contribute

@btm
Owner

Rebased in PR #41

@btm btm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 27, 2012
  1. Add 'grant_option' parameter.

    Stanislav Bogatyrev authored
    Need it to create remote root or give grant privileges to users.
This page is out of date. Refresh to see the latest.
View
2  README.md
@@ -202,6 +202,8 @@ resource depending on your RDBMS: `mysql_database_user` or
:port, :username, :password
- privileges: array of database privileges to grant user. used by the
:grant action. default is :all
+- grant_option: appends 'WITH GRANT OPTION' to grant statement. used by MySQL
+ provider only. default is 'false'
- host: host where user connections are allowed from. used by MySQL
provider only. default is 'localhost'
- table: table to grant privileges on. used by :grant action and MySQL
View
3  libraries/provider_database_mysql_user.rb
@@ -57,6 +57,7 @@ def action_drop
def action_grant
begin
grant_statement = "GRANT #{@new_resource.privileges.join(', ')} ON #{@new_resource.database_name || "*"}.#{@new_resource.table || "*"} TO '#{@new_resource.username}'@'#{@new_resource.host}' IDENTIFIED BY '#{@new_resource.password}'"
+ grant_statement += " WITH GRANT OPTION" if @new_resource.grant_option == true
Chef::Log.info("#{@new_resource}: granting access with statement [#{grant_statement}]")
db.query(grant_statement)
@new_resource.updated_by_last_action(true)
@@ -73,4 +74,4 @@ def exists?
end
end
end
-end
+end
View
8 libraries/resource_database_user.rb
@@ -85,6 +85,14 @@ def privileges(arg=nil)
)
end
+ def grant_option(arg=nil)
+ set_or_return(
+ :grant_option,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ], :default => false
+ )
+ end
+
end
end
end
Something went wrong with that request. Please try again.