Ubuntu – Trying to rename a file via Samba; fails if there is a ‘2’ in the filename

sambaUbuntu

This seems a bizarre issue, hope someone might shed some light. I set up some samba folders on a couple of ubuntu servers for the users to do some file management. After moving a file into the share, the user is trying to rename the file from their windows XP computer through samba, but getting the error "The file name you specified is not valid or too long. Specify a different file name."

I checked the permissions and messed around with it from Windows 7 and am having the same issue. Ultimately I found that I can change the filename as long as the new name does not include the number '2'. The new name of the file should be '285870_full' and we can name it '185870_full' and '385870_full' and anything else I can think to try, but '285870_full' gives the error about "filename you specified is not valid or too long"

I connected to the server via SSH and was able to rename the file that way without any error. Now through samba I can see the file is named '285870_full' and if I try to add another '2' it gives the same error but otherwise I can rename it normally.

I tried with another random small text file and have the same issue – it won't let me rename it to anything with a '2' in the new name, but '134567890' works fine. Any ideas?

Update: I set log level to 3 and here is the relevant portion of the log from a test;

reply_mv : pending/31345678901affiliate_pixel33.txt -> pending/31345678901affiliate_p22.txt
[2013/07/22 21:58:39, 3] smbd/reply.c:5981(rename_internals)
rename_internals: case_sensitive = 0, case_preserve = 1, short case preserve = 1, directory = pending/31345678901affiliate_pixel33.txt, newname = pending/31345678901affiliate_p22.txt, last_component_dest = 31345678901affiliate_p22.txt
[2013/07/22 21:58:39, 3] smbd/dosmode.c:149(unix_mode)
unix_mode(pending/31345678901affiliate_pixel33.txt) returning 0744
[2013/07/22 21:58:39, 2] smbd/open.c:580(open_file)
root opened file pending/31345678901affiliate_pixel33.txt read=No write=No (numopen=1)
[2013/07/22 21:58:39, 2] smbd/close.c:612(close_normal_file)
root closed file pending/31345678901affiliate_pixel33.txt (numopen=0) NT_STATUS_OK
[2013/07/22 21:58:39, 3] smbd/reply.c:6041(rename_internals)
rename_internals: Error NT_STATUS_OBJECT_NAME_INVALID rename pending/31345678901affiliate_pixel33.txt -> pending/31345678901affiliate_p22.txt
[2013/07/22 21:58:39, 3] smbd/error.c:60(error_packet_set)
error packet at smbd/reply.c(6273) cmd=7 (SMBmv) NT_STATUS_OBJECT_NAME_INVALID
[2013/07/22 21:58:39, 3] smbd/process.c:1459(process_smb)
Transaction 14 of length 162 (0 toread)
[2013/07/22 21:58:39, 3] smbd/process.c:1273(switch_message)
switch message SMBtrans2 (pid 11644) conn 0x7fad01371210

I see renaming with a '2' gives NT_STATUS_OBJECT_NAME_INVALID ?

Here is another log snip while it successfully renamed to something without a '2'

[2013/07/22 22:05:33, 3] smbd/reply.c:6263(reply_mv)
reply_mv : pending/31345678901affiliate_pixel33.txt -> pending/31345678901affiliate_44.txt
[2013/07/22 22:05:33, 3] smbd/reply.c:5981(rename_internals)
rename_internals: case_sensitive = 0, case_preserve = 1, short case preserve = 1, directory = pending/31345678901affiliate_pixel33.txt, newname = pending/31345678901affiliate_44.txt, last_component_dest = 31345678901affiliate_44.txt
[2013/07/22 22:05:33, 3] smbd/dosmode.c:149(unix_mode)
unix_mode(pending/31345678901affiliate_pixel33.txt) returning 0744
[2013/07/22 22:05:33, 2] smbd/open.c:580(open_file)
root opened file pending/31345678901affiliate_pixel33.txt read=No write=No (numopen=1)
[2013/07/22 22:05:33, 3] smbd/reply.c:5816(rename_internals_fsp)
rename_internals_fsp: succeeded doing rename on pending/31345678901affiliate_pixel33.txt -> pending/31345678901affiliate_44.txt
[2013/07/22 22:05:33, 2] smbd/close.c:612(close_normal_file)
root closed file pending/31345678901affiliate_44.txt (numopen=0) NT_STATUS_OK
[2013/07/22 22:05:33, 3] smbd/reply.c:6041(rename_internals)
rename_internals: Error NT_STATUS_OK rename pending/31345678901affiliate_pixel33.txt -> pending/31345678901affiliate_44.txt
[2013/07/22 22:05:33, 3] smbd/process.c:1459(process_smb)
Transaction 72 of length 158 (0 toread)

So I wonder why a '2' gives NT_STATUS_OBJECT_NAME_INVALID ?

Best Answer

Well, SSH works!, what about a couple of more test-cases:

  • what about folders with 2 in their name?
  • what about "creating" instead of "renaming"? (copy-pasting a new file with 2 in its name)
  • what about using the SMB client of your server machine (e.g: SMB://192.168.0.1)

The same issue exists?