Class: IO

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

Class Method Summary collapse

Class Method Details

.popen(*args) ⇒ Object



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

def popen(*args)
  if args.size > 0
    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)

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

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

  return tcell_original_popen(*args)
end

.tcell_original_popenObject



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

alias_method :tcell_original_popen, :popen