diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-04-27 16:17:28 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-04-27 16:18:19 +0200 |
commit | 7f25723cf504b3cdc0db68ff4125539baa486975 (patch) | |
tree | 1750a3bdb2ef55b38fd5e76ae10f4fec664149bf /source4/wrepl_server | |
parent | 9dd4419ebe12d8a4eb467cf26640de5575e04e83 (diff) | |
download | samba-7f25723cf504b3cdc0db68ff4125539baa486975.tar.gz samba-7f25723cf504b3cdc0db68ff4125539baa486975.tar.bz2 samba-7f25723cf504b3cdc0db68ff4125539baa486975.zip |
s4:wrepl_server: use tsocket_address functions to get the peer ip
metze
Diffstat (limited to 'source4/wrepl_server')
-rw-r--r-- | source4/wrepl_server/wrepl_in_connection.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index ff0bb6c53d..09fb3255fb 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -103,7 +103,8 @@ static void wreplsrv_accept(struct stream_connection *conn) { struct wreplsrv_service *service = talloc_get_type(conn->private_data, struct wreplsrv_service); struct wreplsrv_in_connection *wrepl_conn; - struct socket_address *peer_ip; + struct tsocket_address *peer_addr; + char *peer_ip; struct tevent_req *subreq; int rc, fd; @@ -151,14 +152,24 @@ static void wreplsrv_accept(struct stream_connection *conn) wrepl_conn->conn = conn; wrepl_conn->service = service; - peer_ip = socket_get_peer_addr(conn->socket, wrepl_conn); + peer_addr = conn->remote_address; + + if (!tsocket_address_is_inet(peer_addr, "ipv4")) { + DEBUG(0,("wreplsrv_accept: non ipv4 peer addr '%s'\n", + tsocket_address_string(peer_addr, wrepl_conn))); + wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_accept: " + "invalid peer IP"); + return; + } + + peer_ip = tsocket_address_inet_addr_string(peer_addr, wrepl_conn); if (peer_ip == NULL) { wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_accept: " - "could not obtain peer IP from kernel"); + "could not convert peer IP into a string"); return; } - wrepl_conn->partner = wreplsrv_find_partner(service, peer_ip->addr); + wrepl_conn->partner = wreplsrv_find_partner(service, peer_ip); irpc_add_name(conn->msg_ctx, "wreplsrv_connection"); /* |