webfp / tor-browser-selenium

Tor Browser automation with Selenium.
MIT License
528 stars 101 forks source link

allow read-only tbb_path/Browser/ #209

Open milahu opened 2 weeks ago

milahu commented 2 weeks ago

currently tbselenium does

# TB can't find bundled "fonts" if we don't switch to tbb_browser_dir
chdir(self.tbb_browser_dir)

which requires a writable tbb_browser_dir for .cache/ and .tor project/

but this should also work with a read-only system-wide installation of torbrowser and it should be possible to use a workdir in tmpfs

TB can't find bundled "fonts" if we don't switch to tbb_browser_dir

works for me


but my actual issue is

profile missing: your tor browser profile cannot be loaded. it may be missing or inaccessible.

which is caused by one of

sudo chown 0:0 "tbb_path/Browser/.cache/"
sudo chown 0:0 "tbb_path/Browser/.tor project/"

... but a different workdir does not fix that issue

i would need a read-only tbb_browser_dir = "tbb_path/Browser/" and separate paths for .cache/ and .tor project/

gunesacar commented 1 week ago

Thanks for filing the issue. This is a busy time of the year, so it'll be a while until I get to this.

sudo chown 0:0 "tbb_path/Browser/.tor project/"

A clarifying question: I am not familiar with the .tor project/ directory. Could you link to the source code you are referring to or some public documentation?

but my actual issue is...

Just to clarify, you get this issue when you use tbselenium on nixos?

milahu commented 1 week ago

yes, this is on nixos linux, see my tbselenium.nix

selenium seems to use $tbb_browser_dir as $HOME hence $tbb_browser_dir/.tor project/

on linux, the torbrowser firefox profile is stored in ~/.tor project/firefox/xxxxxxxx.default/ for firefox that is ~/.mozilla/firefox/xxxxxxxx.default/ for librewolf that is ~/.librewolf/xxxxxxxx.default/ etc

this is not really documented...

i have not found the code for lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME)

https://gitlab.torproject.org/tpo/applications/tor-browser/-/blob/tor-browser-115.12.0esr-13.5-1/browser/confvars.sh

MOZ_APP_VENDOR="Tor Project"

https://searchfox.org/mozilla-central/source/build/moz.configure/init.configure

def moz_app_basename(value, target_is_android):
    if value:
        return value[0]
    if target_is_android:
        return "Fennec"
    return "Firefox"

https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/20497#note_2873088

The profile for torbrowser ends up in $HOME/.tor project/torbrowser

https://issues.guix.gnu.org/42380#42-lineno202

;; Profile location (relative to "~/.").  Default is
;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is:
;; ~/.tor project/firefox.
(setenv "MOZ_APP_PROFILE" "torbrowser/browser")