summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-11-10 15:24:55 +0100
committerJames Turnbull <james@lovedthanlost.net>2008-11-11 10:15:38 +1100
commite032034fc4f5f45d883f24104c436e16ce555c0e (patch)
treee4a0d73ca1664ab02c3e569e628ca0077ca30927 /lib/puppet
parente33d0871028ab3483f555103811f1c8c2685f511 (diff)
downloadpuppet-e032034fc4f5f45d883f24104c436e16ce555c0e.tar.gz
puppet-e032034fc4f5f45d883f24104c436e16ce555c0e.tar.xz
puppet-e032034fc4f5f45d883f24104c436e16ce555c0e.zip
Fix #1737 - ssh_authorized_keys should be able to parse options containing commas
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/provider/ssh_authorized_key/parsed.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb
index 5411a1fb8..77af58ef5 100644
--- a/lib/puppet/provider/ssh_authorized_key/parsed.rb
+++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb
@@ -19,7 +19,7 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
if record[:options].nil?
record[:options] = [:absent]
else
- record[:options] = record[:options].split(',')
+ record[:options] = Puppet::Type::Ssh_authorized_key::ProviderParsed.parse_options(record[:options])
end
},
:pre_gen => proc { |record|
@@ -71,5 +71,25 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
File.chown(Puppet::Util.uid(user), nil, @property_hash[:target])
end
end
+
+ # parse sshv2 option strings, wich is a comma separated list of
+ # either key="values" elements or bare-word elements
+ def self.parse_options(options)
+ result = []
+ scanner = StringScanner.new(options)
+ while !scanner.eos?
+ scanner.skip(/[ \t]*/)
+ # scan a long option
+ if out = scanner.scan(/[-a-z0-9A-Z_]+=\".*?\"/) or out = scanner.scan(/[-a-z0-9A-Z_]+/)
+ result << out
+ else
+ # found an unscannable token, let's abort
+ break
+ end
+ # eat a comma
+ scanner.skip(/[ \t]*,[ \t]*/)
+ end
+ result
+ end
end