www

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

commit e1327877749cbace21d551d2e62d22a56fd26890
parent 0957f8de021b0874442990ddd6674d4ea5f8d7ca
Author: Simon Kornblith <simon@simonster.com>
Date:   Wed,  7 Aug 2013 18:32:40 -0400

Move root check to before DB initialization

Diffstat:
Mchrome/content/zotero/standalone/standalone.js | 32--------------------------------
Mchrome/content/zotero/xpcom/zotero.js | 32++++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js @@ -38,7 +38,6 @@ const ZoteroStandalone = new function() { window.close(); return; } - _checkRoot(); ZoteroPane.init(); ZoteroPane.makeVisible(); @@ -147,37 +146,6 @@ 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") { - // Show warning - 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) { - Components.utils.import("resource://gre/modules/ctypes.jsm"); - var exit = Zotero.IPC.getLibc().declare("exit", ctypes.default_abi, - ctypes.void_t, ctypes.int); - // Zap cache files - try { - Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).remove(true); - } catch(e) {} - // Exit Zotero without giving XULRunner the opportunity to figure out the - // cache is missing. Otherwise XULRunner will zap the prefs - exit(0); - } - } - } - } } /** Taken from browser.js **/ diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -308,6 +308,9 @@ Components.utils.import("resource://gre/modules/Services.jsm"); else { Zotero.dir = 'ltr'; } + + // Make sure that Zotero Standalone is not running as root + if(Zotero.isStandalone && !Zotero.isWin) _checkRoot(); try { var dataDir = Zotero.getZoteroDirectory(); @@ -1962,6 +1965,35 @@ Components.utils.import("resource://gre/modules/Services.jsm"); return true; } + + /** + * Warn if Zotero Standalone is running as root and clobber the cache directory if it is + */ + function _checkRoot() { + var env = Components.classes["@mozilla.org/process/environment;1"]. + getService(Components.interfaces.nsIEnvironment); + var user = env.get("USER") || env.get("USERNAME"); + if(user === "root") { + // Show warning + 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) { + Components.utils.import("resource://gre/modules/ctypes.jsm"); + var exit = Zotero.IPC.getLibc().declare("exit", ctypes.default_abi, + ctypes.void_t, ctypes.int); + // Zap cache files + try { + Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).remove(true); + } catch(e) {} + // Exit Zotero without giving XULRunner the opportunity to figure out the + // cache is missing. Otherwise XULRunner will zap the prefs + exit(0); + } + } + } /** * Observer for console messages