@@ -145,28 +145,45 @@ class Msfupdate
145
145
end
146
146
end
147
147
148
-
149
148
# 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)
151
150
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?
154
162
stderr . puts '[-] ERROR: Failed to check git settings'
155
163
return false
156
164
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
157
175
158
- conf = `git config --list` # Need the output for this
159
-
160
- if !conf . include? 'user.name'
176
+ if !output . include? 'user.name'
161
177
stderr . puts '[-] ERROR: user.name is not set in your global git configuration'
162
- stderr . puts ''
163
178
stderr . puts '[-] Set it by running: \'git config --global user.name "NAME HERE"\''
179
+ stderr . puts ''
164
180
return false
165
181
end
166
- if !conf . include? 'user.email'
182
+
183
+ if !output . include? 'user.email'
167
184
stderr . puts '[-] ERROR: user.email is not set in your global git configuration'
168
- stderr . puts ''
169
185
stderr . puts '[-] Set it by running: \'git config --global user.email "[email protected] "\''
186
+ stderr . puts ''
170
187
return false
171
188
end
172
189
@@ -234,8 +251,6 @@ class Msfupdate
234
251
end
235
252
end
236
253
237
-
238
-
239
254
def update_binary_install!
240
255
update_script = File . expand_path ( File . join ( @msfbase_dir , ".." , "engine" , "update.rb" ) )
241
256
product_key = File . expand_path ( File . join ( @msfbase_dir , ".." , "engine" , "license" , "product.key" ) )
0 commit comments