--- main.c.org Fri Apr 27 21:57:23 2001 +++ main.c Wed Oct 31 19:41:00 2001 @@ -12,6 +12,10 @@ * */ +#include +#include +#include +#include #include #include "cvs.h" @@ -715,13 +719,36 @@ #endif /* This is only used for writing into the history file. For - remote connections, it might be nice to have hostname - and/or remote path, on the other hand I'm not sure whether - it is worth the trouble. */ + remote connections, log hostname. */ #ifdef SERVER_SUPPORT - if (server_active) - CurDir = xstrdup (""); + if (server_active) + { + struct sockaddr_in peer; + int len; + struct hostent *hp; + + len = sizeof(peer); + + if (getpeername (STDIN_FILENO, (struct sockaddr *) &peer, &len) < 0) + { + /* getpeername failed */ + CurDir = xstrdup (""); + } + else + { + hp = gethostbyaddr (&peer.sin_addr, sizeof (struct in_addr), AF_INET); + if (hp == NULL) + { + /* gethostbyaddr failed. Log IP. */ + CurDir = xstrdup (inet_ntoa (peer.sin_addr)); + } + else + { + CurDir = xstrdup (hp->h_name); + } + } + } else #endif {