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

tor-browser-bundle-bin: fix (noscript) extension startup #102622

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,6 +1,7 @@
{ stdenv
, fetchurl
, makeDesktopItem
, writeText

# Common run-time dependencies
, zlib
Expand Down Expand Up @@ -106,6 +107,19 @@ let
sha256 = "sha256-EanW2Q8TtCPY5FSp8zfgBXMte9+RfKE24fu8ROtArK0=";
};
};

policiesJson = writeText "policies.json" (builtins.toJSON enterprisePolicies);

enterprisePolicies.policies = {
ExtensionSettings = {
"${noScriptId}" = {
installation_mode = "force_installed";
install_url = "${builtins.placeholder "out"}/share/tor-browser/TorBrowser/Data/Browser/profile.default/extensions/${noScriptId}.xpi";
};
};
};

noScriptId = "{73a6fe31-595d-460b-a920-fcc0f8843232}";
in
stdenv.mkDerivation rec {
pname = "tor-browser-bundle-bin";
Expand Down Expand Up @@ -168,6 +182,9 @@ stdenv.mkDerivation rec {
sed -i TorBrowser/Data/Tor/torrc-defaults \
-e "s|\(ClientTransportPlugin snowflake\) exec|\1 exec $interp|"

# Set up enterprise policies
mkdir -p distribution
cp ${policiesJson} distribution/policies.json

# Prepare for autoconfig.
#
Expand Down Expand Up @@ -229,12 +246,6 @@ stdenv.mkDerivation rec {
sed -i "$FONTCONFIG_FILE" \
-e "s,<dir>fonts</dir>,<dir>$TBB_IN_STORE/fonts</dir>,"

# Preload extensions by moving into the runtime instead of storing under the
# user's profile directory.
mkdir -p "$TBB_IN_STORE/browser/extensions"
mv "$TBB_IN_STORE/TorBrowser/Data/Browser/profile.default/extensions/"* \
"$TBB_IN_STORE/browser/extensions"

# Hard-code paths to geoip data files. TBB resolves the geoip files
# relative to torrc-defaults_path but if we do not hard-code them
# here, these paths end up being written to the torrc in the user's
Expand Down Expand Up @@ -286,13 +297,10 @@ stdenv.mkDerivation rec {
# TBB will fail if ownership is too permissive
chmod 0700 "\$HOME/TorBrowser/Data/Tor"

# Initialize the browser profile state. Note that the only data
# copied from the Store payload is the initial bookmark file, which is
# never updated once created. All other files under user's profile
# dir are generated by TBB.
# Initialize the browser profile state.
mkdir -p "\$HOME/TorBrowser/Data/Browser/profile.default"
cp -u --no-preserve=mode,owner "$TBB_IN_STORE/TorBrowser/Data/Browser/profile.default/bookmarks.html" \
"\$HOME/TorBrowser/Data/Browser/profile.default/bookmarks.html"
cp -uR --no-preserve=mode,owner "$TBB_IN_STORE/TorBrowser/Data/Browser/profile.default/"* \
"\$HOME/TorBrowser/Data/Browser/profile.default/"

# Clear out some files that tend to capture store references but are
# easily generated by firefox at startup.
Expand Down Expand Up @@ -409,6 +417,5 @@ stdenv.mkDerivation rec {
# the compound is "libre" in a strict sense (some components place certain
# restrictions on redistribution), it's free enough for our purposes.
license = licenses.free;
broken = true;
};
}