Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/tcell_agent/cmdi.rb

Class Method Summary collapse

Class Method Details

.popen(*args) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/tcell_agent/cmdi.rb', line 90

def popen(*args)
  unless args.empty?
    cmd = ''

    TCellAgent::Instrumentation.safe_block('CMDI Parsing popen *args') do
      args_copy = Array.new(args)
      args_copy.shift if args_copy.first.is_a?(Hash)
      args_copy.pop if args_copy.last.is_a?(Hash)

      cmd = if args_copy.first.is_a?(String)
              args_copy.shift
            else
              TCellAgent::Cmdi.parse_command(*args_copy.shift)
            end
    end

    if TCellAgent::Cmdi.block_command?(cmd)
      raise Errno::ENOENT, "tCell.io Agent: Command not allowed by policy: #{cmd}"
    end
  end

  tcell_original_popen(*args)
end

.tcell_original_popenObject



89
# File 'lib/tcell_agent/cmdi.rb', line 89

alias_method :tcell_original_popen, :popen