Bug 11634 - smbclient does not support colon in file name
Summary: smbclient does not support colon in file name
Status: RESOLVED WORKSFORME
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 4.3.1
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-04 19:15 UTC by Nerijus Baliūnas
Modified: 2017-11-14 08:22 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nerijus Baliūnas 2015-12-04 19:15:58 UTC
it seems smbclient does not support colon (:). I created a file with a colon in a cifs mounted directory:

$ touch a:b
$ mkdir A:B
$ ls -l a:b
-rw-r--r--+ 1 user user 0 2015-12-04 20:31 a:b

Now I try to access this file with a smbclient:

$ smbclient //server/d -Uuser
Domain=[A] OS=[Windows 6.1] Server=[Samba 4.3.1]

smb: \> ls a*
  AB                               D        0  Fri Dec  4 20:36:02 2015
  ab                               N        0  Fri Dec  4 20:31:41 2015
here between a and b is a symbol with hex code 0xF022

smb: \> ls a:b
NT_STATUS_NO_SUCH_FILE listing \a:b
smb: \> cd A:B
cd \A:B\: NT_STATUS_OBJECT_NAME_INVALID
smb: \> get a:b
NT_STATUS_OBJECT_NAME_NOT_FOUND opening remote file \a:b
Comment 1 Jeremy Allison 2015-12-04 19:20:23 UTC
Windows doesn't support colons in file names. They are stream delimiters.

What cifsfs does is to encode a ':' as a character in the unicode private area. That is what you're seeing here from smbclient.

This isn't IMHO an smbclient bug.
Comment 2 Nerijus Baliūnas 2015-12-04 19:44:39 UTC
My problem is that I use smbclient to backup files from the remote server:
smbclient //server/share -A /etc/.smbclient -c "lcd /home/backup; prompt; recurse; mget *; exit;"

and it fails when encounters colon:

getting file \...
...
NT_STATUS_OBJECT_NAME_INVALID listing \dir\INTRO:EXTRO (STREAMING)\*
NT_STATUS_OBJECT_NAME_INVALID listing \dir\*
NT_STATUS_OBJECT_NAME_INVALID listing \*

How can I use smbclient in such case?
Comment 3 Nerijus Baliūnas 2015-12-04 19:49:03 UTC
In my case remote server is Apple Time Capsule, and it displays colon in file name:
smb: \dir\> ls
  .                                   D        0  Fri Sep 18 17:26:39 2015
  ..                                  D        0  Thu Nov 12 10:20:29 2015
  .DS_Store                           H    12292  Thu Oct 15 14:52:35 2015
  INTRO:EXTRO (STREAMING)             D        0  Fri Sep 18 17:26:49 2015
Comment 4 Jeremy Allison 2015-12-04 19:51:12 UTC
You're using the 'mapchars' option on cifsfs. smbclient doesn't support that mapping.

Try backing up using cifsfs.
Comment 5 Nerijus Baliūnas 2015-12-04 20:00:43 UTC
I cannot use cifsfs as the virtual machine does not support it on OpenVZ. Is it possible to patch smbclient to accept ":" in file names?
Comment 6 Jeremy Allison 2015-12-04 20:17:08 UTC
smbclient would need an option to support the cifsfs mapchars. This isn't a trivial change. I will think about this some more.
Comment 7 Nerijus Baliūnas 2015-12-07 10:03:11 UTC
If it's not trivial, could it be possible to make smbclient not to exit, when it encounters colon, but skip it (when doing recurse; mget *;)?
Comment 8 Nerijus Baliūnas 2015-12-07 10:32:02 UTC
BTW, smbclient shows directory as INTRO:EXTRO (STREAMING), while Mac displays it as INTRO / EXTRO (STREAMING).
Comment 9 Björn Jacke 2015-12-11 15:05:18 UTC
maybe convmv helps you, starting from 2.0 on it allows to convert the filenames to/from the mapping that apple uses. If you convert your files to that mapped encoding you will be able to save the files to that device I guess.

btw: cifs vfs unfortunately still uses it's own mapping, not compatible with the mapping that apple uses. It would be great if cifs vfs would switch to the much more commonly used mapping of apple, see https://bugzilla.samba.org/show_bug.cgi?id=11206
Comment 10 Nerijus Baliūnas 2015-12-11 15:37:57 UTC
(In reply to Björn Jacke from comment #9)
I don't think it will help in my case, because I can save the files with colons on Linux, the problem is that smbclient errors out and stops when encounters remote file with a colon (which originally is /) in filename.

But I found smbget, which is perfect for my backup purposes, so I don't use smbclient any more.
Comment 11 Björn Jacke 2017-11-14 08:22:06 UTC
cifs vfs uses the SFM mapping these days and the catia mappings recommended in https://bugzilla.samba.org/show_bug.cgi?id=12830#c2 will do the mapping from ":" on the server to the 0xF0.. mapping that your client does. So also your backup with colons in the file names should work that way.