File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
lib/msf/ui/console/command_dispatcher Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -1687,12 +1687,12 @@ def cmd_db_status(*args)
16871687 return if not db_check_driver
16881688
16891689 if framework . db . connection_established?
1690- cdb = ""
1691- ::ActiveRecord ::Base . connection_pool . with_connection { |conn |
1692- if conn . respond_to? :current_database
1690+ cdb = ''
1691+ ::ActiveRecord ::Base . connection_pool . with_connection do |conn |
1692+ if conn . respond_to? ( :current_database )
16931693 cdb = conn . current_database
16941694 end
1695- }
1695+ end
16961696 print_status ( "#{ framework . db . driver } connected to #{ cdb } " )
16971697 else
16981698 print_status ( "#{ framework . db . driver } selected, no connection" )
@@ -1706,6 +1706,17 @@ def cmd_db_connect_help
17061706
17071707 def cmd_db_connect ( *args )
17081708 return if not db_check_driver
1709+ if args [ 0 ] != '-h' && framework . db . connection_established?
1710+ cdb = ''
1711+ ::ActiveRecord ::Base . connection_pool . with_connection do |conn |
1712+ if conn . respond_to? ( :current_database )
1713+ cdb = conn . current_database
1714+ end
1715+ end
1716+ print_error ( "#{ framework . db . driver } already connected to #{ cdb } " )
1717+ print_error ( 'Run db_disconnect first if you wish to connect to a different database' )
1718+ return
1719+ end
17091720 if ( args [ 0 ] == "-y" )
17101721 if ( args [ 1 ] and not ::File . exists? ::File . expand_path ( args [ 1 ] ) )
17111722 print_error ( "File not found" )
You can’t perform that action at this time.
0 commit comments