diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2011-05-30 20:31:14 +0200 |
|---|---|---|
| committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-07-26 14:04:28 -0700 |
| commit | 6401dfe5602fd39cc59ec1f1b3822110e4ad864a (patch) | |
| tree | ccea4f33b572c998cd4770feab3e6959f354b7eb | |
| parent | 0c385f1fb436ab6f667693d347f711470305a019 (diff) | |
| download | puppet-6401dfe5602fd39cc59ec1f1b3822110e4ad864a.tar.gz puppet-6401dfe5602fd39cc59ec1f1b3822110e4ad864a.tar.xz puppet-6401dfe5602fd39cc59ec1f1b3822110e4ad864a.zip | |
Fix #6026 - security file should support inline comments
Auth.conf, namespaceauth.conf and fileserver.conf were not supporting
trailing inlined comments.
Also this commit fixes some indentation and error management.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
| -rw-r--r-- | lib/puppet/file_serving/configuration/parser.rb | 19 | ||||
| -rw-r--r-- | lib/puppet/network/authconfig.rb | 2 | ||||
| -rw-r--r-- | spec/integration/network/rest_authconfig_spec.rb | 1 | ||||
| -rwxr-xr-x | spec/unit/file_serving/configuration/parser_spec.rb | 8 | ||||
| -rwxr-xr-x | spec/unit/network/authconfig_spec.rb | 11 |
5 files changed, 26 insertions, 15 deletions
diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index 334201d37..83b75e28f 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -24,9 +24,10 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile when /^\s*$/; next # skip blank lines when /\[([-\w]+)\]/ mount = newmount($1) - when /^\s*(\w+)\s+(.+)$/ + when /^\s*(\w+)\s+(.+?)(\s*#.*)?$/ var = $1 value = $2 + value.strip! raise(ArgumentError, "Fileserver configuration file does not use '=' as a separator") if value =~ /^=/ case var when "path" @@ -58,12 +59,8 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile begin mount.info "allowing #{val} access" mount.allow(val) - rescue AuthStoreError => detail - - raise ArgumentError.new( - detail.to_s, - - @count, file) + rescue Puppet::AuthStoreError => detail + raise ArgumentError.new(detail.to_s, @count, file) end } end @@ -75,12 +72,8 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile begin mount.info "denying #{val} access" mount.deny(val) - rescue AuthStoreError => detail - - raise ArgumentError.new( - detail.to_s, - - @count, file) + rescue Puppet::AuthStoreError => detail + raise ArgumentError.new(detail.to_s, @count, file) end } end diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb index 61fb24ded..1e486a2f9 100644 --- a/lib/puppet/network/authconfig.rb +++ b/lib/puppet/network/authconfig.rb @@ -102,7 +102,7 @@ module Puppet name = $3 if $2 == "path" name.chomp! right = newrights.newright(name, count, @file) - when /^\s*(allow|deny|method|environment|auth(?:enticated)?)\s+(.+)$/ + when /^\s*(allow|deny|method|environment|auth(?:enticated)?)\s+(.+?)(\s*#.*)?$/ parse_right_directive(right, $1, $2, count) else raise ConfigurationError, "Invalid line #{count}: #{line}" diff --git a/spec/integration/network/rest_authconfig_spec.rb b/spec/integration/network/rest_authconfig_spec.rb index 7c50d8970..0e5278860 100644 --- a/spec/integration/network/rest_authconfig_spec.rb +++ b/spec/integration/network/rest_authconfig_spec.rb @@ -125,7 +125,6 @@ describe Puppet::Network::RestAuthConfig do end it "should support inlined comments" do - pending('bug #6026') add_rule('allow host.domain.com # will it work?') @auth.should allow(request) diff --git a/spec/unit/file_serving/configuration/parser_spec.rb b/spec/unit/file_serving/configuration/parser_spec.rb index 3d6b3e234..5ccfc5075 100755 --- a/spec/unit/file_serving/configuration/parser_spec.rb +++ b/spec/unit/file_serving/configuration/parser_spec.rb @@ -118,6 +118,14 @@ describe Puppet::FileServing::Configuration::Parser do @parser.parse end + it "should support inline comments" do + mock_file_content "[one]\nallow something \# will it work?\n" + + @mount.expects(:info) + @mount.expects(:allow).with("something") + @parser.parse + end + it "should tell the mount to deny any deny values from the section" do mock_file_content "[one]\ndeny something\n" diff --git a/spec/unit/network/authconfig_spec.rb b/spec/unit/network/authconfig_spec.rb index f33de7872..ca94cc1ab 100755 --- a/spec/unit/network/authconfig_spec.rb +++ b/spec/unit/network/authconfig_spec.rb @@ -196,6 +196,17 @@ describe Puppet::Network::AuthConfig do @authconfig.read end + it "should allow ACE inline comments" do + acl = stub 'acl', :info + + @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?') + @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl) + + acl.expects(:allow).with('127.0.0.1') + + @authconfig.read + end + it "should create an allow ACE on each subsequent allow" do acl = stub 'acl', :info |
