Skip to content

Commit 187a044

Browse files
committed
Issue rapid7#4868 - Adding warning message to db_connect when already connected
1 parent 6031791 commit 187a044

File tree

1 file changed

+9
-0
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+9
-0
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,15 @@ def cmd_db_connect_help
17061706

17071707
def cmd_db_connect(*args)
17081708
return if not db_check_driver
1709+
if framework.db.connection_established?
1710+
cdb = ""
1711+
::ActiveRecord::Base.connection_pool.with_connection { |conn|
1712+
if conn.respond_to? :current_database
1713+
cdb = conn.current_database
1714+
end
1715+
}
1716+
return print_status("#{framework.db.driver} already connected to #{cdb}")
1717+
end
17091718
if (args[0] == "-y")
17101719
if (args[1] and not ::File.exists? ::File.expand_path(args[1]))
17111720
print_error("File not found")

0 commit comments

Comments
 (0)