Page MenuHomePhabricator

make tb-updater installation path configurable / change default installation directory to ~/.tb
Closed, ResolvedPublic

Description

In T337#5157, @nrgaway wrote:

I noticed tor-browser installs in the root of the users home directory.

Would it be possible to automatically install it in the ~/bin directory as not to clutter the root directory?

Details

Impact
Normal

Event Timeline

Patrick created this task.Jun 3 2015, 10:36 PM
Patrick updated the task description. (Show Details)
Patrick raised the priority of this task from to Normal.
Patrick added a project: tb-updater.
Patrick set Impact to Normal.
Patrick added subscribers: Patrick, nrgaway.

No, I don't think so. This is because TBB's folder and application is structured as a linux portable app. All binaries and user data is supposed to be stored in a writeable folder in the user's home folder. If you wanted to install binaries to ~/bin and user data to /home/user, i.e. how usual linux applications work, it would require extensive changes upstream in TBB.

If you disagree and/or want to research this further, you can either:

You just place it in the ~/bin directory. That's where all of my 'personal' binaries go that are not part of a package.

I run tor-browser right now out of the ~/bin directory without any issues.

Starting the browser as user or root?

But then you also have your user data inside ~/bin or where does it get stored?

I start it as user; never usually start a program as root.

And the user data get placed within the tor-browser directory tree; you can move it anywhere and still start and access your data as it uses the tor-browser directory as a base

In T338#5190, @nrgaway wrote:

And the user data get placed within the tor-browser directory tree;

Option 1:

So user data will also be in ~/bin? Doesn't this require user user having write access to ~/bin?

Option 2:

User data gets written in ~/home? Unlikely. Probably not?

In T338#5216, @Patrick wrote:
In T338#5190, @nrgaway wrote:

And the user data get placed within the tor-browser directory tree;

Option 1:

So user data will also be in ~/bin? Doesn't this require user user having write access to ~/bin?

~/bin == /home/user/bin :)

Tor browser user data then gets written into /home/user/bin/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default

Option 2:

User data gets written in ~/home? Unlikely. Probably not?

Alright. I was confused about this. You wrote about ~/bin from start. Somehow I thought /bin/. That's where confusion came from. Sorry.


Now on the real topic...

In T337#5157, @nrgaway wrote:

I noticed tor-browser installs in the root of the users home directory.

Would it be possible to automatically install it in the ~/bin directory as not to clutter the root directory?

Yes, it would not be hard to change the installation directory in tb-updater and/or to make that configurable.

You want an option or to change the default?

I think an option make more sense, so as not to confuse existing users on other platforms like virtualbox. I personally do not like any non standard directory within ~/home/user unless its a .hidden directory.

Its just weird how Firefox is so self contained. I am used to users data going in to ~/.local/shared, config data going into ~/.config and cache data going into ~/.cache

Patrick renamed this task from Install Tor Browser into ~/bin? to make tb-updater installation path configurable.Jun 5 2015, 7:31 PM
Patrick claimed this task.
In T338#5220, @nrgaway wrote:

I think an option make more sense, so as not to confuse existing users on other platforms like virtualbox.

Phew. So glad we're not debating default TBB installation folder.

The good news is, that's already supported.

Create a file /etc/torbrowser.d/50_user with the following content.

tb_home_folder=~/bin

Just now tested. Works for me for tb-updater. Please try and leave feedback.

tb-starter doesn't support it. Something I am happy to fix for Whonix 12. In meanwhile you have to manually start it, create your own shortcut and patch tb-starter.

Its just weird how Firefox is so self contained.

Yes!

{FYI: The background is, that want it as an probable app on Windows. portableapps.com alike. And because there is no package manager on Windows. And they want to support easy uninstall. Ideally they wanted it forensically clean. These goals clash with usually installed applications.}

Actually, that tb-starter fix is so simple, it can be included in next tag and Whonix 11. Shouldn't stop you from testing this now anyhow.

Made path to Tor Browser configurable by tb_home_folder variable. Renamed variable home_folder to tb_home_folder to synchronize it with tb-updater. - https://phabricator.whonix.org/T338:
https://github.com/Whonix/tb-starter/commit/46803cdeb68bfe6655660b73f6f1fa0783ad1c80

Patrick changed the task status from Open to Review.Jun 5 2015, 8:00 PM
Patrick added a project: tb-starter.

Included in tb-starter >= 1.6-1 and Whonix >= 11.0.0.2.5-developers-only.

Works well, thank you.

