mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 20:42:48 -05:00
Log identifying information for the other end of connections.
When anyone connects to a PuTTY tool's listening socket - whether it's a user of a local->remote port forwarding, a connection-sharing downstream or a client of Pageant - we'd like to log as much information as we can find out about where the connection came from. To that end, I've implemented a function sk_peer_info() in the socket abstraction, which returns a freeform text string as best it can (or NULL, if it can't get anything at all) describing the thing at the other end of the connection. For TCP connections, this is done using getpeername() to get an IP address and port in the obvious way; for Unix-domain sockets, we attempt SO_PEERCRED (conditionalised on some moderately hairy autoconfery) to get the pid and owner of the peer. I haven't implemented anything for Windows named pipes, but I will if I hear of anything useful.
This commit is contained in:
@ -71,6 +71,11 @@ static const char *sk_namedpipeserver_socket_error(Socket s)
|
||||
return ps->error;
|
||||
}
|
||||
|
||||
static char *sk_namedpipeserver_peer_info(Socket s)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int create_named_pipe(Named_Pipe_Server_Socket ps, int first_instance)
|
||||
{
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
@ -211,7 +216,8 @@ Socket new_named_pipe_listener(const char *pipename, Plug plug)
|
||||
NULL /* write_eof */,
|
||||
NULL /* flush */,
|
||||
NULL /* set_frozen */,
|
||||
sk_namedpipeserver_socket_error
|
||||
sk_namedpipeserver_socket_error,
|
||||
sk_namedpipeserver_peer_info,
|
||||
};
|
||||
|
||||
Named_Pipe_Server_Socket ret;
|
||||
|
Reference in New Issue
Block a user