This file is indexed.

/usr/lib/ruby/vendor_ruby/chef_compat/monkeypatches/chef/run_context.rb is in ruby-compat-resource 12.10.5-1.

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'chef/run_context'
require 'chef_compat/monkeypatches/chef/resource_collection'

if Gem::Requirement.new("< 12.10.24").satisfied_by?(Gem::Version.new(Chef::VERSION))
  module ChefCompat
    module Monkeypatches
      module Chef
        module RunContext
          # for versions after we added intialize_child_state but before 12.10.24
          def initialize_child_state(*args)
            super
            @resource_collection.run_context = self
            @delayed_actions = []
          end
        end
      end
    end
  end

  class Chef
    class RunContext
      #
      # NOTE:  The root run_context is created long before we start monkeying around
      # with patching the class.  No child run context has been created yet.  This
      # still patches the root run_context and implements the new behaviors on it.
      #
      # This does affect our ability to patch methods like #initialize, since the
      # root has already been created and initialized, obviously.
      #

      unless method_defined?(:parent_run_context)
        attr_accessor :parent_run_context
      end

      unless method_defined?(:delayed_actions)
        def delayed_actions
          @delayed_actions ||= []
        end
      end

      unless method_defined?(:initialize_child_state)
        #
        # Copied verbatim from 12.10.24 Chef::RunContext
        #
        def initialize_child_state
          @audits = {}
          @resource_collection = Chef::ResourceCollection.new(self)
          @before_notification_collection = Hash.new { |h, k| h[k] = [] }
          @immediate_notification_collection = Hash.new { |h, k| h[k] = [] }
          @delayed_notification_collection = Hash.new { |h, k| h[k] = [] }
          @delayed_actions = []
        end
      else
        prepend ChefCompat::Monkeypatches::Chef::RunContext
      end

      unless method_defined?(:add_delayed_action)
        def add_delayed_action(notification)
          if delayed_actions.any? { |existing_notification| existing_notification.duplicates?(notification) }
            Chef::Log.info( "#{notification.notifying_resource} not queuing delayed action #{notification.action} on #{notification.resource}"\
                           " (delayed), as it's already been queued")
          else
            delayed_actions << notification
          end
        end
      end

      unless method_defined?(:create_child)
        def create_child
          result = dup
          result.parent_run_context = self
          result.initialize_child_state
          result
        end
      end
    end
  end
end