Closed commitay closed 7 years ago
Problem verified, but I am not sure how to fix it.
Running the command "$(brew --repository)/Library/Taps/caskroom/homebrew-cask/developer/bin/list_payload_in_pkg"
yields (among other things):
/bin/metasploit-aggregator
/bin/msfbinscan
/bin/msfconsole
/bin/msfd
/bin/msfdb
/bin/msfelfscan
/bin/msfmachscan
/bin/msfpescan
/bin/msfremove
/bin/msfrop
/bin/msfrpc
/bin/msfrpcd
/bin/msfupdate
/bin/msfvenom
Thank you for checking @miccal. I just tried #31877 and it produces the same error.
I can reproduce this error with other casks vfuse and karabiner.
All three are pkg
installs with a binary
that points directly to a location rather that a binary "#{appdir}/calibre.app/Contents/MacOS/calibre"
or binary 'rar/rar'
.
I'm not sure if this actually means anything but it's the only thing I can see that they have in common.
I've tried a few casks with binary
- vmware-fusion, calibre, rar, happygrep, qiniu-devtools - all install without error.
Found a possible cause for this.
I've tried this with all the casks I mention in the previous post, the ones that had errors now work properly and it doesn't seem to impact any of the others.
Removing this allows the symlinks to be created without error.
==> installer:PHASE:The software was successfully installed.
==> installer: The install was successful.
==> Installing artifact of class Hbc::Artifact::Binary
==> Linking Binary 'metasploit-aggregator' to '/usr/local/bin/metasploit-aggregator'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/metasploit-aggregator", "/usr/local/bin/metasploit-aggregator"]
==> Linking Binary 'msfbinscan' to '/usr/local/bin/msfbinscan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfbinscan", "/usr/local/bin/msfbinscan"]
==> Linking Binary 'msfconsole' to '/usr/local/bin/msfconsole'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfconsole", "/usr/local/bin/msfconsole"]
==> Linking Binary 'msfd' to '/usr/local/bin/msfd'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfd", "/usr/local/bin/msfd"]
==> Linking Binary 'msfdb' to '/usr/local/bin/msfdb'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfdb", "/usr/local/bin/msfdb"]
==> Linking Binary 'msfelfscan' to '/usr/local/bin/msfelfscan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfelfscan", "/usr/local/bin/msfelfscan"]
==> Linking Binary 'msfmachscan' to '/usr/local/bin/msfmachscan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfmachscan", "/usr/local/bin/msfmachscan"]
==> Linking Binary 'msfpescan' to '/usr/local/bin/msfpescan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfpescan", "/usr/local/bin/msfpescan"]
==> Linking Binary 'msfremove' to '/usr/local/bin/msfremove'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfremove", "/usr/local/bin/msfremove"]
==> Linking Binary 'msfrop' to '/usr/local/bin/msfrop'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfrop", "/usr/local/bin/msfrop"]
==> Linking Binary 'msfrpc' to '/usr/local/bin/msfrpc'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfrpc", "/usr/local/bin/msfrpc"]
==> Linking Binary 'msfrpcd' to '/usr/local/bin/msfrpcd'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfrpcd", "/usr/local/bin/msfrpcd"]
==> Linking Binary 'msfupdate' to '/usr/local/bin/msfupdate'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfupdate", "/usr/local/bin/msfupdate"]
==> Linking Binary 'msfvenom' to '/usr/local/bin/msfvenom'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfvenom", "/usr/local/bin/msfvenom"]
🍺 metasploit was successfully installed!
Couldn’t look at this in depth, but I suspect the issue might lie in us not being able to chmod
something in /opt
for lack of permissions. That’s the difference between this cask and the others. @commitay Mind checking the permissions/ownership of those directories?
Solution might be to create /opt/metasploit-framework/bin
and give ourselves permissions on it in a preflight
.
If no one does it in the meantime, I’ll take a look tomorrow if I have time. Good night, everyone!
Good night, everyone!
Good night, @vitorgalvao!
Mind checking the permissions/ownership of those directories?
drwxr-xr-x 8 root wheel 272B 6 Apr 12:24 metasploit-framework
-rw-r--r-- 1 root wheel 34K 4 Apr 19:38 LICENSE
drwxr-xr-x 145 root wheel 4.8K 4 Apr 19:38 LICENSES
drwxr-xr-x 16 root wheel 544B 4 Apr 19:38 bin
drwxr-xr-x 9 root wheel 306B 4 Apr 19:35 embedded
-rw-r--r-- 1 root wheel 8.2K 4 Apr 19:38 version-manifest.json
-rw-r--r-- 1 root wheel 3.7K 4 Apr 19:38 version-manifest.txt
Solution might be to create /opt/metasploit-framework/bin and give ourselves permissions on it in a preflight.
I'm not sure if I've done these correctly, I copied them from examples in the docs.
Manually created /opt/metasploit-framework/bin
with sudo mkdir -p
before each installation.
preflight do
set_permissions '/opt/metasploit-framework/bin', '0755'
end
==> installer: The install was successful.
==> Installing artifact of class Hbc::Artifact::Binary
==> Linking Binary 'metasploit-aggregator' to '/usr/local/bin/metasploit-aggregator'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/metasploit-aggregator", "/usr/local/bin/metasploit-aggregator"]
==> Reverting installation of artifact of class Hbc::Artifact::PreflightBlock
==> Purging files for version 4.14.8,20170404092313 of Cask metasploit
Error: Operation not permitted - /opt/metasploit-framework/bin/metasploit-aggregator
preflight do
set_ownership '/opt/metasploit-framework/bin'
end
==> installer: The install was successful.
==> Installing artifact of class Hbc::Artifact::Binary
==> Linking Binary 'metasploit-aggregator' to '/usr/local/bin/metasploit-aggregator'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/metasploit-aggregator", "/usr/local/bin/metasploit-aggregator"]
==> Reverting installation of artifact of class Hbc::Artifact::PreflightBlock
==> Purging files for version 4.14.8,20170404092313 of Cask metasploit
Error: Operation not permitted - /opt/metasploit-framework/bin/metasploit-aggregator
but I suspect the issue might lie in us not being able to chmod
I think it might be FileUtils.chmod "+x", source
failing as if it is replaced with @command.run!("/bin/chmod", args: ["+x", source])
it works without any changes to the cask.
==> installer: The install was successful.
==> Installing artifact of class Hbc::Artifact::Binary
==> Linking Binary 'metasploit-aggregator' to '/usr/local/bin/metasploit-aggregator'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/metasploit-aggregator", "/usr/local/bin/metasploit-aggregator"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/metasploit-aggregator"]
==> Linking Binary 'msfbinscan' to '/usr/local/bin/msfbinscan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfbinscan", "/usr/local/bin/msfbinscan"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfbinscan"]
==> Linking Binary 'msfconsole' to '/usr/local/bin/msfconsole'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfconsole", "/usr/local/bin/msfconsole"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfconsole"]
==> Linking Binary 'msfd' to '/usr/local/bin/msfd'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfd", "/usr/local/bin/msfd"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfd"]
==> Linking Binary 'msfdb' to '/usr/local/bin/msfdb'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfdb", "/usr/local/bin/msfdb"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfdb"]
==> Linking Binary 'msfelfscan' to '/usr/local/bin/msfelfscan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfelfscan", "/usr/local/bin/msfelfscan"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfelfscan"]
==> Linking Binary 'msfmachscan' to '/usr/local/bin/msfmachscan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfmachscan", "/usr/local/bin/msfmachscan"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfmachscan"]
==> Linking Binary 'msfpescan' to '/usr/local/bin/msfpescan'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfpescan", "/usr/local/bin/msfpescan"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfpescan"]
==> Linking Binary 'msfremove' to '/usr/local/bin/msfremove'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfremove", "/usr/local/bin/msfremove"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfremove"]
==> Linking Binary 'msfrop' to '/usr/local/bin/msfrop'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfrop", "/usr/local/bin/msfrop"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfrop"]
==> Linking Binary 'msfrpc' to '/usr/local/bin/msfrpc'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfrpc", "/usr/local/bin/msfrpc"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfrpc"]
==> Linking Binary 'msfrpcd' to '/usr/local/bin/msfrpcd'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfrpcd", "/usr/local/bin/msfrpcd"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfrpcd"]
==> Linking Binary 'msfupdate' to '/usr/local/bin/msfupdate'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfupdate", "/usr/local/bin/msfupdate"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfupdate"]
==> Linking Binary 'msfvenom' to '/usr/local/bin/msfvenom'.
==> Executing: ["/bin/ln", "-h", "-f", "-s", "--", "/opt/metasploit-framework/bin/msfvenom", "/usr/local/bin/msfvenom"]
==> Executing: ["/bin/chmod", "+x", "/opt/metasploit-framework/bin/msfvenom"]
🍺 metasploit was successfully installed!
I think it might be
FileUtils.chmod "+x", source
failing as if it is replaced with@command.run!("/bin/chmod", args: ["+x", source])
it works without any changes to the cask.
Ping @reitermarkus.
So what's a sensible workaround for this issue, while you're working on a fix?
brew cask install metasploit --no-binaries
will allow the installation to complete.
Add /opt/metasploit-framework/bin
to your path manually.
--no-binaries will allow the installation to complete.
Couldn't get karabiner
installed even with --no-binaries
option.
Couldn't get
karabiner
installed even with--no-binaries
option.
That is likely to be a separate problem, please follow the instructions here: reporting-bugs and then open a new issue if needed.
Sorry @creasty, I didn't see that you referenced another issue. I'm not sure why --no-binaries
isn't working in your case.
I think it might be
FileUtils.chmod "+x", source
failing as if it is replaced with@command.run!("/bin/chmod", args: ["+x", source])
it works without any changes to the cask.
Does @command.run!("/bin/chmod", args: ["+x", source])
work without sudo
? Might be because is skips it if it already is executable?
@commitay, would you mind submitting a PR with this over at https://github.com/homebrew/brew? Thanks!
Does
@command.run!("/bin/chmod", args: ["+x", source]
) work withoutsudo
? Might be because is skips it if it already is executable?
I'm not sure how sudo
would be passed to chmod
in this case.
I've tested replacing the FileUtils.chmod
with /bin/chmod
which works, but I've also tried commenting FileUtils.chmod
out and that also creates working symlinks. Do you mean a install which requires sudo
?
would you mind submitting a PR with this over at https://github.com/homebrew/brew
@reitermarkus, I'll submit a PR and mark it WIP as I'm not sure how to modify binary_spec.rb
so it passes brew tests
.
I'm not sure how
sudo
would be passed to chmod in this case.
@command.run!("/bin/chmod", args: ["+x", source], sudo: true)
Under the hood this is basically the same as system_command
in Casks.
@command.run!("/bin/chmod", args: ["+x", source], sudo: true)
sudo: true
is not required for the casks I've tested this with.
sudo: true
is not required for the casks I've tested this with.
I suspect that the reason that you don't need sudo
is that these binaries are already executable, so chmod
skips it, instead of asking for permission. Try chmod -x
on one of those.
I suspect that the reason that you don't need sudo is that these binaries are already executable, so chmod skips it, instead of asking for permissions.
You're right, chmod -x
fails without sudo
but works with sudo
.
General troubleshooting steps
brew update-reset && brew update
and retried my command.brew doctor
, fixed as many issues as possible and retried my command.Description of issue
metasploit install fails when
Linking Binary
errors withOperation not permitted
.brew cask install metasploit --verbose --debug
fails with the same error on two computers (10.12.4 - CLT 8.3 and 10.12.3 - CLT 8.2) with up to date HB and in new VM (10.12.4 - CLT 8.3) with fresh HB install.The cask itself is less than two weeks old and installed without error for me about a week ago.
I've manually installed the first version of this cask #31311 and the newest version from rapid7 metasploit-framework-4.14.8+20170404092313-1rapid7-1.pkg and the permissions after install appear to be the same. I've included the permissions at the end.
Outputs below are from the VM.
Output of your command with
--verbose --debug
Output of
brew cask doctor
Output of
brew doctor
Output of
brew config
File permissions
current metasploit cask
original metasploit cask
newest metasploit version