diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-04-24 09:52:29 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-04-24 09:52:29 +0000 |
commit | 596de71fc60b622d7a9d5e12baf234db0bf22499 (patch) | |
tree | 3b7ad2e4a2fce6bc1ffc9142716477ccdaa35802 /source3/lib | |
parent | 29133d967761908a0f1492c1b907350a076f4a01 (diff) | |
download | samba-596de71fc60b622d7a9d5e12baf234db0bf22499.tar.gz samba-596de71fc60b622d7a9d5e12baf234db0bf22499.tar.bz2 samba-596de71fc60b622d7a9d5e12baf234db0bf22499.zip |
When possible, store the IP address of the connecting client, not just the
hostname.
This makes 'last -i' show the IP.
Thanks to Philip Anderson <pza@australia.op.org> for the idea.
Andrew Bartlett
(This used to be commit 107731c080da1e3e4e13e966f8b79bfd2692a952)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_sock.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 5460bf57b8..2439cd8eac 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -764,6 +764,19 @@ char *client_addr(void) return get_socket_addr(client_fd); } +struct in_addr *client_inaddr(struct sockaddr *sa) +{ + struct sockaddr_in *sockin = (struct sockaddr_in *) (sa); + int length = sizeof(*sa); + + if (getpeername(client_fd, sa, &length) < 0) { + DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) )); + return NULL; + } + + return &sockin->sin_addr; +} + /******************************************************************* matchname - determine if host name matches IP address. Used to confirm a hostname lookup to prevent spoof attacks |