I did more research and the proper place for the tor-browser package to go was in ~/opt. I looked into it more cause I thought it was strange to have a package in bin directory since usually they are individual binaries. opt is used same as on local system, for pre-compiled packages. ~/bin then would be used to add a soft-link to start Tor and then make sure ~/bin is added to users PATH. I usually add the ~/bin PATH before the other PATHs to allow one to override a system default application if so desired just by placing it in users home directory ~bin.

I did have an issue with TB being installed via whonix_build using tb_home_folder=~/opt in 40_qubes cause it tried to install it in /root directory it seemed like. I already needed to create a temporary torbuilder.d configuration file located in the chroot at /etc/torbrowser.d/40whonix_build since qubes-builder does not get installed until after Whonix is installed, so I just changed that path to tb_home_folder=/home/user/opt which ended up working. The temp file gets removed just fine during qubes-builder cleanup stage and the real file gets placed by qubes-whonix.

It was nice to see it work :)

In T338#5350, @nrgaway wrote:

I did have an issue with TB being installed via whonix_build using tb_home_folder=~/opt in 40_qubes cause it tried to install it in /root directory it seemed like. I already needed to create a temporary torbuilder.d configuration file located in the chroot at /etc/torbrowser.d/40whonix_build since qubes-builder does not get installed until after Whonix is installed, so I just changed that path to tb_home_folder=/home/user/opt which ended up working. The temp file gets removed just fine during qubes-builder cleanup stage and the real file gets placed by qubes-whonix.

I can imagine why this happens.

Consider this test script /home/user/a.

#!/bin/bash
echo ~
sudo su
root@host:~# sudo -u user /home/user/a
/home/user
sudo su
root@host:~# sudo -E -u user /home/user/a
/root

anon-shared-build-inst-tb 70_torbrowser chroot script runs as root and runs:

sudo -E -u user /usr/bin/update-torbrowser --devbuildpassthrough

That's probably why ~ expands to root.

(Using sudo -E to allow influencing other tb-updater environment variables.)

In T338#5350, @nrgaway wrote:

I did more research and the proper place for the tor-browser package to go was in ~/opt. I looked into it more cause I thought it was strange to have a package in bin directory since usually they are individual binaries. opt is used same as on local system, for pre-compiled packages. ~/bin then would be used to add a soft-link to start Tor and then make sure ~/bin is added to users PATH. I usually add the ~/bin PATH before the other PATHs to allow one to override a system default application if so desired just by placing it in users home directory ~bin.

So you changed the default in Qubes-Whonix. I don't think this is a good idea.

  • Different Tor Browser installation path Whonix vs Qubes-Whonix. Probably causing confusion.
  • Users are less likely to find their Tor Browser so they can backup it. Probably causing questions.
  • Who uses ~/opt?
  • Even if there was ~/opt, similar to /opt/, as far I know opt binaries aren't supposed to be in a sub folder. I.e. for example /opt/some-bin, not /opt/some-sub-folder/some-bin. (But TBB without sub folder would also be weird.)

Dunno. Pre-Installation to /home/ as distribution is always non-standard, bad. /home/user/tor-browser_en-US isn't great, but I find /home/user/opt/tor-browser_en-US worse.

(torbrowser-launcher installs to ~/.tbb btw. But we shouldn't use ~/.tbb to avoid confilcts and allow co-installability of tb-updater and torbrowser-launcher.)

Another issue with different Tor Browser installation paths Whonix vs Qubes-Whonix / changing Tor Browser installation path by default is, that it breaks apparmor-profile-torbrowser.

Could you just not change the apparmor-profile?

from:

/home/*/tor-browser_*/Browser/firefox {

to:

/home/{*,*/opt}/tor-browser_*/Browser/firefox {

That would perhaps solve the AppArmor issue.

Patrick renamed this task from make tb-updater installation path configurable to make tb-updater installation path configurable / change default installation directory to ~/opt.Jun 8 2015, 1:33 AM
Patrick added subscribers: marmarek, mfc.
Patrick changed the task status from Review to Open.Jun 15 2015, 6:57 AM

Can you undo the ~/opt thing please? @nrgaway

What ya mean? Is it causing issues? In following standards or defacto standards the ~/opt directory is the correct spot to place pre-built packages that do not adhere to XDG specs.

Yes, causing issues.

  • 1) Too much of a rush for Whonix 11. Too controversial to quickly sneak this in.
  • 2) apparmor-profile-torbrowser package not patched yet with new location, therefore containing Tor Browser is not as simple as installing that package.
  • Other issues I raised at: https://phabricator.whonix.org/T338#5356... To update those...
    • 3) Different Tor Browser installation path Whonix vs Qubes-Whonix. Probably causing confusion.
    • 4) Users are less likely to find their Tor Browser so they can backup it. Probably causing questions.
    • 5) Who uses ~/opt? I used google to search for "/home/user/opt" and "~/opt". Very few results. Haven't found any distribution / standard using that. Please clarify who uses that.
    • 6) Even if there was ~/opt, similar to /opt/, as far I know, opt binaries aren't supposed to be in a sub folder. I.e. for example /opt/some-bin, not /opt/some-sub-folder/some-bin. (But TBB without sub folder would also be weird.)

