]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/postgresql/providers/user.rb
Escape passwords when creating postgres users
[chef.git] / cookbooks / postgresql / providers / user.rb
index 4f21b4d291487d6fd4113fefd113f9c94f2a6df5..5df0f3847845d07a19fb188bc25b97540587e5cb 100644 (file)
 # limitations under the License.
 #
 
+require "shellwords"
+
+use_inline_resources
+
 def load_current_resource
   @pg = Chef::PostgreSQL.new(new_resource.cluster)
 
@@ -33,7 +37,7 @@ def load_current_resource
 end
 
 action :create do
-  password = new_resource.password ? "ENCRYPTED PASSWORD '#{new_resource.password}'" : ""
+  password = new_resource.password ? "ENCRYPTED PASSWORD '#{new_resource.password.shellescape}'" : ""
   superuser = new_resource.superuser ? "SUPERUSER" : "NOSUPERUSER"
   createdb = new_resource.createdb ? "CREATEDB" : "NOCREATEDB"
   createrole = new_resource.createrole ? "CREATEROLE" : "NOCREATEROLE"