зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1162772, part 3 - Add a getChannelResultPrincipalIfNotSandboxed method to nsIScriptSecurityManager. r=bz
MozReview-Commit-ID: 4QwM1y6wRb
This commit is contained in:
Родитель
1b7bc2f61d
Коммит
73ea9dd190
|
@ -26,7 +26,7 @@ class DomainPolicyClone;
|
|||
[ptr] native JSObjectPtr(JSObject);
|
||||
[ptr] native DomainPolicyClonePtr(mozilla::dom::DomainPolicyClone);
|
||||
|
||||
[scriptable, uuid(b7ae2310-576e-11e5-a837-0800200c9a66)]
|
||||
[scriptable, uuid(da831650-4241-4892-806c-cce8465a2ba8)]
|
||||
interface nsIScriptSecurityManager : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -242,6 +242,24 @@ interface nsIScriptSecurityManager : nsISupports
|
|||
*/
|
||||
nsIPrincipal getChannelResultPrincipal(in nsIChannel aChannel);
|
||||
|
||||
/**
|
||||
* Temporary API until bug 1220687 is fixed.
|
||||
*
|
||||
* Returns the same value as getChannelResultPrincipal, but ignoring
|
||||
* sandboxing. Specifically, if sandboxing would have prevented the
|
||||
* channel's triggering principal from being returned by
|
||||
* getChannelResultPrincipal, the triggering principal will be returned
|
||||
* by this method.
|
||||
*
|
||||
* Note that this method only ignores sandboxing of the channel in
|
||||
* question, it does not ignore sandboxing of any channels further up a
|
||||
* document chain. The triggering principal itself may still be the null
|
||||
* principal due to sandboxing further up a document chain. In that regard
|
||||
* the ignoring of sandboxing is limited.
|
||||
*/
|
||||
[noscript, nostdcall]
|
||||
nsIPrincipal getChannelResultPrincipalIfNotSandboxed(in nsIChannel aChannel);
|
||||
|
||||
/**
|
||||
* Get the codebase principal for the channel's URI.
|
||||
* aChannel must not be null.
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "xpcprivate.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIInputStreamChannel.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
|
@ -328,6 +329,23 @@ nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
|
|||
NS_IMETHODIMP
|
||||
nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
return GetChannelResultPrincipal(aChannel, aPrincipal,
|
||||
/*aIgnoreSandboxing*/ false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptSecurityManager::GetChannelResultPrincipalIfNotSandboxed(nsIChannel* aChannel,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
return GetChannelResultPrincipal(aChannel, aPrincipal,
|
||||
/*aIgnoreSandboxing*/ true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
|
||||
nsIPrincipal** aPrincipal,
|
||||
bool aIgnoreSandboxing)
|
||||
{
|
||||
NS_PRECONDITION(aChannel, "Must have channel!");
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
|
@ -343,7 +361,7 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
|
|||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
if (loadInfo) {
|
||||
if (loadInfo->GetLoadingSandboxed()) {
|
||||
if (!aIgnoreSandboxing && loadInfo->GetLoadingSandboxed()) {
|
||||
RefPtr<nsNullPrincipal> prin;
|
||||
if (loadInfo->LoadingPrincipal()) {
|
||||
prin =
|
||||
|
@ -359,7 +377,17 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (loadInfo->GetForceInheritPrincipal()) {
|
||||
bool forceInterit = loadInfo->GetForceInheritPrincipal();
|
||||
if (aIgnoreSandboxing && !forceInterit) {
|
||||
// Check if SEC_FORCE_INHERIT_PRINCIPAL was dropped because of
|
||||
// sandboxing:
|
||||
if (loadInfo->GetLoadingSandboxed() &&
|
||||
(loadInfo->GetSecurityFlags() &
|
||||
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL_WAS_DROPPED)) {
|
||||
forceInterit = true;
|
||||
}
|
||||
}
|
||||
if (forceInterit) {
|
||||
NS_ADDREF(*aPrincipal = loadInfo->TriggeringPrincipal());
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -120,6 +120,10 @@ private:
|
|||
// If aURI is a moz-extension:// URI, set mAddonId to the associated addon.
|
||||
nsresult MaybeSetAddonIdFromURI(mozilla::PrincipalOriginAttributes& aAttrs, nsIURI* aURI);
|
||||
|
||||
nsresult GetChannelResultPrincipal(nsIChannel* aChannel,
|
||||
nsIPrincipal** aPrincipal,
|
||||
bool aIgnoreSandboxing);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mSystemPrincipal;
|
||||
bool mPrefInitialized;
|
||||
bool mIsJavaScriptEnabled;
|
||||
|
|
Загрузка…
Ссылка в новой задаче