This file is indexed.

/usr/bin/restclient is in ruby-rest-client 1.6.7-4.

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

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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env ruby

$:.unshift File.dirname(__FILE__) + "/../lib"

require 'rubygems'
require 'restclient'
require 'yaml'

def usage(why = nil)
  puts "failed for reason: #{why}" if why
  puts "usage: restclient [get|put|post|delete] url|name [username] [password]"
  puts "  The verb is optional, if you leave it off you'll get an interactive shell."
  puts "  put and post both take the input body on stdin."
  exit(1)
end

POSSIBLE_VERBS = ['get', 'put', 'post', 'delete']

if POSSIBLE_VERBS.include? ARGV.first
  @verb = ARGV.shift
else
  @verb = nil
end

@url = ARGV.shift || 'http://localhost:4567'

config = YAML.load(File.read(ENV['HOME'] + "/.restclient")) rescue {}

@url, @username, @password = if c = config[@url]
  [c['url'], c['username'], c['password']]
else
  [@url, * ARGV]
end

usage("invalid url '#{@url}") unless @url =~ /^https?/
usage("too few args") unless ARGV.size < 3

def r
  @r ||= RestClient::Resource.new(@url, @username, @password)
end

r # force rc to load

if @verb
  begin
    if %w( put post ).include? @verb
      puts r.send(@verb, STDIN.read)
    else
      puts r.send(@verb)
    end
    exit 0
  rescue RestClient::Exception => e
    puts e.response.body if e.respond_to? :response
    raise
  end
end

POSSIBLE_VERBS.each do |m|
  eval <<-end_eval
def  #{m}(path, *args, &b)
	r[path].#{m}(*args, &b)
end
  end_eval
end

def method_missing(s, * args, & b)
  if POSSIBLE_VERBS.include? s
    begin
      r.send(s, *args, & b)
    rescue RestClient::RequestFailed => e
      print STDERR, e.response.body
      raise e
    end
  else
    super
  end
end

require 'irb'
require 'irb/completion'

if File.exists? ".irbrc"
  ENV['IRBRC'] = ".irbrc"
end

if File.exists?(File.expand_path(rcfile = "~/.restclientrc"))
  load(rcfile)
end

ARGV.clear

IRB.start
exit!