Skip to content
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

Adds fix for msfdb issues on Ubuntu #14759

Closed

Conversation

cgranleese-r7
Copy link
Contributor

This PR resolves #12098.

ENV['PATH'] = "/usr/lib/postgresql/12/bin:#{ENV['PATH']}" has been added into the msfdb script, this sets postgresql to be included within $PATH. Prior to this change, this was something Ubuntu users had required to do manually as a fix.

The user will also have to run sudo adduser {your-user-name} postgres to add themselves as a user for the postgres group. So I plan to make some changes to the wiki to step users through setting that up. I have added a mock for the wiki below.

Before

image

After

image

Mock wiki update

I think adding the following in as a third step makes sense.

image

Environment

For testing I used a fresh Ubuntu VM and installed Metasploit via Git clone. Do not use the omnibus installer, as this bug is not present in that installation method as postgres comes embedded.
Once I had Metasploit cloned I just followed the wiki to get everything set-up. Once you have verified you're getting the original error.
Then add my change via vim and ensure the error is gone and ./msfdb init runs successfully.
There may be smarter ways to test this, but thought I'd mention my method.

Add the following code:

ENV['PATH'] = "/usr/lib/postgresql/12/bin:#{ENV['PATH']}"

into the following file, at line 50:

metasploit-framework/msfdb

Verification

List the steps needed to make sure this thing works

  • Git clone Metasploit onto a Ubuntu VM
  • Follow the wiki to get everything set-up
  • Verify your getting the original error
  • Add in the fix describe above in Environment section
  • Verify you can run ./msfdb init without receiving any errors.

@@ -47,6 +47,8 @@ require 'msfenv'
@components = %w(database webservice)
@environments = %w(production development)

ENV['PATH'] = "/usr/lib/postgresql/12/bin:#{ENV['PATH']}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might need some more work, as this would only work for version 12 - but not 11, or 13 etc.
Folk may have their tooling installed elsewhere too, for instance this is the location on my mac:

$ locate pg_ctl
/usr/local/Cellar/postgresql@11/11.9/bin/pg_ctl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, well I never thought of that. I'll have to look at this and see what I can come up with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this problem/solution overlaps with this discussion where it's suggested not to use pg_ctl but pg_ctlcluster instead:
#11369

For context, with a fresh install on a ubuntu machine pg_ctl is not on my path, but pg_ctlcluster is:

user@ubuntu:~$ pg_ctl
pg_ctl: command not found
user@ubuntu:~$ pg_ctlcluster
Error: Usage: /usr/bin/pg_ctlcluster <version> <cluster> <action> [-- <pg_ctl options>]

Note that later on that thread there's a link to the effort/semantic differences between the current tools we're using:
#11369 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. Adding pg_ctl onto your path works for the environment that you tested on, but it wouldn't always work for everyone

@cgranleese-r7
Copy link
Contributor Author

Going to close this for now. After some more investigation, it's looking like this won't be as simple a fix as I first thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

msfdb init failed in ubuntu
2 participants