www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 1055187c8be280ddd9d22aa22282d396c98e7840
parent 185c5a3a4d3111c5f25b31dcb30573b7ce44c2b5
Author: Simon Kornblith <simon@simonster.com>
Date:   Thu, 25 Jul 2013 00:47:38 -0400

If Zotero is run as root, clobber the cache directory and show a warning

Diffstat:
Mchrome/content/zotero/standalone/standalone.js | 27+++++++++++++++++++++++++++
Mchrome/locale/en-US/zotero/zotero.properties | 3+++
2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js @@ -38,6 +38,7 @@ const ZoteroStandalone = new function() { window.close(); return; } + _checkRoot(); ZoteroPane.init(); ZoteroPane.makeVisible(); @@ -146,6 +147,32 @@ const ZoteroStandalone = new function() { this.onUnload = function() { ZoteroPane.destroy(); } + + /** + * Warn if Zotero Standalone is running as root and clobber the cache directory + */ + function _checkRoot() { + if(!Zotero.isWin) { + var env = Components.classes["@mozilla.org/process/environment;1"]. + getService(Components.interfaces.nsIEnvironment); + var user = env.get("USER") || env.get("USERNAME"); + if(user === "root") { + // Zap cache files + try { + Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).remove(true); + } catch(e) {} + // Warn user never to do this again + if(Services.prompt.confirmEx(null, "", Zotero.getString("standalone.rootWarning"), + Services.prompt.BUTTON_POS_0*Services.prompt.BUTTON_TITLE_IS_STRING | + Services.prompt.BUTTON_POS_1*Services.prompt.BUTTON_TITLE_IS_STRING, + Zotero.getString("standalone.rootWarning.exit"), + Zotero.getString("standalone.rootWarning.continue"), + null, null, {}) == 0) { + goQuitApplication(); + } + } + } + } } /** Taken from browser.js **/ diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -934,6 +934,9 @@ locate.manageLocateEngines = Manage Lookup Engines… standalone.corruptInstallation = Your Zotero Standalone installation appears to be corrupted due to a failed auto-update. While Zotero may continue to function, to avoid potential bugs, please download the latest version of Zotero Standalone from http://zotero.org/support/standalone as soon as possible. standalone.addonInstallationFailed.title = Add-on Installation Failed standalone.addonInstallationFailed.body = The add-on "%S" could not be installed. It may be incompatible with this version of Zotero Standalone. +standalone.rootWarning = You appear to be running Zotero Standalone as root. This is insecure and may prevent Zotero from functioning when launched from your user account.\n\nIf you wish to install an automatic update, modify the Zotero program directory to be writeable by your user account. +standalone.rootWarning.exit = Exit +standalone.rootWarning.continue = Continue connector.error.title = Zotero Connector Error connector.standaloneOpen = Your database cannot be accessed because Zotero Standalone is currently open. Please view your items in Zotero Standalone.