From b16b1359a704f146afc6acea7e3ad97318f93448 Mon Sep 17 00:00:00 2001 From: tigro Date: Fri, 1 Nov 2024 16:17:21 +0300 Subject: [PATCH] Return support of Yandex search engine --- .firefox.metadata | 1 + .../0001-Return-Yandex-engine-support.patch | 53 +++++ SOURCES/use_yandex_search_as_default.py | 181 +++++++++++++++--- SPECS/firefox.spec | 22 ++- 4 files changed, 225 insertions(+), 32 deletions(-) create mode 100644 SOURCES/0001-Return-Yandex-engine-support.patch diff --git a/.firefox.metadata b/.firefox.metadata index 1ec362a..0d59734 100644 --- a/.firefox.metadata +++ b/.firefox.metadata @@ -5,3 +5,4 @@ d744f92e874688cc4b5376477dfdd639a97a6cd4 SOURCES/nspr-4.35.0-1.el8_1.src.rpm f466d7213e85773e002c48897524eaf909480046 SOURCES/nss-3.101.0-7.el8_2.src.rpm 0413d22a58ba1bba99acec9c3c2a4db56a4100c7 SOURCES/nss-3.101.0-7.el9_2.src.rpm +d9df5043d0405b3f5ddaacb74db36623dd3969dc SOURCES/32dc5c21-98c7-4355-8603-398c9f5eec49 diff --git a/SOURCES/0001-Return-Yandex-engine-support.patch b/SOURCES/0001-Return-Yandex-engine-support.patch new file mode 100644 index 0000000..ef0521d --- /dev/null +++ b/SOURCES/0001-Return-Yandex-engine-support.patch @@ -0,0 +1,53 @@ +From 70366cd339ac14a32e5b0cdab05a25166ec169a3 Mon Sep 17 00:00:00 2001 +From: tigro +Date: Fri, 1 Nov 2024 14:58:02 +0300 +Subject: [PATCH] Return Yandex engine support + +--- + services/settings/dumps/main/moz.build | 2 ++ + .../components/backgroundtasks/BackgroundTask_message.sys.mjs | 2 +- + toolkit/modules/AppConstants.sys.mjs | 2 +- + 3 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/services/settings/dumps/main/moz.build b/services/settings/dumps/main/moz.build +index 5b1e881..6a89f0d 100644 +--- a/services/settings/dumps/main/moz.build ++++ b/services/settings/dumps/main/moz.build +@@ -62,6 +62,8 @@ if CONFIG["MOZ_BUILD_APP"] == "browser": + "search-config-icons/2e835b0e-9709-d1bb-9725-87f59f3445ca.meta.json", + "search-config-icons/32d26d19-aeb0-5c01-32e8-f8970be9246f", + "search-config-icons/32d26d19-aeb0-5c01-32e8-f8970be9246f.meta.json", ++ "search-config-icons/32dc5c21-98c7-4355-8603-398c9f5eec49", ++ "search-config-icons/32dc5c21-98c7-4355-8603-398c9f5eec49.meta.json", + "search-config-icons/39979158-80cf-4f0c-8bd6-9220eb09e751", + "search-config-icons/39979158-80cf-4f0c-8bd6-9220eb09e751.meta.json", + "search-config-icons/47da97b5-600f-c450-fd15-a52bb2169c11", +diff --git a/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs b/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs +index aafe4a6..6ef1c45 100644 +--- a/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs ++++ b/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs +@@ -71,7 +71,7 @@ ChromeUtils.defineESModuleGetters(lazy, { + Utils: "resource://services-settings/Utils.sys.mjs", + }); + +-const SERVER_STAGE = "https://firefox.settings.services.allizom.org/v1"; ++const SERVER_STAGE = "https://127.0.0.1"; + + // Default profile targeting snapshot. + let defaultProfileTargetingSnapshot = {}; +diff --git a/toolkit/modules/AppConstants.sys.mjs b/toolkit/modules/AppConstants.sys.mjs +index 4678835..4913eca 100644 +--- a/toolkit/modules/AppConstants.sys.mjs ++++ b/toolkit/modules/AppConstants.sys.mjs +@@ -421,7 +421,7 @@ export var AppConstants = Object.freeze({ + #ifdef MOZ_THUNDERBIRD + "https://thunderbird-settings.thunderbird.net/v1", + #else +- "https://firefox.settings.services.mozilla.com/v1", ++ "https://127.0.0.1", + #endif + + REMOTE_SETTINGS_VERIFY_SIGNATURE: +-- +2.47.0 + diff --git a/SOURCES/use_yandex_search_as_default.py b/SOURCES/use_yandex_search_as_default.py index f456af3..64118df 100644 --- a/SOURCES/use_yandex_search_as_default.py +++ b/SOURCES/use_yandex_search_as_default.py @@ -1,44 +1,171 @@ +import datetime import json +import os +import shutil import sys -import datetime -YANDEX_SECTION = json.loads(''' +YANDEX_SEARCH_ENGINE_SECTION = json.loads(''' { - "appliesTo": [ + "base": { + "aliases": [ + "yandex" + ], + "classification": "general", + "name": "Yandex", + "partnerCode": "", + "urls": { + "search": { + "base": "https://yandex.ru/search/", + "params": [ + { + "name": "clid", + "value": "{partnerCode}" + } + ], + "searchTermParamName": "text" + }, + "suggestions": { + "base": "https://suggest.yandex.ru/suggest-ff.cgi", + "params": [ + { + "name": "clid", + "value": "{partnerCode}" + } + ], + "searchTermParamName": "part" + } + } + }, + "id": "", + "identifier": "yandex", + "last_modified": 0, + "recordType": "engine", + "schema": 0, + "variants": [ { - "default": "yes", - "included": { - "everywhere": true + "environment": { + "allRegionsAndLocales": true } } + ] + } +''') + +YANDEX_ICON_SECTION = json.loads(''' + { + "schema": 0, + "imageSize": 32, + "attachment": { + "hash": "6bb91f1d74389b18bce6e71772e4c5573648c1a4823338193f700afdf8216be5", + "size": 5750, + "filename": "yandex-32-firefox.png", + "location": "main-workspace/search-config-icons/1f0aef96-9d62-4519-906d-379b710a80e8.ico", + "mimetype": "image/x-icon" + }, + "engineIdentifiers": [ + "yandex" ], - "id": "a0e7f96a-14e0-4d56-9f54-e0c7e49fd306", - "last_modified": 1679065511545, - "schema": 1639069022290, - "webExtension": { - "id": "yandex@search.mozilla.org" - } + "filter_expression": "env.appinfo.ID == \\"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}\\"", + "id": "", + "last_modified": 0 } ''') +YANDEX_SEARCH_ENGINE_ID = "403a24ac-3e95-4581-88e4-a479eb4ce558" +YANDEX_ICON_ID = "32dc5c21-98c7-4355-8603-398c9f5eec49" + +# ROSA Linux +PARTNER_CLID = "2800424" + +SEARCH_CONFIG_RELATIVE_PATH = "services/settings/dumps/main/search-config-v2.json" +SEARCH_CONFIG_ICONS_RELATIVE_PATH = "services/settings/dumps/main/search-config-icons.json" +YANDEX_ICON_META_RELATIVE_DIR = "services/settings/dumps/main/search-config-icons/" + +search_config_path = SEARCH_CONFIG_RELATIVE_PATH +if not os.path.isfile(search_config_path): + print(search_config_path, "not found") + exit(1) + +search_config_icons_path = SEARCH_CONFIG_ICONS_RELATIVE_PATH +if not os.path.isfile(search_config_icons_path): + print(search_config_icons_path, "not found") + exit(2) + +yandex_icon_meta_path = os.path.join(YANDEX_ICON_META_RELATIVE_DIR, YANDEX_ICON_ID + ".meta.json") + +YANDEX_SEARCH_ENGINE_SECTION["id"] = YANDEX_SEARCH_ENGINE_ID +YANDEX_SEARCH_ENGINE_SECTION["base"]["partnerCode"] = PARTNER_CLID + +timestamp = int( datetime.datetime.now().timestamp() ) * 1000 +YANDEX_SEARCH_ENGINE_SECTION["last_modified"] = timestamp +YANDEX_SEARCH_ENGINE_SECTION["schema"] = timestamp + +YANDEX_ICON_SECTION["id"] = YANDEX_ICON_ID +YANDEX_ICON_SECTION["last_modified"] = timestamp +YANDEX_ICON_SECTION["schema"] = timestamp + search_config = None -with open(sys.argv[1]) as f: +with open(search_config_path) as f: search_config = json.load(f) + f.close() + +yandex_search_engine_inserted = False +for i, engine in enumerate(search_config["data"]): + if "globalDefault" in engine: + engine["globalDefault"] = "yandex" + engine["last_modified"] = timestamp + engine["schema"] = timestamp + elif "orders" in engine: + for order in engine["orders"]: + if "order" in order: + yandex_inserted = False + for s in order["order"]: + if s == "yandex": + yandex_inserted = True + if not yandex_inserted: + order["order"] = ["yandex"] + order["order"] + engine["last_modified"] = timestamp + engine["schema"] = timestamp + elif "id" in engine and engine["id"] == YANDEX_SEARCH_ENGINE_ID: + yandex_search_engine_inserted = True + search_config["data"][i] = YANDEX_SEARCH_ENGINE_SECTION + +search_config["timestamp"] = timestamp +if not yandex_search_engine_inserted: + search_config["data"] = [YANDEX_SEARCH_ENGINE_SECTION] + search_config["data"] + +with open(search_config_path, 'w', encoding='utf8') as f: + json.dump(search_config, f, ensure_ascii=False, indent=2) + f.close() + +search_config_icons = None +with open(search_config_icons_path) as f: + search_config_icons = json.load(f) + f.close() + +yandex_icon_inserted = False +for i, icon in enumerate(search_config_icons["data"]): + if "id" in icon and icon["id"] == YANDEX_ICON_ID: + yandex_icon_inserted = True + search_config_icons["data"][i] = YANDEX_ICON_SECTION + +search_config_icons["timestamp"] = timestamp +if not yandex_icon_inserted: + search_config_icons["data"] = [YANDEX_ICON_SECTION] + search_config_icons["data"] + +with open(search_config_icons_path, 'w', encoding='utf8') as f: + json.dump(search_config_icons, f, ensure_ascii=False, indent=2) + f.close() + +with open(yandex_icon_meta_path, 'w', encoding='utf8') as f: + json.dump(YANDEX_ICON_SECTION, f, ensure_ascii=False) + f.close() -inserted = False -for engine in search_config["data"]: - if engine["webExtension"]["id"] == "yandex@search.mozilla.org": - inserted = True - engine = YANDEX_SECTION - else: - for applies in engine["appliesTo"]: - if "default" in applies and applies["default"] == "yes": - applies["default"] = "no" +YANDEX_ICON_RELATIVE_DIR = "services/settings/dumps/main/search-config-icons/" -if not inserted: - search_config["data"] = [YANDEX_SECTION] + search_config["data"] +src_icon_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), YANDEX_ICON_ID) +dst_icon_path = os.path.join(YANDEX_ICON_RELATIVE_DIR, YANDEX_ICON_ID) -search_config["timestamp"] = int( datetime.datetime.now().timestamp() ) * 1000 +shutil.copy(src_icon_path, dst_icon_path) -with open(sys.argv[1], 'w') as f: - json.dump(search_config, f, indent=2) +exit(0) diff --git a/SPECS/firefox.spec b/SPECS/firefox.spec index f068797..35f40c9 100644 --- a/SPECS/firefox.spec +++ b/SPECS/firefox.spec @@ -196,6 +196,15 @@ Source402: nspr-4.35.0-1.el8_1.src.rpm Source403: nss-3.101.0-7.el8_2.src.rpm Source404: nss-3.101.0-7.el9_2.src.rpm +# MSVSphere added Russian Trusted Root CA +Source500: rootca_ssl_rsa2022.cer +Source501: policies.json +# apply script from ROSA to set Yandex provides +# as default search provider for Firefox +# https://abf.rosalinux.ru/import/firefox/raw/rosa2023.1/use_yandex_search_as_default.py +Source502: 32dc5c21-98c7-4355-8603-398c9f5eec49 +Source503: use_yandex_search_as_default.py + # ---- RHEL specific patches --- # -- Downstream only -- Patch01: build-disable-elfhack.patch @@ -258,6 +267,7 @@ Patch202: D224588.1728128098.diff # MSVSphere Patch10000: 0001-Overt-telemetry-disabling.patch +Patch10001: 0001-Return-Yandex-engine-support.patch # BUILD REQURES/REQUIRES %if %{?system_nss} && !0%{?bundle_nss} @@ -1193,13 +1203,11 @@ echo "--------------------------------------------" %patch -P202 -p1 -b .D224588 %endif - # ---- Security patches ---- -# set Yandex search provider by default -python3 %{SOURCE502} services/settings/dumps/main/search-config.json - -%patch10000 -p1 -b .0001-Overt-telemetry-disabling +# MSVSphere +%patch -P10000 -p1 -b .0001-Overt-telemetry-disabling +%patch -P10001 -p1 -b .0001-Return-Yandex-engine-support %{__rm} -f .mozconfig %{__cp} %{SOURCE10} .mozconfig @@ -1287,6 +1295,10 @@ chmod a-x third_party/rust/ash/src/extensions/ext/*.rs chmod a-x third_party/rust/ash/src/extensions/khr/*.rs chmod a-x third_party/rust/ash/src/extensions/nv/*.rs +# Return Yandex engine support +cp %{SOURCE502} . +python3 %{SOURCE503} + #--------------------------------------------------------------------- %build