Bug 13534 - Samba makes my files 0 bytes (i.e. deletes all contents)
Summary: Samba makes my files 0 bytes (i.e. deletes all contents)
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.1.3
Hardware: x86 All
: P5 normal (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-17 11:04 UTC by meneerjansen00
Modified: 2018-10-08 06:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description meneerjansen00 2018-07-17 11:04:19 UTC
Dear Samba developers,

I think that I might have found a bug in Samba. Some data on beforehand:

* Linux (= Samba server) = Linux Mint 17.1 "Rebecca" long term support
* Samba version: 4.3.11-Ubuntu
* /etc/samba/smb.conf: see further on in this bug report
* Samba client = Windows 10 (32 bit! not all Windows 10 versions are 64 bit!)
* Samba log file: https://pastebin.com/ft1RqzLr

I've shared directories on my 64 bit Linux computer with Windows 10 (32 bit edition!). But when I try to create a file on said Linux share from within Windows 10 then Windows won't do that and throws me the following error:

--> "An unexpected error is keeping you from creating the file. If you continue to receive this error, you can use the error code to search for help with this problem.
Error 0x8007003B: an unexpected network error occurred." <---

Upon inspection on the Linux PC it appears that the new file IS indeed created on the Linux share! 

Additionally, when I try to edit a text file from the Linux share on Windows (e.g. w/ Wordpad) then I can see it's contents and when I try to save the text file then Windows can not do that so I choose "Cancel". Upon inspecting the file in Linux it appears that said text file is zero bytes and hence the *complete contents* of the file is deleted!

I've googled the error but on the internet there a many (strange) pieces of advice's and/or workarounds that do not work like deleting registry entries and disabling Windows' firewall. So what I tried and what does not work is:

* In the registry key: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels/Microsoft-Windows-DxpTaskRingtone/Analytic" place the letter "s" after "Analytic" so it reads "AnalyticS". (see https://social.technet.microsoft.com/Forums/ie/en-US/01b5f31b-e911-410f-a24e-f5175ceed709/error-0x8007003b-an-unexpected-network-error-occurred?forum=w8itpronetworking )
* Delete said registry key
* Disable Windows' firewall for the home network

This is my /etc/samba/smb.conf:

================================================
[global]
client max protocol = SMB3
server max protocol = SMB3
netbios name = Desktop-PC
name resolve order = bcast lmhosts host wins
log file = /var/log/samba/log.%m
max log size = 1000
panic action = /usr/share/samba/panic-action %d
passdb backend = tdbsam
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

[printers]
    comment = All Printers
    browseable = no
    path = /var/spool/samba
    printable = yes
    create mask = 0700
[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers

[Afbldngen]
    comment = Afbeeldingen Desktop-PC
    path = /home/ik/afbeeldingen
        locking = no
        available = yes
        browsable = yes
        public = yes
        writable = yes
        guest ok = yes
        read only = no
;       valid users = 
;       force user = 
============================================

Did I find a bug? 

Best regards,

Michel
Holland
Comment 1 Amit Kumar 2018-10-04 06:42:14 UTC
Dear Michel Holland,

Either add in share definition and then try creating a file.
        admin users = <>
OR
       force user = <>
       force group = <>

Thanks
Amit
Comment 2 meneerjansen00 2018-10-04 13:17:56 UTC
(In reply to amitkuma from comment #1)
Unfortunately text files on my Linux computer still get to be "reset" to 0 byte files when I try to edit them in Windows with Wordpad.

And I can still create files on said share even though Windows says that I can't.
Comment 3 Amit Kumar 2018-10-08 06:00:22 UTC
(In reply to meneerjansen00 from comment #2)
====(RHEL-7.5)(samba-4.7.1-9) smb.conf======
[global]
client max protocol = SMB3
server max protocol = SMB3
netbios name = Desktop-PC
name resolve order = bcast lmhosts host wins
log file = /var/log/samba/log.%m
max log size = 1000
panic action = /usr/share/samba/panic-action %d
passdb backend = tdbsam
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

[printers]
    comment = All Printers
    browseable = no
    path = /var/spool/samba
    printable = yes
    create mask = 0700
[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers

[myshare]
    comment = Afbeeldingen Desktop-PC
    path = /share
        locking = no
        available = yes
        browsable = yes
        public = yes
        writable = yes
        guest ok = yes
        read only = no
;       valid users = 
;       force user = 
        admin users = fred
=============================

File created successfully from Windows-10. Logs on smb server while creation of file.
check_user_ok: user fred is an admin user. Setting uid as 0
windows2008-2 (ipv4:10.65.232.56:63366) connect to service myshare initially as user fred (uid=0, gid=1000) (pid 20078)
fred opened file New Text Document (4).txt read=Yes write=Yes (numopen=2)
fred closed file New Text Document (4).txt (numopen=1) NT_STATUS_OK
fred opened file New Text Document (4).txt read=No write=No (numopen=2)
fred closed file gg.txt (numopen=1) NT_STATUS_OK
fred opened file gg.txt read=No write=No (numopen=2)
fred closed file gg.txt (numopen=1) NT_STATUS_OK
fred opened file gg.txt read=No write=No (numopen=2)
fred closed file gg.txt (numopen=2) NT_STATUS_OK
fred opened file gg.txt read=No write=No (numopen=3)
fred closed file gg.txt (numopen=2) NT_STATUS_OK
fred opened file gg.txt read=Yes write=No (numopen=3)
fred opened file gg.txt read=No write=No (numopen=4)
fred closed file gg.txt (numopen=3) NT_STATUS_OK
fred opened file gg.txt read=Yes write=Yes (numopen=4)
fred closed file gg.txt (numopen=3) NT_STATUS_OK

-------Now 2 things-------
1. Can you try repro with the latest samba version? 4.7.1-9, you are using bit older
2. Can you try repro on RHEL, or other OS than Mint 17.1, also on latest mint?
3. From https://pastebin.com/ft1RqzLr It looks smbd crashed while serving the request. If you still find smbd crashing while trying to serve the share to the client, Please provide us coredump. But Again I will advise upgrading to latest samba version, Latest OS version If still it crashes provide us the dump. It may be the case bug is already fixed in the latest version and we spend a lot on time in reinventing the wheel.