From 0376d03e6db6713285bad9ad27c3b48e8c11b848 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 2 Jan 2011 12:42:47 +0100 Subject: s3: Lift my_mailslot from prep_getdc_request --- source3/libsmb/clidgram.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index c9592a15ac..734564dcbb 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -117,13 +117,12 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, const char *domain_name, const struct dom_sid *sid, uint32_t nt_version, + const char *my_mailslot, int dgm_id, struct packet_struct *p) { TALLOC_CTX *frame = talloc_stackframe(); - struct in_addr dc_ip; const char *my_acct_name; - const char *my_mailslot; struct nbt_netlogon_packet packet; struct NETLOGON_SAM_LOGON_REQUEST *s; enum ndr_err_code ndr_err; @@ -131,10 +130,6 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, struct dom_sid my_sid; bool ret = false; - if (dc_ss->ss_family != AF_INET) { - goto fail; - } - ZERO_STRUCT(packet); ZERO_STRUCT(my_sid); @@ -142,13 +137,6 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, my_sid = *sid; } - dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr; - - my_mailslot = mailslot_name(talloc_tos(), dc_ip); - if (my_mailslot == NULL) { - goto fail; - } - my_acct_name = talloc_asprintf(talloc_tos(), "%s$", global_myname()); if (my_acct_name == NULL) { goto fail; @@ -195,21 +183,37 @@ bool send_getdc_request(struct messaging_context *msg_ctx, { struct packet_struct p; pid_t nmbd_pid; + char *my_mailslot; + struct in_addr dc_ip; + NTSTATUS status; if ((nmbd_pid = pidfile_pid("nmbd")) == 0) { DEBUG(3, ("No nmbd found\n")); return False; } + if (dc_ss->ss_family != AF_INET) { + return false; + } + dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr; + + my_mailslot = mailslot_name(talloc_tos(), dc_ip); + if (my_mailslot == NULL) { + return NULL; + } + if (!prep_getdc_request(dc_ss, domain_name, sid, nt_version, - dgm_id, &p)) { + my_mailslot, dgm_id, &p)) { + TALLOC_FREE(my_mailslot); return false; } - return NT_STATUS_IS_OK(messaging_send_buf(msg_ctx, - pid_to_procid(nmbd_pid), - MSG_SEND_PACKET, - (uint8 *)&p, sizeof(p))); + status = messaging_send_buf(msg_ctx, pid_to_procid(nmbd_pid), + MSG_SEND_PACKET, + (uint8 *)&p, sizeof(p)); + TALLOC_FREE(my_mailslot); + + return NT_STATUS_IS_OK(status); } bool receive_getdc_response(TALLOC_CTX *mem_ctx, -- cgit