From 927d1875f0c09fe7b2e1c1bc4b1af2c0b8de0f7c Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Tue, 12 Aug 1997 23:02:45 +0000 Subject: [PATCH] charset.c: Fixed bug with 'valid chars' param. loadparm.c: Fixed bug with 'valid chars' param. nameelect.c:Unregister the 1b name from the WINS server when unbecoming master. nameservresp.c: Fix nasty browse bug where we were sending the query to the wrong ip address. Jeremy (jallison@whistle.com) --- source/lib/charset.c | 11 +++++++++++ source/nameelect.c | 4 ++++ source/nameservresp.c | 31 +++++++++++++++++++++++++------ source/param/loadparm.c | 6 ++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/source/lib/charset.c b/source/lib/charset.c index 6b4f0b07bcb..55e2239b559 100644 --- a/source/lib/charset.c +++ b/source/lib/charset.c @@ -232,6 +232,15 @@ void codepage_initialise(int client_codepage) { int i; unsigned char (*cp)[4] = NULL; + static BOOL done = False; + + if(done == True) + { + DEBUG(6, + ("codepage_initialise: called twice - ignoring second client code page = %d\n", + client_codepage)); + return; + } DEBUG(6,("codepage_initialise: client code page = %d\n", client_codepage)); @@ -259,6 +268,8 @@ void codepage_initialise(int client_codepage) for(i = 0; (cp[i][0] != '\0') && (cp[i][1] != '\0'); i++) add_dos_char(cp[i][0], (BOOL)cp[i][2], cp[i][1], (BOOL)cp[i][3]); } + + done = True; } /******************************************************************* diff --git a/source/nameelect.c b/source/nameelect.c index 0ae8c9766d7..06f3e870af1 100644 --- a/source/nameelect.c +++ b/source/nameelect.c @@ -641,6 +641,10 @@ void unbecome_domain_master(struct subnet_record *d, struct work_record *work, how it was registered. */ remove_name_entry(d,work->work_group,0x1b); } + + /* Unregister the 1b name from the WINS server. */ + if(wins_subnet != NULL) + remove_name_entry(wins_subnet, myworkgroup, 0x1b); } } diff --git a/source/nameservresp.c b/source/nameservresp.c index 2fb38a04070..a88481d06b0 100644 --- a/source/nameservresp.c +++ b/source/nameservresp.c @@ -143,21 +143,40 @@ static void response_name_reg(struct nmb_name *ans_name, NAME_QUERY_SRV_CHK, and NAME_QUERY_FIND_MST dealt with here. ****************************************************************************/ static void response_server_check(struct nmb_name *ans_name, - struct response_record *n, struct subnet_record *d) + struct response_record *n, struct subnet_record *d, struct packet_struct *p) { + struct nmb_packet *nmb = &p->packet.nmb; + struct in_addr send_ip; + enum state_type cmd; + + /* This next fix was from Bernhard Laeser + who noticed we were replying directly back to the server + we sent to - rather than reading the response. + */ + + if (nmb->header.rcode == 0 && nmb->answers->rdata) + putip((char*)&send_ip,&nmb->answers->rdata[2]); + else + { + + DEBUG(2,("response_server_check: name query for %s failed\n", + namestr(ans_name))); + return; + } + /* issue another state: this time to do a name status check */ - enum state_type cmd = (n->state == NAME_QUERY_DOM_SRV_CHK) ? + cmd = (n->state == NAME_QUERY_DOM_SRV_CHK) ? NAME_STATUS_DOM_SRV_CHK : NAME_STATUS_SRV_CHK; - /* initiate a name status check on the server that replied - in addition, the workgroup being checked has been stored + /* initiate a name status check on address given in the reply + record. In addition, the workgroup being checked has been stored in the response_record->my_name (see announce_master) we also propagate this into the same field. */ queue_netbios_packet(d,ClientNMB,NMB_STATUS, cmd, ans_name->name, ans_name->name_type, 0,0,0,n->my_name,NULL, - False,False,n->send_ip,n->reply_to_ip); + False,False,send_ip,n->reply_to_ip); } @@ -720,7 +739,7 @@ static void response_process(struct subnet_record *d, struct packet_struct *p, case NAME_QUERY_SRV_CHK: case NAME_QUERY_FIND_MST: { - response_server_check(ans_name, n, d); + response_server_check(ans_name, n, d, p); break; } diff --git a/source/param/loadparm.c b/source/param/loadparm.c index df4d72cf207..8c048ad0798 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -1500,6 +1500,12 @@ static BOOL handle_valid_chars(char *pszParmValue,char **ptr) { string_set(ptr,pszParmValue); + /* A dependency here is that the parameter client code page must be + set before this is called - as calling codepage_initialise() + would overwrite the valid char lines. + */ + codepage_initialise(lp_client_code_page()); + add_char_string(pszParmValue); return(True); } -- 2.11.4.GIT