~ubuntu-branches/ubuntu/precise/puppet/precise-security

« back to all changes in this revision

Viewing changes to .pc/2.7.17-Puppet-July-2012-CVE-fixes.patch/lib/puppet/file_serving/configuration.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-10 07:58:03 UTC
  • Revision ID: package-import@ubuntu.com-20120710075803-og8iubg2a90dtk7f
Tags: 2.7.11-1ubuntu2.1
* SECURITY UPDATE: Multiple July 2012 security issues
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch: upstream
    patch to fix multiple security issues.
  - CVE-2012-3864: arbitrary file read on master from authenticated
    clients
  - CVE-2012-3865: arbitrary file delete or denial of service on master
    from authenticated clients
  - CVE-2012-3866: last_run_report.yaml report file is world readable and
    leads to arbitrary file read on master by an agent
  - CVE-2012-3867: insufficient input validation for agent cert hostnames

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'monitor'
 
2
require 'puppet'
 
3
require 'puppet/file_serving'
 
4
require 'puppet/file_serving/mount'
 
5
require 'puppet/file_serving/mount/file'
 
6
require 'puppet/file_serving/mount/modules'
 
7
require 'puppet/file_serving/mount/plugins'
 
8
 
 
9
class Puppet::FileServing::Configuration
 
10
  require 'puppet/file_serving/configuration/parser'
 
11
 
 
12
  extend MonitorMixin
 
13
 
 
14
  def self.configuration
 
15
    synchronize do
 
16
      @configuration ||= new
 
17
    end
 
18
  end
 
19
 
 
20
  Mount = Puppet::FileServing::Mount
 
21
 
 
22
  private_class_method  :new
 
23
 
 
24
  attr_reader :mounts
 
25
  #private :mounts
 
26
 
 
27
  # Find the right mount.  Does some shenanigans to support old-style module
 
28
  # mounts.
 
29
  def find_mount(mount_name, environment)
 
30
    # Reparse the configuration if necessary.
 
31
    readconfig
 
32
 
 
33
    if mount = mounts[mount_name]
 
34
      return mount
 
35
    end
 
36
 
 
37
    if environment.module(mount_name)
 
38
      Puppet::Util::Warnings.notice_once "DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release.  Please fix module '#{mount_name}' when no 0.24.x clients are present"
 
39
      return mounts["modules"]
 
40
    end
 
41
 
 
42
    # This can be nil.
 
43
    mounts[mount_name]
 
44
  end
 
45
 
 
46
  def initialize
 
47
    @mounts = {}
 
48
    @config_file = nil
 
49
 
 
50
    # We don't check to see if the file is modified the first time,
 
51
    # because we always want to parse at first.
 
52
    readconfig(false)
 
53
  end
 
54
 
 
55
  # Is a given mount available?
 
56
  def mounted?(name)
 
57
    @mounts.include?(name)
 
58
  end
 
59
 
 
60
  # Split the path into the separate mount point and path.
 
61
  def split_path(request)
 
62
    # Reparse the configuration if necessary.
 
63
    readconfig
 
64
 
 
65
    mount_name, path = request.key.split(File::Separator, 2)
 
66
 
 
67
    raise(ArgumentError, "Cannot find file: Invalid path '#{mount_name}'") unless mount_name =~ %r{^[-\w]+$}
 
68
 
 
69
    return nil unless mount = find_mount(mount_name, request.environment)
 
70
    if mount.name == "modules" and mount_name != "modules"
 
71
      # yay backward-compatibility
 
72
      path = "#{mount_name}/#{path}"
 
73
    end
 
74
 
 
75
    if path == ""
 
76
      path = nil
 
77
    elsif path
 
78
      # Remove any double slashes that might have occurred
 
79
      path = path.gsub(/\/+/, "/")
 
80
    end
 
81
 
 
82
    return mount, path
 
83
  end
 
84
 
 
85
  def umount(name)
 
86
    @mounts.delete(name) if @mounts.include? name
 
87
  end
 
88
 
 
89
  private
 
90
 
 
91
  def mk_default_mounts
 
92
    @mounts["modules"] ||= Mount::Modules.new("modules")
 
93
    @mounts["modules"].allow('*') if @mounts["modules"].empty?
 
94
    @mounts["plugins"] ||= Mount::Plugins.new("plugins")
 
95
    @mounts["plugins"].allow('*') if @mounts["plugins"].empty?
 
96
  end
 
97
 
 
98
  # Read the configuration file.
 
99
  def readconfig(check = true)
 
100
    config = Puppet[:fileserverconfig]
 
101
 
 
102
    return unless FileTest.exists?(config)
 
103
 
 
104
    @parser ||= Puppet::FileServing::Configuration::Parser.new(config)
 
105
 
 
106
    return if check and ! @parser.changed?
 
107
 
 
108
    # Don't assign the mounts hash until we're sure the parsing succeeded.
 
109
    begin
 
110
      newmounts = @parser.parse
 
111
      @mounts = newmounts
 
112
    rescue => detail
 
113
      puts detail.backtrace if Puppet[:trace]
 
114
      Puppet.err "Error parsing fileserver configuration: #{detail}; using old configuration"
 
115
    end
 
116
 
 
117
  ensure
 
118
    # Make sure we've got our plugins and modules.
 
119
    mk_default_mounts
 
120
  end
 
121
end