Pre-Installation to /home/ as distribution is always non-standard, bad. /home/user/tor-browser_en-US isn't great, but I find /home/user/opt/tor-browser_en-US worse.

This will cause confusion because it goes against users' reasonable expectations for uniform default behavior - opening the door to balkanization of Whonix versions. We also have to be compatible with the expectations of upstream because at some point they will ship an upstream apparmor profile too.

Just my 2 satoshis

I can revert to use original path although if talking about 'reasonable expectations for uniform default behaviour' and wanting to keep all the Whonix variations similar we may want to consider changing the path for all the other versions as well then since the /home/user/opt is the proper and defacto standard location path to install pre-built personal/private binary applications that are not XDG aware.

If the TB package was not private, it would have been installed in the /opt directory.

I suggest this since Patrick seems to like to follow standards as much as possible, and the time to change this would be in the new version.

Yes, please undo for now.

We can consider this for Whonix 12.

Yes, following standards is good.

I've searched XGD standards by using the following google query:

site:http://standards.freedesktop.org opt

Not found. Haven't found any mentioning of /home/user/opt, /home/<user>/opt, ~/opt or so. Also as previously mentioned, a more general google search didn't yield any useful results. Please show any code, documentation examples or distributions [...] using ~/opt.

I will revert the change for now by adding a comment to the configuration file that sets the path.

The opt path is deferentially not part of XDG standard, completely opposite. ~/bin /~opt is part of a long time honoured defacto standard.

Here are some discussions on it including which include using ~opt
https://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself

