mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8c64b0474c
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app". There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id. I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: sw=2 ts=8 et :
|
|
*/
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "AppProcessPermissions.h"
|
|
#include "ContentParent.h"
|
|
#include "mozIApplication.h"
|
|
#include "mozilla/hal_sandbox/PHalParent.h"
|
|
#include "nsIDOMApplicationRegistry.h"
|
|
#include "TabParent.h"
|
|
|
|
using namespace mozilla::dom;
|
|
using namespace mozilla::hal_sandbox;
|
|
using namespace mozilla::services;
|
|
|
|
namespace mozilla {
|
|
|
|
bool
|
|
AssertAppProcessPermission(PBrowserParent* aActor, const char* aPermission)
|
|
{
|
|
if (!aActor) {
|
|
NS_WARNING("Testing permissions for null actor");
|
|
return false;
|
|
}
|
|
|
|
TabParent* tab = static_cast<TabParent*>(aActor);
|
|
nsCOMPtr<mozIApplication> app = tab->GetOwnOrContainingApp();
|
|
bool hasPermission = false;
|
|
|
|
// isBrowser frames inherit their app descriptor to identify their
|
|
// data storage, but they don't inherit the permissions associated
|
|
// with that descriptor.
|
|
if (app && !tab->IsBrowserElement()) {
|
|
if (!NS_SUCCEEDED(app->HasPermission(aPermission, &hasPermission))) {
|
|
hasPermission = false;
|
|
}
|
|
}
|
|
|
|
if (!hasPermission) {
|
|
printf_stderr("Security problem: Content process does not have `%s' permission. It will be killed.\n", aPermission);
|
|
ContentParent* process = static_cast<ContentParent*>(aActor->Manager());
|
|
process->KillHard();
|
|
}
|
|
return hasPermission;
|
|
}
|
|
|
|
bool
|
|
AssertAppProcessPermission(PContentParent* aActor, const char* aPermission)
|
|
{
|
|
const InfallibleTArray<PBrowserParent*>& browsers =
|
|
aActor->ManagedPBrowserParent();
|
|
for (uint32_t i = 0; i < browsers.Length(); ++i) {
|
|
if (AssertAppProcessPermission(browsers[i], aPermission)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
AssertAppProcessPermission(PHalParent* aActor, const char* aPermission)
|
|
{
|
|
return AssertAppProcessPermission(aActor->Manager(), aPermission);
|
|
}
|
|
|
|
} // namespace mozilla
|