mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s3:winbind: Set local and remote addresses in the crafted dcesrv_conn
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
0dbdc27604
commit
c957d2dd77
@ -35,6 +35,7 @@
|
||||
#include "rpc_server/rpc_config.h"
|
||||
#include "rpc_server/rpc_server.h"
|
||||
#include "rpc_dce.h"
|
||||
#include "lib/tsocket/tsocket.h"
|
||||
|
||||
struct wbint_bh_state {
|
||||
struct winbindd_domain *domain;
|
||||
@ -449,6 +450,55 @@ fail:
|
||||
return status;
|
||||
}
|
||||
|
||||
static NTSTATUS set_remote_addresses(struct dcesrv_connection *conn,
|
||||
int sock)
|
||||
{
|
||||
struct sockaddr_storage st = { 0 };
|
||||
struct sockaddr *sar = (struct sockaddr *)&st;
|
||||
struct tsocket_address *remote = NULL;
|
||||
struct tsocket_address *local = NULL;
|
||||
socklen_t sa_len = sizeof(st);
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
ZERO_STRUCT(st);
|
||||
ret = getpeername(sock, sar, &sa_len);
|
||||
if (ret != 0) {
|
||||
status = map_nt_error_from_unix(ret);
|
||||
DBG_ERR("getpeername failed: %s", nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
ret = tsocket_address_bsd_from_sockaddr(conn, sar, sa_len, &remote);
|
||||
if (ret != 0) {
|
||||
status = map_nt_error_from_unix(ret);
|
||||
DBG_ERR("tsocket_address_bsd_from_sockaddr failed: %s",
|
||||
nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(st);
|
||||
ret = getsockname(sock, sar, &sa_len);
|
||||
if (ret != 0) {
|
||||
status = map_nt_error_from_unix(ret);
|
||||
DBG_ERR("getsockname failed: %s", nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
ret = tsocket_address_bsd_from_sockaddr(conn, sar, sa_len, &local);
|
||||
if (ret != 0) {
|
||||
status = map_nt_error_from_unix(ret);
|
||||
DBG_ERR("tsocket_address_bsd_from_sockaddr failed: %s",
|
||||
nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
conn->local_address = talloc_move(conn, &local);
|
||||
conn->remote_address = talloc_move(conn, &remote);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/* initialise a wbint binding handle */
|
||||
struct dcerpc_binding_handle *wbint_binding_handle(TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_domain *domain,
|
||||
@ -510,6 +560,11 @@ enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = set_remote_addresses(dcesrv_conn, state->sock);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
dcesrv_call = talloc_zero(dcesrv_conn, struct dcesrv_call_state);
|
||||
if (dcesrv_call == NULL) {
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user