mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
linux: Check for SO_PASSCRED on client sockets before setting
Bug: crashpad:252 Change-Id: I742fc8923a8497fe83dc40a4a280217ffc691ae7 Reviewed-on: https://chromium-review.googlesource.com/1226115 Commit-Queue: Joshua Peraza <jperaza@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
b918119ca2
commit
076d760d63
@ -307,12 +307,25 @@ void ExceptionHandlerServer::HandleEvent(Event* event, uint32_t event_type) {
|
||||
}
|
||||
|
||||
bool ExceptionHandlerServer::InstallClientSocket(ScopedFileHandle socket) {
|
||||
int optval = 1;
|
||||
// The handler may not have permission to set SO_PASSCRED on the socket, but
|
||||
// it doesn't need to if the client has already set it.
|
||||
// https://bugs.chromium.org/p/crashpad/issues/detail?id=252
|
||||
int optval;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
if (setsockopt(socket.get(), SOL_SOCKET, SO_PASSCRED, &optval, optlen) != 0) {
|
||||
if (getsockopt(socket.get(), SOL_SOCKET, SO_PASSCRED, &optval, &optlen) !=
|
||||
0) {
|
||||
PLOG(ERROR) << "getsockopt";
|
||||
return false;
|
||||
}
|
||||
if (!optval) {
|
||||
optval = 1;
|
||||
optlen = sizeof(optval);
|
||||
if (setsockopt(socket.get(), SOL_SOCKET, SO_PASSCRED, &optval, optlen) !=
|
||||
0) {
|
||||
PLOG(ERROR) << "setsockopt";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto event = std::make_unique<Event>();
|
||||
event->type = Event::Type::kClientMessage;
|
||||
|
Loading…
x
Reference in New Issue
Block a user