mirror of
https://github.com/samba-team/samba.git
synced 2025-12-21 20:23:50 +03:00
r2581: added "hosts allow" and "hosts deny" checking in smbd. I needed this
as my box keeps getting hit by viruses spreading on my companies
internal network, which screws up my debug log badly (sigh).
metze, I'm not sure if you think access.c should go in the socket
library or not. It is closely tied to the socket functions, but you
may prefer it separate.
The access.c code is a port from Samba3, but with some cleanups to
make it (slighly) less ugly.
(This used to be commit 058b2fd99e)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
5d4fc1284e
commit
fe45888e22
@@ -293,6 +293,26 @@ static NTSTATUS ipv4_tcp_set_option(struct socket_context *sock, const char *opt
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
static char *ipv4_tcp_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct sockaddr_in peer_addr;
|
||||
socklen_t len = sizeof(peer_addr);
|
||||
struct hostent *he;
|
||||
int ret;
|
||||
|
||||
ret = getpeername(sock->fd, (struct sockaddr *)&peer_addr, &len);
|
||||
if (ret == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
he = gethostbyaddr((char *)&peer_addr.sin_addr, sizeof(peer_addr.sin_addr), AF_INET);
|
||||
if (he == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return talloc_strdup(mem_ctx, he->h_name);
|
||||
}
|
||||
|
||||
static char *ipv4_tcp_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct sockaddr_in peer_addr;
|
||||
@@ -368,6 +388,7 @@ static const struct socket_ops ipv4_tcp_ops = {
|
||||
|
||||
.set_option = ipv4_tcp_set_option,
|
||||
|
||||
.get_peer_name = ipv4_tcp_get_peer_name,
|
||||
.get_peer_addr = ipv4_tcp_get_peer_addr,
|
||||
.get_peer_port = ipv4_tcp_get_peer_port,
|
||||
.get_my_addr = ipv4_tcp_get_my_addr,
|
||||
|
||||
Reference in New Issue
Block a user