Bug 1029148 - store current search engine configuration outside of prefs - add a disclaimer in the salt, r=gavin.

This commit is contained in:
Florian Quèze 2014-08-05 01:02:20 +02:00
Родитель ed17f38980
Коммит 3c6fe6df80
2 изменённых файлов: 41 добавлений и 2 удалений

Просмотреть файл

@ -3800,14 +3800,22 @@ SearchService.prototype = {
},
_getVerificationHash: function SRCH_SVC__getVerificationHash(aName) {
let str = OS.Path.basename(OS.Constants.Path.profileDir) + aName;
let disclaimer = "By modifying this file, I agree that I am doing so " +
"only within $appName itself, using official, user-driven search " +
"engine selection processes, and in a way which does not circumvent " +
"user consent. I acknowledge that any attempt to change this file " +
"from outside of $appName is a malicious act, and will be responded " +
"to accordingly."
let salt = OS.Path.basename(OS.Constants.Path.profileDir) + aName +
disclaimer.replace(/\$appName/g, Services.appinfo.name);
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8";
// Data is an array of bytes.
let data = converter.convertToByteArray(str, {});
let data = converter.convertToByteArray(salt, {});
let hasher = Cc["@mozilla.org/security/hash;1"]
.createInstance(Ci.nsICryptoHash);
hasher.init(hasher.SHA256);

Просмотреть файл

@ -21,6 +21,37 @@ const MODE_WRONLY = FileUtils.MODE_WRONLY;
const MODE_CREATE = FileUtils.MODE_CREATE;
const MODE_TRUNCATE = FileUtils.MODE_TRUNCATE;
// nsSearchService.js uses Services.appinfo.name to build a salt for a hash.
var XULAppInfo = {
vendor: "Mozilla",
name: "XPCShell",
ID: "xpcshell@test.mozilla.org",
version: "5",
appBuildID: "2007010101",
platformVersion: "1.9",
platformBuildID: "2007010101",
inSafeMode: false,
logConsoleErrors: true,
OS: "XPCShell",
XPCOMABI: "noarch-spidermonkey",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, Ci.nsIXULRuntime,
Ci.nsISupports])
};
var XULAppInfoFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return XULAppInfo.QueryInterface(iid);
}
};
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(Components.ID("{ecff8849-cee8-40a7-bd4a-3f4fdfeddb5c}"),
"XULAppInfo", "@mozilla.org/xre/app-info;1",
XULAppInfoFactory);
// Need to create and register a profile folder.
var gProfD = do_get_profile();