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

Problem creating NativeMessagingHosts directory #5272

Open
jonathansampson opened this issue Jul 17, 2019 · 10 comments
Open

Problem creating NativeMessagingHosts directory #5272

jonathansampson opened this issue Jul 17, 2019 · 10 comments
Assignees
Labels
bug feature/extensions OS/Desktop OS/macOS priority/P2 A bad problem. We might uplift this to the next planned release.

Comments

@jonathansampson
Copy link
Contributor

jonathansampson commented Jul 17, 2019

Description

Request from the AgileBits team (https://twitter.com/dteare/status/1151548356637941762):

I was trying to go Brave-only on my new setup here but was required to install Chrome to have the ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/ folder created. Is this something you could create during Brave setup?

Steps to Reproduce

  1. Install Brave
  2. Attempt to locate the following folder: ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/

Actual result:

Folder does not exist.

Expected result:

Folder, for compat reasons, should exist.

Reproduces how often:

Always.

Brave version (brave://version info)

0.66.100

Other Additional Information:

  • Is the issue reproducible on the latest version of Chrome? No

Miscellaneous Information:

Similar issue was resolved for Muon about 2 years ago:

On macOS, the user may need to copy the Chrome/NativeMessagingHosts directory over to Brave/NativeMessagingHosts to give Brave access to the 1Password manifest. Ideally, Brave would read from any pre-existing Chrome/NativeMessagingHosts directory.

@bsclifton
Copy link
Member

We'll want a fix similar to what is done here (where directory is created if it doesn't exist):
https://github.com/brave/muon/pull/259/files

@bsclifton
Copy link
Member

bsclifton commented Apr 15, 2021

Update: I think this is affecting ANY extension which uses the nativeMessaging manifest permission 😱

Also note-worthy: we did port the change over here: brave/brave-core#53 - however, the user_data_dir won't exist if users hadn't installed Chrome before. Will dig into this some more

@bsclifton bsclifton self-assigned this Apr 15, 2021
@bsclifton bsclifton changed the title Create NativeMessagingHosts Directory Use a Brave-specific NativeMessagingHosts Directory May 4, 2021
@bsclifton bsclifton changed the title Use a Brave-specific NativeMessagingHosts Directory Use a Brave-specific NativeMessagingHosts directory May 4, 2021
@bsclifton
Copy link
Member

bsclifton commented May 4, 2021

Huge thanks to @simonhong for helping me narrow down the issue 😄 I updated the title after we verified the behavior. We are creating a directory use with nativeMessaging permission, but it's not what extensions may be expecting:
https://github.com/brave/brave-core/blob/1bb8c0c05bf0137e7f2a0388e3c13aaa7f24082e/app/brave_main_delegate.cc#L143-L148

I believe that people experiencing a problem with this not being created are having a permissions issue (ex: can't create Google/Chrome directory under ~/Library/Application\ Support). base::PathService::OverrideAndCreateIfNeeded does return true/false so we COULD catch this scenario. Maybe a good first step would be to log failures as this code runs each launch and we can ask users (Twitter, community, etc) if they're seeing the error

On a healthy machine, @simonhong removed ~/Library/Application\ Support/Google/Chrome directory and the full directory path was created (~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts). Our code is working as expected and we are creating the directory 😄

However, this may introduce a few problems:

  • applications that are reading/writing content into this folder need to know to look in Chrome profile directory (not Brave). It's worth checking what other Chromium browsers do for this scenario (Edge, Vivaldi, Opera). 1Password is a great app / extension to test as it will create a file here immediately that the extension can read
  • different versions of Chrome will create the NativeMessagingHosts directory in their respective profile directories (Stable, Beta, Canary). We may be introducing unexpected behavior by using Chrome's stable directory. A user may run into a problem if they're running more than one instance of Brave OR if they're running Brave and Chrome.

@bridiver @iefremov @simonhong (others welcome as well) do you think we should continue to override this directory as Google/Chrome? Or should we be creating NativeMessagingHosts inside the respective (Release, Beta, Nightly) Brave user profile directory (similar to Chrome w/ the different channels)?

@bsclifton bsclifton changed the title Use a Brave-specific NativeMessagingHosts directory Problem creating NativeMessagingHosts directory May 4, 2021
@iefremov
Copy link
Contributor

iefremov commented May 4, 2021

I gather keeping the current way is better than switching to our own directories in case external apps do really expect Chrome paths.

So I think to answer this we need to:

  1. Check what native apps do really expect
  2. Check other browsers behavior, e.g. Edge

@simonhong
Copy link
Member

FYI - edge uses its own directory

Simon-iMac-Pro:~ simon$ ls -la ~/Library/ApplicationSupport/Microsoft\ Edge/NativeMessagingHosts
total 8
drwx------@  3 simon  staff   96 Oct 12  2020 .
drwx------  30 simon  staff  960 Apr 28 16:47 ..
-rw-r--r--@  1 simon  staff  497 Oct 12  2020 2bua8c4s2c.com.agilebits.1password.json

@rebron
Copy link
Collaborator

rebron commented May 4, 2021

Reminder to check other browsers e.g. use 1password for Vivaldi, Opera to see if they're creating own folder or using the Chrome directory
cc: @kjozwiak @stephendonner @LaurenWags

@stephendonner
Copy link

Vivaldi 3.8.2259.37 (Stable channel) (x86_64) creates a directory, but doesn't populate it, even when using 1Password version 1.25.5 for Chrome, which gets installed as a Chrome extension:

stephendonner@Stephens-MacBook-Pro NativeMessagingHosts % ls -la ~/Library/Application\ Support/Vivaldi/NativeMessagingHosts
total 0
drwx------@ 2 stephendonner staff 64 May 4 16:57 .
drwx------ 34 stephendonner staff 1088 May 4 17:02 ..

I haven't yet found a directory created by Opera for its browser - will come back and edit once I'm able to.

@bridiver
Copy link
Contributor

bridiver commented May 5, 2021

@iefremov there is another option discussed in a related issue which is to copy everything from Chrome/NativeMessagingHosts into Brave/NativeMessagingHosts. @diracdeltas seemed to be ok with that option.

@bridiver
Copy link
Contributor

bridiver commented May 5, 2021

also Is this something you could create during Brave setup - we do create that during setup. Or at least we did at one point and if we aren't anymore it's a regression.

@rebron rebron added this to General May 28, 2024
@rebron rebron moved this to P1 & P2 Backlog in General May 28, 2024
@agowa
Copy link

agowa commented Aug 29, 2024

Was this already fixed? When I search for all folders named NativeMessagingHosts, I find one at ~/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts which actually got populated. I cannot see any ~/Library/Application Support/Brave/NativeMessagingHosts though.

Edit: And that folder is not getting used. Brave is looking into the Google Chrome's NativeMessagingHosts folder incorrectly. Even though apparently the above Brave specific path exists by now it is unusable as only ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/ will take effect. Please fix to use the correct path then this issue should be resolved completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feature/extensions OS/Desktop OS/macOS priority/P2 A bad problem. We might uplift this to the next planned release.
Projects
Status: P1 & P2 Backlog
Development

No branches or pull requests

8 participants