From 1c7f0c3530846d9935bbc13cda33430cf5632975 Mon Sep 17 00:00:00 2001 From: Stefan Schulte Date: Tue, 12 Apr 2011 00:48:26 +0200 Subject: (#7114) Improve value validation for authorized_key Whitespaces in any of the properties can lead to incorrect entries in the authorized_keys file. Reviewed-By: Nick Lewis Reviewed-By: Josh Cooper --- lib/puppet/type/ssh_authorized_key.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index 8338e2d64..170dc8383 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -14,6 +14,10 @@ module Puppet system-wide primary key and therefore has to be unique." isnamevar + + validate do |value| + raise Puppet::Error, "Resourcename must not contain whitespace: #{value}" if value =~ /\s/ + end end newproperty(:type) do @@ -28,6 +32,10 @@ module Puppet newproperty(:key) do desc "The key itself; generally a long string of hex digits." + + validate do |value| + raise Puppet::Error, "Key must not contain whitespace: #{value}" if value =~ /\s/ + end end newproperty(:user) do @@ -82,6 +90,10 @@ module Puppet value.join(",") end end + + validate do |value| + raise Puppet::Error, "Options must be provided as an array, not a comma separated list" if value != :absent and value.include?(',') + end end autorequire(:user) do -- cgit From 551cb3e5ee6c1ef4218adcebf04004c50fe4119f Mon Sep 17 00:00:00 2001 From: Stefan Schulte Date: Sat, 23 Apr 2011 10:30:09 +0200 Subject: (#7114) Target returns correct value Fix the ssh_authorized_key parsedfile provider to return the current target value instead of the should value. Without this change puppet always thinks that the target property is in sync and thus will never move one key to the correct file. Reviewed-By: Nick Lewis Reviewed-By: Josh Cooper --- lib/puppet/provider/ssh_authorized_key/parsed.rb | 6 ------ 1 file changed, 6 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index 6a3855c0e..81b1fbcfa 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -42,12 +42,6 @@ require 'puppet/provider/parsedfile' 0600 end - def target - @resource.should(:target) || File.expand_path("~#{@resource.should(:user)}/.ssh/authorized_keys") - rescue - raise Puppet::Error, "Target not defined and/or specified user does not exist yet" - end - def user uid = File.stat(target).uid Etc.getpwuid(uid).name -- cgit