Bug 10491 - Incorrect name mangling: dot-ended filename is distorted and has not long filename
Incorrect name mangling: dot-ended filename is distorted and has not long fil...
Status: ASSIGNED
Product: Samba 3.6
Classification: Unclassified
Component: File services
3.6.22
x86 FreeBSD
: P5 enhancement
: ---
Assigned To: Jeremy Allison
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-03-08 15:22 UTC by Sergey
Modified: 2014-03-16 18:34 UTC (History)
0 users

See Also:


Attachments
Archive with dot-ended directory (157 bytes, application/x-7z-compressed)
2014-03-16 17:42 UTC, Sergey
no flags Details
Explorer shows dot-ended name correctly (64.88 KB, image/jpeg)
2014-03-16 18:33 UTC, Sergey
no flags Details
Far Manager shows two different directory (67.86 KB, image/jpeg)
2014-03-16 18:34 UTC, Sergey
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey 2014-03-08 15:22:00 UTC
If file or directory name is ended dot (.) it losts "long name" and has only distorted, "hashed" short name.

Lets make directory with last name and first name, for example, "Ivanov Ivan".
Then I try use last name and abbreviation of first name, "Ivanov I." (abbreviation is dot-ended).

On Windows side dot-ended name has distorted: 

N:\mangle_test>dir

08.03.2014  19:13    <DIR>          .
08.03.2014  15:32    <DIR>          ..
08.03.2014  19:13    <DIR>          Ivanov Ivan
08.03.2014  19:13    <DIR>          ID3EUP~Z

Also on Windows side dot-ended name and has not short file name:

N:\mangle_test>dir /X

08.03.2014  19:13    <DIR>                       .
08.03.2014  15:32    <DIR>                       ..
08.03.2014  19:13    <DIR>          IIUDQI~Y     Ivanov Ivan
08.03.2014  19:13    <DIR>                       ID3EUP~Z


On FreeBSD side all correct:
mangle_test>ls -1
Ivanov I.
Ivanov Ivan
mangle_test>ls -l
total 8
drwxrwxr-x  2 user  domain_users  512  8 мар 19:13 Ivanov I.
drwxrwxr-x  2 user  domain_users  512  8 мар 19:13 Ivanov Ivan


Workaround:
Set at smb.conf mangled names = no
Comment 1 Sergey 2014-03-08 16:17:28 UTC
Global parameters at smb.conf:
        mangling method = hash2
        mangle prefix = 1
        mangling char = ~
        mangled names = Yes
        default case = lower
        case sensitive = Auto
        preserve case = Yes
        short preserve case = Yes
Comment 2 Jeremy Allison 2014-03-08 17:03:39 UTC
Unfortunately this is "Just The Way Windows Works" (tm) :-(. There is nothing Samba can do to fix this. Windows does not allow a file or directory name ending in a dot to be stored (try this on Windows). On a local filesystem it silently truncates the dot to make the name available to client code without the trailing dot.

The only way we can make this available to clients is via the mangled name. As SMB2 doesn't use mangled names it might be interesting to test against a Windows server to see if names ending in dot are allowed to be created, or just return an invalid parameter.

When I have some time I'll look into this, but it's a request for enhancement not a bug - as Samba is currently working as designed here.

Jeremy.
Comment 3 Sergey 2014-03-16 17:42:16 UTC
Created attachment 9775 [details]
Archive with dot-ended directory

Directory "Ivanov I" has "1" subdirectory, directory "Ivanov I." has subdirectory "2"
Comment 4 Sergey 2014-03-16 18:32:33 UTC
(In reply to comment #2)
> Unfortunately this is "Just The Way Windows Works" (tm) :-(. 

  "Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, ".temp"."

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#naming_conventions

   Explorer shows dot-ended directory correctly, but can't copy, move or just enter into this directory. (Explorer.jpg)

Some file managers like Far Manager (http://www.farmanager.com/download.php?l=en) operates dot-ended directory as usual directory name.
(Two directory.jpg)

> When I have some time I'll look into this, but it's a request for enhancement
> not a bug - as Samba is currently working as designed here.
   
   Sure, it is not a bug.
Comment 5 Sergey 2014-03-16 18:33:19 UTC
Created attachment 9776 [details]
Explorer shows dot-ended name correctly
Comment 6 Sergey 2014-03-16 18:34:37 UTC
Created attachment 9777 [details]
Far Manager shows two different directory