Skip to content

Commit e81f2e3

Browse files
committed
Refactor db_{status,connect} a bit
Also allow for db_connect help.
1 parent ee8318d commit e81f2e3

File tree

1 file changed

+10
-10
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,11 +1688,11 @@ def cmd_db_status(*args)
16881688

16891689
if framework.db.connection_established?
16901690
cdb = ""
1691-
::ActiveRecord::Base.connection_pool.with_connection { |conn|
1692-
if conn.respond_to? :current_database
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,16 +1706,16 @@ 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?
1709+
if args[0] != '-h' && framework.db.connection_established?
17101710
cdb = ""
1711-
::ActiveRecord::Base.connection_pool.with_connection { |conn|
1712-
if conn.respond_to? :current_database
1711+
::ActiveRecord::Base.connection_pool.with_connection do |conn|
1712+
if conn.respond_to?(:current_database)
17131713
cdb = conn.current_database
17141714
end
1715-
}
1716-
status = "#{framework.db.driver} already connected to #{cdb}. "
1717-
status += "Run db_disconnect first if you wish to connect to a different database."
1718-
return print_status(status)
1715+
end
1716+
print_status("#{framework.db.driver} already connected to #{cdb}. " +
1717+
"Run db_disconnect first if you wish to connect to a different database.")
1718+
return
17191719
end
17201720
if (args[0] == "-y")
17211721
if (args[1] and not ::File.exists? ::File.expand_path(args[1]))

0 commit comments

Comments
 (0)