diff options
author | Luke Kanies <luke@madstop.com> | 2008-10-17 09:01:04 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-10-17 09:01:04 -0500 |
commit | 8aee40de69e6fe8d67ab58a2e223443b15820584 (patch) | |
tree | 89e230df3b43302a542f2cb6869f63e2fb93f6d8 /lib/puppet | |
parent | 1b517d2fb048603bd1743a662bde74e8ae4b13dc (diff) | |
parent | a74ec60d33dee1c592ec858faeccc23d7a7b79f3 (diff) | |
download | puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.tar.gz puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.tar.xz puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.zip |
Merge branch '0.24.x' Removed the 'after' blocks that call Type.clear,
since that method is deprecated.
Conflicts:
CHANGELOG
bin/puppetca
lib/puppet/file_serving/fileset.rb
lib/puppet/network/xmlrpc/client.rb
lib/puppet/type/file/selcontext.rb
spec/unit/file_serving/metadata.rb
spec/unit/type/file.rb
Diffstat (limited to 'lib/puppet')
69 files changed, 2315 insertions, 1200 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index d0dcb1c51..ba47dcd25 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -116,16 +116,11 @@ module Puppet namespaces and methods. This can be used as a coarse-grained authorization system for both ``puppetd`` and ``puppetmasterd``." ], - :environments => ["production,development", "The valid environments for Puppet clients. - This is more useful as a server-side setting than client, but any - environment chosen must be in this list. Values should be - separated by a comma."], :environment => {:default => "production", :desc => "The environment Puppet is running in. For clients (e.g., ``puppetd``) this determines the environment itself, which is used to find modules and much more. For servers (i.e., ``puppetmasterd``) this provides the default environment for nodes - we know nothing about.", - :hook => proc { |value| raise(ArgumentError, "Invalid environment %s" % value) unless Puppet::Node::Environment.valid?(value) } + we know nothing about." }, :diff_args => ["", "Which arguments to pass to the diff command when printing differences between files."], :diff => ["diff", "Which diff command to use when printing differences between files."], diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index a90734a2b..b28fb2d7e 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -20,7 +20,7 @@ class Puppet::FileServing::Fileset # Now strip off the leading path, so each file becomes relative, and remove # any slashes that might end up at the beginning of the path. - result = files.collect { |file| file.sub(@path, '').sub(%r{^/},'') } + result = files.collect { |file| file.sub(%r{^#{Regexp.escape(@path)}/*}, '') } # And add the path itself. result.unshift(".") @@ -122,7 +122,7 @@ class Puppet::FileServing::Fileset return result end - + public # Stat a given file, using the links-appropriate method. def stat(path) unless defined?(@stat_method) diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 1cc3fa355..1fc2b40ab 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -60,10 +60,10 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base case stat.ftype when "file": - @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path) + @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s when "directory": # Always just timestamp the directory. - sumtype = @checksum_type.to_s =~ /time/ ? @checksum_type : "ctime" - @checksum = ("{%s}" % sumtype) + send("%s_file" % sumtype, path).to_s + @checksum_type = "ctime" + @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, path).to_s when "link": @destination = File.readlink(real_path) else diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index b34f2f8b0..9385812b1 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -73,17 +73,23 @@ class Puppet::Module end template_paths = templatepath(environment) - default_template_path = File::join(template_paths.first, template) + if template_paths + # If we can find the template in :templatedir, we return that. + td_file = template_paths.collect { |path| + File::join(path, template) + }.find { |f| File.exists?(f) } - # If we can find the template in :templatedir, we return that. - td_file = template_paths.collect { |path| - File::join(path, template) - }.find { |f| File.exists?(f) } - - return td_file unless td_file == nil + return td_file unless td_file == nil + end td_file = find_template_for_module(template, environment) - td_file ||= default_template_path + + # check in the default template dir, if there is one + if td_file.nil? + raise Puppet::Error, "No valid template directory found, please check templatedir settings" if template_paths.nil? + td_file = File::join(template_paths.first, template) + end + td_file end def self.find_template_for_module(template, environment = nil) diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index 14319ef96..160dab1bb 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -70,7 +70,9 @@ class Puppet::Network::Handler mount.debug("Describing %s for %s" % [url, client]) if client # use the mount to resolve the path for us. - metadata = Puppet::FileServing::Metadata.new(url, :path => mount.file_path(path, client), :links => links) + return "" unless full_path = mount.file_path(path, client) + + metadata = Puppet::FileServing::Metadata.new(url, :path => full_path, :links => links) return "" unless metadata.exist? @@ -654,55 +656,38 @@ class Puppet::Network::Handler # and "bad batch". # def list(relpath, recurse, ignore, client = nil) - reclist(file_path(relpath, client), nil, recurse, ignore) - end - - # Recursively list the files in this tree. - def reclist(basepath, abspath, recurse, ignore) - abspath = basepath if abspath.nil? - relpath = abspath.sub(%r{^#{basepath}}, '') - relpath = "/#{relpath}" if relpath[0] != ?/ #/ - - return unless FileTest.exists?(abspath) - - desc = [relpath] - - ftype = File.stat(abspath).ftype - - desc << ftype - if recurse.is_a?(Integer) - recurse -= 1 + abspath = file_path(relpath, client) + if FileTest.exists?(abspath) + if FileTest.directory?(abspath) and recurse + return reclist(abspath, recurse, ignore) + else + return [["/", File.stat(abspath).ftype]] + end end + return nil + end - ary = [desc] - if recurse == true or (recurse.is_a?(Integer) and recurse > -1) - if ftype == "directory" - children = Dir.entries(abspath) - if ignore - children = handleignore(children, abspath, ignore) - end - children.each { |child| - next if child =~ /^\.\.?$/ - reclist(basepath, File.join(abspath, child), recurse, ignore).each { |cobj| - ary << cobj - } - } + def reclist(abspath, recurse, ignore) + require 'puppet/file_serving' + require 'puppet/file_serving/fileset' + args = { :recurse => recurse, :links => :follow } + args[:ignore] = ignore if ignore + fs = Puppet::FileServing::Fileset.new(abspath, args) + ary = fs.files.collect do |file| + if file == "." + file = "/" + else + file = File.join("/", file ) end + stat = fs.stat(File.join(abspath, file)) + next if stat.nil? + [ file, stat.ftype ] end return ary.compact end - # Deal with ignore parameters. - def handleignore(files, path, ignore_patterns) - ignore_patterns.each do |ignore| - files.delete_if do |entry| - File.fnmatch(ignore, entry, File::FNM_DOTMATCH) - end - end - return files - end - end + end # A special mount class specifically for the plugins mount -- just # has some magic to effectively do a union mount of the 'plugins' @@ -730,7 +715,7 @@ class Puppet::Network::Handler end def file_path(relpath, client = nil) - mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first + return nil unless mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first mod_file_path(mod, relpath, client) end @@ -738,9 +723,16 @@ class Puppet::Network::Handler def list(relpath, recurse, ignore, client = nil) result = [] valid_modules.each do |m| - ary = reclist(mod_file_path(m, relpath, client), nil, recurse, ignore) - ary = [] if ary.nil? - result += ary + modpath = mod_file_path(m, relpath, client) + if FileTest.exists?(modpath) + if FileTest.directory?(modpath) and recurse + ary = reclist(modpath, recurse, ignore) + ary = [] if ary.nil? + result += ary + else + result += [["/", File.stat(modpath).ftype]] + end + end end result end diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index 05ae7b9a2..71b633a09 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -24,7 +24,7 @@ class Puppet::Network::Handler # Tell a client whether there's a fresh config for it def freshness(client = nil, clientip = nil) # Always force a recompile. Newer clients shouldn't do this (as of April 2008). - return 0 + return Time.now.to_i end def initialize(hash = {}) diff --git a/lib/puppet/network/http_server/rack.rb b/lib/puppet/network/http_server/rack.rb new file mode 100644 index 000000000..806007a05 --- /dev/null +++ b/lib/puppet/network/http_server/rack.rb @@ -0,0 +1,148 @@ +# Author: Christian Hofstaedtler <hofstaedtler@inqnet.at> +# Copyright (c) 2006 Manuel Holtgrewe, 2007 Luke Kanies, +# 2008 Christian Hofstaedtler +# +# This file is mostly based on the mongrel module, which is part of +# the standard puppet distribution. +# +# puppet/network/http_server/mongrel.rb has the following license, +# and is based heavily on a file retrieved from: +# http://ttt.ggnore.net/2006/11/15/xmlrpc-with-mongrel-and-ruby-off-rails/ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +require 'puppet' +require 'puppet/network/handler' +require 'puppet/sslcertificates' + +require 'xmlrpc/server' +require 'puppet/network/xmlrpc/server' +require 'puppet/network/http_server' +require 'puppet/network/client_request' +require 'puppet/network/handler' + +require 'resolv' +require 'rack' + +# A handler for a Rack-style puppet(master)d. For the most part, it works +# exactly the same as HTTPServer::Mongrel: +# After checking whether the request itself is sane, the handler forwards +# it to an internal instance of XMLRPC::BasicServer to process it. +module Puppet::Network + class HTTPServer::Rack + attr_reader :xmlrpc_server + + def initialize(handlers) + @debug = false + if Puppet[:debug] + @debug = true + end + + Puppet.info "Starting Rack server for puppet version %s" % Puppet.version + if Puppet[:name] != "puppetmasterd" then + Puppet.warn 'Rack server is not named "puppetmasterd", this may be not what you want. ($0 = %s)' % $0 + end + + @xmlrpc_server = Puppet::Network::XMLRPCServer.new + handlers.each do |name, args| + unless handler = Puppet::Network::Handler.handler(name) + raise ArgumentError, "Invalid handler %s" % name + end + h = handler.new(args) + @xmlrpc_server.add_handler(handler.interface, h) + end + Puppet.info "Rack server is waiting to serve requests." + end + + # Validate a rack-style request (in env), and run the requested XMLRPC + # call. + def process(env) + # time to serve a request + req = Rack::Request.new(env) + + if @debug then + Puppet.info "Handling request, details:" + env.each do |name, val| + l = " env: %s ->" % name + l = l + ' %s' % val + Puppet.info l + end + end + + if not req.post? then + return [405, { "Content-Type" => "text/html" }, "Method Not Allowed"] + end + if req.media_type() != "text/xml" then + return [400, { "Content-Type" => "text/html" }, "Bad Request"] + end + if req.content_length().to_i <= 0 then + return [411, { "Content-Type" => "text/html" }, "Length Required"] + end + + body = '' + req.body().each { |line| body = body + line } + if @debug then + Puppet.info "Request Body: %s" % body + end + if body.size != req.content_length().to_i then + if @debug then + Puppet.info "body length didnt match %d" % body.size + Puppet.info " vs. -> %d" % req.content_length().to_i + end + return [400, { "Content-Type" => "text/html" }, "Bad Request Length"] + end + info = client_info(env) + begin + data = @xmlrpc_server.process(body, info) + return [200, { "Content-Type" => "text/xml; charset=utf-8" }, data] + rescue => detail + Puppet.err "Rack: Internal Server Error: XMLRPC_Server.process problem. Details follow: " + detail.backtrace.each { |line| Puppet.err " --> %s" % line } + return [500, { "Content-Type" => "text/html" }, "Internal Server Error"] + end + end + + private + + def client_info(request) + ip = request["REMOTE_ADDR"] + # JJM #906 The following dn.match regular expression is forgiving + # enough to match the two Distinguished Name string contents + # coming from Apache, Pound or other reverse SSL proxies. + if dn = request[Puppet[:ssl_client_header]] and dn_matchdata = dn.match(/^.*?CN\s*=\s*(.*)/) + client = dn_matchdata[1].to_str + valid = (request[Puppet[:ssl_client_verify_header]] == 'SUCCESS') + else + begin + client = Resolv.getname(ip) + rescue => detail + Puppet.err "Could not resolve %s: %s" % [ip, detail] + client = "unknown" + end + valid = false + end + info = Puppet::Network::ClientRequest.new(client, ip, valid) + return info + end + end +end + diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index dfd4a95a7..c79f91d57 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -35,10 +35,6 @@ module Puppet::Network interface.methods.each { |ary| method = ary[0] - if public_method_defined?(method) - raise Puppet::DevError, "Method %s is already defined" % - method - end newclient.send(:define_method,method) { |*args| Puppet.debug "Calling %s.%s" % [namespace, method] begin @@ -52,7 +48,6 @@ module Puppet::Network ["certificate verify failed", "hostname was not match", "hostname not match"].each do |str| if detail.message.include?(str) Puppet.warning "Certificate validation failed; consider using the certname configuration option" - break end end raise XMLRPCClientError, @@ -75,6 +70,10 @@ module Puppet::Network Puppet.warning "Other end went away; restarting connection and retrying" self.recycle_connection retry + rescue Timeout::Error => detail + Puppet.err "Connection timeout calling %s.%s: %s" % + [namespace, method, detail.to_s] + raise XMLRPCClientError.new("Connection Timeout").set_backtrace(detail.backtrace) rescue => detail if detail.message =~ /^Wrong size\. Was \d+, should be \d+$/ Puppet.warning "XMLRPC returned wrong size. Retrying." diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index 77f1f0780..9650562d4 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -15,12 +15,7 @@ class Puppet::Node attr_accessor :name, :classes, :parameters, :source, :ipaddress attr_reader :time - - # Set the environment, making sure that it's valid. - def environment=(value) - raise(ArgumentError, "Invalid environment %s" % value) unless Puppet::Node::Environment.valid?(value) - @environment = value - end + attr_writer :environment # Do not return environments that are the empty string, and use # explicitly set environments, then facts, then a central env @@ -28,7 +23,6 @@ class Puppet::Node def environment unless @environment if env = parameters["environment"] - raise(ArgumentError, "Invalid environment %s from parameters" % env) unless Puppet::Node::Environment.valid?(env) @environment = env else @environment = Puppet::Node::Environment.new.name.to_s diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index 343720a62..b64b9c2c4 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -1,30 +1,14 @@ # Model the environment that a node can operate in. This class just # provides a simple wrapper for the functionality around environments. class Puppet::Node::Environment - # Return the list of valid environments. Just looks them up in - # the settings. - def self.valid - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] - x = Puppet.settings.value(:environments).split(",").collect { |e| e.to_sym } - end - - # Is the provided environment valid? - def self.valid?(name) - return false if name.to_s == "" - valid.include?(name.to_sym) - end - @seen = {} - # Return an existing environment instance, or create a new one, - # validating the environment name. + # Return an existing environment instance, or create a new one. def self.new(name = nil) name ||= Puppet.settings.value(:environment) raise ArgumentError, "Environment name must be specified" unless name - raise(ArgumentError, "'%s' is not a valid environment" % name) unless valid?(name) - symbol = name.to_sym return @seen[symbol] if @seen[symbol] diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index c9bd7c9e8..ddf88521c 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -74,19 +74,25 @@ class Puppet::Parser::AST end # And include all of the AST subclasses. +require 'puppet/parser/ast/arithmetic_operator' require 'puppet/parser/ast/astarray' require 'puppet/parser/ast/branch' +require 'puppet/parser/ast/boolean_operator' require 'puppet/parser/ast/caseopt' require 'puppet/parser/ast/casestatement' require 'puppet/parser/ast/collection' require 'puppet/parser/ast/collexpr' +require 'puppet/parser/ast/comparison_operator' require 'puppet/parser/ast/definition' require 'puppet/parser/ast/else' require 'puppet/parser/ast/function' require 'puppet/parser/ast/hostclass' require 'puppet/parser/ast/ifstatement' require 'puppet/parser/ast/leaf' +require 'puppet/parser/ast/minus' require 'puppet/parser/ast/node' +require 'puppet/parser/ast/nop' +require 'puppet/parser/ast/not' require 'puppet/parser/ast/resource' require 'puppet/parser/ast/resource_defaults' require 'puppet/parser/ast/resource_override' diff --git a/lib/puppet/parser/ast/arithmetic_operator.rb b/lib/puppet/parser/ast/arithmetic_operator.rb new file mode 100644 index 000000000..8d9cef86a --- /dev/null +++ b/lib/puppet/parser/ast/arithmetic_operator.rb @@ -0,0 +1,41 @@ +require 'puppet' +require 'puppet/parser/ast/branch' + +class Puppet::Parser::AST + class ArithmeticOperator < AST::Branch + + attr_accessor :operator, :lval, :rval + + # Iterate across all of our children. + def each + [@lval,@rval,@operator].each { |child| yield child } + end + + # Returns a boolean which is the result of the boolean operation + # of lval and rval operands + def evaluate(scope) + # evaluate the operands, should return a boolean value + lval = @lval.safeevaluate(scope) + lval = Puppet::Parser::Scope.number?(lval) + if lval == nil + raise ArgumentError, "left operand of %s is not a number" % @operator + end + rval = @rval.safeevaluate(scope) + rval = Puppet::Parser::Scope.number?(rval) + if rval == nil + raise ArgumentError, "right operand of %s is not a number" % @operator + end + + # compute result + lval.send(@operator, rval) + end + + def initialize(hash) + super + + unless %w{+ - * / << >>}.include?(@operator) + raise ArgumentError, "Invalid arithmetic operator %s" % @operator + end + end + end +end diff --git a/lib/puppet/parser/ast/boolean_operator.rb b/lib/puppet/parser/ast/boolean_operator.rb new file mode 100644 index 000000000..c3b5c7d41 --- /dev/null +++ b/lib/puppet/parser/ast/boolean_operator.rb @@ -0,0 +1,48 @@ +require 'puppet' +require 'puppet/parser/ast/branch' + +class Puppet::Parser::AST + class BooleanOperator < AST::Branch + + attr_accessor :operator, :lval, :rval + + # Iterate across all of our children. + def each + [@lval,@rval,@operator].each { |child| yield child } + end + + # Returns a boolean which is the result of the boolean operation + # of lval and rval operands + def evaluate(scope) + # evaluate the first operand, should return a boolean value + lval = @lval.safeevaluate(scope) + + # return result + # lazy evaluate right operand + case @operator + when "and"; + if Puppet::Parser::Scope.true?(lval) + rval = @rval.safeevaluate(scope) + Puppet::Parser::Scope.true?(rval) + else # false and false == false + false + end + when "or"; + if Puppet::Parser::Scope.true?(lval) + true + else + rval = @rval.safeevaluate(scope) + Puppet::Parser::Scope.true?(rval) + end + end + end + + def initialize(hash) + super + + unless %w{and or}.include?(@operator) + raise ArgumentError, "Invalid boolean operator %s" % @operator + end + end + end +end diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb index 3e13d9400..baed325cb 100644 --- a/lib/puppet/parser/ast/collexpr.rb +++ b/lib/puppet/parser/ast/collexpr.rb @@ -30,7 +30,12 @@ class CollExpr < AST::Branch case @oper when "and": code1.call(resource) and code2.call(resource) when "or": code1.call(resource) or code2.call(resource) - when "==": resource[str1] == str2 + when "==": + if resource[str1].is_a?(Array) && form != :exported + resource[str1].include?(str2) + else + resource[str1] == str2 + end when "!=": resource[str1] != str2 end end diff --git a/lib/puppet/parser/ast/comparison_operator.rb b/lib/puppet/parser/ast/comparison_operator.rb new file mode 100644 index 000000000..63aa36c7f --- /dev/null +++ b/lib/puppet/parser/ast/comparison_operator.rb @@ -0,0 +1,37 @@ +require 'puppet' +require 'puppet/parser/ast/branch' + +class Puppet::Parser::AST + class ComparisonOperator < AST::Branch + + attr_accessor :operator, :lval, :rval + + # Iterate across all of our children. + def each + [@lval,@rval,@operator].each { |child| yield child } + end + + # Returns a boolean which is the result of the boolean operation + # of lval and rval operands + def evaluate(scope) + # evaluate the operands, should return a boolean value + lval = @lval.safeevaluate(scope) + rval = @rval.safeevaluate(scope) + + # return result + unless @operator == '!=' + lval.send(@operator,rval) + else + lval != rval + end + end + + def initialize(hash) + super + + unless %w{== != < > <= >=}.include?(@operator) + raise ArgumentError, "Invalid comparison operator %s" % @operator + end + end + end +end diff --git a/lib/puppet/parser/ast/minus.rb b/lib/puppet/parser/ast/minus.rb new file mode 100644 index 000000000..b0779a8ee --- /dev/null +++ b/lib/puppet/parser/ast/minus.rb @@ -0,0 +1,23 @@ +require 'puppet' +require 'puppet/parser/ast/branch' + +# An object that returns a boolean which is the boolean not +# of the given value. +class Puppet::Parser::AST + class Minus < AST::Branch + attr_accessor :value + + def each + yield @value + end + + def evaluate(scope) + val = @value.safeevaluate(scope) + val = Puppet::Parser::Scope.number?(val) + if val == nil + raise ArgumentError, "minus operand %s is not a number" % val + end + return -val + end + end +end diff --git a/lib/puppet/parser/ast/nop.rb b/lib/puppet/parser/ast/nop.rb new file mode 100644 index 000000000..ea5232043 --- /dev/null +++ b/lib/puppet/parser/ast/nop.rb @@ -0,0 +1,11 @@ +require 'puppet/parser/ast/branch' + +class Puppet::Parser::AST + # This class is a no-op, it doesn't produce anything + # when evaluated, hence it's name :-) + class Nop < AST::Leaf + def evaluate(scope) + # nothing to do + end + end +end diff --git a/lib/puppet/parser/ast/not.rb b/lib/puppet/parser/ast/not.rb new file mode 100644 index 000000000..c8fa1df2c --- /dev/null +++ b/lib/puppet/parser/ast/not.rb @@ -0,0 +1,19 @@ +require 'puppet' +require 'puppet/parser/ast/branch' + +# An object that returns a boolean which is the boolean not +# of the given value. +class Puppet::Parser::AST + class Not < AST::Branch + attr_accessor :value + + def each + yield @value + end + + def evaluate(scope) + val = @value.safeevaluate(scope) + return ! Puppet::Parser::Scope.true?(val) + end + end +end diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb index f9464acda..8380dcd00 100644 --- a/lib/puppet/parser/ast/resource_override.rb +++ b/lib/puppet/parser/ast/resource_override.rb @@ -19,7 +19,7 @@ class Puppet::Parser::AST # in the current scope. def evaluate(scope) # Get our object reference. - object = @object.safeevaluate(scope) + resource = @object.safeevaluate(scope) hash = {} @@ -30,21 +30,28 @@ class Puppet::Parser::AST # Now we just create a normal resource, but we call a very different # method on the scope. - obj = Puppet::Parser::Resource.new( - :type => object.type, - :title => object.title, - :params => params, - :file => @file, - :line => @line, - :source => scope.source, - :scope => scope - ) - - # Now we tell the scope that it's an override, and it behaves as - # necessary. - scope.compiler.add_override(obj) - - obj + resource = [resource] unless resource.is_a?(Array) + + resource = resource.collect do |r| + res = Puppet::Parser::Resource.new( + :type => r.type, + :title => r.title, + :params => params, + :file => @file, + :line => @line, + :source => scope.source, + :scope => scope + ) + + # Now we tell the scope that it's an override, and it behaves as + # necessary. + scope.compiler.add_override(res) + + res + end + # decapsulate array in case of only one item + return resource.pop if resource.length == 1 + return resource end # Create our ResourceDef. Handles type checking for us. diff --git a/lib/puppet/parser/ast/resource_reference.rb b/lib/puppet/parser/ast/resource_reference.rb index 4bb41165a..e5e2dce99 100644 --- a/lib/puppet/parser/ast/resource_reference.rb +++ b/lib/puppet/parser/ast/resource_reference.rb @@ -24,16 +24,20 @@ class Puppet::Parser::AST # and name. def evaluate(scope) title = @title.safeevaluate(scope) + title = [title] unless title.is_a?(Array) + if @type.to_s.downcase == "class" - objtype = "class" - title = qualified_class(scope, title) + resource_type = "class" + title = title.collect { |t| qualified_class(scope, t) } else - objtype = qualified_type(scope) + resource_type = qualified_type(scope) end - return Puppet::Parser::Resource::Reference.new( - :type => objtype, :title => title - ) + title = title.collect { |t| Puppet::Parser::Resource::Reference.new( + :type => resource_type, :title => t + ) } + return title.pop if title.length == 1 + return title end # Look up a fully qualified class name. diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index bcba9528e..0f9072510 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -72,7 +72,8 @@ class Puppet::Parser::Collector def collect_exported # First get everything from the export table. Just reuse our # collect_virtual method but tell it to use 'exported? for the test. - resources = collect_virtual(true).reject { |r| ! r.virtual? } + resources = collect_virtual(true).reject { |r| ! r.virtual? }.each { |r| r.exported = false } + #resources = collect_virtual(true).reject { |r| ! r.virtual? } count = resources.length diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index 07666acb4..7f07cc322 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -9,7 +9,19 @@ token FALSE EQUALS APPENDS LESSEQUAL NOTEQUAL DOT COLON LLCOLLECT RRCOLLECT token QMARK LPAREN RPAREN ISEQUAL GREATEREQUAL GREATERTHAN LESSTHAN token IF ELSE IMPORT DEFINE ELSIF VARIABLE CLASS INHERITS NODE BOOLEAN token NAME SEMIC CASE DEFAULT AT LCOLLECT RCOLLECT CLASSNAME CLASSREF -token NOT OR AND UNDEF PARROW +token NOT OR AND UNDEF PARROW PLUS MINUS TIMES DIV LSHIFT RSHIFT UMINUS + +prechigh + right NOT + nonassoc UMINUS + left TIMES DIV + left MINUS PLUS + left LSHIFT RSHIFT + left NOTEQUAL ISEQUAL + left GREATEREQUAL GREATERTHAN LESSTHAN LESSEQUAL + left AND + left OR +preclow rule program: statements { @@ -283,7 +295,7 @@ resourcename: quotedtext | variable | array -assignment: VARIABLE EQUALS rvalue { +assignment: VARIABLE EQUALS expression { if val[0] =~ /::/ raise Puppet::ParseError, "Cannot assign to variables in other namespaces" end @@ -292,7 +304,7 @@ assignment: VARIABLE EQUALS rvalue { result = ast AST::VarDef, :name => variable, :value => val[2] } -append: VARIABLE APPENDS rvalue { +append: VARIABLE APPENDS expression { variable = ast AST::Name, :value => val[0] result = ast AST::VarDef, :name => variable, :value => val[2], :append => true } @@ -388,14 +400,14 @@ boolean: BOOLEAN { result = ast AST::Boolean, :value => val[0] } -resourceref: NAME LBRACK rvalue RBRACK { +resourceref: NAME LBRACK rvalues RBRACK { Puppet.warning addcontext("Deprecation notice: Resource references should now be capitalized") result = ast AST::ResourceReference, :type => val[0], :title => val[2] -} | classref LBRACK rvalue RBRACK { +} | classref LBRACK rvalues RBRACK { result = ast AST::ResourceReference, :type => val[0], :title => val[2] } -ifstatement: IF iftest LBRACE statements RBRACE else { +ifstatement: IF expression LBRACE statements RBRACE else { args = { :test => val[1], :statements => val[3] @@ -407,15 +419,91 @@ ifstatement: IF iftest LBRACE statements RBRACE else { result = ast AST::IfStatement, args } + | IF expression LBRACE RBRACE else { + args = { + :test => val[1], + :statements => ast(AST::Nop) + } + + if val[4] + args[:else] = val[4] + end + + result = ast AST::IfStatement, args +} else: # nothing | ELSE LBRACE statements RBRACE { result = ast AST::Else, :statements => val[2] } + | ELSE LBRACE RBRACE { + result = ast AST::Else, :statements => ast(AST::Nop) +} + +# Unlike yacc/bison, it seems racc +# gives tons of shift/reduce warnings +# with the following syntax: +# +# expression: ... +# | expression arithop expressio { ... } +# +# arithop: PLUS | MINUS | DIVIDE | TIMES ... +# +# So I had to develop the expression by adding one rule +# per operator :-( -# Currently we only support a single value, but eventually one assumes -# we'll support operators and such. -iftest: rvalue +expression: rvalue + | expression PLUS expression { + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression MINUS expression { + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression DIV expression { + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression TIMES expression { + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression LSHIFT expression { + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression RSHIFT expression { + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | MINUS expression =UMINUS { + result = ast AST::Minus, :value => val[1] +} + | expression NOTEQUAL expression { + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression ISEQUAL expression { + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression GREATERTHAN expression { + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression GREATEREQUAL expression { + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression LESSTHAN expression { + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression LESSEQUAL expression { + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | NOT expression { + result = ast AST::Not, :value => val[1] +} + | expression AND expression { + result = ast AST::BooleanOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | expression OR expression { + result = ast AST::BooleanOperator, :operator => val[1], :lval => val[0], :rval => val[2] +} + | LPAREN expression RPAREN { + result = val[1] +} casestatement: CASE rvalue LBRACE caseopts RBRACE { options = val[3] diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 71210d919..9226434da 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -126,12 +126,22 @@ class Puppet::Parser::Lexer '\\' => :BACKSLASH, '=>' => :FARROW, '+>' => :PARROW, + '+' => :PLUS, + '-' => :MINUS, + '/' => :DIV, + '*' => :TIMES, + '<<' => :LSHIFT, + '>>' => :RSHIFT, %r{([a-z][-\w]*::)+[a-z][-\w]*} => :CLASSNAME, %r{((::){0,1}[A-Z][-\w]*)+} => :CLASSREF ) TOKENS.add_tokens "Whatever" => :DQTEXT, "Nomatter" => :SQTEXT, "alsonomatter" => :BOOLEAN + TOKENS.add_token :NUMBER, %r{\b(?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?)\b} do |lexer, value| + [TOKENS[:NAME], value] + end + TOKENS.add_token :NAME, %r{[a-z0-9][-\w]*} do |lexer, value| string_token = self # we're looking for keywords here @@ -145,10 +155,6 @@ class Puppet::Parser::Lexer [string_token, value] end - TOKENS.add_token :NUMBER, %r{[0-9]+} do |lexer, value| - [TOKENS[:NAME], value] - end - TOKENS.add_token :COMMENT, %r{#.*}, :skip => true TOKENS.add_token :RETURN, "\n", :skip => true, :incr_line => true, :skip_text => true @@ -432,6 +438,9 @@ class Puppet::Parser::Lexer str.gsub!(/\\#{quote}/,quote) end + # Add to our line count for every carriage return in multi-line strings. + @line += str.count("\n") + return str end diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index 69225cc2b..b025d52c5 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -29,7 +29,7 @@ module Puppet class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..id7dbe8301d1', 'grammar.ra', 644 +module_eval <<'..end grammar.ra modeval..idf5ced460e1', 'grammar.ra', 732 # It got too annoying having code in a file that needs to be compiled. require 'puppet/parser/parser_support' @@ -41,524 +41,693 @@ require 'puppet/parser/parser_support' # $Id$ -..end grammar.ra modeval..id7dbe8301d1 +..end grammar.ra modeval..idf5ced460e1 ##### racc 1.4.5 generates ### racc_reduce_table = [ 0, 0, :racc_error, - 1, 53, :_reduce_1, - 1, 53, :_reduce_none, - 1, 54, :_reduce_none, - 2, 54, :_reduce_4, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 1, 56, :_reduce_none, - 4, 64, :_reduce_18, - 3, 64, :_reduce_19, - 2, 64, :_reduce_20, - 1, 70, :_reduce_none, - 1, 70, :_reduce_none, - 1, 71, :_reduce_none, - 3, 71, :_reduce_24, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_32, - 1, 72, :_reduce_none, - 3, 72, :_reduce_34, - 5, 57, :_reduce_35, - 5, 57, :_reduce_36, - 5, 57, :_reduce_37, - 5, 68, :_reduce_38, - 2, 58, :_reduce_39, - 1, 89, :_reduce_40, - 2, 89, :_reduce_41, - 2, 59, :_reduce_42, - 3, 90, :_reduce_43, - 3, 90, :_reduce_44, - 1, 91, :_reduce_none, - 1, 91, :_reduce_none, - 3, 91, :_reduce_47, - 1, 92, :_reduce_none, - 3, 92, :_reduce_49, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 3, 94, :_reduce_52, - 3, 94, :_reduce_53, - 1, 95, :_reduce_none, - 1, 95, :_reduce_none, - 4, 97, :_reduce_56, - 1, 83, :_reduce_none, - 3, 83, :_reduce_58, - 0, 84, :_reduce_none, - 1, 84, :_reduce_none, - 1, 99, :_reduce_61, - 1, 74, :_reduce_62, - 1, 76, :_reduce_63, - 1, 98, :_reduce_none, - 1, 98, :_reduce_none, + 1, 60, :_reduce_1, + 1, 60, :_reduce_none, + 1, 61, :_reduce_none, + 2, 61, :_reduce_4, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 1, 63, :_reduce_none, + 4, 71, :_reduce_18, + 3, 71, :_reduce_19, + 2, 71, :_reduce_20, + 1, 77, :_reduce_none, + 1, 77, :_reduce_none, + 1, 78, :_reduce_none, + 3, 78, :_reduce_24, + 1, 80, :_reduce_none, + 1, 80, :_reduce_none, + 1, 80, :_reduce_none, + 1, 80, :_reduce_none, + 1, 80, :_reduce_none, + 1, 80, :_reduce_none, + 1, 80, :_reduce_none, + 1, 80, :_reduce_32, + 1, 79, :_reduce_none, + 3, 79, :_reduce_34, + 5, 64, :_reduce_35, + 5, 64, :_reduce_36, + 5, 64, :_reduce_37, + 5, 75, :_reduce_38, + 2, 65, :_reduce_39, + 1, 96, :_reduce_40, + 2, 96, :_reduce_41, + 2, 66, :_reduce_42, + 3, 97, :_reduce_43, + 3, 97, :_reduce_44, 1, 98, :_reduce_none, 1, 98, :_reduce_none, - 1, 98, :_reduce_none, - 1, 98, :_reduce_none, - 3, 60, :_reduce_70, - 3, 69, :_reduce_71, - 0, 85, :_reduce_72, - 1, 85, :_reduce_73, - 3, 85, :_reduce_74, - 3, 102, :_reduce_75, - 3, 103, :_reduce_76, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 0, 88, :_reduce_79, - 1, 88, :_reduce_80, - 3, 88, :_reduce_81, + 3, 98, :_reduce_47, + 1, 99, :_reduce_none, + 3, 99, :_reduce_49, + 1, 100, :_reduce_none, + 1, 100, :_reduce_none, + 3, 101, :_reduce_52, + 3, 101, :_reduce_53, + 1, 102, :_reduce_none, + 1, 102, :_reduce_none, + 4, 104, :_reduce_56, + 1, 90, :_reduce_none, + 3, 90, :_reduce_58, + 0, 91, :_reduce_none, + 1, 91, :_reduce_none, + 1, 106, :_reduce_61, + 1, 81, :_reduce_62, + 1, 83, :_reduce_63, 1, 105, :_reduce_none, - 3, 105, :_reduce_83, - 1, 96, :_reduce_none, - 1, 96, :_reduce_none, - 1, 96, :_reduce_none, - 1, 96, :_reduce_none, - 1, 96, :_reduce_none, - 1, 96, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 1, 101, :_reduce_none, - 4, 78, :_reduce_100, - 3, 78, :_reduce_101, - 1, 80, :_reduce_102, - 1, 80, :_reduce_103, - 1, 77, :_reduce_104, - 4, 81, :_reduce_105, - 4, 81, :_reduce_106, - 6, 62, :_reduce_107, - 0, 108, :_reduce_none, - 4, 108, :_reduce_109, - 1, 107, :_reduce_none, - 5, 61, :_reduce_111, - 1, 109, :_reduce_none, - 2, 109, :_reduce_113, - 5, 110, :_reduce_114, - 4, 110, :_reduce_115, - 1, 111, :_reduce_none, - 3, 111, :_reduce_117, - 3, 79, :_reduce_118, - 1, 113, :_reduce_none, - 4, 113, :_reduce_120, - 1, 115, :_reduce_none, - 3, 115, :_reduce_122, - 3, 114, :_reduce_123, - 1, 112, :_reduce_none, - 1, 112, :_reduce_none, - 1, 112, :_reduce_none, - 1, 112, :_reduce_none, - 1, 112, :_reduce_none, + 1, 105, :_reduce_none, + 1, 105, :_reduce_none, + 1, 105, :_reduce_none, + 1, 105, :_reduce_none, + 1, 105, :_reduce_none, + 3, 67, :_reduce_70, + 3, 76, :_reduce_71, + 0, 92, :_reduce_72, + 1, 92, :_reduce_73, + 3, 92, :_reduce_74, + 3, 109, :_reduce_75, + 3, 111, :_reduce_76, 1, 112, :_reduce_none, 1, 112, :_reduce_none, - 1, 112, :_reduce_131, - 1, 116, :_reduce_132, - 3, 116, :_reduce_133, - 2, 63, :_reduce_134, - 6, 65, :_reduce_135, - 5, 65, :_reduce_136, - 6, 66, :_reduce_137, - 5, 66, :_reduce_138, - 6, 67, :_reduce_139, - 5, 67, :_reduce_140, - 1, 87, :_reduce_none, - 1, 82, :_reduce_none, - 1, 82, :_reduce_none, - 1, 119, :_reduce_none, - 3, 119, :_reduce_145, - 1, 121, :_reduce_none, - 1, 121, :_reduce_none, - 1, 121, :_reduce_none, - 1, 121, :_reduce_none, - 0, 55, :_reduce_150, - 0, 122, :_reduce_151, - 1, 117, :_reduce_none, - 3, 117, :_reduce_153, - 3, 117, :_reduce_154, - 1, 123, :_reduce_none, - 3, 123, :_reduce_156, - 3, 124, :_reduce_157, - 1, 124, :_reduce_158, - 3, 124, :_reduce_159, - 1, 124, :_reduce_160, - 1, 120, :_reduce_none, - 2, 120, :_reduce_162, + 0, 95, :_reduce_79, + 1, 95, :_reduce_80, + 3, 95, :_reduce_81, + 1, 113, :_reduce_none, + 3, 113, :_reduce_83, + 1, 103, :_reduce_none, + 1, 103, :_reduce_none, + 1, 103, :_reduce_none, + 1, 103, :_reduce_none, + 1, 103, :_reduce_none, + 1, 103, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 1, 110, :_reduce_none, + 4, 85, :_reduce_100, + 3, 85, :_reduce_101, + 1, 87, :_reduce_102, + 1, 87, :_reduce_103, + 1, 84, :_reduce_104, + 4, 88, :_reduce_105, + 4, 88, :_reduce_106, + 6, 69, :_reduce_107, + 5, 69, :_reduce_108, + 0, 115, :_reduce_none, + 4, 115, :_reduce_110, + 3, 115, :_reduce_111, + 1, 108, :_reduce_none, + 3, 108, :_reduce_113, + 3, 108, :_reduce_114, + 3, 108, :_reduce_115, + 3, 108, :_reduce_116, + 3, 108, :_reduce_117, + 3, 108, :_reduce_118, + 2, 108, :_reduce_119, + 3, 108, :_reduce_120, + 3, 108, :_reduce_121, + 3, 108, :_reduce_122, + 3, 108, :_reduce_123, + 3, 108, :_reduce_124, + 3, 108, :_reduce_125, + 2, 108, :_reduce_126, + 3, 108, :_reduce_127, + 3, 108, :_reduce_128, + 3, 108, :_reduce_129, + 5, 68, :_reduce_130, + 1, 116, :_reduce_none, + 2, 116, :_reduce_132, + 5, 117, :_reduce_133, + 4, 117, :_reduce_134, 1, 118, :_reduce_none, - 2, 118, :_reduce_164, - 1, 125, :_reduce_none, + 3, 118, :_reduce_136, + 3, 86, :_reduce_137, + 1, 120, :_reduce_none, + 4, 120, :_reduce_139, + 1, 122, :_reduce_none, + 3, 122, :_reduce_141, + 3, 121, :_reduce_142, + 1, 119, :_reduce_none, + 1, 119, :_reduce_none, + 1, 119, :_reduce_none, + 1, 119, :_reduce_none, + 1, 119, :_reduce_none, + 1, 119, :_reduce_none, + 1, 119, :_reduce_none, + 1, 119, :_reduce_150, + 1, 123, :_reduce_151, + 3, 123, :_reduce_152, + 2, 70, :_reduce_153, + 6, 72, :_reduce_154, + 5, 72, :_reduce_155, + 6, 73, :_reduce_156, + 5, 73, :_reduce_157, + 6, 74, :_reduce_158, + 5, 74, :_reduce_159, + 1, 94, :_reduce_none, + 1, 89, :_reduce_none, + 1, 89, :_reduce_none, + 1, 126, :_reduce_none, + 3, 126, :_reduce_164, + 1, 128, :_reduce_none, + 1, 128, :_reduce_none, + 1, 128, :_reduce_none, + 1, 128, :_reduce_none, + 0, 62, :_reduce_169, + 0, 129, :_reduce_170, + 1, 124, :_reduce_none, + 3, 124, :_reduce_172, + 3, 124, :_reduce_173, + 1, 130, :_reduce_none, + 3, 130, :_reduce_175, + 3, 131, :_reduce_176, + 1, 131, :_reduce_177, + 3, 131, :_reduce_178, + 1, 131, :_reduce_179, + 1, 127, :_reduce_none, + 2, 127, :_reduce_181, 1, 125, :_reduce_none, - 1, 75, :_reduce_167, - 3, 100, :_reduce_168, - 2, 100, :_reduce_169, - 1, 106, :_reduce_none, - 1, 106, :_reduce_none, - 0, 86, :_reduce_none, - 1, 86, :_reduce_173 ] + 2, 125, :_reduce_183, + 1, 132, :_reduce_none, + 1, 132, :_reduce_none, + 1, 82, :_reduce_186, + 3, 107, :_reduce_187, + 2, 107, :_reduce_188, + 1, 114, :_reduce_none, + 1, 114, :_reduce_none, + 0, 93, :_reduce_none, + 1, 93, :_reduce_192 ] -racc_reduce_n = 174 +racc_reduce_n = 193 -racc_shift_n = 279 +racc_shift_n = 317 racc_action_table = [ - 77, 57, 60, 246, 167, 105, 77, 57, 60, 101, - 199, 235, -124, 167, 241, 203, 77, 57, 60, 234, - 54, 92, 77, 57, 60, 94, 131, 240, 208, 209, - 104, 47, 77, 57, 60, 59, 63, 47, 95, 68, - 131, 59, 63, 137, 55, 68, 166, 47, 65, 211, - 55, 59, 178, 47, 65, 68, -125, 59, 63, 173, - 116, 68, 96, 47, 65, -126, 55, 59, 119, -128, - 65, 68, 77, 57, 60, 147, 116, 208, 209, 147, - 65, 213, 77, 57, 60, 147, 47, 40, 41, 212, - 47, 151, 54, 57, 60, 151, 47, 35, 77, 57, - 60, 151, 188, 47, 4, 9, 172, 59, 63, 199, - 9, 68, 50, 47, 203, -125, 55, 59, 63, 204, - 65, 68, 42, 47, 205, 43, 55, 59, 63, 47, - 65, 68, 35, 59, 63, 51, 55, 68, 167, 4, - 65, 147, 55, 77, 57, 60, 65, 33, 34, 77, - 57, 60, 47, 171, 40, 41, 35, 151, -127, 77, - 57, 60, -129, 4, 214, 77, 57, 60, 208, 209, - 40, 41, 57, 60, 47, 77, 57, 60, 59, 63, - 47, 171, 68, -124, 59, 63, -130, 55, 68, 42, - 47, 65, 43, 55, 59, 63, 47, 65, 68, -125, - 59, 63, 219, 55, 68, 42, 47, 65, 43, 55, - 59, 63, 111, 65, 68, 77, 57, 60, 92, 55, - 191, 262, -127, 65, -124, 77, 57, 60, 135, 57, - 60, 35, 57, 60, 159, 189, 224, 225, 4, 191, - 192, 145, 57, 60, 145, 228, 47, 131, 57, 60, - 59, 63, 127, 133, 68, 231, 47, 54, 132, 55, - 59, 63, 47, 65, 68, -126, 59, 63, 168, 55, - 68, -141, 47, 65, 51, 55, 59, 178, 47, 65, - 68, 238, 59, 178, 239, 116, 68, 57, 60, 65, - -126, 116, 242, 57, 60, 65, 129, 245, -128, 138, - -129, 111, 94, 57, 60, -127, 171, 91, 165, 263, - 265, 90, 163, 57, 60, 139, 140, 47, 46, 57, - 60, 59, 178, 47, -129, 68, -126, 59, 178, 51, - 116, 68, -124, 47, 65, -127, 116, 59, 178, 184, - 65, 68, -125, 47, 57, 60, 116, 59, 178, 47, - 65, 68, 45, 59, 63, 272, 116, 68, -173, 273, - 65, 51, 55, 160, 57, 60, 65, 179, 143, 145, - 183, 57, 60, nil, 47, 237, nil, nil, 59, 178, - nil, nil, 68, nil, nil, nil, nil, 116, nil, nil, - nil, 65, nil, nil, 47, nil, 278, nil, 59, 178, - nil, 47, 68, nil, nil, 59, 178, 116, nil, 68, - nil, 65, nil, nil, 116, 257, nil, 20, 65, 24, - 26, nil, 1, 5, nil, 12, nil, 18, nil, 22, - nil, 27, nil, nil, 4, 9, 20, 243, 24, 26, - nil, 1, 5, nil, 12, nil, 18, nil, 22, nil, - 27, nil, nil, 4, 9, nil, 270, nil, 20, nil, - 24, 26, nil, 1, 5, nil, 12, nil, 18, nil, - 22, nil, 27, nil, nil, 4, 9, 20, 233, 24, - 26, nil, 1, 5, nil, 12, nil, 18, nil, 22, - nil, 27, nil, nil, 4, 9, nil, 277, nil, 20, - nil, 24, 26, nil, 1, 5, nil, 12, nil, 18, - nil, 22, nil, 27, nil, nil, 4, 9, 20, 274, - 24, 26, nil, 1, 5, nil, 12, nil, 18, nil, - 22, nil, 27, nil, nil, 4, 9, nil, 217, nil, - 20, nil, 24, 26, nil, 1, 5, nil, 12, nil, - 18, nil, 22, nil, 27, nil, nil, 4, 9, 20, - 215, 24, 26, nil, 1, 5, nil, 12, nil, 18, - nil, 22, nil, 27, nil, nil, 4, 9, nil, 256, - nil, 20, nil, 24, 26, nil, 1, 5, nil, 12, - nil, 18, nil, 22, nil, 27, nil, nil, 4, 9, - 20, nil, 24, 26, nil, 1, 5, nil, 12, nil, - 18, nil, 22, nil, 27, nil, nil, 4, 9, 20, - nil, 24, 26, nil, 1, 5, nil, 12, nil, 18, - nil, 22, nil, 27, nil, nil, 4, 9, 20, nil, - 24, 26, nil, 1, 5, nil, 12, nil, 18, nil, - 22, nil, 27, nil, nil, 4, 9, 20, nil, 24, - 26, nil, 1, 5, nil, 12, nil, 18, nil, 22, - nil, 27, nil, nil, 4, 9, 20, nil, 24, 26, - nil, 1, 5, nil, 12, nil, 18, nil, 22, nil, - 27, nil, nil, 4, 9 ] + 75, 54, 57, 273, 178, 39, 40, 201, 88, 238, + 51, 178, 89, 213, 245, 8, 265, 198, 199, 246, + 72, 75, 54, 57, 136, 90, 39, 40, 236, 237, + 136, 45, 39, 40, 129, 56, 59, 236, 237, 66, + 41, 72, 154, 44, 52, 76, 177, 162, 62, 92, + 146, 84, 45, 75, 54, 57, 56, 59, 45, 126, + 66, 41, 250, 167, 44, 52, 76, 41, -146, 62, + 44, -143, 84, 72, 75, 54, 57, 291, 156, 157, + 158, 144, 145, 147, 45, 234, 253, 286, 56, 59, + 290, 162, 66, 233, 72, 285, 37, 52, 76, 158, + 144, 62, 45, 4, 84, 45, 154, 167, 37, 56, + 59, 155, 162, 66, 146, 4, 8, 37, 52, 76, + 150, 154, 62, 45, 4, 84, 158, 144, 167, 146, + 148, 151, 153, 105, 230, 75, 54, 57, 198, 199, + 33, 34, 156, 157, 158, 144, 145, 147, 156, 157, + 158, 144, 138, 149, 152, 72, 154, 156, 157, 158, + 144, 145, 147, 257, 146, 162, 45, 75, 54, 57, + 56, 59, 245, -145, 66, 37, 45, 246, 183, 52, + 76, 167, 4, 62, 54, 57, 84, 72, 75, 54, + 57, 259, 156, 157, 158, 144, 145, 147, 45, 161, + 239, 161, 56, 59, 236, 237, 66, 137, 72, 154, + 136, 52, 76, 198, 299, 62, -147, 146, 84, 45, + 75, 54, 57, 56, 59, 197, 51, 66, -144, 198, + 199, -148, 52, 76, 54, 57, 62, 268, 178, 84, + 72, 75, 54, 57, 188, 156, 157, 158, 144, 145, + 147, 45, -149, -144, 88, 56, 59, -146, -148, 66, + -143, 72, 135, -147, 52, 76, -160, 271, 62, -145, + 161, 84, 45, 75, 54, 57, 56, 59, 272, 172, + 66, 156, 157, 158, 144, 52, 76, 132, 173, 62, + 89, 108, 84, 72, 75, 54, 57, 156, 157, 158, + 144, 145, 147, 174, 45, 287, 288, 289, 56, 59, + 180, 105, 66, 100, 72, 188, 184, 52, 76, 186, + -143, 62, 271, 302, 84, 45, 75, 54, 57, 56, + 59, -143, -146, 66, -144, -148, -145, 303, 52, 76, + 188, -146, 62, 71, 193, 84, 72, 75, 54, 57, + 156, 157, 158, 144, 145, 147, 191, 45, 38, 310, + -192, 56, 59, -145, 35, 66, 189, 72, -144, nil, + 52, 76, nil, nil, 62, nil, nil, 84, 45, 75, + 54, 57, 56, 59, nil, nil, 66, nil, nil, nil, + nil, 52, 76, nil, nil, 62, nil, nil, 84, 72, + 75, 54, 57, nil, nil, nil, nil, nil, nil, nil, + 45, nil, nil, nil, 56, 59, nil, nil, 66, nil, + 72, nil, nil, 52, 76, nil, nil, 62, nil, nil, + 84, 45, 75, 54, 57, 56, 59, nil, nil, 66, + nil, nil, nil, nil, 52, 76, nil, nil, 62, nil, + nil, 84, 72, 75, 54, 57, nil, nil, nil, nil, + nil, nil, nil, 45, nil, nil, nil, 56, 59, nil, + nil, 66, nil, 72, nil, nil, 52, 76, nil, nil, + 62, nil, nil, 84, 45, 75, 54, 57, 56, 59, + nil, nil, 66, nil, nil, nil, nil, 52, 76, nil, + nil, 62, nil, nil, 84, 72, 75, 54, 57, nil, + nil, nil, nil, nil, nil, nil, 45, 75, 54, 57, + 56, 59, nil, nil, 66, nil, 72, nil, nil, 52, + 76, nil, nil, 62, nil, nil, 84, 45, 75, 54, + 57, 56, 59, nil, nil, 66, nil, nil, 45, nil, + 52, 76, 56, 116, 62, nil, 66, 84, 72, nil, + nil, 111, 75, 54, 57, 62, nil, nil, nil, 45, + nil, nil, nil, 56, 59, nil, nil, 66, 75, 54, + 57, 141, 52, 76, nil, nil, 62, nil, nil, 84, + nil, nil, nil, 45, 75, 54, 57, 56, 59, nil, + nil, 66, nil, nil, nil, nil, 52, nil, nil, 45, + 62, nil, nil, 56, 59, nil, nil, 66, 75, 54, + 57, nil, 52, nil, nil, 45, 62, nil, nil, 56, + 59, nil, nil, 66, 75, 54, 57, nil, 52, nil, + nil, nil, 62, nil, 75, 54, 57, nil, nil, 45, + 75, 54, 57, 56, 59, nil, nil, 66, nil, nil, + nil, nil, 52, nil, nil, 45, 62, nil, nil, 56, + 59, nil, nil, 66, nil, 45, nil, nil, 52, 56, + 195, 45, 62, 66, nil, 56, 59, nil, 111, 66, + nil, nil, 62, nil, 52, 75, 54, 57, 62, nil, + nil, 51, 54, 57, nil, nil, nil, nil, nil, nil, + nil, 75, 54, 57, nil, nil, nil, 75, 54, 57, + nil, 48, nil, nil, nil, nil, 45, 75, 54, 57, + 56, 59, 45, nil, 66, nil, 56, 59, nil, 52, + 66, nil, 45, 62, 49, 52, 56, 59, 45, 62, + 66, nil, 56, 59, nil, 52, 66, nil, 45, 62, + nil, 52, 56, 59, nil, 62, 66, 54, 57, 54, + 57, 52, nil, nil, nil, 62, nil, nil, nil, nil, + nil, nil, nil, 54, 57, 54, 57, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, 45, nil, 45, + nil, 56, 195, 56, 195, 66, nil, 66, 54, 57, + 111, 49, 111, 45, 62, 45, 62, 56, 195, 56, + 195, 66, nil, 66, nil, nil, 111, nil, 111, nil, + 62, nil, 62, 54, 57, 54, 57, 284, 45, nil, + nil, nil, 56, 195, nil, nil, 66, nil, nil, 54, + 57, 111, 208, nil, nil, 62, 54, 57, nil, nil, + nil, nil, nil, 45, nil, 45, nil, 56, 195, 56, + 195, 66, nil, 66, nil, nil, 111, nil, 111, 45, + 62, nil, 62, 56, 195, nil, 45, 66, 54, 57, + 56, 195, 111, nil, 66, nil, 62, nil, nil, 111, + nil, nil, nil, 62, 54, 57, nil, nil, 131, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 45, nil, + nil, nil, 56, 59, 203, nil, 66, nil, nil, nil, + 49, 52, nil, nil, 45, 62, nil, nil, 56, 59, + nil, nil, 66, 150, 154, nil, 49, 52, nil, nil, + nil, 62, 146, 148, 151, 153, 150, 154, nil, nil, + nil, nil, nil, nil, 212, 146, 148, 151, 153, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + 156, 157, 158, 144, 145, 147, nil, nil, nil, 149, + 152, 150, 154, 156, 157, 158, 144, 145, 147, nil, + 146, 148, 151, 153, 150, 154, nil, nil, nil, nil, + nil, nil, nil, 146, 148, 151, 153, nil, nil, nil, + nil, nil, nil, nil, 149, 152, nil, nil, 156, 157, + 158, 144, 145, 147, nil, nil, 296, nil, 152, 150, + 154, 156, 157, 158, 144, 145, 147, nil, 146, 148, + 151, 153, nil, nil, nil, nil, nil, 16, nil, 23, + 27, 294, 1, 5, nil, 10, nil, 13, nil, 20, + nil, 28, 149, 152, 4, 8, 156, 157, 158, 144, + 145, 147, 16, 293, 23, 27, nil, 1, 5, nil, + 10, nil, 13, nil, 20, nil, 28, nil, nil, 4, + 8, nil, 269, nil, 16, nil, 23, 27, nil, 1, + 5, nil, 10, nil, 13, nil, 20, nil, 28, nil, + nil, 4, 8, 16, 226, 23, 27, nil, 1, 5, + nil, 10, nil, 13, nil, 20, nil, 28, nil, nil, + 4, 8, nil, 308, nil, 16, nil, 23, 27, nil, + 1, 5, nil, 10, nil, 13, nil, 20, nil, 28, + nil, nil, 4, 8, 16, 312, 23, 27, nil, 1, + 5, nil, 10, nil, 13, nil, 20, nil, 28, nil, + nil, 4, 8, nil, 314, nil, 16, nil, 23, 27, + nil, 1, 5, nil, 10, nil, 13, nil, 20, nil, + 28, nil, nil, 4, 8, 16, 263, 23, 27, nil, + 1, 5, nil, 10, nil, 13, nil, 20, nil, 28, + nil, nil, 4, 8, nil, 315, nil, 16, nil, 23, + 27, nil, 1, 5, nil, 10, nil, 13, nil, 20, + nil, 28, nil, nil, 4, 8, 16, 256, 23, 27, + nil, 1, 5, nil, 10, nil, 13, nil, 20, nil, + 28, nil, nil, 4, 8, nil, 316, nil, 16, nil, + 23, 27, nil, 1, 5, nil, 10, nil, 13, nil, + 20, nil, 28, nil, nil, 4, 8, 16, nil, 23, + 27, nil, 1, 5, nil, 10, nil, 13, nil, 20, + nil, 28, nil, nil, 4, 8, 16, nil, 23, 27, + nil, 1, 5, nil, 10, nil, 13, nil, 20, nil, + 28, nil, nil, 4, 8, 16, nil, 23, 27, nil, + 1, 5, nil, 10, nil, 13, nil, 20, nil, 28, + nil, nil, 4, 8 ] racc_action_check = [ - 228, 228, 228, 207, 111, 44, 54, 54, 54, 36, - 241, 195, 83, 119, 201, 241, 168, 168, 168, 195, - 63, 30, 92, 92, 92, 30, 119, 201, 207, 207, - 44, 228, 46, 46, 46, 228, 228, 54, 30, 228, - 63, 54, 54, 82, 228, 54, 111, 168, 228, 149, - 54, 168, 168, 92, 54, 168, 85, 92, 92, 128, - 168, 92, 30, 46, 168, 80, 92, 46, 46, 75, - 92, 46, 167, 167, 167, 95, 46, 149, 149, 147, - 46, 153, 166, 166, 166, 96, 95, 105, 105, 153, - 147, 95, 18, 18, 18, 147, 96, 6, 20, 20, - 20, 96, 133, 167, 6, 6, 126, 167, 167, 140, - 133, 167, 18, 166, 140, 125, 167, 166, 166, 142, - 167, 166, 105, 18, 144, 105, 166, 18, 18, 20, - 166, 18, 5, 20, 20, 18, 18, 20, 145, 5, - 18, 210, 20, 22, 22, 22, 20, 1, 1, 242, - 242, 242, 210, 146, 12, 12, 26, 210, 123, 238, - 238, 238, 74, 26, 156, 34, 34, 34, 156, 156, - 104, 104, 139, 139, 22, 33, 33, 33, 22, 22, - 242, 122, 22, 121, 242, 242, 73, 22, 242, 12, - 238, 22, 12, 242, 238, 238, 34, 242, 238, 72, - 34, 34, 164, 238, 34, 104, 33, 238, 104, 34, - 33, 33, 165, 34, 33, 190, 190, 190, 71, 33, - 230, 230, 70, 33, 69, 77, 77, 77, 77, 24, - 24, 101, 50, 50, 101, 136, 169, 170, 101, 136, - 136, 171, 235, 235, 172, 174, 190, 178, 138, 138, - 190, 190, 50, 66, 190, 185, 77, 188, 64, 190, - 77, 77, 50, 190, 77, 58, 50, 50, 120, 77, - 50, 55, 235, 77, 50, 50, 235, 235, 138, 50, - 235, 199, 138, 138, 200, 235, 138, 132, 132, 235, - 118, 138, 203, 260, 260, 138, 53, 206, 52, 86, - 49, 45, 38, 213, 213, 84, 227, 29, 107, 233, - 234, 27, 106, 212, 212, 88, 89, 132, 17, 131, - 131, 132, 132, 260, 248, 132, 250, 260, 260, 132, - 132, 260, 251, 213, 132, 253, 260, 213, 213, 131, - 260, 213, 254, 212, 179, 179, 213, 212, 212, 131, - 213, 212, 15, 131, 131, 261, 212, 131, 262, 263, - 212, 131, 131, 102, 129, 129, 131, 129, 91, 94, - 130, 197, 197, nil, 179, 197, nil, nil, 179, 179, - nil, nil, 179, nil, nil, nil, nil, 179, nil, nil, - nil, 179, nil, nil, 129, nil, 276, nil, 129, 129, - nil, 197, 129, nil, nil, 197, 197, 129, nil, 197, - nil, 129, nil, nil, 197, 218, nil, 276, 197, 276, - 276, nil, 276, 276, nil, 276, nil, 276, nil, 276, - nil, 276, nil, nil, 276, 276, 218, 204, 218, 218, - nil, 218, 218, nil, 218, nil, 218, nil, 218, nil, - 218, nil, nil, 218, 218, nil, 244, nil, 204, nil, - 204, 204, nil, 204, 204, nil, 204, nil, 204, nil, - 204, nil, 204, nil, nil, 204, 204, 244, 193, 244, - 244, nil, 244, 244, nil, 244, nil, 244, nil, 244, - nil, 244, nil, nil, 244, 244, nil, 275, nil, 193, - nil, 193, 193, nil, 193, 193, nil, 193, nil, 193, - nil, 193, nil, 193, nil, nil, 193, 193, 275, 265, - 275, 275, nil, 275, 275, nil, 275, nil, 275, nil, - 275, nil, 275, nil, nil, 275, 275, nil, 163, nil, - 265, nil, 265, 265, nil, 265, 265, nil, 265, nil, - 265, nil, 265, nil, 265, nil, nil, 265, 265, 163, - 160, 163, 163, nil, 163, 163, nil, 163, nil, 163, - nil, 163, nil, 163, nil, nil, 163, 163, nil, 216, - nil, 160, nil, 160, 160, nil, 160, 160, nil, 160, - nil, 160, nil, 160, nil, 160, nil, nil, 160, 160, - 216, nil, 216, 216, nil, 216, 216, nil, 216, nil, - 216, nil, 216, nil, 216, nil, nil, 216, 216, 273, - nil, 273, 273, nil, 273, 273, nil, 273, nil, 273, - nil, 273, nil, 273, nil, nil, 273, 273, 32, nil, - 32, 32, nil, 32, 32, nil, 32, nil, 32, nil, - 32, nil, 32, nil, nil, 32, 32, 137, nil, 137, - 137, nil, 137, 137, nil, 137, nil, 137, nil, 137, - nil, 137, nil, nil, 137, 137, 0, nil, 0, 0, + 158, 158, 158, 232, 105, 129, 129, 135, 17, 170, + 59, 116, 17, 140, 174, 135, 202, 140, 140, 174, + 158, 84, 84, 84, 116, 17, 10, 10, 232, 232, + 59, 158, 126, 126, 42, 158, 158, 170, 170, 158, + 129, 84, 221, 129, 158, 158, 105, 162, 158, 17, + 221, 158, 84, 144, 144, 144, 84, 84, 162, 42, + 84, 10, 175, 162, 10, 84, 84, 126, 78, 84, + 126, 77, 84, 144, 145, 145, 145, 248, 221, 221, + 221, 221, 221, 221, 144, 165, 179, 242, 144, 144, + 248, 92, 144, 165, 145, 242, 5, 144, 144, 227, + 227, 144, 92, 5, 144, 145, 223, 92, 24, 145, + 145, 85, 90, 145, 223, 24, 24, 27, 145, 145, + 85, 85, 145, 90, 27, 145, 228, 228, 90, 85, + 85, 85, 85, 180, 159, 146, 146, 146, 159, 159, + 1, 1, 223, 223, 223, 223, 223, 223, 217, 217, + 217, 217, 71, 85, 85, 146, 218, 85, 85, 85, + 85, 85, 85, 185, 218, 235, 146, 157, 157, 157, + 146, 146, 291, 70, 146, 108, 235, 291, 108, 146, + 146, 235, 108, 146, 23, 23, 146, 157, 154, 154, + 154, 187, 218, 218, 218, 218, 218, 218, 157, 188, + 171, 189, 157, 157, 171, 171, 157, 68, 154, 220, + 195, 157, 157, 267, 267, 157, 67, 220, 157, 154, + 16, 16, 16, 154, 154, 134, 201, 154, 79, 134, + 134, 65, 154, 154, 173, 173, 154, 209, 161, 154, + 16, 147, 147, 147, 160, 220, 220, 220, 220, 220, + 220, 16, 80, 63, 61, 16, 16, 60, 81, 16, + 58, 147, 53, 82, 16, 16, 52, 226, 16, 87, + 89, 16, 147, 153, 153, 153, 147, 147, 231, 94, + 147, 215, 215, 215, 215, 147, 147, 50, 95, 147, + 97, 36, 147, 153, 152, 152, 152, 224, 224, 224, + 224, 224, 224, 99, 153, 245, 246, 247, 153, 153, + 106, 35, 153, 28, 152, 261, 109, 153, 153, 112, + 113, 153, 269, 271, 153, 152, 76, 76, 76, 152, + 152, 274, 276, 152, 277, 278, 280, 285, 152, 152, + 114, 115, 152, 15, 130, 152, 76, 151, 151, 151, + 216, 216, 216, 216, 216, 216, 127, 76, 6, 298, + 299, 76, 76, 125, 2, 76, 119, 151, 118, nil, + 76, 76, nil, nil, 76, nil, nil, 76, 151, 148, + 148, 148, 151, 151, nil, nil, 151, nil, nil, nil, + nil, 151, 151, nil, nil, 151, nil, nil, 151, 148, + 149, 149, 149, nil, nil, nil, nil, nil, nil, nil, + 148, nil, nil, nil, 148, 148, nil, nil, 148, nil, + 149, nil, nil, 148, 148, nil, nil, 148, nil, nil, + 148, 149, 72, 72, 72, 149, 149, nil, nil, 149, + nil, nil, nil, nil, 149, 149, nil, nil, 149, nil, + nil, 149, 72, 34, 34, 34, nil, nil, nil, nil, + nil, nil, nil, 72, nil, nil, nil, 72, 72, nil, + nil, 72, nil, 34, nil, nil, 72, 72, nil, nil, + 72, nil, nil, 72, 34, 150, 150, 150, 34, 34, + nil, nil, 34, nil, nil, nil, nil, 34, 34, nil, + nil, 34, nil, nil, 34, 150, 156, 156, 156, nil, + nil, nil, nil, nil, nil, nil, 150, 38, 38, 38, + 150, 150, nil, nil, 150, nil, 156, nil, nil, 150, + 150, nil, nil, 150, nil, nil, 150, 156, 33, 33, + 33, 156, 156, nil, nil, 156, nil, nil, 38, nil, + 156, 156, 38, 38, 156, nil, 38, 156, 33, nil, + nil, 38, 196, 196, 196, 38, nil, nil, nil, 33, + nil, nil, nil, 33, 33, nil, nil, 33, 75, 75, + 75, 75, 33, 33, nil, nil, 33, nil, nil, 33, + nil, nil, nil, 196, 51, 51, 51, 196, 196, nil, + nil, 196, nil, nil, nil, nil, 196, nil, nil, 75, + 196, nil, nil, 75, 75, nil, nil, 75, 268, 268, + 268, nil, 75, nil, nil, 51, 75, nil, nil, 51, + 51, nil, nil, 51, 20, 20, 20, nil, 51, nil, + nil, nil, 51, nil, 186, 186, 186, nil, nil, 268, + 287, 287, 287, 268, 268, nil, nil, 268, nil, nil, + nil, nil, 268, nil, nil, 20, 268, nil, nil, 20, + 20, nil, nil, 20, nil, 186, nil, nil, 20, 186, + 186, 287, 20, 186, nil, 287, 287, nil, 186, 287, + nil, nil, 186, nil, 287, 288, 288, 288, 287, nil, + nil, 13, 13, 13, nil, nil, nil, nil, nil, nil, + nil, 178, 178, 178, nil, nil, nil, 177, 177, 177, + nil, 13, nil, nil, nil, nil, 288, 88, 88, 88, + 288, 288, 13, nil, 288, nil, 13, 13, nil, 288, + 13, nil, 178, 288, 13, 13, 178, 178, 177, 13, + 178, nil, 177, 177, nil, 178, 177, nil, 88, 178, + nil, 177, 88, 88, nil, 177, 88, 208, 208, 132, + 132, 88, nil, nil, nil, 88, nil, nil, nil, nil, + nil, nil, nil, 233, 233, 234, 234, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, 208, nil, 132, + nil, 208, 208, 132, 132, 208, nil, 132, 286, 286, + 208, 132, 132, 233, 208, 234, 132, 233, 233, 234, + 234, 233, nil, 234, nil, nil, 233, nil, 234, nil, + 233, nil, 234, 240, 240, 297, 297, 240, 286, nil, + nil, nil, 286, 286, nil, nil, 286, nil, nil, 137, + 137, 286, 137, nil, nil, 286, 172, 172, nil, nil, + nil, nil, nil, 240, nil, 297, nil, 240, 240, 297, + 297, 240, nil, 297, nil, nil, 240, nil, 297, 137, + 240, nil, 297, 137, 137, nil, 172, 137, 48, 48, + 172, 172, 137, nil, 172, nil, 137, nil, nil, 172, + nil, nil, nil, 172, 136, 136, nil, nil, 48, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 48, nil, + nil, nil, 48, 48, 136, nil, 48, nil, nil, nil, + 48, 48, nil, nil, 136, 48, nil, nil, 136, 136, + nil, nil, 136, 222, 222, nil, 136, 136, nil, nil, + nil, 136, 222, 222, 222, 222, 139, 139, nil, nil, + nil, nil, nil, nil, 139, 139, 139, 139, 139, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + 222, 222, 222, 222, 222, 222, nil, nil, nil, 139, + 139, 102, 102, 139, 139, 139, 139, 139, 139, nil, + 102, 102, 102, 102, 219, 219, nil, nil, nil, nil, + nil, nil, nil, 219, 219, 219, 219, nil, nil, nil, + nil, nil, nil, nil, 102, 102, nil, nil, 102, 102, + 102, 102, 102, 102, nil, nil, 262, nil, 219, 101, + 101, 219, 219, 219, 219, 219, 219, nil, 101, 101, + 101, 101, nil, nil, nil, nil, nil, 262, nil, 262, + 262, 255, 262, 262, nil, 262, nil, 262, nil, 262, + nil, 262, 101, 101, 262, 262, 101, 101, 101, 101, + 101, 101, 255, 250, 255, 255, nil, 255, 255, nil, + 255, nil, 255, nil, 255, nil, 255, nil, nil, 255, + 255, nil, 225, nil, 250, nil, 250, 250, nil, 250, + 250, nil, 250, nil, 250, nil, 250, nil, 250, nil, + nil, 250, 250, 225, 155, 225, 225, nil, 225, 225, + nil, 225, nil, 225, nil, 225, nil, 225, nil, nil, + 225, 225, nil, 292, nil, 155, nil, 155, 155, nil, + 155, 155, nil, 155, nil, 155, nil, 155, nil, 155, + nil, nil, 155, 155, 292, 302, 292, 292, nil, 292, + 292, nil, 292, nil, 292, nil, 292, nil, 292, nil, + nil, 292, 292, nil, 303, nil, 302, nil, 302, 302, + nil, 302, 302, nil, 302, nil, 302, nil, 302, nil, + 302, nil, nil, 302, 302, 303, 191, 303, 303, nil, + 303, 303, nil, 303, nil, 303, nil, 303, nil, 303, + nil, nil, 303, 303, nil, 311, nil, 191, nil, 191, + 191, nil, 191, 191, nil, 191, nil, 191, nil, 191, + nil, 191, nil, nil, 191, 191, 311, 184, 311, 311, + nil, 311, 311, nil, 311, nil, 311, nil, 311, nil, + 311, nil, nil, 311, 311, nil, 313, nil, 184, nil, + 184, 184, nil, 184, 184, nil, 184, nil, 184, nil, + 184, nil, 184, nil, nil, 184, 184, 313, nil, 313, + 313, nil, 313, 313, nil, 313, nil, 313, nil, 313, + nil, 313, nil, nil, 313, 313, 0, nil, 0, 0, nil, 0, 0, nil, 0, nil, 0, nil, 0, nil, - 0, nil, nil, 0, 0 ] + 0, nil, nil, 0, 0, 19, nil, 19, 19, nil, + 19, 19, nil, 19, nil, 19, nil, 19, nil, 19, + nil, nil, 19, 19 ] racc_action_pointer = [ - 648, 134, nil, nil, nil, 94, 59, nil, nil, nil, - nil, nil, 151, nil, nil, 346, nil, 312, 90, nil, - 96, nil, 141, nil, 226, nil, 118, 269, nil, 307, - 19, nil, 610, 173, 163, nil, -26, nil, 296, nil, - nil, nil, nil, nil, -5, 263, 30, nil, nil, 279, - 229, nil, 277, 275, 4, 269, nil, nil, 244, nil, - nil, nil, nil, 18, 248, nil, 243, nil, nil, 203, - 201, 216, 178, 165, 141, 48, nil, 223, nil, nil, - 44, nil, 37, -9, 284, 35, 293, nil, 305, 294, - nil, 368, 20, nil, 331, 53, 63, nil, nil, nil, - nil, 193, 357, nil, 167, 84, 306, 298, nil, nil, - nil, -5, nil, nil, nil, nil, nil, nil, 269, 4, - 229, 162, 171, 137, nil, 94, 88, nil, 36, 361, - 365, 316, 284, 64, nil, nil, 230, 629, 245, 169, - 76, nil, 113, nil, 119, 129, 143, 57, nil, 29, - nil, nil, nil, 65, nil, nil, 120, nil, nil, nil, - 553, nil, nil, 531, 195, 174, 80, 70, 14, 229, - 230, 203, 206, nil, 236, nil, nil, nil, 225, 341, - nil, nil, nil, nil, nil, 232, nil, nil, 255, nil, - 213, nil, nil, 471, nil, 1, nil, 368, nil, 268, - 261, 4, nil, 279, 430, nil, 290, -20, nil, nil, - 119, nil, 310, 300, nil, nil, 572, nil, 408, nil, - nil, nil, nil, nil, nil, nil, nil, 296, -2, nil, - 211, nil, nil, 280, 304, 239, nil, nil, 157, nil, - nil, -23, 147, nil, 449, nil, nil, nil, 303, nil, - 305, 311, nil, 314, 321, nil, nil, nil, nil, nil, - 290, 348, 351, 353, nil, 512, nil, nil, nil, nil, - nil, nil, nil, 591, nil, 490, 389, nil, nil ] + 1278, 127, 358, nil, nil, 58, 352, nil, nil, nil, + 23, nil, nil, 699, nil, 343, 218, 6, nil, 1297, + 632, nil, nil, 181, 70, nil, nil, 79, 271, nil, + nil, nil, nil, 536, 451, 273, 256, nil, 515, nil, + nil, nil, 24, nil, nil, nil, nil, nil, 885, nil, + 277, 592, 264, 252, nil, nil, nil, nil, 239, 8, + 236, 252, nil, 232, nil, 210, nil, 195, 186, nil, + 152, 152, 430, nil, nil, 576, 324, 50, 47, 207, + 231, 237, 242, nil, 19, 105, nil, 248, 725, 232, + 90, nil, 69, nil, 273, 278, nil, 284, nil, 281, + nil, 1024, 976, nil, nil, -5, 300, nil, 137, 310, + nil, nil, 280, 299, 330, 320, 2, nil, 347, 348, + nil, nil, nil, nil, nil, 342, 29, 350, nil, 2, + 321, nil, 766, nil, 220, -31, 901, 846, nil, 941, + 8, nil, nil, nil, 51, 72, 133, 239, 377, 398, + 483, 345, 292, 271, 186, 1117, 504, 165, -2, 129, + 234, 229, 25, nil, nil, 69, nil, nil, nil, nil, + -11, 156, 853, 231, -19, 56, nil, 715, 709, 79, + 95, nil, nil, nil, 1240, 156, 642, 184, 161, 163, + nil, 1199, nil, nil, nil, 188, 560, nil, nil, nil, + nil, 224, -7, nil, nil, nil, nil, nil, 764, 228, + nil, nil, nil, nil, nil, 229, 298, 96, 140, 989, + 193, 26, 928, 90, 245, 1095, 238, 45, 72, nil, + nil, 271, -20, 780, 782, 143, nil, nil, nil, nil, + 830, nil, 77, nil, nil, 292, 293, 284, 67, nil, + 1076, nil, nil, nil, nil, 1054, nil, nil, nil, nil, + nil, 305, 1029, nil, nil, nil, nil, 204, 616, 293, + nil, 317, nil, nil, 310, nil, 311, 313, 314, nil, + 315, nil, nil, nil, nil, 331, 805, 648, 693, nil, + nil, 139, 1136, nil, nil, nil, nil, 832, 352, 353, + nil, nil, 1158, 1177, nil, nil, nil, nil, nil, nil, + nil, 1218, nil, 1259, nil, nil, nil ] racc_action_default = [ - -150, -174, -14, -2, -143, -174, -174, -15, -3, -141, - -16, -5, -174, -17, -6, -174, -7, -174, -142, -8, - -174, -9, -174, -10, -174, -11, -174, -40, -12, -174, - -174, -13, -1, -174, -174, -142, -150, -39, -174, -144, - -148, -147, -146, -149, -150, -79, -72, -167, -130, -28, - -174, -32, -29, -174, -174, -63, -30, -102, -31, -104, - -103, -33, -20, -62, -21, -61, -22, -23, -131, -25, - -26, -174, -27, -99, -93, -98, -96, -174, -110, -94, - -90, -97, -174, -91, -95, -92, -174, -132, -134, -150, - -41, -174, -174, -42, -72, -150, -150, -4, -70, -71, - -163, -174, -174, -161, -174, -174, -174, -172, -77, -78, - -80, -174, -129, -128, -69, -67, -63, -73, -64, -62, - -59, -65, -172, -68, -57, -66, -174, -19, -174, -174, - -174, -174, -174, -174, -82, -169, -174, -174, -174, -174, - -151, -152, -174, 279, -174, -174, -172, -150, -45, -174, - -46, -62, -48, -174, -55, -54, -174, -164, -165, -166, - -174, -162, -145, -174, -174, -173, -174, -174, -60, -174, - -174, -173, -72, -18, -174, -126, -118, -119, -62, -174, - -124, -127, -125, -105, -101, -174, -24, -34, -174, -168, - -174, -170, -171, -174, -112, -174, -116, -174, -133, -160, - -174, -174, -155, -158, -174, -106, -174, -174, -51, -50, - -174, -44, -174, -174, -43, -138, -174, -140, -174, -38, - -81, -76, -75, -58, -35, -36, -74, -172, -174, -121, - -172, -100, -83, -108, -174, -174, -113, -111, -174, -153, - -154, -174, -174, -136, -174, -37, -49, -47, -87, -88, - -84, -85, -52, -89, -86, -53, -137, -139, -56, -123, - -174, -174, -171, -174, -107, -174, -117, -159, -156, -157, - -135, -122, -120, -174, -115, -174, -174, -114, -109 ] + -169, -193, -193, -7, -162, -193, -193, -8, -160, -9, + -193, -10, -11, -161, -12, -193, -193, -193, -13, -1, + -193, -14, -2, -193, -193, -15, -3, -193, -40, -16, + -5, -17, -6, -193, -193, -79, -169, -161, -72, -167, + -166, -165, -169, -163, -168, -186, -33, -20, -193, -32, + -21, -193, -63, -22, -102, -23, -104, -103, -25, -62, + -26, -193, -61, -27, -149, -28, -150, -29, -193, -30, + -31, -193, -193, -112, -97, -193, -193, -91, -95, -92, + -99, -93, -98, -96, -193, -193, -94, -90, -193, -72, + -169, -42, -169, -4, -193, -153, -151, -193, -39, -169, + -41, -70, -71, -78, -80, -193, -191, -77, -193, -193, + -182, -63, -59, -65, -191, -68, -62, -57, -66, -193, + -148, -147, -69, -67, -73, -64, -193, -193, -180, -193, + -193, -19, -193, -82, -193, -193, -193, -193, 317, -193, + -193, -188, -126, -119, -193, -193, -193, -193, -193, -193, + -193, -193, -193, -193, -193, -193, -193, -193, -193, -193, + -191, -193, -169, -46, -48, -193, -55, -62, -54, -45, + -193, -193, -193, -193, -170, -193, -171, -193, -193, -193, + -192, -183, -184, -185, -193, -193, -60, -193, -192, -72, + -181, -193, -164, -18, -24, -62, -193, -105, -189, -190, + -34, -193, -193, -101, -138, -143, -146, -144, -193, -193, + -145, -137, -129, -187, -115, -117, -121, -118, -123, -128, + -125, -122, -127, -124, -120, -193, -109, -113, -114, -116, + -106, -193, -193, -193, -193, -193, -51, -50, -44, -43, + -193, -131, -193, -135, -152, -179, -177, -193, -193, -174, + -193, -76, -75, -38, -81, -193, -157, -35, -58, -36, + -74, -191, -193, -159, -83, -100, -140, -191, -193, -109, + -108, -193, -37, -49, -85, -52, -89, -86, -87, -88, + -84, -53, -47, -132, -130, -193, -193, -193, -193, -172, + -173, -193, -193, -155, -156, -56, -158, -193, -193, -190, + -142, -107, -193, -193, -136, -178, -176, -175, -154, -141, + -139, -193, -111, -193, -134, -110, -133 ] racc_goto_table = [ - 30, 32, 56, 108, 174, 97, 38, 110, 52, 39, - 122, 177, 62, 196, 190, 3, 202, 114, 194, 29, - 58, 124, 149, 156, 164, 247, 87, 136, 36, 93, - 115, 82, 30, 264, 56, 197, 113, 252, 255, 170, - 52, 107, 169, 176, 128, 120, 230, 88, 118, 89, - 142, 100, 58, 102, 174, 44, 106, 186, 146, 103, - 49, 229, 200, 206, 201, 37, 157, nil, nil, nil, - nil, 61, 196, 81, 207, 81, nil, 236, nil, nil, - nil, nil, nil, nil, nil, nil, 81, 81, 112, nil, - nil, nil, 49, nil, nil, nil, nil, nil, nil, nil, - nil, 161, 162, 61, 141, nil, nil, 81, 260, nil, - 266, nil, nil, nil, nil, 56, 56, 268, 72, 113, - nil, 52, 52, 108, 158, 185, nil, 220, 113, 226, - 81, 175, nil, 58, 58, 174, 227, 30, 193, 114, - 175, 198, 271, 223, 258, 81, 125, 261, nil, nil, - 72, nil, 115, nil, nil, nil, nil, nil, 113, nil, - 30, 216, nil, 30, 218, nil, 97, nil, nil, 113, - 118, 112, nil, 49, 49, nil, nil, nil, nil, 70, - 112, 175, nil, nil, 61, nil, 187, 113, nil, 97, - nil, 97, nil, 30, nil, nil, 249, 249, nil, 175, - nil, nil, 113, 113, 30, 244, nil, 123, nil, nil, - 112, 70, nil, nil, 250, 250, 30, 97, 30, 81, - 81, 112, nil, nil, nil, 113, nil, nil, nil, 182, - nil, 72, 72, nil, nil, nil, nil, 175, 182, 112, - nil, nil, nil, 81, 30, nil, nil, nil, 97, 97, - 113, nil, nil, nil, 248, 248, 155, 155, nil, nil, - nil, nil, 175, nil, nil, 30, 275, nil, 125, 78, - nil, 86, 69, 30, 276, 30, 30, 112, nil, 182, - nil, 81, 98, 99, nil, nil, nil, nil, nil, nil, - 181, 81, 70, 70, nil, 81, nil, 182, nil, 181, - 121, nil, 112, 130, 69, nil, nil, nil, 155, 73, - nil, 73, 254, 254, nil, nil, nil, nil, nil, nil, - nil, nil, 73, 73, nil, nil, 134, nil, nil, 123, - nil, nil, nil, nil, nil, 182, nil, nil, nil, nil, - 181, 144, nil, 73, nil, nil, nil, nil, nil, 154, - 154, nil, nil, nil, nil, nil, nil, nil, 181, nil, - 182, nil, nil, nil, nil, nil, 73, nil, nil, nil, - nil, 155, nil, 253, 253, nil, nil, nil, nil, nil, - nil, 73, nil, 180, nil, 69, 69, nil, nil, nil, - nil, nil, 180, nil, nil, nil, 181, nil, nil, nil, - nil, 154, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, 221, 222, nil, nil, nil, - nil, 181, 121, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, 180, nil, nil, nil, nil, nil, 232, + 2, 179, 93, 17, 209, 43, 19, 204, 47, 187, + 249, 122, 104, 46, 36, 70, 22, 114, 107, 2, + 241, 170, 17, 171, 117, 96, 270, 97, 15, 134, + 275, 281, 282, 297, 91, 240, 99, 106, 185, 243, + 125, 211, 112, 130, 267, 95, 64, 175, 46, 109, + 70, 42, 110, 140, 127, 231, 194, 247, 128, 67, + 248, 98, 181, nil, nil, nil, 159, nil, 160, 301, + 69, 64, nil, nil, nil, 209, nil, nil, 266, nil, + nil, 64, nil, nil, 121, nil, nil, nil, 283, nil, + nil, nil, nil, 232, 67, 123, nil, nil, nil, nil, + nil, nil, nil, nil, nil, 69, nil, 243, nil, nil, + nil, 94, nil, nil, nil, 176, nil, 182, nil, nil, + nil, 190, nil, nil, 192, 65, nil, 307, nil, nil, + nil, 202, nil, nil, 70, 200, 46, nil, 70, 210, + nil, nil, 133, nil, nil, nil, nil, nil, nil, nil, + 120, nil, nil, 304, nil, 2, 295, 254, 17, 122, + 65, 225, 298, 107, 209, 64, 133, 309, 261, 64, + 64, 260, 258, nil, 210, 244, nil, nil, 67, 133, + nil, nil, 67, 121, 2, nil, nil, 17, 125, 69, + 255, 2, nil, 69, 17, nil, nil, 262, nil, 60, + nil, nil, 63, nil, nil, 64, nil, nil, 93, nil, + 210, nil, nil, nil, nil, nil, nil, nil, 121, 64, + nil, nil, nil, nil, 115, 2, nil, 118, 17, nil, + nil, nil, 121, nil, 60, 280, 280, 63, 93, nil, + nil, 64, 210, 123, 65, 93, nil, nil, 65, 120, + 2, nil, nil, 17, 121, 2, 292, nil, 17, nil, + nil, nil, 2, nil, nil, 17, 64, 64, 251, 252, + nil, nil, nil, 64, nil, 93, 168, nil, 168, 121, + 121, nil, nil, nil, 120, nil, 121, 264, 210, nil, + 279, 279, 2, nil, 93, 17, 93, nil, 120, 210, + nil, nil, 2, 2, nil, 17, 17, nil, 311, 313, + nil, 2, 58, 2, 17, nil, 17, 85, 60, 64, + 120, 63, 60, 206, nil, 63, 207, nil, nil, nil, + 64, nil, 121, nil, 101, 102, nil, 113, nil, nil, + nil, nil, nil, 121, nil, 278, 278, 58, 168, nil, + nil, nil, 120, nil, nil, nil, nil, nil, 206, 300, + nil, 207, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, 115, 139, nil, 118, nil, 142, 305, 306, + nil, nil, nil, nil, nil, 143, nil, nil, nil, 166, + nil, 166, nil, nil, 206, nil, nil, 207, 120, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, 120, + nil, nil, nil, nil, nil, nil, nil, nil, nil, 276, + 276, 168, 277, 277, nil, nil, 206, nil, nil, 207, + nil, 58, nil, nil, nil, 58, 205, nil, nil, nil, + nil, nil, nil, nil, nil, 214, 215, 216, 217, 218, + 219, 220, 221, 222, 223, 224, nil, 227, 228, 229, + nil, 166, nil, nil, nil, nil, nil, nil, nil, nil, + nil, 205, 206, nil, nil, 207, nil, nil, nil, nil, + nil, nil, nil, 206, nil, 113, 207, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, 205, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 180, nil, nil, nil, 73, 73, nil, nil, nil, - nil, nil, nil, nil, 154, nil, 251, 251, nil, nil, - nil, nil, nil, nil, nil, nil, nil, 259, nil, 73, - nil, nil, nil, nil, nil, nil, nil, 267, nil, 180, - nil, 269, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, 274, 274, 166, nil, nil, nil, nil, 205, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 180, nil, nil, 73, nil, nil, - nil, nil, nil, nil, nil, nil, nil, 73, nil, nil, - nil, 73 ] + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, 205, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 205 ] racc_goto_check = [ - 35, 2, 27, 50, 60, 4, 35, 52, 26, 69, - 33, 62, 18, 60, 54, 3, 72, 48, 58, 1, - 28, 45, 39, 39, 34, 40, 28, 53, 30, 38, - 27, 55, 35, 56, 27, 57, 26, 44, 44, 34, - 26, 36, 32, 61, 18, 31, 63, 64, 28, 30, - 65, 3, 28, 66, 60, 67, 68, 21, 33, 3, - 25, 62, 70, 34, 71, 5, 73, nil, nil, nil, - nil, 29, 60, 29, 39, 29, nil, 58, nil, nil, - nil, nil, nil, nil, nil, nil, 29, 29, 25, nil, - nil, nil, 25, nil, nil, nil, nil, nil, nil, nil, - nil, 69, 69, 29, 3, nil, nil, 29, 54, nil, - 60, nil, nil, nil, nil, 27, 27, 72, 24, 26, - nil, 26, 26, 50, 30, 18, nil, 52, 26, 50, - 29, 28, nil, 28, 28, 60, 33, 35, 2, 48, - 28, 28, 62, 45, 34, 29, 24, 34, nil, nil, - 24, nil, 27, nil, nil, nil, nil, nil, 26, nil, - 35, 2, nil, 35, 2, nil, 4, nil, nil, 26, - 28, 25, nil, 25, 25, nil, nil, nil, nil, 23, - 25, 28, nil, nil, 29, nil, 29, 26, nil, 4, - nil, 4, nil, 35, nil, nil, 27, 27, nil, 28, - nil, nil, 26, 26, 35, 2, nil, 23, nil, nil, - 25, 23, nil, nil, 28, 28, 35, 4, 35, 29, - 29, 25, nil, nil, nil, 26, nil, nil, nil, 24, - nil, 24, 24, nil, nil, nil, nil, 28, 24, 25, - nil, nil, nil, 29, 35, nil, nil, nil, 4, 4, - 26, nil, nil, nil, 25, 25, 23, 23, nil, nil, - nil, nil, 28, nil, nil, 35, 2, nil, 24, 49, - nil, 49, 22, 35, 2, 35, 35, 25, nil, 24, - nil, 29, 49, 49, nil, nil, nil, nil, nil, nil, - 23, 29, 23, 23, nil, 29, nil, 24, nil, 23, - 22, nil, 25, 49, 22, nil, nil, nil, 23, 47, - nil, 47, 24, 24, nil, nil, nil, nil, nil, nil, - nil, nil, 47, 47, nil, nil, 49, nil, nil, 23, - nil, nil, nil, nil, nil, 24, nil, nil, nil, nil, - 23, 49, nil, 47, nil, nil, nil, nil, nil, 22, - 22, nil, nil, nil, nil, nil, nil, nil, 23, nil, - 24, nil, nil, nil, nil, nil, 47, nil, nil, nil, - nil, 23, nil, 23, 23, nil, nil, nil, nil, nil, - nil, 47, nil, 22, nil, 22, 22, nil, nil, nil, - nil, nil, 22, nil, nil, nil, 23, nil, nil, nil, + 29, 34, 4, 35, 60, 69, 2, 62, 18, 34, + 72, 48, 53, 29, 30, 28, 3, 33, 50, 29, + 58, 39, 35, 39, 45, 28, 56, 35, 1, 54, + 44, 44, 40, 55, 38, 57, 30, 36, 32, 60, + 28, 61, 31, 18, 63, 64, 47, 65, 29, 66, + 28, 67, 3, 54, 68, 34, 21, 70, 3, 26, + 71, 5, 73, nil, nil, nil, 54, nil, 33, 56, + 27, 47, nil, nil, nil, 60, nil, nil, 62, nil, + nil, 47, nil, nil, 26, nil, nil, nil, 58, nil, + nil, nil, nil, 39, 26, 27, nil, nil, nil, nil, + nil, nil, nil, nil, nil, 27, nil, 60, nil, nil, + nil, 51, nil, nil, nil, 3, nil, 30, nil, nil, + nil, 69, nil, nil, 69, 25, nil, 72, nil, nil, + nil, 18, nil, nil, 28, 29, 29, nil, 28, 28, + nil, nil, 51, nil, nil, nil, nil, nil, nil, nil, + 25, nil, nil, 60, nil, 29, 34, 53, 35, 48, + 25, 2, 34, 50, 60, 47, 51, 62, 33, 47, + 47, 50, 45, nil, 28, 28, nil, nil, 26, 51, + nil, nil, 26, 26, 29, nil, nil, 35, 28, 27, + 2, 29, nil, 27, 35, nil, nil, 2, nil, 23, + nil, nil, 24, nil, nil, 47, nil, nil, 4, nil, + 28, nil, nil, nil, nil, nil, nil, nil, 26, 47, + nil, nil, nil, nil, 23, 29, nil, 24, 35, nil, + nil, nil, 26, nil, 23, 28, 28, 24, 4, nil, + nil, 47, 28, 27, 25, 4, nil, nil, 25, 25, + 29, nil, nil, 35, 26, 29, 2, nil, 35, nil, + nil, nil, 29, nil, nil, 35, 47, 47, 51, 51, + nil, nil, nil, 47, nil, 4, 23, nil, 23, 26, + 26, nil, nil, nil, 25, nil, 26, 51, 28, nil, + 27, 27, 29, nil, 4, 35, 4, nil, 25, 28, + nil, nil, 29, 29, nil, 35, 35, nil, 2, 2, + nil, 29, 22, 29, 35, nil, 35, 49, 23, 47, + 25, 24, 23, 23, nil, 24, 24, nil, nil, nil, + 47, nil, 26, nil, 49, 49, nil, 22, nil, nil, + nil, nil, nil, 26, nil, 25, 25, 22, 23, nil, + nil, nil, 25, nil, nil, nil, nil, nil, 23, 51, + nil, 24, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, 23, 49, nil, 24, nil, 49, 51, 51, + nil, nil, nil, nil, nil, 49, nil, nil, nil, 22, + nil, 22, nil, nil, 23, nil, nil, 24, 25, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, 25, + nil, nil, nil, nil, nil, nil, nil, nil, nil, 23, + 23, 23, 24, 24, nil, nil, 23, nil, nil, 24, + nil, 22, nil, nil, nil, 22, 22, nil, nil, nil, + nil, nil, nil, nil, nil, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, nil, 49, 49, 49, nil, 22, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, 49, 49, nil, nil, nil, - nil, 23, 22, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, 22, nil, nil, nil, nil, nil, 49, + nil, 22, 23, nil, nil, 24, nil, nil, nil, nil, + nil, nil, nil, 23, nil, 22, 24, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, 22, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, 22, 22, 22, nil, nil, nil, nil, 22, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 22, nil, nil, nil, 47, 47, nil, nil, nil, - nil, nil, nil, nil, 22, nil, 22, 22, nil, nil, - nil, nil, nil, nil, nil, nil, nil, 49, nil, 47, - nil, nil, nil, nil, nil, nil, nil, 49, nil, 22, - nil, 49, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 22, nil, nil, 47, nil, nil, - nil, nil, nil, nil, nil, nil, nil, 47, nil, nil, - nil, 47 ] + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, 22, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 22 ] racc_goto_pointer = [ - nil, 19, 1, 15, -27, 59, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, -6, nil, - nil, -75, 254, 161, 100, 42, -10, -16, 2, 53, - 23, -1, -78, -36, -83, 0, -4, nil, -1, -73, - -185, nil, nil, nil, -175, -25, nil, 289, -29, 249, - -42, nil, -38, -50, -122, 11, -200, -103, -120, nil, - -125, -86, -118, -133, 23, -39, 17, 43, 12, -3, - -78, -76, -124, -35 ] + nil, 28, 6, 16, -17, 37, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, -5, nil, + nil, -76, 299, 186, 189, 112, 46, 57, 2, 0, + 9, 4, -74, -21, -105, 3, 2, nil, 17, -69, + -203, nil, nil, nil, -203, -14, nil, 33, -27, 301, + -17, 91, nil, -23, -22, -234, -200, -137, -152, nil, + -133, -96, -130, -164, 22, -52, 13, 41, 12, -5, + -117, -114, -164, -46 ] racc_goto_default = [ - nil, nil, nil, 148, 8, 11, 14, 16, 19, 21, - 23, 25, 28, 31, 2, 7, 10, 13, nil, 64, - 66, 67, 83, 84, 85, 74, 75, 79, 80, 15, - 17, nil, nil, nil, nil, 71, nil, 6, nil, nil, - 150, 210, 152, 153, nil, nil, 126, 48, 76, nil, - 117, 109, nil, nil, nil, nil, nil, nil, nil, 195, - 53, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, 169, 26, 30, 32, 3, 7, 9, + 11, 12, 14, 18, 21, 25, 29, 31, nil, 50, + 53, 55, 77, 78, 79, 81, 82, 86, 87, 74, + 6, nil, nil, nil, nil, 61, nil, 24, nil, nil, + 163, 235, 164, 165, nil, nil, 119, 80, 83, nil, + 124, 73, 103, nil, nil, 196, nil, nil, nil, 242, + 68, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ] racc_token_table = { @@ -613,11 +782,18 @@ racc_token_table = { :OR => 48, :AND => 49, :UNDEF => 50, - :PARROW => 51 } + :PARROW => 51, + :PLUS => 52, + :MINUS => 53, + :TIMES => 54, + :DIV => 55, + :LSHIFT => 56, + :RSHIFT => 57, + :UMINUS => 58 } racc_use_result_var = true -racc_nt_base = 52 +racc_nt_base = 59 Racc_arg = [ racc_action_table, @@ -688,6 +864,13 @@ Racc_token_to_s_table = [ 'AND', 'UNDEF', 'PARROW', +'PLUS', +'MINUS', +'TIMES', +'DIV', +'LSHIFT', +'RSHIFT', +'UMINUS', '$start', 'program', 'statements', @@ -737,13 +920,13 @@ Racc_token_to_s_table = [ 'resourcename', 'undef', 'array', -'rvalue', +'expression', 'param', +'rvalue', 'addparam', 'anyparam', 'rvalues', 'comma', -'iftest', 'else', 'caseopts', 'caseopt', @@ -769,7 +952,7 @@ Racc_debug_parser = false # reduce 0 omitted -module_eval <<'.,.,', 'grammar.ra', 30 +module_eval <<'.,.,', 'grammar.ra', 42 def _reduce_1( val, _values, result ) if val[0] # Make sure we always return an array. @@ -793,7 +976,7 @@ module_eval <<'.,.,', 'grammar.ra', 30 # reduce 3 omitted -module_eval <<'.,.,', 'grammar.ra', 46 +module_eval <<'.,.,', 'grammar.ra', 58 def _reduce_4( val, _values, result ) if val[0] and val[1] if val[0].instance_of?(AST::ASTArray) @@ -836,7 +1019,7 @@ module_eval <<'.,.,', 'grammar.ra', 46 # reduce 17 omitted -module_eval <<'.,.,', 'grammar.ra', 69 +module_eval <<'.,.,', 'grammar.ra', 81 def _reduce_18( val, _values, result ) args = aryfy(val[2]) result = ast AST::Function, @@ -847,7 +1030,7 @@ module_eval <<'.,.,', 'grammar.ra', 69 end .,., -module_eval <<'.,.,', 'grammar.ra', 75 +module_eval <<'.,.,', 'grammar.ra', 87 def _reduce_19( val, _values, result ) result = ast AST::Function, :name => val[0], @@ -857,7 +1040,7 @@ module_eval <<'.,.,', 'grammar.ra', 75 end .,., -module_eval <<'.,.,', 'grammar.ra', 82 +module_eval <<'.,.,', 'grammar.ra', 94 def _reduce_20( val, _values, result ) args = aryfy(val[1]) result = ast AST::Function, @@ -874,7 +1057,7 @@ module_eval <<'.,.,', 'grammar.ra', 82 # reduce 23 omitted -module_eval <<'.,.,', 'grammar.ra', 92 +module_eval <<'.,.,', 'grammar.ra', 104 def _reduce_24( val, _values, result ) result = aryfy(val[0], val[2]) result.line = @lexer.line @@ -897,7 +1080,7 @@ module_eval <<'.,.,', 'grammar.ra', 92 # reduce 31 omitted -module_eval <<'.,.,', 'grammar.ra', 105 +module_eval <<'.,.,', 'grammar.ra', 117 def _reduce_32( val, _values, result ) result = ast AST::Name, :value => val[0] result @@ -906,7 +1089,7 @@ module_eval <<'.,.,', 'grammar.ra', 105 # reduce 33 omitted -module_eval <<'.,.,', 'grammar.ra', 116 +module_eval <<'.,.,', 'grammar.ra', 128 def _reduce_34( val, _values, result ) unless val[0].is_a?(AST::ASTArray) val[0] = aryfy(val[0]) @@ -919,7 +1102,7 @@ module_eval <<'.,.,', 'grammar.ra', 116 end .,., -module_eval <<'.,.,', 'grammar.ra', 137 +module_eval <<'.,.,', 'grammar.ra', 149 def _reduce_35( val, _values, result ) array = val[2] if array.instance_of?(AST::ResourceInstance) @@ -943,7 +1126,7 @@ module_eval <<'.,.,', 'grammar.ra', 137 end .,., -module_eval <<'.,.,', 'grammar.ra', 140 +module_eval <<'.,.,', 'grammar.ra', 152 def _reduce_36( val, _values, result ) # This is a deprecated syntax. error "All resource specifications require names" @@ -951,7 +1134,7 @@ module_eval <<'.,.,', 'grammar.ra', 140 end .,., -module_eval <<'.,.,', 'grammar.ra', 143 +module_eval <<'.,.,', 'grammar.ra', 155 def _reduce_37( val, _values, result ) # a defaults setting for a type result = ast(AST::ResourceDefaults, :type => val[0], :params => val[2]) @@ -959,14 +1142,14 @@ module_eval <<'.,.,', 'grammar.ra', 143 end .,., -module_eval <<'.,.,', 'grammar.ra', 148 +module_eval <<'.,.,', 'grammar.ra', 160 def _reduce_38( val, _values, result ) result = ast AST::ResourceOverride, :object => val[0], :params => val[2] result end .,., -module_eval <<'.,.,', 'grammar.ra', 175 +module_eval <<'.,.,', 'grammar.ra', 187 def _reduce_39( val, _values, result ) type = val[0] @@ -994,21 +1177,21 @@ module_eval <<'.,.,', 'grammar.ra', 175 end .,., -module_eval <<'.,.,', 'grammar.ra', 176 +module_eval <<'.,.,', 'grammar.ra', 188 def _reduce_40( val, _values, result ) result = :virtual result end .,., -module_eval <<'.,.,', 'grammar.ra', 177 +module_eval <<'.,.,', 'grammar.ra', 189 def _reduce_41( val, _values, result ) result = :exported result end .,., -module_eval <<'.,.,', 'grammar.ra', 200 +module_eval <<'.,.,', 'grammar.ra', 212 def _reduce_42( val, _values, result ) if val[0] =~ /^[a-z]/ Puppet.warning addcontext("Collection names must now be capitalized") @@ -1031,7 +1214,7 @@ module_eval <<'.,.,', 'grammar.ra', 200 end .,., -module_eval <<'.,.,', 'grammar.ra', 210 +module_eval <<'.,.,', 'grammar.ra', 222 def _reduce_43( val, _values, result ) if val[1] result = val[1] @@ -1043,7 +1226,7 @@ module_eval <<'.,.,', 'grammar.ra', 210 end .,., -module_eval <<'.,.,', 'grammar.ra', 218 +module_eval <<'.,.,', 'grammar.ra', 230 def _reduce_44( val, _values, result ) if val[1] result = val[1] @@ -1059,7 +1242,7 @@ module_eval <<'.,.,', 'grammar.ra', 218 # reduce 46 omitted -module_eval <<'.,.,', 'grammar.ra', 226 +module_eval <<'.,.,', 'grammar.ra', 238 def _reduce_47( val, _values, result ) result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2] result @@ -1068,7 +1251,7 @@ module_eval <<'.,.,', 'grammar.ra', 226 # reduce 48 omitted -module_eval <<'.,.,', 'grammar.ra', 232 +module_eval <<'.,.,', 'grammar.ra', 244 def _reduce_49( val, _values, result ) result = val[1] result.parens = true @@ -1080,7 +1263,7 @@ module_eval <<'.,.,', 'grammar.ra', 232 # reduce 51 omitted -module_eval <<'.,.,', 'grammar.ra', 240 +module_eval <<'.,.,', 'grammar.ra', 252 def _reduce_52( val, _values, result ) result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2] #result = ast AST::CollExpr @@ -1089,7 +1272,7 @@ module_eval <<'.,.,', 'grammar.ra', 240 end .,., -module_eval <<'.,.,', 'grammar.ra', 245 +module_eval <<'.,.,', 'grammar.ra', 257 def _reduce_53( val, _values, result ) result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2] #result = ast AST::CollExpr @@ -1102,7 +1285,7 @@ module_eval <<'.,.,', 'grammar.ra', 245 # reduce 55 omitted -module_eval <<'.,.,', 'grammar.ra', 252 +module_eval <<'.,.,', 'grammar.ra', 264 def _reduce_56( val, _values, result ) result = ast AST::ResourceInstance, :children => [val[0],val[2]] result @@ -1111,7 +1294,7 @@ module_eval <<'.,.,', 'grammar.ra', 252 # reduce 57 omitted -module_eval <<'.,.,', 'grammar.ra', 262 +module_eval <<'.,.,', 'grammar.ra', 274 def _reduce_58( val, _values, result ) if val[0].instance_of?(AST::ResourceInstance) result = ast AST::ASTArray, :children => [val[0],val[2]] @@ -1127,21 +1310,21 @@ module_eval <<'.,.,', 'grammar.ra', 262 # reduce 60 omitted -module_eval <<'.,.,', 'grammar.ra', 269 +module_eval <<'.,.,', 'grammar.ra', 281 def _reduce_61( val, _values, result ) result = ast AST::Undef, :value => :undef result end .,., -module_eval <<'.,.,', 'grammar.ra', 273 +module_eval <<'.,.,', 'grammar.ra', 285 def _reduce_62( val, _values, result ) result = ast AST::Name, :value => val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 277 +module_eval <<'.,.,', 'grammar.ra', 289 def _reduce_63( val, _values, result ) result = ast AST::Type, :value => val[0] result @@ -1160,7 +1343,7 @@ module_eval <<'.,.,', 'grammar.ra', 277 # reduce 69 omitted -module_eval <<'.,.,', 'grammar.ra', 293 +module_eval <<'.,.,', 'grammar.ra', 305 def _reduce_70( val, _values, result ) if val[0] =~ /::/ raise Puppet::ParseError, "Cannot assign to variables in other namespaces" @@ -1172,7 +1355,7 @@ module_eval <<'.,.,', 'grammar.ra', 293 end .,., -module_eval <<'.,.,', 'grammar.ra', 298 +module_eval <<'.,.,', 'grammar.ra', 310 def _reduce_71( val, _values, result ) variable = ast AST::Name, :value => val[0] result = ast AST::VarDef, :name => variable, :value => val[2], :append => true @@ -1180,21 +1363,21 @@ module_eval <<'.,.,', 'grammar.ra', 298 end .,., -module_eval <<'.,.,', 'grammar.ra', 303 +module_eval <<'.,.,', 'grammar.ra', 315 def _reduce_72( val, _values, result ) result = ast AST::ASTArray result end .,., -module_eval <<'.,.,', 'grammar.ra', 303 +module_eval <<'.,.,', 'grammar.ra', 315 def _reduce_73( val, _values, result ) result = val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 312 +module_eval <<'.,.,', 'grammar.ra', 324 def _reduce_74( val, _values, result ) if val[0].instance_of?(AST::ASTArray) val[0].push(val[2]) @@ -1206,14 +1389,14 @@ module_eval <<'.,.,', 'grammar.ra', 312 end .,., -module_eval <<'.,.,', 'grammar.ra', 316 +module_eval <<'.,.,', 'grammar.ra', 328 def _reduce_75( val, _values, result ) result = ast AST::ResourceParam, :param => val[0], :value => val[2] result end .,., -module_eval <<'.,.,', 'grammar.ra', 321 +module_eval <<'.,.,', 'grammar.ra', 333 def _reduce_76( val, _values, result ) result = ast AST::ResourceParam, :param => val[0], :value => val[2], :add => true @@ -1225,21 +1408,21 @@ module_eval <<'.,.,', 'grammar.ra', 321 # reduce 78 omitted -module_eval <<'.,.,', 'grammar.ra', 329 +module_eval <<'.,.,', 'grammar.ra', 341 def _reduce_79( val, _values, result ) result = ast AST::ASTArray result end .,., -module_eval <<'.,.,', 'grammar.ra', 329 +module_eval <<'.,.,', 'grammar.ra', 341 def _reduce_80( val, _values, result ) result = val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 338 +module_eval <<'.,.,', 'grammar.ra', 350 def _reduce_81( val, _values, result ) if val[0].instance_of?(AST::ASTArray) val[0].push(val[2]) @@ -1253,7 +1436,7 @@ module_eval <<'.,.,', 'grammar.ra', 338 # reduce 82 omitted -module_eval <<'.,.,', 'grammar.ra', 347 +module_eval <<'.,.,', 'grammar.ra', 359 def _reduce_83( val, _values, result ) if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) @@ -1296,7 +1479,7 @@ module_eval <<'.,.,', 'grammar.ra', 347 # reduce 99 omitted -module_eval <<'.,.,', 'grammar.ra', 374 +module_eval <<'.,.,', 'grammar.ra', 386 def _reduce_100( val, _values, result ) args = aryfy(val[2]) result = ast AST::Function, @@ -1307,7 +1490,7 @@ module_eval <<'.,.,', 'grammar.ra', 374 end .,., -module_eval <<'.,.,', 'grammar.ra', 379 +module_eval <<'.,.,', 'grammar.ra', 391 def _reduce_101( val, _values, result ) result = ast AST::Function, :name => val[0], @@ -1317,28 +1500,28 @@ module_eval <<'.,.,', 'grammar.ra', 379 end .,., -module_eval <<'.,.,', 'grammar.ra', 383 +module_eval <<'.,.,', 'grammar.ra', 395 def _reduce_102( val, _values, result ) result = ast AST::String, :value => val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 385 +module_eval <<'.,.,', 'grammar.ra', 397 def _reduce_103( val, _values, result ) result = ast AST::FlatString, :value => val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 389 +module_eval <<'.,.,', 'grammar.ra', 401 def _reduce_104( val, _values, result ) result = ast AST::Boolean, :value => val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 394 +module_eval <<'.,.,', 'grammar.ra', 406 def _reduce_105( val, _values, result ) Puppet.warning addcontext("Deprecation notice: Resource references should now be capitalized") result = ast AST::ResourceReference, :type => val[0], :title => val[2] @@ -1346,14 +1529,14 @@ module_eval <<'.,.,', 'grammar.ra', 394 end .,., -module_eval <<'.,.,', 'grammar.ra', 396 +module_eval <<'.,.,', 'grammar.ra', 408 def _reduce_106( val, _values, result ) result = ast AST::ResourceReference, :type => val[0], :title => val[2] result end .,., -module_eval <<'.,.,', 'grammar.ra', 409 +module_eval <<'.,.,', 'grammar.ra', 421 def _reduce_107( val, _values, result ) args = { :test => val[1], @@ -1369,19 +1552,161 @@ module_eval <<'.,.,', 'grammar.ra', 409 end .,., - # reduce 108 omitted +module_eval <<'.,.,', 'grammar.ra', 433 + def _reduce_108( val, _values, result ) + args = { + :test => val[1], + :statements => ast(AST::Nop) + } -module_eval <<'.,.,', 'grammar.ra', 414 - def _reduce_109( val, _values, result ) - result = ast AST::Else, :statements => val[2] + if val[4] + args[:else] = val[4] + end + + result = ast AST::IfStatement, args result end .,., - # reduce 110 omitted + # reduce 109 omitted + +module_eval <<'.,.,', 'grammar.ra', 438 + def _reduce_110( val, _values, result ) + result = ast AST::Else, :statements => val[2] + result + end +.,., -module_eval <<'.,.,', 'grammar.ra', 426 +module_eval <<'.,.,', 'grammar.ra', 441 def _reduce_111( val, _values, result ) + result = ast AST::Else, :statements => ast(AST::Nop) + result + end +.,., + + # reduce 112 omitted + +module_eval <<'.,.,', 'grammar.ra', 458 + def _reduce_113( val, _values, result ) + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 461 + def _reduce_114( val, _values, result ) + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 464 + def _reduce_115( val, _values, result ) + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 467 + def _reduce_116( val, _values, result ) + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 470 + def _reduce_117( val, _values, result ) + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 473 + def _reduce_118( val, _values, result ) + result = ast AST::ArithmeticOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 476 + def _reduce_119( val, _values, result ) + result = ast AST::Minus, :value => val[1] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 479 + def _reduce_120( val, _values, result ) + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 482 + def _reduce_121( val, _values, result ) + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 485 + def _reduce_122( val, _values, result ) + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 488 + def _reduce_123( val, _values, result ) + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 491 + def _reduce_124( val, _values, result ) + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 494 + def _reduce_125( val, _values, result ) + result = ast AST::ComparisonOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 497 + def _reduce_126( val, _values, result ) + result = ast AST::Not, :value => val[1] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 500 + def _reduce_127( val, _values, result ) + result = ast AST::BooleanOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 503 + def _reduce_128( val, _values, result ) + result = ast AST::BooleanOperator, :operator => val[1], :lval => val[0], :rval => val[2] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 506 + def _reduce_129( val, _values, result ) + result = val[1] + result + end +.,., + +module_eval <<'.,.,', 'grammar.ra', 514 + def _reduce_130( val, _values, result ) options = val[3] unless options.instance_of?(AST::ASTArray) options = ast AST::ASTArray, :children => [val[3]] @@ -1391,10 +1716,10 @@ module_eval <<'.,.,', 'grammar.ra', 426 end .,., - # reduce 112 omitted + # reduce 131 omitted -module_eval <<'.,.,', 'grammar.ra', 436 - def _reduce_113( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 524 + def _reduce_132( val, _values, result ) if val[0].instance_of?(AST::ASTArray) val[0].push val[1] result = val[0] @@ -1405,15 +1730,15 @@ module_eval <<'.,.,', 'grammar.ra', 436 end .,., -module_eval <<'.,.,', 'grammar.ra', 440 - def _reduce_114( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 528 + def _reduce_133( val, _values, result ) result = ast AST::CaseOpt, :value => val[0], :statements => val[3] result end .,., -module_eval <<'.,.,', 'grammar.ra', 445 - def _reduce_115( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 533 + def _reduce_134( val, _values, result ) result = ast(AST::CaseOpt, :value => val[0], :statements => ast(AST::ASTArray) @@ -1422,10 +1747,10 @@ module_eval <<'.,.,', 'grammar.ra', 445 end .,., - # reduce 116 omitted + # reduce 135 omitted -module_eval <<'.,.,', 'grammar.ra', 455 - def _reduce_117( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 543 + def _reduce_136( val, _values, result ) if val[0].instance_of?(AST::ASTArray) val[0].push(val[2]) result = val[0] @@ -1436,26 +1761,26 @@ module_eval <<'.,.,', 'grammar.ra', 455 end .,., -module_eval <<'.,.,', 'grammar.ra', 459 - def _reduce_118( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 547 + def _reduce_137( val, _values, result ) result = ast AST::Selector, :param => val[0], :values => val[2] result end .,., - # reduce 119 omitted + # reduce 138 omitted -module_eval <<'.,.,', 'grammar.ra', 461 - def _reduce_120( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 549 + def _reduce_139( val, _values, result ) result = val[1] result end .,., - # reduce 121 omitted + # reduce 140 omitted -module_eval <<'.,.,', 'grammar.ra', 472 - def _reduce_122( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 560 + def _reduce_141( val, _values, result ) if val[0].instance_of?(AST::ASTArray) val[0].push(val[2]) result = val[0] @@ -1466,50 +1791,50 @@ module_eval <<'.,.,', 'grammar.ra', 472 end .,., -module_eval <<'.,.,', 'grammar.ra', 476 - def _reduce_123( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 564 + def _reduce_142( val, _values, result ) result = ast AST::ResourceParam, :param => val[0], :value => val[2] result end .,., - # reduce 124 omitted + # reduce 143 omitted - # reduce 125 omitted + # reduce 144 omitted - # reduce 126 omitted + # reduce 145 omitted - # reduce 127 omitted + # reduce 146 omitted - # reduce 128 omitted + # reduce 147 omitted - # reduce 129 omitted + # reduce 148 omitted - # reduce 130 omitted + # reduce 149 omitted -module_eval <<'.,.,', 'grammar.ra', 487 - def _reduce_131( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 575 + def _reduce_150( val, _values, result ) result = ast AST::Default, :value => val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 489 - def _reduce_132( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 577 + def _reduce_151( val, _values, result ) result = [val[0].value] result end .,., -module_eval <<'.,.,', 'grammar.ra', 493 - def _reduce_133( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 581 + def _reduce_152( val, _values, result ) results = val[0] << val[2].value result end .,., -module_eval <<'.,.,', 'grammar.ra', 501 - def _reduce_134( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 589 + def _reduce_153( val, _values, result ) val[1].each do |file| import(file) end @@ -1519,8 +1844,8 @@ module_eval <<'.,.,', 'grammar.ra', 501 end .,., -module_eval <<'.,.,', 'grammar.ra', 511 - def _reduce_135( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 599 + def _reduce_154( val, _values, result ) newdefine classname(val[1]), :arguments => val[2], :code => val[4] @lexer.indefine = false result = nil @@ -1530,8 +1855,8 @@ module_eval <<'.,.,', 'grammar.ra', 511 end .,., -module_eval <<'.,.,', 'grammar.ra', 515 - def _reduce_136( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 603 + def _reduce_155( val, _values, result ) newdefine classname(val[1]), :arguments => val[2] @lexer.indefine = false result = nil @@ -1539,8 +1864,8 @@ module_eval <<'.,.,', 'grammar.ra', 515 end .,., -module_eval <<'.,.,', 'grammar.ra', 523 - def _reduce_137( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 611 + def _reduce_156( val, _values, result ) # Our class gets defined in the parent namespace, not our own. @lexer.namepop newclass classname(val[1]), :code => val[4], :parent => val[2] @@ -1549,8 +1874,8 @@ module_eval <<'.,.,', 'grammar.ra', 523 end .,., -module_eval <<'.,.,', 'grammar.ra', 528 - def _reduce_138( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 616 + def _reduce_157( val, _values, result ) # Our class gets defined in the parent namespace, not our own. @lexer.namepop newclass classname(val[1]), :parent => val[2] @@ -1559,32 +1884,32 @@ module_eval <<'.,.,', 'grammar.ra', 528 end .,., -module_eval <<'.,.,', 'grammar.ra', 533 - def _reduce_139( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 621 + def _reduce_158( val, _values, result ) newnode val[1], :parent => val[2], :code => val[4] result = nil result end .,., -module_eval <<'.,.,', 'grammar.ra', 536 - def _reduce_140( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 624 + def _reduce_159( val, _values, result ) newnode val[1], :parent => val[2] result = nil result end .,., - # reduce 141 omitted + # reduce 160 omitted - # reduce 142 omitted + # reduce 161 omitted - # reduce 143 omitted + # reduce 162 omitted - # reduce 144 omitted + # reduce 163 omitted -module_eval <<'.,.,', 'grammar.ra', 550 - def _reduce_145( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 638 + def _reduce_164( val, _values, result ) result = val[0] result = [result] unless result.is_a?(Array) result << val[2] @@ -1592,49 +1917,49 @@ module_eval <<'.,.,', 'grammar.ra', 550 end .,., - # reduce 146 omitted + # reduce 165 omitted - # reduce 147 omitted + # reduce 166 omitted - # reduce 148 omitted + # reduce 167 omitted - # reduce 149 omitted + # reduce 168 omitted -module_eval <<'.,.,', 'grammar.ra', 559 - def _reduce_150( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 647 + def _reduce_169( val, _values, result ) result = nil result end .,., -module_eval <<'.,.,', 'grammar.ra', 563 - def _reduce_151( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 651 + def _reduce_170( val, _values, result ) result = ast AST::ASTArray, :children => [] result end .,., - # reduce 152 omitted + # reduce 171 omitted -module_eval <<'.,.,', 'grammar.ra', 568 - def _reduce_153( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 656 + def _reduce_172( val, _values, result ) result = nil result end .,., -module_eval <<'.,.,', 'grammar.ra', 572 - def _reduce_154( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 660 + def _reduce_173( val, _values, result ) result = val[1] result = [result] unless result[0].is_a?(Array) result end .,., - # reduce 155 omitted + # reduce 174 omitted -module_eval <<'.,.,', 'grammar.ra', 579 - def _reduce_156( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 667 + def _reduce_175( val, _values, result ) result = val[0] result = [result] unless result[0].is_a?(Array) result << val[2] @@ -1642,67 +1967,67 @@ module_eval <<'.,.,', 'grammar.ra', 579 end .,., -module_eval <<'.,.,', 'grammar.ra', 584 - def _reduce_157( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 672 + def _reduce_176( val, _values, result ) Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") result = [val[0], val[2]] result end .,., -module_eval <<'.,.,', 'grammar.ra', 588 - def _reduce_158( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 676 + def _reduce_177( val, _values, result ) Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") result = [val[0]] result end .,., -module_eval <<'.,.,', 'grammar.ra', 590 - def _reduce_159( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 678 + def _reduce_178( val, _values, result ) result = [val[0], val[2]] result end .,., -module_eval <<'.,.,', 'grammar.ra', 592 - def _reduce_160( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 680 + def _reduce_179( val, _values, result ) result = [val[0]] result end .,., - # reduce 161 omitted + # reduce 180 omitted -module_eval <<'.,.,', 'grammar.ra', 597 - def _reduce_162( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 685 + def _reduce_181( val, _values, result ) result = val[1] result end .,., - # reduce 163 omitted + # reduce 182 omitted -module_eval <<'.,.,', 'grammar.ra', 602 - def _reduce_164( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 690 + def _reduce_183( val, _values, result ) result = val[1] result end .,., - # reduce 165 omitted + # reduce 184 omitted - # reduce 166 omitted + # reduce 185 omitted -module_eval <<'.,.,', 'grammar.ra', 608 - def _reduce_167( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 696 + def _reduce_186( val, _values, result ) result = ast AST::Variable, :value => val[0] result end .,., -module_eval <<'.,.,', 'grammar.ra', 616 - def _reduce_168( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 704 + def _reduce_187( val, _values, result ) if val[1].instance_of?(AST::ASTArray) result = val[1] else @@ -1712,21 +2037,21 @@ module_eval <<'.,.,', 'grammar.ra', 616 end .,., -module_eval <<'.,.,', 'grammar.ra', 618 - def _reduce_169( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 706 + def _reduce_188( val, _values, result ) result = ast AST::ASTArray result end .,., - # reduce 170 omitted + # reduce 189 omitted - # reduce 171 omitted + # reduce 190 omitted - # reduce 172 omitted + # reduce 191 omitted -module_eval <<'.,.,', 'grammar.ra', 623 - def _reduce_173( val, _values, result ) +module_eval <<'.,.,', 'grammar.ra', 711 + def _reduce_192( val, _values, result ) result = nil result end diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index d214a60ee..747338b3b 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -369,7 +369,7 @@ class Puppet::Parser::Resource next unless val = scope.lookupvar(name.to_s, false) and val != :undefined # The default case: just set the value - return set_parameter(name, val) unless @params[name] + set_parameter(name, val) and next unless @params[name] # For relationship params, though, join the values (a la #446). @params[name].value = [@params[name].value, val].flatten diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 1ff998d96..4acdf41c9 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -43,6 +43,29 @@ class Puppet::Parser::Scope end end + # Is the value a number?, return the correct object or nil if not a number + def self.number?(value) + unless value.is_a?(Fixnum) or value.is_a?(Bignum) or value.is_a?(Float) or value.is_a?(String) + return nil + end + + if value.is_a?(String) + if value =~ /^-?\d+(:?\.\d+|(:?\.\d+)?e\d+)$/ + return value.to_f + elsif value =~ /^0x\d+/i + return value.to_i(16) + elsif value =~ /^0\d+/i + return value.to_i(8) + elsif value =~ /^-?\d+/ + return value.to_i + else + return nil + end + end + # it is one of Fixnum,Bignum or Float + return value + end + # Add to our list of namespaces. def add_namespace(ns) return false if @namespaces.include?(ns) diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 3b74e62d4..fc716b0fd 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -37,6 +37,16 @@ class Puppet::Parser::TemplateWrapper end end + # Allow templates to access the defined classes + def classes + return scope.catalog.classes + end + + # Allow templates to access the defined tags + def tags + return scope.catalog.tags + end + # Ruby treats variables like methods, so we used to expose variables # within scope to the ERB code via method_missing. As per RedMine #1427, # though, this means that conflicts between methods in our inheritance diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb new file mode 100644 index 000000000..4e7f6ec90 --- /dev/null +++ b/lib/puppet/property/list.rb @@ -0,0 +1,78 @@ +require 'puppet/property' + +module Puppet + class Property + class List < Property + + def should_to_s(should_value) + #just return the should value + should_value + end + + def is_to_s(currentvalue) + currentvalue.join(delimiter) + end + + def membership + :membership + end + + def add_should_with_current(should, current) + if current.is_a?(Array) + should += current + end + should.uniq + end + + def inclusive? + @resource[membership] == :inclusive + end + + def should + unless defined? @should and @should + return nil + end + + members = @should + #inclusive means we are managing everything so if it isn't in should, its gone + if ! inclusive? + members = add_should_with_current(members, retrieve) + end + + members.sort.join(delimiter) + end + + def delimiter + "," + end + + def retrieve + #ok, some 'convention' if the list property is named groups, provider should implement a groups method + if tmp = provider.send(name) and tmp != :absent + return tmp.split(delimiter) + else + return :absent + end + end + + def prepare_is_for_comparison(is) + if is.is_a? Array + is = is.sort.join(delimiter) + end + is + end + + def insync?(is) + unless defined? @should and @should + return true + end + + unless is + return true + end + + return (prepare_is_for_comparison(is) == self.should) + end + end + end +end diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb index 84d17367a..0ef90d6d8 100644 --- a/lib/puppet/provider/confine/variable.rb +++ b/lib/puppet/provider/confine/variable.rb @@ -1,11 +1,19 @@ require 'puppet/provider/confine' +# Require a specific value for a variable, either a Puppet setting +# or a Facter value. This class is a bit weird because the name +# is set explicitly by the ConfineCollection class -- from this class, +# it's not obvious how the name would ever get set. class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine + # Provide a hash summary of failing confines -- the key of the hash + # is the name of the confine, and the value is the missing yet required values. + # Only returns failed values, not all required values. def self.summarize(confines) result = Hash.new { |hash, key| hash[key] = [] } - confines.inject(result) { |total, confine| total[confine.fact] += confine.values unless confine.valid?; total } + confines.inject(result) { |total, confine| total[confine.name] += confine.values unless confine.valid?; total } end + # This is set by ConfineCollection. attr_accessor :name # Retrieve the value from facter @@ -20,6 +28,7 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine "facter value '%s' for '%s' not in required list '%s'" % [value, self.name, values.join(",")] end + # Compare the passed-in value to the retrieved value. def pass?(value) test_value.downcase.to_s == value.to_s.downcase end diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index 9764b5cf8..c1e21af08 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -179,11 +179,33 @@ class Puppet::Provider::NameService < Puppet::Provider end def create - self.ensure = :present + if exists? + info "already exists" + # The object already exists + return nil + end + + begin + execute(self.addcmd) + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error, "Could not create %s %s: %s" % + [@resource.class.name, @resource.name, detail] + end end def delete - self.ensure = :absent + unless exists? + info "already absent" + # the object already doesn't exist + return nil + end + + begin + execute(self.deletecmd) + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error, "Could not delete %s %s: %s" % + [@resource.class.name, @resource.name, detail] + end end def ensure @@ -194,43 +216,6 @@ class Puppet::Provider::NameService < Puppet::Provider end end - # This is only used when creating or destroying the object. - def ensure=(value) - cmd = nil - event = nil - case value - when :absent - # we need to remove the object... - unless exists? - info "already absent" - # the object already doesn't exist - return nil - end - - # again, needs to be set by the ind. property or its - # parent - cmd = self.deletecmd - type = "delete" - when :present - if exists? - info "already exists" - # The object already exists - return nil - end - - # blah blah, define elsewhere, blah blah - cmd = self.addcmd - type = "create" - end - - begin - execute(cmd) - rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not %s %s %s: %s" % - [type, @resource.class.name, @resource.name, detail] - end - end - # Does our object exist? def exists? if getinfo(true) diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index e2e68b2ca..fcc44f9e3 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -206,9 +206,18 @@ class DirectoryService < Puppet::Provider::NameService if ensure_value == :present @resource.class.validproperties.each do |name| next if name == :ensure - next unless val = @resource.should(name) || autogen(name) - # JJM: This calls the method. - self.send(name.to_s + "=", val) + + # LAK: We use property.sync here rather than directly calling + # the settor method because the properties might do some kind + # of conversion. In particular, the user gid property might + # have a string and need to convert it to a number + if @resource.should(name) + @resource.property(name).sync + elsif value = autogen(name) + self.send(name.to_s + "=", value) + else + next + end end end end diff --git a/lib/puppet/provider/nameservice/netinfo.rb b/lib/puppet/provider/nameservice/netinfo.rb index 29600052b..ac7bc94b1 100644 --- a/lib/puppet/provider/nameservice/netinfo.rb +++ b/lib/puppet/provider/nameservice/netinfo.rb @@ -138,8 +138,18 @@ class NetInfo < Puppet::Provider::NameService if arg == :present @resource.class.validproperties.each do |name| next if name == :ensure - next unless val = @resource.should(name) || autogen(name) - self.send(name.to_s + "=", val) + + # LAK: We use property.sync here rather than directly calling + # the settor method because the properties might do some kind + # of conversion. In particular, the user gid property might + # have a string and need to convert it to a number + if @resource.should(name) + @resource.property(name).sync + elsif value = autogen(name) + self.send(name.to_s + "=", value) + else + next + end end end end diff --git a/lib/puppet/provider/nameservice/objectadd.rb b/lib/puppet/provider/nameservice/objectadd.rb index b7efe8388..256368ee1 100644 --- a/lib/puppet/provider/nameservice/objectadd.rb +++ b/lib/puppet/provider/nameservice/objectadd.rb @@ -2,15 +2,6 @@ require 'puppet/provider/nameservice' class Puppet::Provider::NameService class ObjectAdd < Puppet::Provider::NameService - # Does the object already exist? - def self.exists?(obj) - if obj.getinfo(true) - return true - else - return false - end - end - def deletecmd [command(:delete), @resource[:name]] end @@ -23,7 +14,7 @@ class ObjectAdd < Puppet::Provider::NameService def modifycmd(param, value) cmd = [command(:modify), flag(param), value] - if @resource.allowdupe? && ((param == :uid and self.class.name == :useradd) || (param == :gid and self.class.name == :groupadd)) + if @resource.allowdupe? && ((param == :uid) || (param == :gid and self.class.name == :groupadd)) cmd << "-o" end cmd << @resource[:name] diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 016623d71..80465129d 100755 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -10,7 +10,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do commands :aptcache => "/usr/bin/apt-cache" commands :preseed => "/usr/bin/debconf-set-selections" - defaultfor :operatingsystem => :debian + defaultfor :operatingsystem => [:debian, :ubuntu] ENV['DEBIAN_FRONTEND'] = "noninteractive" @@ -45,9 +45,19 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do if @resource[:responsefile] self.run_preseed end - should = @resource.should(:ensure) + should = @resource[:ensure] checkforcdrom() + cmd = %w{-q -y} + + keep = "" + if config = @resource[:configfiles] + if config == :keep + cmd << "-o" << 'DPkg::Options::=--force-confold' + else + cmd << "-o" << 'DPkg::Options::=--force-confnew' + end + end str = @resource[:name] case should @@ -57,19 +67,6 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do # Add the package version str += "=%s" % should end - cmd = %w{-q -y} - - keep = "" - if config = @resource[:configfiles] - case config - when :keep - cmd << "-o" << 'DPkg::Options::=--force-confold' - when :replace - cmd << "-o" << 'DPkg::Options::=--force-confnew' - else - raise Puppet::Error, "Invalid 'configfiles' value %s" % config - end - end cmd << :install << str @@ -92,7 +89,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do # preseeds answers to dpkg-set-selection from the "responsefile" # def run_preseed - if response = @resource[:responsefile] and FileTest.exists?(response) + if response = @resource[:responsefile] and FileTest.exist?(response) self.info("Preseeding %s to debconf-set-selections" % response) preseed response @@ -101,16 +98,12 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do end end - def update - self.install - end - def uninstall aptget "-y", "-q", :remove, @resource[:name] end def purge - aptget '-y', '-q', 'remove', '--purge', @resource[:name] + aptget '-y', '-q', :remove, '--purge', @resource[:name] # workaround a "bug" in apt, that already removed packages are not purged super end diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index 402e8a1de..a2f86aa5a 100755 --- a/lib/puppet/provider/package/blastwave.rb +++ b/lib/puppet/provider/package/blastwave.rb @@ -6,6 +6,8 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun pkgget = "/opt/csw/bin/pkg-get" end + confine :operatingsystem => :solaris + commands :pkgget => pkgget # This is so stupid, but then, so is blastwave. diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index ae79f714c..67d31a592 100755 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -23,30 +23,39 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package # now turn each returned line into a package object process.each { |line| - if match = regex.match(line) - hash = {} + if hash = parse_line(line) + packages << new(hash) + end + } + end - fields.zip(match.captures) { |field,value| - hash[field] = value - } + return packages + end - hash[:provider] = self.name + REGEX = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*)$} + FIELDS = [:desired, :error, :status, :name, :ensure] - if hash[:status] == 'not-installed' - hash[:ensure] = :purged - elsif hash[:status] != "installed" - hash[:ensure] = :absent - end + def self.parse_line(line) + if match = REGEX.match(line) + hash = {} - packages << new(hash) - else - Puppet.warning "Failed to match dpkg-query line %s" % - line.inspect - end + FIELDS.zip(match.captures) { |field,value| + hash[field] = value } + + hash[:provider] = self.name + + if hash[:status] == 'not-installed' + hash[:ensure] = :purged + elsif hash[:status] != "installed" + hash[:ensure] = :absent + end + else + Puppet.warning "Failed to match dpkg-query line %s" % line.inspect + return nil end - return packages + return hash end def install @@ -56,15 +65,10 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package args = [] - if config = @resource[:configfiles] - case config - when :keep - args << '--force-confold' - when :replace - args << '--force-confnew' - else - raise Puppet::Error, "Invalid 'configfiles' value %s" % config - end + if @resource[:configfiles] == :keep + args << '--force-confold' + else + args << '--force-confnew' end args << '-i' << file @@ -80,7 +84,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package output = dpkg_deb "--show", @resource[:source] matches = /^(\S+)\t(\S+)$/.match(output).captures unless matches[0].match(@resource[:name]) - Puppet.warning "source doesn't contain named package, but %s" % matches[0] + warning "source doesn't contain named package, but %s" % matches[0] end matches[1] end @@ -103,22 +107,8 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package :name => @resource[:name], :error => 'ok'} end - # Our regex for matching dpkg-query output. We could probably just - # use split here, but I'm not positive that dpkg-query will never - # return whitespace. - regex = %r{^(\S+) (\S+) (\S+) (\S+) (\S*)$} - line = output.split("\n").shift.chomp - - if match = regex.match(line) - fields.zip(match.captures) { |field,value| - hash[field] = value - } - else - notice "Failed to handle dpkg-query line %s" % line.inspect - return {:ensure => :absent, :status => 'missing', - :name => @resource[:name], :error => 'ok'} - end + hash = self.class.parse_line(output) || {:ensure => :absent, :status => 'missing', :name => @resource[:name], :error => 'ok'} if hash[:error] != "ok" raise Puppet::Error.new( @@ -127,13 +117,6 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package ) end - # DPKG can discuss packages that are no longer installed, so allow that. - if hash[:status] == "not-installed" - hash[:ensure] = :purged - elsif hash[:status] != "installed" - hash[:ensure] = :absent - end - return hash end @@ -145,4 +128,3 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package dpkg "--purge", @resource[:name] end end - diff --git a/lib/puppet/provider/package/fink.rb b/lib/puppet/provider/package/fink.rb index 030e1a347..4d560666b 100755 --- a/lib/puppet/provider/package/fink.rb +++ b/lib/puppet/provider/package/fink.rb @@ -4,7 +4,7 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do desc "Package management via ``fink``." - commands :fink => "/sw/bin/fink" + commands :fink => "/sw/bin/fink" commands :aptget => "/sw/bin/apt-get" commands :aptcache => "/sw/bin/apt-cache" commands :dpkgquery => "/sw/bin/dpkg-query" diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index aa756ead0..202fa24c9 100644 --- a/lib/puppet/provider/package/hpux.rb +++ b/lib/puppet/provider/package/hpux.rb @@ -3,11 +3,16 @@ require 'puppet/provider/package' Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package do + desc "HP-UX's packaging system." + commands :swinstall => "/usr/sbin/swinstall", :swlist => "/usr/sbin/swlist", :swremove => "/usr/sbin/swremove" - defaultfor :operatingsystem => 'hp-ux' + + confine :operatingsystem => "hp-ux" + + defaultfor :operatingsystem => "hp-ux" def self.instances # TODO: This is very hard on HP-UX! diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb index f795d0302..ae7194f89 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -7,6 +7,8 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa commands :emerge => "/usr/bin/emerge", :eix => "/usr/bin/eix", :update_eix => "/usr/bin/update-eix" + confine :operatingsystem => :gentoo + defaultfor :operatingsystem => :gentoo def self.instances @@ -70,7 +72,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa result_format = /(\S+) (\S+) \[(?:([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\([^\)]+\))?(?:\[([^\]]+)\])?[ ]*)*\] \[(?:(?:\{M\})?(?:\([~*]+\))?([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\(([^\)]+)\))?(?:![mf])*(?:\[([^\]]+)\])?)?\] ([\S]*) (.*)/ result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :slot, :overlay, :vendor, :description] - search_field = @resource[:category] ? "--category-name" : "--name" + search_field = package_name.count('/') > 0 ? "--category-name" : "--name" search_value = package_name search_format = "<category> <name> [<installedversionsshort>] [<best>] <homepage> <description>" diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb index a303da4e2..b5a5c5dbc 100755 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -23,9 +23,16 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr def self.instances packages = [] + # rpm < 4.1 don't support --nosignature + output = rpm "--version" + sig = "--nosignature" + if output =~ /RPM version (([123].*)|(4\.0.*))/ + sig = "" + end + # list out all of the packages begin - execpipe("#{command(:rpm)} -qa --nosignature --nodigest --qf '#{NEVRAFORMAT}\n'") { |process| + execpipe("#{command(:rpm)} -qa #{sig} --nodigest --qf '#{NEVRAFORMAT}\n'") { |process| # now turn each returned line into a package object process.each { |line| hash = nevra_to_hash(line) diff --git a/lib/puppet/provider/package/rug.rb b/lib/puppet/provider/package/rug.rb index c5451ad71..1e1d6763f 100644 --- a/lib/puppet/provider/package/rug.rb +++ b/lib/puppet/provider/package/rug.rb @@ -5,8 +5,8 @@ Puppet.type(:package).provide :rug, :parent => :rpm do commands :rug => "/usr/bin/rug" commands :rpm => "rpm" - defaultfor :operatingsystem => :suse - confine :operatingsystem => :suse + defaultfor :operatingsystem => [:suse, :sles] + confine :operatingsystem => [:suse, :sles] # Install a package using 'rug'. def install diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb index 927596df2..0d366388a 100755 --- a/lib/puppet/provider/package/sun.rb +++ b/lib/puppet/provider/package/sun.rb @@ -9,6 +9,8 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d :pkgadd => "/usr/sbin/pkgadd", :pkgrm => "/usr/sbin/pkgrm" + confine :operatingsystem => :solaris + defaultfor :operatingsystem => :solaris def self.instances diff --git a/lib/puppet/provider/package/sunfreeware.rb b/lib/puppet/provider/package/sunfreeware.rb index 8b573fe2b..d7bcd0982 100755 --- a/lib/puppet/provider/package/sunfreeware.rb +++ b/lib/puppet/provider/package/sunfreeware.rb @@ -4,5 +4,8 @@ Puppet::Type.type(:package).provide :sunfreeware, :parent => :blastwave, :source At this point, support is exactly the same as ``blastwave`` support and has not actually been tested." commands :pkgget => "pkg-get" + + confine :operatingsystem => :solaris + end diff --git a/lib/puppet/provider/package/yumhelper.py b/lib/puppet/provider/package/yumhelper.py index 962b96ce4..8eab0d081 100644 --- a/lib/puppet/provider/package/yumhelper.py +++ b/lib/puppet/provider/package/yumhelper.py @@ -4,8 +4,23 @@ # (C) 2007 Red Hat Inc. # David Lutterkort <dlutter @redhat.com> -import yum import sys +import string +import re + +# this maintains compatibility with really old platforms with python 1.x +from os import popen, WEXITSTATUS + +# Try to use the yum libraries by default, but shell out to the yum executable +# if they are not present (i.e. yum <= 2.0). This is only required for RHEL3 +# and earlier that do not support later versions of Yum. Once RHEL3 is EOL, +# shell_out() and related code can be removed. +try: + import yum +except ImportError: + useyumlib = 0 +else: + useyumlib = 1 OVERRIDE_OPTS = { 'debuglevel': 0, @@ -26,14 +41,80 @@ def pkg_lists(my): my.doRpmDBSetup() return my.doPackageLists('updates') -try: +def shell_out(): + try: + p = popen("/usr/bin/env yum check-update 2>&1") + output = p.readlines() + rc = p.close() + + if rc is not None: + # None represents exit code of 0, otherwise the exit code is in the + # format returned by wait(). Exit code of 100 from yum represents + # updates available. + if WEXITSTATUS(rc) != 100: + return WEXITSTATUS(rc) + else: + # Exit code is None (0), no updates waiting so don't both parsing output + return 0 + + # Yum prints a line of hyphens (old versions) or a blank line between + # headers and package data, so skip everything before them + skipheaders = 0 + for line in output: + if not skipheaders: + if re.compile("^((-){80}|)$").search(line): + skipheaders = 1 + continue + + # Skip any blank lines + if re.compile("^[ \t]*$").search(line): + continue + + # Format is: + # Yum 1.x: name arch (epoch:)?version + # Yum 2.0: name arch (epoch:)?version repo + # epoch is optional if 0 + + p = string.split(line) + pname = p[0] + parch = p[1] + pevr = p[2] + + # Separate out epoch:version-release + evr_re = re.compile("^(\d:)?(\S+)-(\S+)$") + evr = evr_re.match(pevr) + + pepoch = "" + if evr.group(1) is None: + pepoch = "0" + else: + pepoch = evr.group(1).replace(":", "") + pversion = evr.group(2) + prelease = evr.group(3) + + print "_pkg", pname, pepoch, pversion, prelease, parch + + return 0 + except: + print sys.exc_info()[0] + return 1 + +if useyumlib: try: - my = yum.YumBase() - ypl = pkg_lists(my) - for pkg in ypl.updates: - print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch) - finally: - my.closeRpmDB() -except IOError, e: - print "_err IOError %d %s" % (e.errno, e) - sys.exit(1) + try: + my = yum.YumBase() + ypl = pkg_lists(my) + for pkg in ypl.updates: + print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch) + finally: + my.closeRpmDB() + except IOError, e: + print "_err IOError %d %s" % (e.errno, e) + sys.exit(1) + except AttributeError, e: + # catch yumlib errors in buggy 2.x versions of yum + print "_err AttributeError %s" % e + sys.exit(1) +else: + rc = shell_out() + sys.exit(rc) diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb index da38c10a2..ca433cbe6 100755 --- a/lib/puppet/provider/service/debian.rb +++ b/lib/puppet/provider/service/debian.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do is that this supports service enabling and disabling via ``update-rc.d``." commands :update => "/usr/sbin/update-rc.d" - defaultfor :operatingsystem => :debian + defaultfor :operatingsystem => [:debian, :ubuntu] def self.defpath superclass.defpath diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb index e5d0453c3..95bde7784 100644 --- a/lib/puppet/provider/service/freebsd.rb +++ b/lib/puppet/provider/service/freebsd.rb @@ -2,6 +2,8 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do desc "FreeBSD's (and probably NetBSD?) form of ``init``-style service management; uses ``rc.conf.d`` for service enabling and disabling." + + confine :operatingsystem => [:freebsd, :netbsd, :openbsd] defaultfor :operatingsystem => :freebsd diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index adbee6970..c5ba7b5f1 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -6,6 +6,8 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do commands :update => "/sbin/rc-update" + confine :operatingsystem => :gentoo + defaultfor :operatingsystem => :gentoo def self.defpath diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index d26f76ebd..faa75476d 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -6,7 +6,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service" - defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos] + defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos, :sles] def self.defpath superclass.defpath diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index c74ce3f8f..ab1fe88c2 100755 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -7,6 +7,8 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do defaultfor :operatingsystem => :solaris + confine :operatingsystem => :solaris + commands :adm => "/usr/sbin/svcadm", :svcs => "/usr/bin/svcs" def enable diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index 602e6dd1b..5411a1fb8 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -30,6 +30,12 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed, end } + record_line :key_v1, + :fields => %w{options bits exponent modulus name}, + :optional => %w{options}, + :rts => /^\s+/, + :match => /^(?:(.+) )?(\d+) (\d+) (\d+)(?: (.+))?$/ + def prefetch # This was done in the type class but path expansion was failing for # not yet existing users, the only workaround I found was to move that diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb new file mode 100644 index 000000000..819516dc4 --- /dev/null +++ b/lib/puppet/provider/user/user_role_add.rb @@ -0,0 +1,89 @@ +require 'puppet/util/user_attr' + +Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd do + + desc "User management inherits ``useradd`` and adds logic to manage roles on Solaris using roleadd." + + defaultfor :operatingsystem => :solaris + + commands :add => "useradd", :delete => "userdel", :modify => "usermod", :role_add => "roleadd", :role_delete => "roledel", :role_modify => "rolemod" + options :home, :flag => "-d", :method => :dir + options :comment, :method => :gecos + options :groups, :flag => "-G" + options :roles, :flag => "-R" + + verify :gid, "GID must be an integer" do |value| + value.is_a? Integer + end + + verify :groups, "Groups must be comma-separated" do |value| + value !~ /\s/ + end + + has_features :manages_homedir, :allows_duplicates, :manages_solaris_rbac + + if Puppet.features.libshadow? + has_feature :manages_passwords + end + + def user_attributes + @user_attributes ||= UserAttr.get_attributes_by_name(@resource[:name]) + end + + def flush + @user_attributes = nil + end + + def command(cmd) + if is_role? or (!exists? and @resource[:ensure] == :role) + cmd = ("role_" + cmd.to_s).intern + end + super(cmd) + end + + def is_role? + user_attributes and user_attributes[:type] == "role" + end + + def run(cmd, msg) + begin + execute(cmd) + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error, "Could not %s %s %s: %s" % + [msg, @resource.class.name, @resource.name, detail] + end + end + + def transition(type) + cmd = [command(:modify)] + cmd << "-K" << "type=#{type}" + cmd << @resource[:name] + end + + def create + if is_role? + run(transition("normal"), "transition role to") + else + run(addcmd, "create") + end + end + + def destroy + run(deletecmd, "delete "+ (is_role? ? "role" : "user")) + end + + def create_role + if exists? and !is_role? + run(transition("role"), "transition user to") + else + run(addcmd, "create role") + end + end + + def roles + if user_attributes + user_attributes[:roles] + end + end +end + diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb index d95944adc..5ca06721d 100644 --- a/lib/puppet/sslcertificates/support.rb +++ b/lib/puppet/sslcertificates/support.rb @@ -133,6 +133,9 @@ module Puppet::SSLCertificates::Support #return nil unless FileTest.directory?(dir) raise ArgumentError, "Tried to fix SSL files to a file containing uppercase" unless short.downcase == short + + return false unless File.directory?(dir) + real_file = Dir.entries(dir).reject { |f| f =~ /^\./ }.find do |other| other.downcase == short end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index eb663968e..2f4ddf794 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -903,19 +903,31 @@ class Type # retrieve the current value of all contained properties def retrieve - return currentpropvalues + return currentpropvalues end - # get a hash of the current properties. - def currentpropvalues(override_value = nil) - # it's important to use the method here, as it follows the order - # in which they're defined in the object - return properties().inject({}) { | prophash, property| - prophash[property] = override_value.nil? ? - property.retrieve : - override_value - prophash - } + # Get a hash of the current properties. Returns a hash with + # the actual property instance as the key and the current value + # as the, um, value. + def currentpropvalues + # It's important to use the 'properties' method here, as it follows the order + # in which they're defined in the class. It also guarantees that 'ensure' + # is the first property, which is important for skipping 'retrieve' on + # all the properties if the resource is absent. + ensure_state = false + return properties().inject({}) do | prophash, property| + if property.name == :ensure + ensure_state = property.retrieve + prophash[property] = ensure_state + else + if ensure_state == :absent + prophash[property] = :absent + else + prophash[property] = property.retrieve + end + end + prophash + end end # Are we running in noop mode? @@ -1437,8 +1449,6 @@ class Type raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog - @resource.info "Adding aliases %s" % aliases.collect { |a| a.inspect }.join(", ") - aliases.each do |other| if obj = @resource.catalog.resource(@resource.class.name, other) unless obj.object_id == @resource.object_id diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index f2cf37e0e..35eccef83 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -369,7 +369,7 @@ module Puppet Find.find(self[:path]) do |f| if File.file?(f) sum = backup.backup(f) - self.info "Filebucketed %s to %s with sum %s" % + self.notice "Filebucketed %s to %s with sum %s" % [f, backup.name, sum] end end @@ -404,7 +404,7 @@ module Puppet case backup when Puppet::Network::Client.client(:Dipper): sum = backup.backup(file) - self.info "Filebucketed to %s with sum %s" % + self.notice "Filebucketed to %s with sum %s" % [backup.name, sum] return true when String: diff --git a/lib/puppet/type/file/checksum.rb b/lib/puppet/type/file/checksum.rb index 3be147cb7..785ed0fee 100755 --- a/lib/puppet/type/file/checksum.rb +++ b/lib/puppet/type/file/checksum.rb @@ -53,6 +53,9 @@ Puppet::Type.type(:file).newproperty(:checksum) do else if FileTest.directory?(@resource[:path]) return :time + elsif @resource[:source] and value.to_s != "md5" + self.warning("Files with source set must use md5 as checksum. Forcing to md5 from %s for %s" % [ value, @resource[:path] ]) + return :md5 else return symbolize(value) end @@ -161,6 +164,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do checktype = :mtime if checktype == :timestamp checktype = :ctime if checktype == :time + self.should = checktype = :md5 if @resource.property(:source) file ||= @resource[:path] diff --git a/lib/puppet/type/file/group.rb b/lib/puppet/type/file/group.rb index cc482ff31..56883add6 100755 --- a/lib/puppet/type/file/group.rb +++ b/lib/puppet/type/file/group.rb @@ -1,6 +1,10 @@ +require 'puppet/util/posix' + # Manage file group ownership. module Puppet Puppet.type(:file).newproperty(:group) do + include Puppet::Util::POSIX + require 'etc' desc "Which group should own the file. Argument can be either group name or group ID." @@ -42,32 +46,23 @@ module Puppet end end - def retrieve - if self.should - @should = @should.collect do |val| - unless val.is_a?(Integer) - if tmp = validgroup?(val) - val = tmp - else - raise "Could not find group %s" % val - end - else - val - end + def insync?(current) + @should.each do |value| + if value =~ /^\d+$/ + gid = Integer(value) + elsif value.is_a?(String) + fail "Could not find group %s" % value unless gid = gid(value) + else + gid = value end - end - stat = @resource.stat(false) - unless stat - return :absent + return true if gid == current end + return false + end - # Set our method appropriately, depending on links. - if stat.ftype == "link" and @resource[:links] != :follow - @method = :lchown - else - @method = :chown - end + def retrieve + return :absent unless stat = resource.stat(false) currentvalue = stat.gid @@ -84,12 +79,8 @@ module Puppet # Determine if the group is valid, and if so, return the GID def validgroup?(value) - if value =~ /^\d+$/ - value = value.to_i - end - - if gid = Puppet::Util.gid(value) - return gid + if number = gid(value) + return number else return false end @@ -99,32 +90,28 @@ module Puppet # we'll just let it fail, but we should probably set things up so # that users get warned if they try to change to an unacceptable group. def sync - unless @resource.stat(false) - stat = @resource.stat(true) - currentvalue = self.retrieve - - unless stat - self.debug "File '%s' does not exist; cannot chgrp" % - @resource[:path] - return nil - end + # Set our method appropriately, depending on links. + if resource[:links] == :manage + method = :lchown + else + method = :chown end gid = nil - unless gid = Puppet::Util.gid(self.should) - raise Puppet::Error, "Could not find group %s" % self.should + @should.each do |group| + break if gid = validgroup?(group) end + raise Puppet::Error, "Could not find group(s) %s" % @should.join(",") unless gid + begin # set owner to nil so it's ignored - File.send(@method,nil,gid,@resource[:path]) + File.send(method, nil, gid, resource[:path]) rescue => detail - error = Puppet::Error.new( "failed to chgrp %s to %s: %s" % - [@resource[:path], self.should, detail.message]) + error = Puppet::Error.new( "failed to chgrp %s to %s: %s" % [resource[:path], gid, detail.message]) raise error end return :file_changed end end end - diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb index f36695075..b2c89e6f8 100644 --- a/lib/puppet/type/file/selcontext.rb +++ b/lib/puppet/type/file/selcontext.rb @@ -20,27 +20,26 @@ # See http://www.nsa.gov/selinux/ for complete docs on SELinux. module Puppet + require 'puppet/util/selinux' + class SELFileContext < Puppet::Property + include Puppet::Util::SELinux def retrieve unless @resource.stat(false) return :absent end - context = `stat -c %C #{@resource[:path]}` - context.chomp! - if context == "unlabeled" + context = self.get_selinux_current_context(@resource[:path]) + return parse_selinux_context(name, context) + end + + def retrieve_default_context(property) + unless context = self.get_selinux_default_context(@resource[:path]) return nil end - unless context =~ /^[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/ - raise Puppet::Error, "Invalid output from stat: #{context}" - end - bits = context.split(':') - ret = { - :seluser => bits[0], - :selrole => bits[1], - :seltype => bits[2] - } - return ret[name] + property_default = self.parse_selinux_context(property, context) + self.debug "Found #{property} default '#{property_default}' for #{@resource[:path]}" + return property_default end def sync @@ -51,25 +50,7 @@ module Puppet end end - flag = '' - - case name - when :seluser - flag = "-u" - when :selrole - flag = "-r" - when :seltype - flag = "-t" - else - raise Puppet::Error, "Invalid SELinux file context component: #{name}" - end - - self.debug "Running chcon #{flag} #{@should} #{@resource[:path]}" - retval = system("chcon #{flag} #{@should} #{@resource[:path]}") - unless retval - error = Puppet::Error.new("failed to chcon %s" % [@resource[:path]]) - raise error - end + self.set_selinux_context(@resource[:path], @should, name) return :file_changed end end @@ -78,18 +59,28 @@ module Puppet desc "What the SELinux User context of the file should be." @event = :file_changed + defaultto { self.retrieve_default_context(:seluser) } end Puppet.type(:file).newproperty(:selrole, :parent => Puppet::SELFileContext) do desc "What the SELinux Role context of the file should be." @event = :file_changed + defaultto { self.retrieve_default_context(:selrole) } end Puppet.type(:file).newproperty(:seltype, :parent => Puppet::SELFileContext) do desc "What the SELinux Type context of the file should be." @event = :file_changed + defaultto { self.retrieve_default_context(:seltype) } + end + + Puppet.type(:file).newproperty(:selrange, :parent => Puppet::SELFileContext) do + desc "What the SELinux Range context of the file should be." + + @event = :file_changed + defaultto { self.retrieve_default_context(:selrange) } end end diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb index 2a5ac30da..cb11a60a4 100755 --- a/lib/puppet/type/group.rb +++ b/lib/puppet/type/group.rb @@ -118,14 +118,6 @@ module Puppet defaultto false end - - def retrieve - if self.provider and @provider.exists? - return super - else - return currentpropvalues(:absent) - end - end end end diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index 1db4a0ac3..4afca1cca 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -1,6 +1,7 @@ module Puppet newtype(:ssh_authorized_key) do - @doc = "Manages ssh authorized keys." + @doc = "Manages SSH authorized keys. Currently only type 2 keys are + supported." ensurable @@ -11,8 +12,7 @@ module Puppet end newproperty(:type) do - desc "The encryption type used. Usually ssh-dss or ssh-rsa for - SSH version 2. Not used for SSH version 1." + desc "The encryption type used: ssh-dss or ssh-rsa." newvalue("ssh-dss") newvalue("ssh-rsa") diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 100c9c377..e0a11f00b 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -1,5 +1,6 @@ require 'etc' require 'facter' +require 'puppet/property/list' module Puppet newtype(:user) do @@ -21,6 +22,9 @@ module Puppet "The provider can modify user passwords, by accepting a password hash." + feature :manages_solaris_rbac, + "The provider can manage roles and normal users" + newproperty(:ensure, :parent => Puppet::Property::Ensure) do newvalue(:present, :event => :user_created) do provider.create @@ -30,6 +34,10 @@ module Puppet provider.delete end + newvalue(:role, :event => :role_created, :required_features => :manages_solaris_rbac) do + provider.create_role + end + desc "The basic state that the object should be in." # If they're talking about the thing at all, they generally want to @@ -44,30 +52,15 @@ module Puppet def retrieve if provider.exists? - return :present + if provider.respond_to?(:is_role?) and provider.is_role? + return :role + else + return :present + end else return :absent end end - - # The default 'sync' method only selects among a list of registered - # values. - def sync -# if self.insync? -# self.info "already in sync" -# return nil - #else - #self.info "%s vs %s" % [self.is.inspect, self.should.inspect] -# end - unless self.class.values - self.devfail "No values defined for %s" % - self.class.name - end - - # Set ourselves to whatever our should value is. - self.set(self.should) - end - end newproperty(:uid) do @@ -95,50 +88,26 @@ module Puppet newproperty(:gid) do desc "The user's primary group. Can be specified numerically or by name." - - def found? - defined? @found and @found - end - - munge do |gid| - method = :getgrgid - case gid - when String - if gid =~ /^[-0-9]+$/ - gid = Integer(gid) - else - method = :getgrnam - end - when Symbol - unless gid == :auto or gid == :absent - self.devfail "Invalid GID %s" % gid - end - # these are treated specially by sync() - return gid - end - if group = Puppet::Util.gid(gid) - @found = true - return group + munge do |value| + if value.is_a?(String) and value =~ /^[-0-9]+$/ + Integer(value) else - @found = false - return gid + value end end - # *shudder* Make sure that we've looked up the group and gotten - # an ID for it. Yuck-o. - def should - unless defined? @should - return super - end - unless found? - @should = @should.each { |val| - next unless val - Puppet::Util.gid(val) - } + def sync + found = false + @should.each do |value| + if number = Puppet::Util.gid(value) + provider.gid = number + found = true + break + end end - super + + fail "Could not find group(s) %s" % @should.join(",") unless found end end @@ -168,95 +137,39 @@ module Puppet end end - newproperty(:groups) do + newproperty(:groups, :parent => Puppet::Property::List) do desc "The groups of which the user is a member. The primary group should not be listed. Multiple groups should be specified as an array." - def should_to_s(newvalue) - self.should - end - - def is_to_s(currentvalue) - currentvalue.join(",") - end - - # We need to override this because the groups need to - # be joined with commas - def should - current_value = retrieve - - unless defined? @should and @should - return nil - end - - if @resource[:membership] == :inclusive - return @should.sort.join(",") - else - members = @should - if current_value.is_a?(Array) - members += current_value - end - return members.uniq.sort.join(",") + validate do |value| + if value =~ /^\d+$/ + raise ArgumentError, "Group names must be provided, not numbers" end - end - - def retrieve - if tmp = provider.groups and tmp != :absent - return tmp.split(",") - else - return :absent + if value.include?(",") + raise ArgumentError, "Group names must be provided as an array, not as a comma-separated list '%s'" % value end end + end - def insync?(is) - unless defined? @should and @should - return true - end - unless defined? is and is - return true - end - tmp = is - if is.is_a? Array - tmp = is.sort.join(",") - end + newproperty(:roles, :parent => Puppet::Property::List, :required_features => :manages_solaris_rbac) do + desc "The roles of which the user the user has. The roles should be + specified as an array." - return tmp == self.should + def membership + :role_membership end validate do |value| if value =~ /^\d+$/ - raise ArgumentError, "Group names must be provided, not numbers" + raise ArgumentError, "Role names must be provided, not numbers" end if value.include?(",") - raise ArgumentError, "Group names must be provided as an array, not a comma-separated list" + raise ArgumentError, "Role names must be provided as an array, not a comma-separated list" end end end - # these three properties are all implemented differently on each platform, - # so i'm disabling them for now - - # FIXME Puppet::Property::UserLocked is currently non-functional - #newproperty(:locked) do - # desc "The expected return code. An error will be returned if the - # executed command returns something else." - #end - - # FIXME Puppet::Property::UserExpire is currently non-functional - #newproperty(:expire) do - # desc "The expected return code. An error will be returned if the - # executed command returns something else." - # @objectaddflag = "-e" - #end - - # FIXME Puppet::Property::UserInactive is currently non-functional - #newproperty(:inactive) do - # desc "The expected return code. An error will be returned if the - # executed command returns something else." - # @objectaddflag = "-f" - #end - newparam(:name) do desc "User name. While limitations are determined for each operating system, it is generally a good idea to keep to @@ -268,7 +181,17 @@ module Puppet desc "Whether specified groups should be treated as the only groups of which the user is a member or whether they should merely be treated as the minimum membership list." - + + newvalues(:inclusive, :minimum) + + defaultto :minimum + end + + newparam(:role_membership) do + desc "Whether specified roles should be treated as the only roles + of which the user is a member or whether they should merely + be treated as the minimum membership list." + newvalues(:inclusive, :minimum) defaultto :minimum @@ -326,7 +249,7 @@ module Puppet current_value = :absent if absent - prophash[property] = :absent + prophash[property] = :absent else current_value = property.retrieve prophash[property] = current_value @@ -334,7 +257,6 @@ module Puppet if property.name == :ensure and current_value == :absent absent = true -# next end prophash } diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index 4fd92672c..7601ec47b 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -377,7 +377,11 @@ end result = setstatus(hash) result else - return currentpropvalues(:absent) + # Return all properties as absent. + return properties().inject({}) do | prophash, property| + prophash[property] = :absent + prophash + end end end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index d6de3e2e1..59f732dae 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -227,7 +227,11 @@ module Util end else x = %x{which #{bin} 2>/dev/null}.chomp - return x + if x == "" + return nil + else + return x + end end end module_function :binary diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index ae078fff4..b10b50fb7 100755 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -1,8 +1,13 @@ # Basic classes for reading, writing, and emptying files. Not much # to see here. + +require 'puppet/util/selinux' + class Puppet::Util::FileType attr_accessor :loaded, :path, :synced + include Puppet::Util::SELinux + class << self attr_accessor :name include Puppet::Util::ClassGen @@ -114,6 +119,8 @@ class Puppet::Util::FileType tf.print text; tf.flush FileUtils.cp(tf.path, @path) tf.close + # If SELinux is present, we need to ensure the file has its expected context + set_selinux_default_context(@path) end end diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 8824a8b50..0dfd36dfa 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -1,10 +1,12 @@ require 'syslog' +require 'puppet/util/tagging' # Pass feedback to the user. Log levels are modeled after syslog's, and it is # expected that that will be the most common log destination. Supports # multiple destinations, one of which is a remote server. class Puppet::Util::Log include Puppet::Util + include Puppet::Util::Tagging @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit] @loglevel = 2 @@ -470,12 +472,12 @@ class Puppet::Util::Log @levels.include?(level) end - attr_accessor :level, :message, :time, :tags, :remote + attr_accessor :level, :message, :time, :remote attr_reader :source def initialize(args) unless args.include?(:level) && args.include?(:message) - raise Puppet::DevError, "Puppet::Util::Log called incorrectly" + raise ArgumentError, "Puppet::Util::Log called incorrectly" end if args[:level].class == String @@ -483,35 +485,27 @@ class Puppet::Util::Log elsif args[:level].class == Symbol @level = args[:level] else - raise Puppet::DevError, - "Level is not a string or symbol: #{args[:level].class}" + raise ArgumentError, "Level is not a string or symbol: #{args[:level].class}" end - # Just return unless we're actually at a level we should send - #return unless self.class.sendlevel?(@level) - @message = args[:message].to_s @time = Time.now - # this should include the host name, and probly lots of other - # stuff, at some point - unless self.class.validlevel?(level) - raise Puppet::DevError, "Invalid message level #{level}" - end - if args.include?(:tags) - @tags = args[:tags] - end + raise ArgumentError, "Invalid log level %s" % level unless self.class.validlevel?(level) - if args.include?(:source) - self.source = args[:source] - else - @source = "Puppet" + if tags = args[:tags] + tags.each { |t| self.tag(t) } end + self.source = args[:source] || "Puppet" + + # Tag myself with my log level + tag(level) + Log.newmessage(self) end - # Was the source of this log an object? + # Was the source of this log a Puppet resource or parameter? def objectsource? if defined? @objectsource and @objectsource @objectsource @@ -533,17 +527,11 @@ class Puppet::Util::Log @objectsource = false @source = source.to_s end - unless defined? @tags and @tags - if source.respond_to?(:tags) - @tags = source.tags - end + if source.respond_to?(:tags) + source.tags.each { |t| tag(t) } end end - def tagged?(tag) - @tags.detect { |t| t.to_s == tag.to_s } - end - def to_report "%s %s (%s): %s" % [self.time, self.source, self.level, self.to_s] end @@ -552,5 +540,8 @@ class Puppet::Util::Log return @message end end -Puppet::Log = Puppet::Util::Log +# This is for backward compatibility from when we changed the constant to Puppet::Util::Log +# because the reports include the constant name. Apparently the alias was created in +# March 2007, should could probably be removed soon. +Puppet::Log = Puppet::Util::Log diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index ca23aa87f..e6d7678aa 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -5,6 +5,8 @@ require 'puppet' class Puppet::Util::Metric # Load the library as a feature, so we can test its presence. + # It's only used by this class, so there's no reason to move it + # to the main feature list. Puppet.features.add :rrd, :libs => 'RRDtool' attr_accessor :type, :name, :value, :label @@ -12,6 +14,15 @@ class Puppet::Util::Metric attr_writer :basedir + # Return a specific value + def [](name) + if value = @values.find { |v| v[0] == name } + return value[2] + else + return nil + end + end + def basedir if defined? @basedir @basedir @@ -93,11 +104,7 @@ class Puppet::Util::Metric def initialize(name,label = nil) @name = name.to_s - if label - @label = label - else - @label = name.to_s.capitalize.gsub("_", " ") - end + @label = label || labelize(name) @values = [] end @@ -107,9 +114,7 @@ class Puppet::Util::Metric end def newvalue(name,value,label = nil) - unless label - label = name.to_s.capitalize.gsub("_", " ") - end + label ||= labelize(name) @values.push [name,label,value] end @@ -145,7 +150,16 @@ class Puppet::Util::Metric def values @values.sort { |a, b| a[1] <=> b[1] } end + + private + + # Convert a name into a label. + def labelize(name) + name.to_s.capitalize.gsub("_", " ") + end end +# This is necessary because we changed the class path in early 2007, +# and reports directly yaml-dump these metrics, so both client and server +# have to agree on the class name. Puppet::Metric = Puppet::Util::Metric - diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index aff797485..3f6c1f6e3 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -7,10 +7,8 @@ module Puppet::Util::POSIX # method search_posix_field in the gid and uid methods if a sanity check # fails def get_posix_field(space, field, id) - unless id - raise ArgumentError, "Did not get id" - end - prefix = "get" + space.to_s + raise Puppet::DevError, "Did not get id from caller" unless id + if id.is_a?(Integer) if id > Puppet[:maximum_uid].to_i Puppet.err "Tried to get %s field for silly id %s" % [field, id] @@ -93,16 +91,16 @@ module Puppet::Util::POSIX # Get the GID of a given group, provided either a GID or a name def gid(group) begin - group = Integer(group) + group = Integer(group) rescue ArgumentError - # pass + # pass end if group.is_a?(Integer) - name = get_posix_field(:group, :name, group) + return nil unless name = get_posix_field(:group, :name, group) gid = get_posix_field(:group, :gid, name) check_value = gid else - gid = get_posix_field(:group, :gid, group) + return nil unless gid = get_posix_field(:group, :gid, group) name = get_posix_field(:group, :name, gid) check_value = name end @@ -116,16 +114,16 @@ module Puppet::Util::POSIX # Get the UID of a given user, whether a UID or name is provided def uid(user) begin - user = Integer(user) + user = Integer(user) rescue ArgumentError - # pass + # pass end if user.is_a?(Integer) - name = get_posix_field(:passwd, :name, user) + return nil unless name = get_posix_field(:passwd, :name, user) uid = get_posix_field(:passwd, :uid, name) check_value = uid else - uid = get_posix_field(:passwd, :uid, user) + return nil unless uid = get_posix_field(:passwd, :uid, user) name = get_posix_field(:passwd, :name, uid) check_value = name end diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb new file mode 100644 index 000000000..0a4af3ca1 --- /dev/null +++ b/lib/puppet/util/selinux.rb @@ -0,0 +1,130 @@ +# Provides utility functions to help interfaces Puppet to SELinux. +# +# Currently this is implemented via the command line tools. At some +# point support should be added to use the new SELinux ruby bindings +# as that will be faster and more reliable then shelling out when they +# are available. At this time (2008-09-26) these bindings aren't bundled on +# any SELinux-using distribution I know of. + +module Puppet::Util::SELinux + + def selinux_support? + FileTest.exists?("/selinux/enforce") + end + + # Retrieve and return the full context of the file. If we don't have + # SELinux support or if the stat call fails then return nil. + def get_selinux_current_context(file) + unless selinux_support? + return nil + end + context = "" + begin + execpipe("/usr/bin/stat -c %C #{file}") do |out| + out.each do |line| + context << line + end + end + rescue Puppet::ExecutionFailure + return nil + end + context.chomp! + # Handle the case that the system seems to have SELinux support but + # stat finds unlabled files. + if context == "(null)" + return nil + end + return context + end + + # Use the matchpathcon command, if present, to return the SELinux context + # which the SELinux policy on the system expects the file to have. We can + # use this to obtain a good default context. If the command does not + # exist or the call fails return nil. + # + # Note: For this command to work a full, non-relative, filesystem path + # should be given. + def get_selinux_default_context(file) + unless selinux_support? + return nil + end + unless FileTest.executable?("/usr/sbin/matchpathcon") + return nil + end + context = "" + begin + execpipe("/usr/sbin/matchpathcon #{file}") do |out| + out.each do |line| + context << line + end + end + rescue Puppet::ExecutionFailure + return nil + end + # For a successful match, matchpathcon returns two fields separated by + # a variable amount of whitespace. The second field is the full context. + context = context.split(/\s/)[1] + return context + end + + # Take the full SELinux context returned from the tools and parse it + # out to the three (or four) component parts. Supports :seluser, :selrole, + # :seltype, and on systems with range support, :selrange. + def parse_selinux_context(component, context) + if context.nil? or context == "unlabeled" + return nil + end + unless context =~ /^([a-z0-9_]+):([a-z0-9_]+):([a-z0-9_]+)(?::([a-zA-Z0-9:,._-]+))?/ + raise Puppet::Error, "Invalid context to parse: #{context}" + end + ret = { + :seluser => $1, + :selrole => $2, + :seltype => $3, + :selrange => $4, + } + return ret[component] + end + + # This updates the actual SELinux label on the file. You can update + # only a single component or update the entire context. It is just a + # wrapper around the chcon command. + def set_selinux_context(file, value, component = false) + unless selinux_support? + return nil + end + case component + when :seluser + flag = "-u" + when :selrole + flag = "-r" + when :seltype + flag = "-t" + when :selrange + flag = "-l" + else + flag = "" + end + + execute(["/usr/bin/chcon","-h",flag,value,file]) + return true + end + + # Since this call relies on get_selinux_default_context it also needs a + # full non-relative path to the file. Fortunately, that seems to be all + # Puppet uses. This will set the file's SELinux context to the policy's + # default context (if any) if it differs from the context currently on + # the file. + def set_selinux_default_context(file) + new_context = get_selinux_default_context(file) + unless new_context + return nil + end + cur_context = get_selinux_current_context(file) + if new_context != cur_context + set_selinux_context(file, new_context) + return new_context + end + return nil + end +end diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 64bb40b52..d0c16ec92 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -115,12 +115,14 @@ class Puppet::Util::Settings end # Do variable interpolation on the value. - def convert(value) + def convert(value, environment = nil) return value unless value return value unless value.is_a? String newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value| varname = $2 || $1 - if pval = self.value(varname) + if varname == "environment" and environment + environment + elsif pval = self.value(varname) pval else raise Puppet::DevError, "Could not find value for %s" % value @@ -692,7 +694,7 @@ Generated on #{Time.now}. val = @config[param].default if val.nil? # Convert it if necessary - val = convert(val) + val = convert(val, environment) # And cache it @cache[environment||"none"][param] = val diff --git a/lib/puppet/util/user_attr.rb b/lib/puppet/util/user_attr.rb new file mode 100644 index 000000000..db8fb81b9 --- /dev/null +++ b/lib/puppet/util/user_attr.rb @@ -0,0 +1,21 @@ +class UserAttr + def self.get_attributes_by_name(name) + attributes = nil + + File.readlines('/etc/user_attr').each do |line| + next if line =~ /^#/ + + token = line.split(':') + + if token[0] == name + attributes = {:name => name} + token[4].split(';').each do |attr| + key_value = attr.split('=') + attributes[key_value[0].intern] = key_value[1].strip + end + break + end + end + return attributes + end +end |