Bug 1732343 - Part 10: Remove the now-unused ipc::DuplicateHandle, r=handyman

This should unblock removing support for BrokerDuplicateHandle from our fork of
the chromium sandboxing code.

Differential Revision: https://phabricator.services.mozilla.com/D126572
This commit is contained in:
Nika Layzell 2021-11-04 19:20:21 +00:00
Родитель 6fb92ec807
Коммит 1cd9e0c087
2 изменённых файлов: 0 добавлений и 46 удалений

Просмотреть файл

@ -65,42 +65,6 @@ IPCResult IPCResult::Fail(NotNull<IProtocol*> actor, const char* where,
return IPCResult(false);
}
#if defined(XP_WIN)
bool DuplicateHandle(HANDLE aSourceHandle, DWORD aTargetProcessId,
HANDLE* aTargetHandle, DWORD aDesiredAccess,
DWORD aOptions) {
// If our process is the target just duplicate the handle.
if (aTargetProcessId == base::GetCurrentProcId()) {
return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle,
::GetCurrentProcess(), aTargetHandle,
aDesiredAccess, false, aOptions);
}
# if defined(MOZ_SANDBOX)
// Try the broker next (will fail if not sandboxed).
if (SandboxTarget::Instance()->BrokerDuplicateHandle(
aSourceHandle, aTargetProcessId, aTargetHandle, aDesiredAccess,
aOptions)) {
return true;
}
# endif
// Finally, see if we already have access to the process.
ScopedProcessHandle targetProcess(
OpenProcess(PROCESS_DUP_HANDLE, FALSE, aTargetProcessId));
if (!targetProcess) {
CrashReporter::AnnotateCrashReport(
CrashReporter::Annotation::IPCTransportFailureReason,
"Failed to open target process."_ns);
return false;
}
return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle,
targetProcess, aTargetHandle, aDesiredAccess,
FALSE, aOptions);
}
#endif
void AnnotateSystemError() {
int64_t error = 0;
#if defined(XP_WIN)

Просмотреть файл

@ -639,16 +639,6 @@ MOZ_NEVER_INLINE void ArrayLengthReadError(const char* aElementName);
MOZ_NEVER_INLINE void SentinelReadError(const char* aElementName);
#if defined(XP_WIN)
// This is a restricted version of Windows' DuplicateHandle() function
// that works inside the sandbox and can send handles but not retrieve
// them. Unlike DuplicateHandle(), it takes a process ID rather than
// a process handle. It returns true on success, false otherwise.
bool DuplicateHandle(HANDLE aSourceHandle, DWORD aTargetProcessId,
HANDLE* aTargetHandle, DWORD aDesiredAccess,
DWORD aOptions);
#endif
/**
* Annotate the crash reporter with the error code from the most recent system
* call. Returns the system error.