eclass != ERRDOS && num != ERRmoredata
[samba.git] / source3 / libsmb / clientgen.c
index fc0df84d4acf49c7311b1dc4069f3e60f3fa63f2..688764fa7320f6c938c91de89a75a2c0bb0d8dc2 100644 (file)
@@ -328,6 +328,8 @@ static BOOL cli_receive_trans(struct cli_state *cli,int trans,
        int total_data=0;
        int total_param=0;
        int this_data,this_param;
+       uint8 eclass;
+       uint32 num;
        
        *data_len = *param_len = 0;
 
@@ -342,7 +344,8 @@ static BOOL cli_receive_trans(struct cli_state *cli,int trans,
                return(False);
        }
 
-       if (cli_error(cli, NULL, NULL))
+       /* DOS error "more data" is an acceptable error code */
+       if (cli_error(cli, &eclass, &num) && !(eclass == ERRDOS && num == ERRmoredata))
        {
                return(False);
        }
@@ -393,7 +396,8 @@ static BOOL cli_receive_trans(struct cli_state *cli,int trans,
                                 CVAL(cli->inbuf,smb_com)));
                        return(False);
                }
-               if (cli_error(cli, NULL, NULL))
+               /* DOS error "more data" is an acceptable error code */
+               if (cli_error(cli, &eclass, &num) && eclass != ERRDOS && num != ERRmoredata)
                {
                        return(False);
                }
@@ -2724,17 +2728,9 @@ BOOL cli_connect_serverlist(struct cli_state *cli, char *p)
        extern pstring scope;
        fstring remote_machine;
        struct in_addr dest_ip;
-       struct nmb_name calling, called;
+       struct nmb_name calling, called, stupid_smbserver_called;
        BOOL connected_ok = False;
 
-       ZERO_STRUCTP(cli);
-
-       if (!cli_initialise(cli))
-       {
-               DEBUG(0,("cli_connect_serverlist: unable to initialize client connection.\n"));
-               return False;
-       }
-
        /*
        * Treat each name in the 'password server =' line as a potential
        * PDC/BDC. Contact each in turn and try and authenticate.
@@ -2742,6 +2738,14 @@ BOOL cli_connect_serverlist(struct cli_state *cli, char *p)
 
        while(p && next_token(&p,remote_machine,LIST_SEP,sizeof(remote_machine)))
        {
+               ZERO_STRUCTP(cli);
+
+               if (!cli_initialise(cli))
+               {
+                       DEBUG(0,("cli_connect_serverlist: unable to initialize client connection.\n"));
+                       return False;
+               }
+
                standard_sub_basic(remote_machine);
                strupper(remote_machine);
 
@@ -2759,19 +2763,28 @@ BOOL cli_connect_serverlist(struct cli_state *cli, char *p)
 
                make_nmb_name(&calling, global_myname , 0x0 , scope);
                make_nmb_name(&called , remote_machine, 0x20, scope);
+               /* stupid microsoft destruction of the ability of netbios
+                * to provide multiple netbios servers on one host.
+                */
+               make_nmb_name(&stupid_smbserver_called , "*SMBSERVER", 0x20, scope);
 
                pwd_set_nullpwd(&cli->pwd);
 
                if (!cli_establish_connection(cli, remote_machine, &dest_ip,
                                              &calling, &called,
                                              "IPC$", "IPC", 
+                                             False, True) &&
+                   !cli_establish_connection(cli, remote_machine, &dest_ip,
+                                             &calling, &stupid_smbserver_called,
+                                             "IPC$", "IPC", 
                                              False, True))
                {
                        cli_shutdown(cli);
                        continue;
                }      
 
-               if (!IS_BITS_SET_ALL(cli->sec_mode, 1))
+               if (cli->protocol < PROTOCOL_LANMAN2 ||
+                   !IS_BITS_SET_ALL(cli->sec_mode, 1))
                {
                        DEBUG(1,("cli_connect_serverlist: machine %s isn't in user level security mode\n",
                                  remote_machine));