Skip to content

Commit 97e47be

Browse files
authored
Make there be no command output
1 parent 7bfb10c commit 97e47be

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

msfupdate

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,45 @@ class Msfupdate
145145
end
146146
end
147147

148-
149148
# We could also do this by running `git config --global user.name` and `git config --global user.email`
150-
# and check the output of those
149+
# and check the output of those. (it's a bit quieter)
151150
def git_globals_okay?
152-
conf_out_status = system('git config --list') # Just see if it runs or not
153-
if conf_out_status.nil?
151+
require 'tempfile'
152+
require 'os'
153+
output = ''
154+
155+
# Make it cross platform
156+
if !OS.windows?
157+
conf_out_status = system('git config --list > /dev/null 2>&1') # Just see if it runs or not
158+
else
159+
conf_out_status = system('git config --list > nul 2&>1')
160+
end
161+
if !conf_out_status || conf_out_status.nil?
154162
stderr.puts '[-] ERROR: Failed to check git settings'
155163
return false
156164
end
165+
166+
begin
167+
conf = Tempfile.new('gitconf') # Create a tempfile
168+
path = conf.path
169+
system("git config --list > #{path}") # Write to the tempfile (Pretty sure this command is cross platform)
170+
output >> conf.read
171+
ensure
172+
conf.close
173+
conf.unlink # Delete the temp file
174+
end
157175

158-
conf = `git config --list` # Need the output for this
159-
160-
if !conf.include? 'user.name'
176+
if !output.include? 'user.name'
161177
stderr.puts '[-] ERROR: user.name is not set in your global git configuration'
162-
stderr.puts ''
163178
stderr.puts '[-] Set it by running: \'git config --global user.name "NAME HERE"\''
179+
stderr.puts ''
164180
return false
165181
end
166-
if !conf.include? 'user.email'
182+
183+
if !output.include? 'user.email'
167184
stderr.puts '[-] ERROR: user.email is not set in your global git configuration'
168-
stderr.puts ''
169185
stderr.puts '[-] Set it by running: \'git config --global user.email "[email protected]"\''
186+
stderr.puts ''
170187
return false
171188
end
172189

@@ -234,8 +251,6 @@ class Msfupdate
234251
end
235252
end
236253

237-
238-
239254
def update_binary_install!
240255
update_script = File.expand_path(File.join(@msfbase_dir, "..", "engine", "update.rb"))
241256
product_key = File.expand_path(File.join(@msfbase_dir, "..", "engine", "license", "product.key"))

0 commit comments

Comments
 (0)