#include "remoting/host/security_key/security_key_auth_handler.h"
#include <unistd.h>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "net/base/net_errors.h"
#include "net/socket/stream_socket.h"
#include "net/socket/unix_domain_server_socket_posix.h"
#include "remoting/base/logging.h"
#include "remoting/host/security_key/security_key_socket.h"
namespace {
const int64_t kDefaultRequestTimeoutSeconds = …;
base::LazyInstance<base::FilePath>::Leaky g_security_key_socket_name =
LAZY_INSTANCE_INITIALIZER;
bool MatchUid(const net::UnixDomainServerSocket::Credentials& credentials) { … }
unsigned int GetCommandCode(const std::string& data) { … }
}
namespace remoting {
class SecurityKeyAuthHandlerPosix : public SecurityKeyAuthHandler { … };
std::unique_ptr<SecurityKeyAuthHandler> SecurityKeyAuthHandler::Create(
ClientSessionDetails* client_session_details,
const SendMessageCallback& send_message_callback,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) { … }
void SecurityKeyAuthHandler::SetSecurityKeySocketName(
const base::FilePath& security_key_socket_name) { … }
SecurityKeyAuthHandlerPosix::SecurityKeyAuthHandlerPosix(
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
: … { … }
SecurityKeyAuthHandlerPosix::~SecurityKeyAuthHandlerPosix() { … }
void SecurityKeyAuthHandlerPosix::CreateSecurityKeyConnection() { … }
void SecurityKeyAuthHandlerPosix::CreateSocket(bool success) { … }
bool SecurityKeyAuthHandlerPosix::IsValidConnectionId(int connection_id) const { … }
void SecurityKeyAuthHandlerPosix::SendClientResponse(
int connection_id,
const std::string& response) { … }
void SecurityKeyAuthHandlerPosix::SendErrorAndCloseConnection(int id) { … }
void SecurityKeyAuthHandlerPosix::SetSendMessageCallback(
const SendMessageCallback& callback) { … }
size_t SecurityKeyAuthHandlerPosix::GetActiveConnectionCountForTest() const { … }
void SecurityKeyAuthHandlerPosix::SetRequestTimeoutForTest(
base::TimeDelta timeout) { … }
void SecurityKeyAuthHandlerPosix::DoAccept() { … }
void SecurityKeyAuthHandlerPosix::OnAccepted(int result) { … }
void SecurityKeyAuthHandlerPosix::OnReadComplete(int connection_id) { … }
SecurityKeyAuthHandlerPosix::ActiveSockets::const_iterator
SecurityKeyAuthHandlerPosix::GetSocketForConnectionId(int connection_id) const { … }
void SecurityKeyAuthHandlerPosix::SendErrorAndCloseActiveSocket(
const ActiveSockets::const_iterator& iter) { … }
void SecurityKeyAuthHandlerPosix::RequestTimedOut(int connection_id) { … }
}