~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/content.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 'puppet/indirector'
 
2
require 'puppet/file_serving'
 
3
require 'puppet/file_serving/base'
 
4
require 'puppet/file_serving/indirection_hooks'
 
5
 
 
6
# A class that handles retrieving file contents.
 
7
# It only reads the file when its content is specifically
 
8
# asked for.
 
9
class Puppet::FileServing::Content < Puppet::FileServing::Base
 
10
  extend Puppet::Indirector
 
11
  indirects :file_content, :extend => Puppet::FileServing::IndirectionHooks
 
12
 
 
13
  attr_writer :content
 
14
 
 
15
  def self.supported_formats
 
16
    [:raw]
 
17
  end
 
18
 
 
19
  def self.from_raw(content)
 
20
    instance = new("/this/is/a/fake/path")
 
21
    instance.content = content
 
22
    instance
 
23
  end
 
24
 
 
25
  # BF: we used to fetch the file content here, but this is counter-productive
 
26
  # for puppetmaster streaming of file content. So collect just returns itself
 
27
  def collect
 
28
    return if stat.ftype == "directory"
 
29
    self
 
30
  end
 
31
 
 
32
  # Read the content of our file in.
 
33
  def content
 
34
    unless @content
 
35
      # This stat can raise an exception, too.
 
36
      raise(ArgumentError, "Cannot read the contents of links unless following links") if stat.ftype == "symlink"
 
37
 
 
38
      @content = Puppet::Util.binread(full_path)
 
39
    end
 
40
    @content
 
41
  end
 
42
 
 
43
  def to_raw
 
44
    File.new(full_path, "rb")
 
45
  end
 
46
end