mozilla.cfg not being applied in 62.0.2 version
I able to use prefs but i am not able to replace the cert9.db in users profile. But my last is working as expected and also it will replace them without any issues.
when i use below code. i am not able to browse any websites. But when i copy cert9.db to user profile it works and i am using below code replace the cert9.db in users profile via mozilla.cfg file.
// This will add missing certs from defaults/profile const {classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); var certDBFile = profileDir.clone(); certDBFile.append("cert9.db")
// If cert9.db isn't there, it's a new profile if (!certDBFile.exists()) {
var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); try { copyDir(defaultProfileDir, profileDir); } catch (e) { Components.utils.reportError(e); }
}else { //if cert9.db is less than 140kb, its a new one without the bank cert copy this one over if(certDBFile.fileSize<140000 ){ var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); try {
copyDir(defaultProfileDir, profileDir);
} catch (e) {
Components.utils.reportError(e);
} }
}
function copyDir(aOriginal, aDestination) {
var enumerator = aOriginal.directoryEntries; while (enumerator.hasMoreElements()) { var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile); if (file.isDirectory()) { var subdir = aDestination.clone(); subdir.append(file.leafName); try { subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); copyDir(file, subdir); } catch (e) { Components.utils.reportError(e); } } else { try { file.copyTo(aDestination, null); } catch (e) { Components.utils.reportError(e); } } }
}
Giải pháp được chọn
You can't use Components in a Firefox versions like 62.0.2 that uses a sandbox for the autoconfig.cfg file. Otherwise you need to use the Firefox 60 ESR version.
You would have to disable the sandbox via a pref() call in the autoconfig.js file if you need to run advanced (privileged) JavaScript code.
- pref("general.config.sandbox_enabled", false);
Tất cả các câu trả lời (9)
hi, this appears to be an intentional change - please refer to the 62 release notes:
AutoConfig is sandboxed to the documented API by default. You can disable the sandbox by setting the preference general.config.sandbox_enabled to false. Our long term plan is to remove the ability to turn off the sandboxing. If you need to continue to use more complex AutoConfig scripts, you will need to use Firefox Extended Support Release (ESR).
I have seen that..Still i am seeing same error "Your connection is not secure"
Things i have notices my prefs in the mozilla.cfg file are working except the scipt to replace the missing certs from defaults/profile is not working.
This is full mozilla.cfg file
This is working--
// Any comment. You must start the file with a comment!
// Disable updater lockPref("app.update.enabled", false); // make absolutely sure it is really off lockPref("app.update.auto", false); lockPref("app.update.mode", 0); lockPref("app.update.service.enabled", false);
// Any comment. You must start the file with a comment! pref("network.negotiate-auth.trusted-uris", "https://123.com"); pref("network.automatic-ntlm-auth.trusted-uris", "https://123.com");
// Disable Add-ons compatibility checking clearPref("extensions.lastAppVersion");
// Don't show 'know your rights' on first run pref("browser.rights.3.shown", true);
// disable default browser check pref("browser.shell.checkDefaultBrowser", false);
// Don't show WhatsNew on first run after every update pref("browser.startup.homepage_override.mstone","ignore");
// Set default homepage - users can change // Requires a complex preference defaultPref("browser.startup.homepage","data:text/plain,browser.startup.homepage=http://www.google.com");
// Disable the internal PDF viewer pref("pdfjs.disabled", true);
// Disable the flash to javascript converter pref("shumway.disabled", true);
// Don't ask to install the Flash plugin pref("plugins.notifyMissingFlash", false);
// This disable the sandbox and allows to use config file pref("general.config.sandbox_enabled", false);
//automatically search for and import CAs from Windows certificate store lockpref("security.enterprise_roots.enabled", true);
//Disable plugin checking lockPref("plugins.hide_infobar_for_outdated_plugin", true); clearPref("plugins.update.url");
// Disable health reporter lockPref("datareporting.healthreport.service.enabled", false);
// Disable all data upload (Telemetry and FHR) lockPref("datareporting.policy.dataSubmissionEnabled", false);
// Disable crash reporter lockPref("toolkit.crashreporter.enabled", false); Components.classes["@mozilla.org/toolkit/crash-reporter;1"].getService(Components.interfaces.nsICrashReporter).submitReports = false;
--This is not working and not copying the cert9.db from defaults/profile to users profile.
script i am using
// This will add missing certs from defaults/profile
const {classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
var certDBFile = profileDir.clone();
certDBFile.append("cert9.db")
// If cert9.db isn't there, it's a new profile if (!certDBFile.exists()) {
var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); try { copyDir(defaultProfileDir, profileDir); } catch (e) { Components.utils.reportError(e); }
}else { //if cert9.db is less than 140kb, its a new one without the bank cert copy this one over if(certDBFile.fileSize<140000 ){ var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); try {
copyDir(defaultProfileDir, profileDir);
} catch (e) {
Components.utils.reportError(e);
} }
}
function copyDir(aOriginal, aDestination) {
var enumerator = aOriginal.directoryEntries; while (enumerator.hasMoreElements()) { var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile); if (file.isDirectory()) { var subdir = aDestination.clone(); subdir.append(file.leafName); try { subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); copyDir(file, subdir); } catch (e) { Components.utils.reportError(e); } } else { try { file.copyTo(aDestination, null); } catch (e) { Components.utils.reportError(e); } } }
}
Được chỉnh sửa bởi Krishna234 vào
Giải pháp được chọn
You can't use Components in a Firefox versions like 62.0.2 that uses a sandbox for the autoconfig.cfg file. Otherwise you need to use the Firefox 60 ESR version.
You would have to disable the sandbox via a pref() call in the autoconfig.js file if you need to run advanced (privileged) JavaScript code.
- pref("general.config.sandbox_enabled", false);
I have used this prefs(pref {"general.config.sandbox_enabled", false); } in my autoconfig.js file also
Still it is not reading the advanced javascript code.
Do you still have an error message in the Browser Console about Components?
Yes, I am still seeing the error.
"Your connection is not secure"
When i copy old cert9.db file to profile is works.
But i need to automate for every user.
The GreD directory is a directory in the Firefox installation folder. If you want to copy files to the Firefox profile folder then you need to use "ProfD".
I have changed that to still not working
I don't know if nested try/catch blocks work properly. You already have a try and catch in copyDir(), so I don't think you need them in the caling code.
So instead of this code:
try { copyDir(defaultProfileDir, profileDir); } catch (e) { Components.utils.reportError(e); }
Use a plain call:
copyDir(defaultProfileDir, profileDir);
If you only need to copy this one file then you can simplify the code.
var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); defaultProfileDir.append("cert9.db");