Dear developers,

I found a problem that 'smbclient' loses some files when it's creating
a tar ball.  A patch attached this message is for samba 2.2.8a and
fixes this problem.  Would you please check it?

I think there is a protocol mismatch with Windows 2000 at
cli_list_new() in libsmb/clilist.c (FIND FIRST2/FIND NEXT2). Samba
assumes that 'Last Name Offset' response field is points to 

   - the first octet of FileName field of the last file/directory
     entry.

But responses from Windows 2000 points to

   - the first octet of the last file/directory entry.

As result, smbclient sets 'mask' incorrectly and Windows 2000 seems to
fail resuming the transaction and lost some files.

As far as I read 'CIFS technical reference', I think Samba is correct.
But I think we need a working around for this protocol mismatch.

***
Problem:

  smbclient loses some files when it is creating a tar ball.

Environment:

  OS:      Red Hat Linux/i386 (Linux2.4.20-18.8)
  cc:      gcc 3.2 20020903
  libc:    glibc-2.3.2 (RPM glibc-2.3.2-4.80.6)
  version:   2.2.8a
  Network: smbclient connects to a Windows 2000(SP4) box in same network.

How to Repeat:

  1. Make a share directory on Windows box.  The share directory
     includes a many many files and directories (26,000+ files and
     300+ directory).  Some directories have many files in it(950+).
  2. Create a tar ball of the share directory using smbclient.
  3. During creating a tar ball, run a job on Windows box like
     'dir /s /b [share directory]'
  4. tar ball (smbclient) lost some files (3-30 files).

--yasuoka

    Yasuoka Masahiko ([EMAIL PROTECTED])
    Second Software Inc.   http://www.second-software.com/
--- clilist.c-orig      2003-03-15 06:34:48.000000000 +0900
+++ clilist.c   2003-07-18 12:01:16.000000000 +0900
@@ -184,7 +184,12 @@ int cli_list_new(struct cli_state *cli,c
                        SSVAL(param,2,max_matches); /* max count */
                        SSVAL(param,4,info_level); 
                        SIVAL(param,6,0); /* ff_resume_key */
+#ifdef DONT_USE_SEARCH_CONTINUE
+                       SSVAL(param,10,4+2);    /* resume required + close on end */
+#else
                        SSVAL(param,10,8+4+2);  /* continue + resume required + close 
on end */
+#endif
+
                        p = param+12;
                        p += clistr_push(cli, param+12, mask, -1, 
                                         STR_TERMINATE|STR_CONVERT);
@@ -246,6 +251,25 @@ int cli_list_new(struct cli_state *cli,c
                        switch(info_level)
                                {
                                case 260:
+#ifdef DONT_USE_SEARCH_CONTINUE
+                               /*
+                                * According to CIFS Technical Document 1.0,
+                                * ff_last_name must point to last FILENAME.
+                                * But Window 2000 points to the first byte
+                                * of last file/directory entry.
+                                */
+                                       if (!ff_eos && !memcmp(p + ff_lastname,
+                                           "\0\0\0\0", 4)) {
+                                               file_info resume_fi;
+
+                                               interpret_long_filename(
+                                                   cli, info_level,
+                                                   p + ff_lastname,
+                                                   &resume_fi);
+                                               strlcpy(mask, resume_fi.name,
+                                                   255);
+                                       } else
+#endif
                                        clistr_pull(cli, mask, p+ff_lastname,
                                                    sizeof(mask), 
                                                    data_len-ff_lastname,
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba

Reply via email to