mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-12 16:47:42 -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:
22
configure.ac
22
configure.ac
@ -132,6 +132,28 @@ AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx])
|
||||
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
|
||||
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
|
||||
|
||||
AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#define _GNU_SOURCE
|
||||
#include <features.h>
|
||||
#include <sys/socket.h>
|
||||
]],[[
|
||||
struct ucred cr;
|
||||
socklen_t crlen = sizeof(cr);
|
||||
return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
|
||||
cr.pid + cr.uid + cr.gid;
|
||||
]]
|
||||
)],
|
||||
AS_VAR_SET(x_cv_linux_so_peercred, yes),
|
||||
AS_VAR_SET(x_cv_linux_so_peercred, no)
|
||||
)
|
||||
])
|
||||
AS_IF([test AS_VAR_GET(x_cv_linux_so_peercred) = yes],
|
||||
[AC_DEFINE([HAVE_SO_PEERCRED], [1],
|
||||
[Define if SO_PEERCRED works in the Linux fashion.])]
|
||||
)
|
||||
|
||||
if test "x$GCC" = "xyes"; then
|
||||
:
|
||||
AC_SUBST(WARNINGOPTS, ['-Wall -Werror'])
|
||||
|
Reference in New Issue
Block a user