diff options
author | Andreas Schneider <asn@redhat.com> | 2009-12-16 16:41:21 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-12-16 20:28:38 +0100 |
commit | 1e5488859a66d25a0dedf0e2f9b545fb7acf1fa2 (patch) | |
tree | 6d420404d24e795bf7ddcbdfe7603359129f9cf6 /source4/auth/gensec | |
parent | ac2d31e24cfa24f6674b645b3661a1a2ce9ab060 (diff) | |
download | samba-1e5488859a66d25a0dedf0e2f9b545fb7acf1fa2.tar.gz samba-1e5488859a66d25a0dedf0e2f9b545fb7acf1fa2.tar.bz2 samba-1e5488859a66d25a0dedf0e2f9b545fb7acf1fa2.zip |
s4-gensec: Replace gensec_get_peer_addr with new tsocket based fn.
Diffstat (limited to 'source4/auth/gensec')
-rw-r--r-- | source4/auth/gensec/cyrus_sasl.c | 12 | ||||
-rw-r--r-- | source4/auth/gensec/gensec.c | 13 | ||||
-rw-r--r-- | source4/auth/gensec/gensec.h | 1 | ||||
-rw-r--r-- | source4/auth/gensec/gensec_krb5.c | 22 |
4 files changed, 21 insertions, 27 deletions
diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c index 39b11ff3d0..f56386784e 100644 --- a/source4/auth/gensec/cyrus_sasl.c +++ b/source4/auth/gensec/cyrus_sasl.c @@ -118,8 +118,8 @@ static NTSTATUS gensec_sasl_client_start(struct gensec_security *gensec_security struct gensec_sasl_state *gensec_sasl_state; const char *service = gensec_get_target_service(gensec_security); const char *target_name = gensec_get_target_hostname(gensec_security); - struct socket_address *remote_socket_addr = gensec_get_peer_addr(gensec_security); const struct tsocket_address *tlocal_addr = gensec_get_local_address(gensec_security); + const struct tsocket_address *tremote_addr = gensec_get_remote_address(gensec_security); char *local_addr = NULL; char *remote_addr = NULL; int sasl_ret; @@ -161,11 +161,11 @@ static NTSTATUS gensec_sasl_client_start(struct gensec_security *gensec_security tsocket_address_inet_port(tlocal_addr)); } - if (remote_socket_addr) { - remote_addr = talloc_asprintf(gensec_sasl_state, - "%s;%d", - remote_socket_addr->addr, - remote_socket_addr->port); + if (tremote_addr) { + remote_addr = talloc_asprintf(gensec_sasl_state, + "%s;%d", + tsocket_address_inet_addr_string(tremote_addr, gensec_sasl_state), + tsocket_address_inet_port(tremote_addr)); } gensec_sasl_state->step = 0; diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c index 603a956442..9190364906 100644 --- a/source4/auth/gensec/gensec.c +++ b/source4/auth/gensec/gensec.c @@ -1280,19 +1280,6 @@ _PUBLIC_ const struct tsocket_address *gensec_get_remote_address(struct gensec_s return gensec_security->remote_addr; } -_PUBLIC_ struct socket_address *gensec_get_peer_addr(struct gensec_security *gensec_security) -{ - if (gensec_security->peer_addr) { - return gensec_security->peer_addr; - } - - /* We could add a 'set sockaddr' call, and do a lookup. This - * would avoid needing to do system calls if nothing asks. - * However, this is not appropriate for the peer addres on - * datagram sockets */ - return NULL; -} - /** * Set the target principal (assuming it it known, say from the SPNEGO reply) diff --git a/source4/auth/gensec/gensec.h b/source4/auth/gensec/gensec.h index fe628bbbe9..293dd16b85 100644 --- a/source4/auth/gensec/gensec.h +++ b/source4/auth/gensec/gensec.h @@ -251,7 +251,6 @@ NTSTATUS gensec_start_mech_by_oid(struct gensec_security *gensec_security, const char *mech_oid); const char *gensec_get_name_by_oid(struct gensec_security *gensec_security, const char *oid_string); struct cli_credentials *gensec_get_credentials(struct gensec_security *gensec_security); -struct socket_address *gensec_get_peer_addr(struct gensec_security *gensec_security); NTSTATUS gensec_init(struct loadparm_context *lp_ctx); NTSTATUS gensec_unseal_packet(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx, diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c index ff26018ae2..46b8181de7 100644 --- a/source4/auth/gensec/gensec_krb5.c +++ b/source4/auth/gensec/gensec_krb5.c @@ -90,8 +90,7 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security, bool krb5_error_code ret; struct gensec_krb5_state *gensec_krb5_state; struct cli_credentials *creds; - const struct socket_address *peer_addr; - const struct tsocket_address *tlocal_addr; + const struct tsocket_address *tlocal_addr, *tremote_addr; krb5_address my_krb5_addr, peer_krb5_addr; creds = gensec_get_credentials(gensec_security); @@ -165,10 +164,19 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security, bool } } - peer_addr = gensec_get_peer_addr(gensec_security); - if (peer_addr && peer_addr->sockaddr) { - ret = krb5_sockaddr2address(gensec_krb5_state->smb_krb5_context->krb5_context, - peer_addr->sockaddr, &peer_krb5_addr); + tremote_addr = gensec_get_remote_address(gensec_security); + if (tremote_addr) { + ssize_t socklen; + struct sockaddr_storage ss; + + socklen = tsocket_address_bsd_sockaddr(tremote_addr, + (struct sockaddr *) &ss, + sizeof(struct sockaddr_storage)); + if (socklen < 0) { + return NT_STATUS_INTERNAL_ERROR; + } + ret = krb5_sockaddr2address(gensec_krb5_state->smb_krb5_context->krb5_context, + (const struct sockaddr *) &ss, &peer_krb5_addr); if (ret) { DEBUG(1,("gensec_krb5_start: krb5_sockaddr2address (local) failed (%s)\n", smb_get_krb5_error_message(gensec_krb5_state->smb_krb5_context->krb5_context, @@ -181,7 +189,7 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security, bool ret = krb5_auth_con_setaddrs(gensec_krb5_state->smb_krb5_context->krb5_context, gensec_krb5_state->auth_context, tlocal_addr ? &my_krb5_addr : NULL, - peer_addr ? &peer_krb5_addr : NULL); + tremote_addr ? &peer_krb5_addr : NULL); if (ret) { DEBUG(1,("gensec_krb5_start: krb5_auth_con_setaddrs failed (%s)\n", smb_get_krb5_error_message(gensec_krb5_state->smb_krb5_context->krb5_context, |