[BTW, This ended up in spam folder again :(]

The opt path is deferentially not part of XDG standard, completely opposite. ~/bin /~opt is part of a long time honoured defacto standard.

Also Filesystem Hierarchy Standard does not include this.

Here are some discussions on it including which include using ~opt
https://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself

It's a non-example. Only a single time ~/opt/ was mentioned. A user wrote I like ~/sbin for bash/ruby/python scripts, and ~/opt/... for compiled installs. That's okay for the user to like it, but it does not show, that this is a standard or even common.

[BTW, This ended up in spam folder again :(]

I recommend to make fixing your mail experience a priority. We don't have that many sender e-mail addresses. Should be whitelistable.


Interestingly, on jessie, ~/.profile includes.

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

So when ~/bin exists, then $HOME/bin is automatically added to PATH. No mention of ~/opt though.


More importantly... Let's assume - what I am not convinced of yet - ~/bin [or supposedly even ~/opt] is a standard...

When using /usr/bin, /usr/local/bin, ~/bin [or supposedly even ~/opt] etc... One is supposed to drop binaries/scripts there - not folders. For example, ~/bin/some-script would be correct. And ~/bin/some-folder/some-script would be incorrect.

I conclude, that ~/bin/tor-browser_en-US/start-tor-browser.desktop [or ~/opt/tor-browser_en-US/start-tor-browser.desktop] would still not be standards conform? Because there is a sub folder (tor-browser_en-US). What do you think?

Starting start-tor-browser.desktop from command line would also fail, because of the sub folder (not included in PATH). (And additionally, start-tor-browser.desktop has an upstream bug(?): You need to cd into the folder, before you can run ./start-tor-browser.desktop.

In T338#5679, @Patrick wrote:

...

So when ~/bin exists, then $HOME/bin is automatically added to PATH. No mention of ~/opt though.

~/opt would never be added to $PATH. ~/bin would create the binary link to package located in ~/opt or an XDG desktop file would be created in the appropriate place.

More importantly... Let's assume - what I am not convinced of yet - ~/bin [or supposedly even ~/opt] is a standard...

When using /usr/bin, /usr/local/bin, ~/bin [or supposedly even ~/opt] etc... One is supposed to drop binaries/scripts there - not folders. For example, ~/bin/some-script would be correct. And ~/bin/some-folder/some-script would be incorrect.

You are correct about /usr/bin, /usr/local/bin and ~/bin being the place to drop binaries. ~/opt is a spot for pre-compiled binary 'packages' and its related files; same as /opt. You would not drop the tor-browser-en-US package in any type of bin directory. You will notice packages such as Google Chrome get installed in main /opt directory (not home user directory).

I conclude, that ~/bin/tor-browser_en-US/start-tor-browser.desktop [or ~/opt/tor-browser_en-US/start-tor-browser.desktop] would still not be standards conform? Because there is a sub folder (tor-browser_en-US). What do you think?

This is also correct, as you suggested, creating a .desktop file in ~/bin/tor-browser_en-US/start-tor-browser.desktop or ~/opt/tor-browser_en-US/start-tor-browser.desktop is the incorrect location for them to go. Since Tor browser is considered a private user application, then any links to it should be within the users home directory. Therefore the .desktop file should then be located in ~/.local/share/applications/, or the path of where the .desktop files is located would need to be added to XDG_DATA_DIRS ENV variable (I think this would be a bad option to add to XDG_DATA_DIRS for only one file).

Now, that solves the issue of placing the .desktop file in the standards base location, but leaves the issue of being able to make sure its in the path to be able to start it from the command line. That's where the ~/bin directory comes into play. We would ensure it's in the uses path and either create a wrapper or softlink to to start Tor browser. Again, `~/bin' is a DE-facto standard location to place private user binaries, and you already mentioned Debian 8 supports this.

Starting start-tor-browser.desktop from command line would also fail, because of the sub folder (not included in PATH). (And additionally, start-tor-browser.desktop has an upstream bug(?): You need to cd into the folder, before you can run ./start-tor-browser.desktop.

This would be the best solution IMO:

The main tor-browser_en-US private package should either be located in ~/.tor-browser_en-US, or within a parent hidden directory like ~/.tb|tor|tor-browser/tor-browser_en-US (to allow old versions, or additional locales) . This keeps the main user directory clean and is an acceptable directory to put such a package according to the Filesystem Hierarchy Standard. The other acceptable location could be the ~/opt directory. My preference though would be in a hidden subdirectory such as ~/.tb/tor-browser_en-US directory.

The desktop application file should then be located in ~/.local/share/applications/start-tor-browser.desktop which is the XDG_DATA_DIR. This would then make the Tor browser application available on the start menu. The XDG user data directories are used to store user data.

Further a wrapper or soft-link can be provided within the ~/bin directory to directly start Tor browser from the command line, or if Tor browser is able to be activated from Dbus the gapplications

Patrick edited projects, added Whonix 12; removed Whonix 11.Jun 24 2015, 2:39 AM
Patrick added a comment.EditedJun 26 2015, 8:53 PM

Whonix 11 currently uses:

  • cache dir: ~/.tb
  • data dir: ~/tor-browser_en-US

Whonix 12 proposal:

  • cache dir: ~/.cache/tb. Maybe even honoring $XDG_CACHE_HOME. (Containing tarballs, signatures, sha.) (Can be deleted without browser data loss.)
  • data dir: ~/.tb (Containing TBB binary and user data, bookmarks etc.) (Supposed to be included in backups by users.)

True. Was a copy'n'paste mistake. Fixed.

Patrick renamed this task from make tb-updater installation path configurable / change default installation directory to ~/opt to make tb-updater installation path configurable / change default installation directory to ~/.tb.Jul 3 2015, 6:54 PM

refactoring, made "$tb_home_folder/tor-browser_$TB_LANG" a variable tb_browser_folder, useful for later moving of the Tor Browser folder to a more appropriate location - https://phabricator.whonix.org/T338:
https://github.com/Whonix/tb-starter/commit/202270d89953851fe039b3db81c85290f6383d55

refactoring, made "$tb_home_folder/tor-browser_$TB_LANG" a variable tb_browser_folder, useful for later moving of the Tor Browser folder to a more appropriate location - https://phabricator.whonix.org/T338:
https://github.com/Whonix/tb-updater/commit/0e5d47f14d2271b4d1aaa9aa33a91c452b4e6279

changed default data dir to ~/.tb and cache dir to ~/.cache/tb - https://phabricator.whonix.org/T338:
https://github.com/Whonix/tb-updater/commit/6e919a326bea5e21d3cee5bfd7efa884e31edde7

changed default data dir to ~/.tb and cache dir to ~/.cache/tb - https://phabricator.whonix.org/T338:
https://github.com/Whonix/tb-starter/commit/8a06f0244a64a563f43503b279015f1e6633c2ef

Patrick changed the task status from Open to Review.Jul 29 2015, 7:14 PM
Patrick closed this task as Resolved.Nov 16 2015, 2:21 AM