The branch, v3-6-test has been updated via f08009e s3: Remove unused mem_ctx arg from set_getdc_request via 5d0a00c s3: Factor out prep_getdc_request (cherry picked from commit b2ba2b956e2b6e8552c74afe65902aae70203843) via 85e8a2d s3: cli_send_mailslot -> cli_prep_mailslot (cherry picked from commit e0abc5c15f8e3b226366d32925d1c50f42a9b225) via 709bd63 s3: Fix some nonempty blank lines via 1c11ad8 nss_wins: Fix a type-punned warning (cherry picked from commit 407a1b3e7463f02d22670ab033c1a2df89c0ce06) from 95cae3e Fix memory leak I introduced when refactoring unexpected packet code. Found by Volker.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test - Log ----------------------------------------------------------------- commit f08009e6d262a88e0f5de513ff6e9d09f580df66 Author: Volker Lendecke <v...@samba.org> Date: Sat Jan 1 16:21:12 2011 +0100 s3: Remove unused mem_ctx arg from set_getdc_request Autobuild-User: Volker Lendecke <vlen...@samba.org> Autobuild-Date: Sat Jan 1 23:00:24 CET 2011 on sn-devel-104 (cherry picked from commit 9ccef4e62b72a42b7281e6ad6bc1127ed9504bbb) commit 5d0a00cf2a6376b50a5ec2de79831ed0fa5bb2be Author: Volker Lendecke <v...@samba.org> Date: Sat Jan 1 16:18:48 2011 +0100 s3: Factor out prep_getdc_request (cherry picked from commit b2ba2b956e2b6e8552c74afe65902aae70203843) commit 85e8a2db0551068b51f16203d45dc88a3754a9e9 Author: Volker Lendecke <v...@samba.org> Date: Sat Jan 1 15:29:11 2011 +0100 s3: cli_send_mailslot -> cli_prep_mailslot (cherry picked from commit e0abc5c15f8e3b226366d32925d1c50f42a9b225) commit 709bd63880df7f66fd3538ac642b945f5c4cae60 Author: Volker Lendecke <v...@samba.org> Date: Sat Jan 1 15:13:30 2011 +0100 s3: Fix some nonempty blank lines Autobuild-User: Volker Lendecke <vlen...@samba.org> Autobuild-Date: Sat Jan 1 16:03:23 CET 2011 on sn-devel-104 (cherry picked from commit bb6da9f06c1159b3b904d654f845442c5a7dec3e) commit 1c11ad8fea82d160dace3300dd6b14915ba0b21a Author: Volker Lendecke <v...@samba.org> Date: Sat Jan 1 15:08:42 2011 +0100 nss_wins: Fix a type-punned warning (cherry picked from commit 407a1b3e7463f02d22670ab033c1a2df89c0ce06) ----------------------------------------------------------------------- Summary of changes: nsswitch/wins.c | 3 +- source3/libsmb/clidgram.c | 121 ++++++++++++++++++++++----------------- source3/libsmb/clidgram.h | 3 +- source3/libsmb/dsgetdcname.c | 2 +- source3/winbindd/winbindd_cm.c | 2 +- 5 files changed, 73 insertions(+), 58 deletions(-) Changeset truncated at 500 lines: diff --git a/nsswitch/wins.c b/nsswitch/wins.c index ac062fe..6e3c84b 100644 --- a/nsswitch/wins.c +++ b/nsswitch/wins.c @@ -125,7 +125,8 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count) free(ret); return NULL; } - *ret = ((struct sockaddr_in *)&address[0].ss)->sin_addr; + *ret = ((struct sockaddr_in *)(void *)&address[0].ss) + ->sin_addr; free( address ); return ret; } diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index 50bcbd8..05a0edc 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -9,12 +9,12 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -27,33 +27,21 @@ * cli_send_mailslot, send a mailslot for client code ... */ -static bool cli_send_mailslot(struct messaging_context *msg_ctx, - bool unique, const char *mailslot, +static bool cli_prep_mailslot(bool unique, const char *mailslot, uint16 priority, char *buf, int len, const char *srcname, int src_type, const char *dstname, int dest_type, const struct sockaddr_storage *dest_ss, - int dgm_id) + int dgm_id, + struct packet_struct *p) { - struct packet_struct p; - struct dgram_packet *dgram = &p.packet.dgram; + struct dgram_packet *dgram = &p->packet.dgram; char *ptr, *p2; char tmp[4]; - pid_t nmbd_pid; char addr[INET6_ADDRSTRLEN]; - if ((nmbd_pid = pidfile_pid("nmbd")) == 0) { - DEBUG(3, ("No nmbd found\n")); - return False; - } - - if (dest_ss->ss_family != AF_INET) { - DEBUG(3, ("cli_send_mailslot: can't send to IPv6 address.\n")); - return false; - } - - memset((char *)&p, '\0', sizeof(p)); + ZERO_STRUCTP(p); /* * Next, build the DGRAM ... @@ -106,9 +94,9 @@ static bool cli_send_mailslot(struct messaging_context *msg_ctx, dgram->datasize = PTR_DIFF(p2,ptr+4); /* +4 for tcp length. */ - p.packet_type = DGRAM_PACKET; - p.ip = ((const struct sockaddr_in *)dest_ss)->sin_addr; - p.timestamp = time(NULL); + p->packet_type = DGRAM_PACKET; + p->ip = ((const struct sockaddr_in *)dest_ss)->sin_addr; + p->timestamp = time(NULL); DEBUG(4,("send_mailslot: Sending to mailslot %s from %s ", mailslot, nmb_namestr(&dgram->source_name))); @@ -116,10 +104,7 @@ static bool cli_send_mailslot(struct messaging_context *msg_ctx, DEBUGADD(4,("to %s IP %s\n", nmb_namestr(&dgram->dest_name), addr)); - return NT_STATUS_IS_OK(messaging_send_buf(msg_ctx, - pid_to_procid(nmbd_pid), - MSG_SEND_PACKET, - (uint8 *)&p, sizeof(p))); + return true; } static const char *mailslot_name(TALLOC_CTX *mem_ctx, struct in_addr dc_ip) @@ -128,43 +113,45 @@ static const char *mailslot_name(TALLOC_CTX *mem_ctx, struct in_addr dc_ip) NBT_MAILSLOT_GETDC, dc_ip.s_addr); } -bool send_getdc_request(TALLOC_CTX *mem_ctx, - struct messaging_context *msg_ctx, - const struct sockaddr_storage *dc_ss, - const char *domain_name, - const struct dom_sid *sid, - uint32_t nt_version, - int dgm_id) +static bool prep_getdc_request(const struct sockaddr_storage *dc_ss, + const char *domain_name, + const struct dom_sid *sid, + uint32_t nt_version, + int dgm_id, + struct packet_struct *p) { + TALLOC_CTX *frame = talloc_stackframe(); struct in_addr dc_ip; - const char *my_acct_name = NULL; - const char *my_mailslot = NULL; + 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; - DATA_BLOB blob; + DATA_BLOB blob = data_blob_null; struct dom_sid my_sid; - - ZERO_STRUCT(packet); - ZERO_STRUCT(my_sid); + bool ret = false; if (dc_ss->ss_family != AF_INET) { - return false; + goto fail; } - if (sid) { + ZERO_STRUCT(packet); + ZERO_STRUCT(my_sid); + + if (sid != NULL) { my_sid = *sid; } dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr; - my_mailslot = mailslot_name(mem_ctx, dc_ip); - if (!my_mailslot) { - return false; + + my_mailslot = mailslot_name(talloc_tos(), dc_ip); + if (my_mailslot == NULL) { + goto fail; } - my_acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname()); - if (!my_acct_name) { - return false; + my_acct_name = talloc_asprintf(talloc_tos(), "%s$", global_myname()); + if (my_acct_name == NULL) { + goto fail; } packet.command = LOGON_SAM_LOGON_REQUEST; @@ -184,17 +171,45 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, NDR_PRINT_DEBUG(nbt_netlogon_packet, &packet); } - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &packet, + ndr_err = ndr_push_struct_blob(&blob, talloc_tos(), &packet, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + goto fail; + } + + ret = cli_prep_mailslot(false, NBT_MAILSLOT_NTLOGON, 0, + (char *)blob.data, blob.length, + global_myname(), 0, domain_name, 0x1c, + dc_ss, dgm_id, p); +fail: + TALLOC_FREE(frame); + return ret; +} + +bool send_getdc_request(struct messaging_context *msg_ctx, + const struct sockaddr_storage *dc_ss, + const char *domain_name, + const struct dom_sid *sid, + uint32_t nt_version, + int dgm_id) +{ + struct packet_struct p; + pid_t nmbd_pid; + + if ((nmbd_pid = pidfile_pid("nmbd")) == 0) { + DEBUG(3, ("No nmbd found\n")); + return False; + } + + if (!prep_getdc_request(dc_ss, domain_name, sid, nt_version, + dgm_id, &p)) { return false; } - return cli_send_mailslot(msg_ctx, - false, NBT_MAILSLOT_NTLOGON, 0, - (char *)blob.data, blob.length, - global_myname(), 0, domain_name, 0x1c, - dc_ss, dgm_id); + return NT_STATUS_IS_OK(messaging_send_buf(msg_ctx, + pid_to_procid(nmbd_pid), + MSG_SEND_PACKET, + (uint8 *)&p, sizeof(p))); } bool receive_getdc_response(TALLOC_CTX *mem_ctx, diff --git a/source3/libsmb/clidgram.h b/source3/libsmb/clidgram.h index 7c650a0..af924f4 100644 --- a/source3/libsmb/clidgram.h +++ b/source3/libsmb/clidgram.h @@ -2,8 +2,7 @@ /* The following definitions come from libsmb/clidgram.c */ -bool send_getdc_request(TALLOC_CTX *mem_ctx, - struct messaging_context *msg_ctx, +bool send_getdc_request(struct messaging_context *msg_ctx, const struct sockaddr_storage *dc_ss, const char *domain_name, const struct dom_sid *sid, diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index b1acee8..63621ed 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -950,7 +950,7 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, return NT_STATUS_UNSUCCESSFUL; } - if (send_getdc_request(mem_ctx, msg_ctx, + if (send_getdc_request(msg_ctx, &dclist[i].ss, domain_name, NULL, nt_version, dgm_id)) { diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 5f42120..d5642a3 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1177,7 +1177,7 @@ static bool dcip_to_name(TALLOC_CTX *mem_ctx, generate_random_buffer((uint8_t *)&val, 2); dgm_id = val; - if (send_getdc_request(mem_ctx, winbind_messaging_context(), + if (send_getdc_request(winbind_messaging_context(), pss, domain->name, &domain->sid, nt_version, dgm_id)) { const char *dc_name = NULL; -- Samba Shared Repository