~ubuntu-branches/ubuntu/quantal/puppet/quantal-security

« back to all changes in this revision

Viewing changes to .pc/CVE-2011-3872.patch/lib/puppet/util/monkey_patches.rb

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-10-24 15:05:12 UTC
  • Revision ID: james.westby@ubuntu.com-20111024150512-yxqwfdp6hcs6of5l
Tags: 2.7.1-1ubuntu3.2
* SECURITY UPDATE: puppet master impersonation via incorrect certificates
  - debian/patches/CVE-2011-3872.patch: refactor certificate handling.
  - Thanks to upstream for providing the patch.
  - CVE-2011-3872

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
unless defined? JRUBY_VERSION
 
3
  Process.maxgroups = 1024
 
4
end
 
5
 
 
6
module RDoc
 
7
  def self.caller(skip=nil)
 
8
    in_gem_wrapper = false
 
9
    Kernel.caller.reject { |call|
 
10
      in_gem_wrapper ||= call =~ /#{Regexp.escape $0}:\d+:in `load'/
 
11
    }
 
12
  end
 
13
end
 
14
 
 
15
 
 
16
require "yaml"
 
17
require "puppet/util/zaml.rb"
 
18
 
 
19
class Symbol
 
20
  def to_zaml(z)
 
21
    z.emit("!ruby/sym ")
 
22
    to_s.to_zaml(z)
 
23
  end
 
24
  def <=> (other)
 
25
    self.to_s <=> other.to_s
 
26
  end
 
27
end
 
28
 
 
29
[Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls|
 
30
  cls.class_eval do
 
31
    def to_yaml(ignored=nil)
 
32
      ZAML.dump(self)
 
33
    end
 
34
  end
 
35
}
 
36
 
 
37
def YAML.dump(*args)
 
38
  ZAML.dump(*args)
 
39
end
 
40
 
 
41
#
 
42
# Workaround for bug in MRI 1.8.7, see
 
43
#     http://redmine.ruby-lang.org/issues/show/2708
 
44
# for details
 
45
#
 
46
if RUBY_VERSION == '1.8.7'
 
47
  class NilClass
 
48
    def closed?
 
49
      true
 
50
    end
 
51
  end
 
52
end
 
53
 
 
54
class Object
 
55
  # ActiveSupport 2.3.x mixes in a dangerous method
 
56
  # that can cause rspec to fork bomb
 
57
  # and other strange things like that.
 
58
  def daemonize
 
59
    raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it."
 
60
  end
 
61
 
 
62
  # The following code allows callers to make assertions that are only
 
63
  # checked when the environment variable PUPPET_ENABLE_ASSERTIONS is
 
64
  # set to a non-empty string.  For example:
 
65
  #
 
66
  #   assert_that { condition }
 
67
  #   assert_that(message) { condition }
 
68
  if ENV["PUPPET_ENABLE_ASSERTIONS"].to_s != ''
 
69
    def assert_that(message = nil)
 
70
      unless yield
 
71
        raise Exception.new("Assertion failure: #{message}")
 
72
      end
 
73
    end
 
74
  else
 
75
    def assert_that(message = nil)
 
76
    end
 
77
  end
 
78
end
 
79
 
 
80
# Workaround for yaml_initialize, which isn't supported before Ruby
 
81
# 1.8.3.
 
82
if RUBY_VERSION == '1.8.1' || RUBY_VERSION == '1.8.2'
 
83
  YAML.add_ruby_type( /^object/ ) { |tag, val|
 
84
    type, obj_class = YAML.read_type_class( tag, Object )
 
85
    r = YAML.object_maker( obj_class, val )
 
86
    if r.respond_to? :yaml_initialize
 
87
      r.instance_eval { instance_variables.each { |name| remove_instance_variable name } }
 
88
      r.yaml_initialize(tag, val)
 
89
    end
 
90
    r
 
91
  }
 
92
end
 
93
 
 
94
class Array
 
95
  # Ruby < 1.8.7 doesn't have this method but we use it in tests
 
96
  def combination(num)
 
97
    return [] if num < 0 || num > size
 
98
    return [[]] if num == 0
 
99
    return map{|e| [e] } if num == 1
 
100
    tmp = self.dup
 
101
    self[0, size - (num - 1)].inject([]) do |ret, e|
 
102
      tmp.shift
 
103
      ret += tmp.combination(num - 1).map{|a| a.unshift(e) }
 
104
    end
 
105
  end unless method_defined? :combination
 
106
end
 
107
 
 
108
 
 
109
class Symbol
 
110
  def to_proc
 
111
    Proc.new { |*args| args.shift.__send__(self, *args) }
 
112
  end unless method_defined? :to_proc
 
113
end