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

« back to all changes in this revision

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