Bug 1277691 - Allow security.turn_off_all_security_so_that_viruses_can_take_over_this_computer only if MOZ_DISABLE_NONLOCAL_CONNECTIONS is set. r=mrbkap

This commit is contained in:
Masatoshi Kimura 2016-06-03 07:40:16 +09:00
parent e5744b11cf
commit 7f91a2f04a
3 changed files with 14 additions and 4 deletions

View File

@ -2333,7 +2333,7 @@ InitializeLegacyNetscapeObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
// uses enablePrivilege. If you're not doing test automation, you _must_ not
// flip this pref, or you will be exposing all your users to security
// vulnerabilities.
if (!Preferences::GetBool("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer")) {
if (!xpc::IsInAutomation()) {
return true;
}

View File

@ -3762,9 +3762,7 @@ bool EnableUniversalXPConnect(JSContext* cx);
inline void
CrashIfNotInAutomation()
{
const char* prefName =
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
MOZ_RELEASE_ASSERT(mozilla::Preferences::GetBool(prefName));
MOZ_RELEASE_ASSERT(IsInAutomation());
}
inline XPCWrappedNativeScope*

View File

@ -25,6 +25,7 @@
#include "nsMathUtils.h"
#include "nsStringBuffer.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/Preferences.h"
class nsGlobalWindow;
class nsIPrincipal;
@ -582,6 +583,17 @@ GetJSRuntime();
void AddGCCallback(xpcGCCallback cb);
void RemoveGCCallback(xpcGCCallback cb);
inline bool
IsInAutomation()
{
const char* prefName =
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
char *s;
return mozilla::Preferences::GetBool(prefName) &&
(s = getenv("MOZ_DISABLE_NONLOCAL_CONNECTIONS")) &&
!!strncmp(s, "0", 1);
}
} // namespace xpc
namespace mozilla {