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

« back to all changes in this revision

Viewing changes to lib/puppet/file_serving/indirection_hooks.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 'uri'
2
 
require 'puppet/file_serving'
3
 
require 'puppet/util'
4
 
 
5
 
# This module is used to pick the appropriate terminus
6
 
# in file-serving indirections.  This is necessary because
7
 
# the terminus varies based on the URI asked for.
8
 
module Puppet::FileServing::IndirectionHooks
9
 
  PROTOCOL_MAP = {"puppet" => :rest, "file" => :file}
10
 
 
11
 
  # Pick an appropriate terminus based on the protocol.
12
 
  def select_terminus(request)
13
 
    # We rely on the request's parsing of the URI.
14
 
 
15
 
    # Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol.
16
 
    return PROTOCOL_MAP["file"] if Puppet::Util.absolute_path?(request.key)
17
 
    return PROTOCOL_MAP["file"] if request.protocol == "file"
18
 
 
19
 
    # We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'apply' or 'puppet'
20
 
    if request.protocol == "puppet" and (request.server or !["puppet","apply"].include?(Puppet.settings[:name]))
21
 
      return PROTOCOL_MAP["puppet"]
22
 
    end
23
 
 
24
 
    if request.protocol and PROTOCOL_MAP[request.protocol].nil?
25
 
      raise(ArgumentError, "URI protocol '#{request.protocol}' is not currently supported for file serving")
26
 
    end
27
 
 
28
 
    # If we're still here, we're using the file_server or modules.
29
 
    :file_server
30
 
  end
31
 
end