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)
1687
1687
return if not db_check_driver
1688
1688
1689
1689
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 )
1693
1693
cdb = conn . current_database
1694
1694
end
1695
- }
1695
+ end
1696
1696
print_status ( "#{ framework . db . driver } connected to #{ cdb } " )
1697
1697
else
1698
1698
print_status ( "#{ framework . db . driver } selected, no connection" )
@@ -1706,6 +1706,17 @@ def cmd_db_connect_help
1706
1706
1707
1707
def cmd_db_connect ( *args )
1708
1708
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
1709
1720
if ( args [ 0 ] == "-y" )
1710
1721
if ( args [ 1 ] and not ::File . exists? ::File . expand_path ( args [ 1 ] ) )
1711
1722
print_error ( "File not found" )
You can’t perform that action at this time.
0 commit comments