Skip to content

Commit 5736f65

Browse files
author
Tod Beardsley
committed
Land rapid7#2148, prefer xdg-open over sensible-browser
2 parents adef046 + 53c3fd2 commit 5736f65

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/rex/compat.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ def self.open_browser(url='http://metasploit.com/')
131131
# Search through the PATH variable (if it exists) and chose a browser
132132
# We are making an assumption about the nature of "PATH" so tread lightly
133133
if defined? ENV['PATH']
134-
# "sensible-browser" opens the "default" browser in Ubuntu and others, so try that first
135-
# but also provide fallbacks
136-
['sensible-browser', 'firefox', 'opera', 'chromium-browser', 'konqueror'].each do |browser|
134+
# "xdg-open" is more general than "sensible-browser" and can be useful for lots of
135+
# file types -- text files, pcaps, or URLs. It's nearly always
136+
# going to use the application the user is expecting. If we're not
137+
# on something Debian-based, fall back to likely browsers.
138+
['xdg-open', 'sensible-browser', 'firefox', 'firefox-bin', 'opera', 'konqueror', 'chromium-browser'].each do |browser|
137139
ENV['PATH'].split(':').each do |path|
138140
# Does the browser exists?
139141
if File.exists?("#{path}/#{browser}")
@@ -143,9 +145,6 @@ def self.open_browser(url='http://metasploit.com/')
143145
end
144146
end
145147
end
146-
147-
# If nothing else worked, default to firefox
148-
system("firefox #{url} &")
149148
end
150149
end
151150

0 commit comments

Comments
 (0)