This file is indexed.

/usr/lib/ruby/vendor_ruby/net/sftp/operations/file_factory.rb is in ruby-net-sftp 1:2.1.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'net/ssh/loggable'
require 'net/sftp/operations/file'

module Net; module SFTP; module Operations

  # A factory class for opening files and returning Operations::File instances
  # that wrap the SFTP handles that represent them. This is a convenience
  # class for use when working with files synchronously. Rather than relying
  # on the programmer to provide callbacks that define a state machine that
  # describes the behavior of the program, this class (and Operations::File)
  # provide an interface where calls will block until they return, mimicking
  # the IO class' interface.
  class FileFactory
    # The SFTP session object that drives this file factory.
    attr_reader :sftp

    # Create a new instance on top of the given SFTP session instance.
    def initialize(sftp)
      @sftp = sftp
    end

    # :call-seq:
    #   open(name, flags="r", mode=nil) -> file
    #   open(name, flags="r", mode=nil) { |file| ... }
    #
    # Attempt to open a file on the remote server. The +flags+ parameter
    # accepts the same values as the standard Ruby ::File#open method. The
    # +mode+ parameter must be an integer describing the permissions to use
    # if a new file is being created.
    #
    # If a block is given, the new Operations::File instance will be yielded
    # to it, and closed automatically when the block terminates. Otherwise
    # the object will be returned, and it is the caller's responsibility to
    # close the file.
    #
    #   sftp.file.open("/tmp/names.txt", "w") do |f|
    #     # ...
    #   end
    def open(name, flags="r", mode=nil, &block)
      handle = sftp.open!(name, flags, :permissions => mode)
      file = Operations::File.new(sftp, handle)

      if block_given?
        begin
          yield file
        ensure
          file.close
        end
      else
        return file
      end
    end

    # Returns +true+ if the argument refers to a directory on the remote host.
    def directory?(path)
      sftp.lstat!(path).directory?
    end
  end

end; end; end