MMCT TEAM
Server IP : 111.118.215.189  /  Your IP : 3.143.218.86
Web Server : Apache
System : Linux md-in-83.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : a1673wkz ( 2475)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/share/ruby/vendor_ruby/puppet/indirector/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/share/ruby/vendor_ruby/puppet/indirector/file_server.rb
require 'puppet/file_serving/configuration'
require 'puppet/file_serving/fileset'
require 'puppet/file_serving/terminus_helper'
require 'puppet/indirector/terminus'

# Look files up using the file server.
class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
  include Puppet::FileServing::TerminusHelper

  # Is the client authorized to perform this action?
  def authorized?(request)
    return false unless [:find, :search].include?(request.method)

    mount, file_path = configuration.split_path(request)

    # If we're not serving this mount, then access is denied.
    return false unless mount
    mount.allowed?(request.node, request.ip)
  end

  # Find our key using the fileserver.
  def find(request)
    mount, relative_path = configuration.split_path(request)

    return nil unless mount

    # The mount checks to see if the file exists, and returns nil
    # if not.
    return nil unless path = mount.find(relative_path, request)
    result = model.new(path)
    result.links = request.options[:links] if request.options[:links]
    result.collect(request.options[:source_permissions])
    result
  end

  # Search for files.  This returns an array rather than a single
  # file.
  def search(request)
    mount, relative_path = configuration.split_path(request)

    unless mount and paths = mount.search(relative_path, request)
      Puppet.info "Could not find filesystem info for file '#{request.key}' in environment #{request.environment}"
      return nil
    end

    filesets = paths.collect do |path|
      # Filesets support indirector requests as an options collection
      Puppet::FileServing::Fileset.new(path, request)
    end

    Puppet::FileServing::Fileset.merge(*filesets).collect do |file, base_path|
      inst = model.new(base_path, :relative_path => file)
      inst.links = request.options[:links] if request.options[:links]
      inst.collect
      inst
    end
  end

  private

  # Our fileserver configuration, if needed.
  def configuration
    Puppet::FileServing::Configuration.configuration
  end
end

MMCT - 2023