From aedd59cb2427c8642b817587b0c5ad1319161daa Mon Sep 17 00:00:00 2001 From: Paul Lathrop Date: Fri, 1 Feb 2008 16:51:48 -0800 Subject: fix bug 974 - filenames with opening bracket characters generate exceptions --- lib/puppet/resource_reference.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/resource_reference.rb b/lib/puppet/resource_reference.rb index 3e92662b2..d5fc90d1f 100644 --- a/lib/puppet/resource_reference.rb +++ b/lib/puppet/resource_reference.rb @@ -37,7 +37,7 @@ class Puppet::ResourceReference # set things appropriately; else, just set it. def title=(value) if value =~ /^(.+)\[(.+)\]$/ - self.type = $1 + @type = $1 @title = $2 else @title = value -- cgit From 139ff33e1f93a0634547fc9a06442a720fe0a58e Mon Sep 17 00:00:00 2001 From: Paul Lathrop Date: Mon, 21 Jan 2008 17:01:53 -0800 Subject: Fujin's patch for ticket #1007 - consistent use of 'environment' instead of 'env' --- lib/puppet/type/exec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 5bb3158c4..a7a046c43 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -228,7 +228,7 @@ module Puppet end end - newparam(:env) do + newparam(:environment) do desc "Any additional environment variables you want to set for a command. Note that if you use this to set PATH, it will override the ``path`` attribute. Multiple environment variables should be @@ -554,32 +554,32 @@ module Puppet begin # Do our chdir Dir.chdir(dir) do - env = {} + environment = {} if self[:path] - env[:PATH] = self[:path].join(":") + environment[:PATH] = self[:path].join(":") end - if envlist = self[:env] + if envlist = self[:environment] envlist = [envlist] unless envlist.is_a? Array envlist.each do |setting| if setting =~ /^(\w+)=((.|\n)+)$/ name = $1 value = $2 - if env.include? name + if environment.include? name warning( "Overriding environment setting '%s' with '%s'" % [name, value] ) end - env[name] = value + environment[name] = value else - warning "Cannot understand env setting %s" % setting.inspect + warning "Cannot understand environment setting %s" % setting.inspect end end end - withenv env do + withenv environment do Timeout::timeout(self[:timeout]) do output, status = Puppet::Util::SUIDManager.run_and_capture( [command], self[:user], self[:group] -- cgit From 8f0d87d498ca12417a7d20b81ba46465658fa210 Mon Sep 17 00:00:00 2001 From: Paul Lathrop Date: Tue, 5 Feb 2008 14:05:14 -0800 Subject: Added :env parameter for backwards-compatibility, with warning about deprecation. :env parameter sets new :environment parameter. Changed instances of :env to :environment for consistency with other types. Added tests for new parameters. This cimmit fixes ticket 1007. --- lib/puppet/type/exec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index a7a046c43..7d3b1abe1 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -228,6 +228,15 @@ module Puppet end end + newparam(:env) do + desc "This parameter is deprecated. Use 'environment' instead." + + munge do |value| + warning "'env' is deprecated on exec; use 'environment' instead." + resource[:environment] = value + end + end + newparam(:environment) do desc "Any additional environment variables you want to set for a command. Note that if you use this to set PATH, it will override -- cgit From b3f67ec4017940a7eb47f3a044fd77c8d32a74cf Mon Sep 17 00:00:00 2001 From: Paul Lathrop Date: Tue, 5 Feb 2008 15:07:05 -0800 Subject: Fix ticket 974. My original "fix" wasn't. This actually fixes the problem by using a regular expression that matches only up to the first square bracket. --- lib/puppet/resource_reference.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/resource_reference.rb b/lib/puppet/resource_reference.rb index d5fc90d1f..771a91be7 100644 --- a/lib/puppet/resource_reference.rb +++ b/lib/puppet/resource_reference.rb @@ -36,8 +36,8 @@ class Puppet::ResourceReference # If the title has square brackets, treat it like a reference and # set things appropriately; else, just set it. def title=(value) - if value =~ /^(.+)\[(.+)\]$/ - @type = $1 + if value =~ /^([^\[\]]+)\[(.+)\]$/ + self.type = $1 @title = $2 else @title = value -- cgit From 2931723bae9e4226ab8eb7f6f806bf9a2ea5cbb8 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 7 Feb 2008 15:31:43 -0600 Subject: Fixing the Settings class so that it correctly handles file values that are false. --- lib/puppet/util/settings.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index ff019edb8..c84a5bfb1 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -509,12 +509,11 @@ class Puppet::Util::Settings objects += add_user_resources(section, obj, done) end + value = obj.value + # Only files are convertable to transportable resources. - next unless obj.respond_to? :to_transportable - next if value(obj.name) =~ /^\/dev/ - next if Puppet::Type::File[obj.value] # skip files that are in our global resource list. + next unless obj.respond_to? :to_transportable and transobjects = obj.to_transportable - transobjects = obj.to_transportable transobjects = [transobjects] unless transobjects.is_a? Array transobjects.each do |trans| # transportable could return nil @@ -1154,12 +1153,15 @@ Generated on #{Time.now}. def to_transportable type = self.type return nil unless type - path = @parent.value(self.name).split(File::SEPARATOR) - path.shift # remove the leading nil - objects = [] path = self.value + return nil unless path.is_a?(String) + return nil if path =~ /^\/dev/ + return nil if Puppet::Type::File[path] # skip files that are in our global resource list. + + objects = [] + # Skip plain files that don't exist, since we won't be managing them anyway. return nil unless self.name.to_s =~ /dir$/ or File.exist?(path) or self.create obj = Puppet::TransObject.new(path, "file") -- cgit From b293763f9ef2e134f18bb2c3fdaaaa502aa2c201 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 7 Feb 2008 15:34:30 -0600 Subject: Applying patch by Jay to fix #989 -- missing crl files are correctly ignored, and you now use 'false' instead of 'none' to explicitly ignore them. --- lib/puppet/defaults.rb | 2 +- lib/puppet/network/http_server/webrick.rb | 4 ++-- lib/puppet/sslcertificates/ca.rb | 6 +++--- lib/puppet/util/settings.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 0c8ac3f82..520a18d1a 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -232,7 +232,7 @@ module Puppet :owner => "$user", :group => "$group", :mode => 0664, - :desc => "The certificate revocation list (CRL) for the CA. Set this to 'none' if you do not want to use a CRL." + :desc => "The certificate revocation list (CRL) for the CA. Set this to 'false' if you do not want to use a CRL." }, :caprivatedir => { :default => "$cadir/private", :owner => "$user", diff --git a/lib/puppet/network/http_server/webrick.rb b/lib/puppet/network/http_server/webrick.rb index 3c9f72e17..e4f00dd73 100644 --- a/lib/puppet/network/http_server/webrick.rb +++ b/lib/puppet/network/http_server/webrick.rb @@ -22,12 +22,12 @@ module Puppet # with them, with flags appropriate for checking client # certificates for revocation def x509store - if Puppet[:cacrl] == 'none' + if Puppet[:cacrl] == 'false' # No CRL, no store needed return nil end unless File.exist?(Puppet[:cacrl]) - raise Puppet::Error, "Could not find CRL; set 'cacrl' to 'none' to disable CRL usage" + raise Puppet::Error, "Could not find CRL; set 'cacrl' to 'false' to disable CRL usage" end crl = OpenSSL::X509::CRL.new(File.read(Puppet[:cacrl])) store = OpenSSL::X509::Store.new diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb index a3edd2cb4..888bcf5b2 100644 --- a/lib/puppet/sslcertificates/ca.rb +++ b/lib/puppet/sslcertificates/ca.rb @@ -194,8 +194,8 @@ class Puppet::SSLCertificates::CA # Revoke the certificate with serial number SERIAL issued by this # CA. The REASON must be one of the OpenSSL::OCSP::REVOKED_* reasons def revoke(serial, reason = OpenSSL::OCSP::REVOKED_STATUS_KEYCOMPROMISE) - if @config[:cacrl] == 'none' - raise Puppet::Error, "Revocation requires a CRL, but ca_crl is set to 'none'" + if @config[:cacrl] == 'false' + raise Puppet::Error, "Revocation requires a CRL, but ca_crl is set to 'false'" end time = Time.now revoked = OpenSSL::X509::Revoked.new @@ -372,7 +372,7 @@ class Puppet::SSLCertificates::CA @crl = OpenSSL::X509::CRL.new( File.read(@config[:cacrl]) ) - elsif @config[:cacrl] == 'none' + elsif @config[:cacrl] == 'false' @crl = nil else # Create new CRL diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index c84a5bfb1..cf15d3194 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -1124,7 +1124,7 @@ Generated on #{Time.now}. # the variable 'dir', or adding a slash at the end. def munge(value) # If it's not a fully qualified path... - if value.is_a?(String) and value !~ /^\$/ and value !~ /^\// + if value.is_a?(String) and value !~ /^\$/ and value !~ /^\// and value != 'false' # Make it one value = File.join(Dir.getwd, value) end -- cgit From 084d0fb6351ed54ff4c052cff20f21e89063620c Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 7 Feb 2008 15:52:02 -0600 Subject: Adding more information to dependencies that do not resolve --- lib/puppet/metatype/metaparams.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb index b35adae66..9983c34d2 100644 --- a/lib/puppet/metatype/metaparams.rb +++ b/lib/puppet/metatype/metaparams.rb @@ -258,7 +258,7 @@ class Puppet::Type @value.each do |value| unless @resource.catalog.resource(*value) description = self.class.direction == :in ? "dependency" : "dependent" - raise Puppet::Error, "Could not find #{description} %s[%s]" % [value[0].to_s.capitalize, value[1]] + fail Puppet::Error, "Could not find #{description} %s[%s] for %s" % [value[0].to_s.capitalize, value[1], resource.ref] end end end -- cgit