diff options
| author | Stefan Schulte <stefan.schulte@taunusstein.net> | 2010-11-21 20:52:49 +0100 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2010-11-30 16:17:19 -0800 |
| commit | 0ab5e0f779d7261c4a9faf890cef8df52726a82a (patch) | |
| tree | ea38e57b7665a65854e555f4d3367eeebf653bb0 /lib | |
| parent | 701021f97870b4b0be07440b30a5c53faaf39933 (diff) | |
(#2495) Better value validation for sshkey
As mentioned in the ticket it is not obvious that aliases do not belong
in the resourcename but have to be specified with the property
"host_aliases". On the puppet-user list I saw someone using this as a
resource
@@sshkey {"$fqdn,$hostname,$ipaddress":
type => rsa,
key => $sshrsakey,
}
Puppet will now write a correct entry to the know_hosts file, but when
it rereads the file, the field $fqdn,$hostname,$ipaddress is split into
name ($fqdn) and host_aliases ([$hostname,$ipaddress]). Since we dont
find the resource the user specified, puppet will put the same key in
the file over and over again. This patch adds a simple validation on
resourcename.
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/puppet/type/sshkey.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/puppet/type/sshkey.rb b/lib/puppet/type/sshkey.rb index b7a1b8a8d..59a1a12f8 100755 --- a/lib/puppet/type/sshkey.rb +++ b/lib/puppet/type/sshkey.rb @@ -41,7 +41,7 @@ module Puppet raise Puppet::Error, "Aliases cannot include whitespace" end if value =~ /,/ - raise Puppet::Error, "Aliases cannot include whitespace" + raise Puppet::Error, "Aliases must be provided as an array, not a comma-separated list" end end end @@ -50,6 +50,11 @@ module Puppet desc "The host name that the key is associated with." isnamevar + + validate do |value| + raise Puppet::Error, "Resourcename cannot include whitespaces" if value =~ /\s/ + raise Puppet::Error, "No comma in resourcename allowed. If you want to specify aliases use the host_aliases property" if value.include?(',') + end end newproperty(:target) do |
