@@ -145,6 +145,35 @@ class Msfupdate
145
145
end
146
146
end
147
147
148
+
149
+ # 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
151
+ 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?
154
+ stderr . puts '[-] ERROR: Failed to check git settings'
155
+ return false
156
+ end
157
+
158
+ conf = `git config --list` # Need the output for this
159
+
160
+ if !conf . include? 'user.name'
161
+ stderr . puts '[-] ERROR: user.name is not set in your global git configuration'
162
+ stderr . puts ''
163
+ stderr . puts '[-] Set it by running: \'git config --global user.name "NAME HERE"\''
164
+ return false
165
+ end
166
+ if !conf . include? 'user.email'
167
+ stderr . puts '[-] ERROR: user.email is not set in your global git configuration'
168
+ stderr . puts ''
169
+ stderr . puts '[-] Set it by running: \'git config --global user.email "[email protected] "\''
170
+ return false
171
+ end
172
+
173
+ true
174
+
175
+ end
176
+
148
177
def update_git!
149
178
####### Since we're Git, do it all that way #######
150
179
stdout . puts "[*] Checking for updates via git"
@@ -163,8 +192,15 @@ class Msfupdate
163
192
# to begin with.
164
193
#
165
194
# Note, this requires at least user.name and user.email
166
- # to be configured in the global git config. Installers should
167
- # take care that this is done. TODO: Enforce this in msfupdate
195
+ # to be configured in the global git config. Installers
196
+ # will be told to set them if they aren't already set.
197
+
198
+ # Checks user.name and user.email
199
+ global_status = git_globals_okay?
200
+ maybe_wait_and_exit ( 1 ) if !global_status
201
+
202
+
203
+ # We shouldn't get here if the globals dont check out
168
204
committed = system ( "git" , "diff" , "--quiet" , "HEAD" )
169
205
if committed . nil?
170
206
stderr . puts "[-] ERROR: Failed to run git"
@@ -198,6 +234,8 @@ class Msfupdate
198
234
end
199
235
end
200
236
237
+
238
+
201
239
def update_binary_install!
202
240
update_script = File . expand_path ( File . join ( @msfbase_dir , ".." , "engine" , "update.rb" ) )
203
241
product_key = File . expand_path ( File . join ( @msfbase_dir , ".." , "engine" , "license" , "product.key" ) )
0 commit comments