charset.c: Fixed bug with 'valid chars' param.
authorSamba Release Account <samba-bugs@samba.org>
Tue, 12 Aug 1997 23:02:45 +0000 (23:02 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Tue, 12 Aug 1997 23:02:45 +0000 (23:02 +0000)
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)
(This used to be commit 927d1875f0c09fe7b2e1c1bc4b1af2c0b8de0f7c)

source3/lib/charset.c
source3/nameelect.c
source3/nameservresp.c
source3/param/loadparm.c

index 6b4f0b07bcbd689d552464acbff9495aaedc5ea6..55e2239b55900bf0013cb641450e01074079c5ce 100644 (file)
@@ -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;
 }
 
 /*******************************************************************
index 0ae8c9766d713d790724ed34fe67fc98b8212693..06f3e870af1854fda8dee87c5ae95a8a7dc970d1 100644 (file)
@@ -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);
   }
 }
 
index 2fb38a04070aee231659765dbe0fbada547f9ab8..a88481d06b0a61cd601d3d7579393d626721e7f5 100644 (file)
@@ -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 <nlaesb@ascom.ch>
+       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;
       }
     
index df4d72cf207fccbc3266faa83800cf1e678b87ee..8c048ad0798a1a7ab5ecbbc3e757c90e04e28501 100644 (file)
@@ -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);
 }