Skip to content

Commit 7bfb10c

Browse files
authored
Update msfupdate
1 parent 69769b1 commit 7bfb10c

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

msfupdate

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,35 @@ class Msfupdate
145145
end
146146
end
147147

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+
148177
def update_git!
149178
####### Since we're Git, do it all that way #######
150179
stdout.puts "[*] Checking for updates via git"
@@ -163,8 +192,15 @@ class Msfupdate
163192
# to begin with.
164193
#
165194
# 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
168204
committed = system("git", "diff", "--quiet", "HEAD")
169205
if committed.nil?
170206
stderr.puts "[-] ERROR: Failed to run git"
@@ -198,6 +234,8 @@ class Msfupdate
198234
end
199235
end
200236

237+
238+
201239
def update_binary_install!
202240
update_script = File.expand_path(File.join(@msfbase_dir, "..", "engine", "update.rb"))
203241
product_key = File.expand_path(File.join(@msfbase_dir, "..", "engine", "license", "product.key"))

0 commit comments

Comments
 (0)