I have the following situation on a 3.6.25 and two 4.2.5 samba servers. Create a new directory in a share with two subdirectories: db1 share # mkdir test db1 share # cd test db1 test # mkdir "3392 Lampenabdeckungen" db1 test # mkdir "3077 Stahl Biegearbeiten 1 Zoll" Given the leading number, I need to find out the complete name, so I use: db1 test # smbclient //db1/share -c "ls test/3077*" Domain=[...] OS=[Windows 6.1] Server=[Samba 4.2.5] 3077 Stahl Biegearbeiten 1 Zoll D 0 Thu Jan 14 15:26:19 2016 which is fine. But trying this for the other number gives a wrong result: db1 test # smbclient //db1/share -c "ls test/3392*" Domain=[...] OS=[Windows 6.1] Server=[Samba 4.2.5] 3077 Stahl Biegearbeiten 1 Zoll D 0 Thu Jan 14 15:26:19 2016 3392 Lampenabdeckungen D 0 Thu Jan 14 15:26:06 2016 This popped up in a larger directory (>1100 subdirs named similarly), where a VBA-Macro used Dir on a samba share to determine the full name given the leading project number. About 10 matches like the above in that directory returned an additional wrong result. I can't post the other names due to privacy concerns.
Almost certainly this is a match on the 8.3 (truncated name). Samba matches wildcards against both, to cope with UNIX names like a:file:name which otherwise can't be returned to Windows clients. Try setting the per-share parameter: mangled names = no on the share and see if the problem goes away.
First time in over 15 years of using samba that name mangling even has become visible to me. I'd never have expected that. Deactivating mangling solves the problem for me. Thank you very much, Jeremy. Is resolved/invalid the correct status for this should-have-RTFM-instead-of-filing-a-bug situation?