Skip to content

Commit

Permalink
Merge pull request #2 from wvu-r7/pr/4902
Browse files Browse the repository at this point in the history
Refactor db_{status,connect} a bit
  • Loading branch information
nstarke committed Mar 10, 2015
2 parents ee8318d + e81f2e3 commit 4d12690
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/msf/ui/console/command_dispatcher/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1688,11 +1688,11 @@ def cmd_db_status(*args)

if framework.db.connection_established?
cdb = ""
::ActiveRecord::Base.connection_pool.with_connection { |conn|
if conn.respond_to? :current_database
::ActiveRecord::Base.connection_pool.with_connection do |conn|
if conn.respond_to?(:current_database)
cdb = conn.current_database
end
}
end
print_status("#{framework.db.driver} connected to #{cdb}")
else
print_status("#{framework.db.driver} selected, no connection")
Expand All @@ -1706,16 +1706,16 @@ def cmd_db_connect_help

def cmd_db_connect(*args)
return if not db_check_driver
if framework.db.connection_established?
if args[0] != '-h' && framework.db.connection_established?
cdb = ""
::ActiveRecord::Base.connection_pool.with_connection { |conn|
if conn.respond_to? :current_database
::ActiveRecord::Base.connection_pool.with_connection do |conn|
if conn.respond_to?(:current_database)
cdb = conn.current_database
end
}
status = "#{framework.db.driver} already connected to #{cdb}. "
status += "Run db_disconnect first if you wish to connect to a different database."
return print_status(status)
end
print_status("#{framework.db.driver} already connected to #{cdb}. " +
"Run db_disconnect first if you wish to connect to a different database.")
return
end
if (args[0] == "-y")
if (args[1] and not ::File.exists? ::File.expand_path(args[1]))
Expand Down

0 comments on commit 4d12690

Please sign in to comment.