Bug 5320 - smbclient -c "tar cX foo.tar" doesn't exclude file names with blanks
Summary: smbclient -c "tar cX foo.tar" doesn't exclude file names with blanks
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: smbclient (show other bugs)
Version: 3.0.14a
Hardware: x86 Linux
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-12 09:07 UTC by Dirk Hagedorn
Modified: 2020-01-06 11:26 UTC (History)
0 users

See Also:


Attachments
Comment #3 as Plain Text (4.21 KB, text/plain)
2008-03-26 03:40 UTC, Dirk Hagedorn
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Hagedorn 2008-03-12 09:07:30 UTC
Scenario:

- smbclient (3.0.14a-Debian) accessing (German) Windows 2000 user share
- trying to create a backup tar while excluding some files
- target dir is C:\Dokumente und Einstellungen\username\Eigene Dateien
  (on an English Win2k this might be
   C:\Documents and Settings\username\My Documents")
- A sub directory TEST contains two files: foo.txt and bar.txt
- The goal is to tar all files of TEST while excluding foo.txt

    smbclient -A authfile.smb "//win2k/C\$" \
              -D "/Dokumente und Einstellungen/username/Eigene Dateien/TEST"

When entering the following command to the smbclient prompt all files will be saved, foo.txt won't be excluded:

    tar cX too-many-files.tar /Dokumente und Einstellungen/username/Eigene Dateien/TEST/foo.txt

Escaping the path has no effect - foo.txt won't be excluded:

    tar cX too-many-files.tar "/Dokumente und Einstellungen/username/Eigene Dateien/TEST/foo.txt"

It doesn't work either if you use tar with the -c option of smbclient.
 

When using the 8+3-notation it works:

    smbclient -A authfile.smb "//win2k/C\$" \
              -D "/Dokume~1/username/Eigene~1/TEST"

    tar cX without-foo.tar /Dokume~1/username/Eigene~1/TEST/foo.txt

When using -T it works, too:

    smbclient -A authfile.smb "//win2k/C\$" \
              -D "/Dokumente und Einstellungen/username/Eigene Dateien/TEST" \
              -TXc without-foo.tar "/Dokumente und Einstellungen/username/Eigene Dateien/TEST/foo.txt"

I've set the debuglevel to 10.

When using 'smbclient -Txc ... ' (where it's OK) I get these debug messages:

    Processing an item, /Dokumente und Einstellungen/username/Eigene Dateien/Test/foo.txt
    firstb=8122210, secondb=BFFFFB61, len=64
    Processed an item, Dokumente und Einstellungen\username\Eigene Dateien\Test\foo.txt
    Cliplist is: /Dokumente und Einstellungen/username/Eigene Dateien/Test/foo.txt 

When using 'smbclient -c "tar cX ..."' (where it fails) I get these debug messages:

    Processing an item, /Dokumente
    firstb=81BB208, secondb=BFFFE5AE, len=12
    Processed an item, \Dokumente
    Cliplist is: /Dokumente
    Processing an item, und
    firstb=81BAD48, secondb=BFFFE5BA, len=4
    Processed an item, und
    Cliplist is: /Dokumente
    Processing an item, Einstellungen/username/Eigene
    firstb=81BAE30, secondb=BFFFE5BE, len=28
    Processed an item, Einstellungen\username\Eigene
    Cliplist is: /Dokumente
    Processing an item, Dateien/Test/foo.txt
    firstb=81BAE88, secondb=BFFFE5DA, len=22
    Processed an item, Dateien\Test\foo.txt
    Cliplist is: /Dokumente 

There's something wrong if the exclude file names contain blanks. smbclient's source seems to build a list with those filenames that have to be excluded. As I said above escaping the path has no effect.
Comment 1 Jeremy Allison 2008-03-12 17:31:15 UTC
Please try this with the latest released Samba 3.0.28a, and let me know if this bug still exists there. 3.0.14a is a very old release.
Jeremy.
Comment 2 Dirk Hagedorn 2008-03-25 05:04:00 UTC
(In reply to comment #1)
I cannot update samba on our productive system thus I tried it with Knoppix 5.0. There - with smbclient 3.0.22 - the problem exists, too. I'll soon check it with the latest Knoppix version (and hopefully a later smbclient version)...
Comment 3 Dirk Hagedorn 2008-03-26 03:33:28 UTC
(In reply to comment #1)
> Please try this with the latest released Samba 3.0.28a, and let me know if this
> bug still exists there. 3.0.14a is a very old release.
> Jeremy.
> 

I used smbclient 3.0.28 (with Knoppix 5.3) and the bug still exists. The behaviour of smbclient changed a lot, but it's even worse now!

I guess that using the -D option confuses smbclient now if the given directory contains blanks.

The directory tree on the Windows side looks like this:

   C:\Dokumente und Einstellungen\user\Eigene Dateien\Test\Foo\foo.txt
   C:\Dokumente und Einstellungen\user\Eigene Dateien\Test\Bar\bar.txt
   C:\Dokumente und Einstellungen\user\Eigene Dateien\Test\foo.txt
   C:\Dokumente und Einstellungen\user\Eigene Dateien\Test\bar.txt

When trying to tar all of the files of "Test" at the smbclient prompt and usind the -D option the tar file is completely trashy:

----------
smbclient -A authfile "//192.1.1.142/C\$" -D "/Dokumente und Einstellungen/user/Eigene Dateien/Test"
Domain=[user] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
smb: \Dokumente und Einstellungen\user\Eigene Dateien\Test> tar c trash.tar
                directory \Dokumente und Einstellungen\user\Eigene Dateien\TestBAR\
NT_STATUS_OBJECT_NAME_NOT_FOUND listing \Dokumente und Einstellungen\user\Eigene Dateien\TestBAR\*
NT_STATUS_OBJECT_NAME_NOT_FOUND opening remote file \Dokumente und Einstellungen\user\Eigene Dateien\Testbar.txt (\Dokumente und Einstellungen\user\Eigene Dateien\Test)
                directory \Dokumente und Einstellungen\user\Eigene Dateien\TestFOO\
NT_STATUS_OBJECT_NAME_NOT_FOUND listing \Dokumente und Einstellungen\user\Eigene Dateien\TestFOO\*
NT_STATUS_OBJECT_NAME_NOT_FOUND opening remote file \Dokumente und Einstellungen\user\Eigene Dateien\Testfoo.txt (\Dokumente und Einstellungen\user\Eigene Dateien\Test)
tar: dumped 2 files and directories
Total bytes written: 0
----------


If I don't use the -D option and cd to the Test directory it works (to tar all files - to exclude files there never works):

----------
knoppix@Knoppix:~$ smbclient -A authfile "//192.1.1.142/C\$"
Domain=[user] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
smb: \> cd "Dokumente und Einstellungen/user/Eigene Dateien/Test"
smb: \Dokumente und Einstellungen\user\Eigene Dateien\Test\> tar c try1.tar
                directory \Dokumente und Einstellungen\user\Eigene Dateien\Test\BAR\
           5 (    2,4 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\BAR\bar.txt
           5 (    2,4 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\bar.txt
                directory \Dokumente und Einstellungen\user\Eigene Dateien\Test\FOO\
           5 (    0,6 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\FOO\foo.txt
           5 (    2,4 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\foo.txt
tar: dumped 6 files and directories
Total bytes written: 2048
----------


Here are my test for excluding the file Test/foo.txt. All of the commands produce the same lower output:

----------
smb: \Dokumente und Einstellungen\user\Eigene Dateien\Test\> tar cX try2.tar foo.txt
                directory \Dokumente und Einstellungen\user\Eigene Dateien\Test\BAR\
           5 (    2,4 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\BAR\bar.txt
           5 (    1,2 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\bar.txt
                directory \Dokumente und Einstellungen\user\Eigene Dateien\Test\FOO\
           5 (    2,4 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\FOO\foo.txt
           5 (    2,4 kb/s) \Dokumente und Einstellungen\user\Eigene Dateien\Test\foo.txt
tar: dumped 6 files and directories
Total bytes written: 2048
smb: \Dokumente und Einstellungen\user\Eigene Dateien\Test\> tar cX try3.tar "/Dokumente und Einstellungen/user/Eigene Dateien/Test/foo.txt"
smb: \Dokumente und Einstellungen\user\Eigene Dateien\Test\> tar cX try4.tar "\Dokumente und Einstellungen\user\Eigene Dateien\Test\foo.txt"
smb: \Dokumente und Einstellungen\user\Eigene Dateien\Test\> tar Xc try5.tar "\Dokumente und Einstellungen\user\Eigene Dateien\Test\foo.txt"
----------

You see "Test\foo.txt" is never excluded, it is always part of the tar file.
Comment 4 Dirk Hagedorn 2008-03-26 03:40:32 UTC
Created attachment 3215 [details]
Comment #3 as Plain Text

This is comment #3 as plain text, just for a better readability
Comment 5 Björn Jacke 2020-01-06 11:26:16 UTC
this is working with current versions:

smb: \t2\> tar Xc backup.tar "/t2/Dokumente und Einstellungen/user/Eigene Dateien/Test/Foo/foo.txt"

excludes foo.txt as intended.