-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DB initialization when missing database YAML file #9860
Fix DB initialization when missing database YAML file #9860
Conversation
c1e089d
to
e639fda
Compare
👏 |
@@ -153,9 +157,6 @@ def check | |||
# | |||
def initialize_database_support | |||
begin | |||
# Database drivers can reset our KCODE, do not let them | |||
$KCODE = 'NONE' if RUBY_VERSION =~ /^1\.8\./ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this just removed because we no longer support Ruby 1.8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unfortunate KCODE
doesn't mean Konami Code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbarnett-r7 Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wvu-r7 ⬆️⬆️⬇️⬇️⬅️➡️⬅️➡️
@@ -1653,8 +1653,8 @@ def cmd_db_nmap_tabs(str, words) | |||
# Database management | |||
# | |||
def db_check_driver | |||
if(not framework.db.driver) | |||
print_error("No database driver installed. Try 'gem install pg'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the suggestion to install the pg gem removed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the suggestion to gem install pg
is not relevant given we now use bundler
. Is this correct @busterb?
@@ -1909,6 +1909,12 @@ def each_host_range_chunk(host_ranges, &block) | |||
####### | |||
|
|||
def add_data_service(*args) | |||
# database is required to use Mdm objects | |||
unless framework.db.active | |||
print_error("Database not connected; connect to an existing database with db_connect before using data_services") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like longer term we should move everything under a single command (either db_connect or data_services). Agree/disagree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
This PR fixes a bug introduced with goliath that caused incorrect error messages and other error messages when no database.yml was present. It also improves the messaging around that use case and loads CommandDispatcher::Db correctly.
Release NotesFixes issues introduced with Goliath #9717 that caused confusing error messages and subsequent DB operations to fail to work as expected due to the framework not loading |
Fixes DB initialization when the database YAML file is missing. The message "WARNING: No database support: NilClass" reported during msfconsole startup is the first indicator of the issue. Subsequent DB operations fail to work as expected due to the framework not loading
CommandDispatcher::Db
. Fixes #9811This also cleans up some things that were not caught in the early Goliath changes.
Verification
database.yml
file:mv ~/.msf4/database.yml ~/.msf4/database.yml.disable
msfconsole
db_status
postgresql selected, no connection
db_connect -y ~/.msf4/database.yml.disable
db_status
reports it is connected to the specified database (postgresql connected to ...
)msfdb_ws
data_services --add <host>
database.yml
file:mv ~/.msf4/database.yml.disable ~/.msf4/database.yml