openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
4.01k stars 3.49k forks source link

samba4: The FAT/exFAT file system shared by samba is writing abnormally under macOS when "Enable macOS compatible shares" #23688

Open jjm2473 opened 7 months ago

jjm2473 commented 7 months ago

Maintainer: @miska Environment:

DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='22.03.6'
DISTRIB_REVISION='r20265-f85a79bcb4'
DISTRIB_TARGET='x86/64'
DISTRIB_ARCH='x86_64'
DISTRIB_DESCRIPTION='OpenWrt 22.03.6 r20265-f85a79bcb4'
DISTRIB_TAINTS=''

samba4 version (smbd -V): 4.18.8 macOS version: 12.7.2

Description: Same as closed issue https://github.com/openwrt/packages/issues/11369

Related configuration files:

/etc/config/samba4:


config samba
        option workgroup 'WORKGROUP'
        option charset 'UTF-8'
        option description 'Samba on OpenWRT'
        option macos '1'

config sambashare
        option name 'test'
        option path '/mnt/vfat'
        option read_only 'no'
        option force_root '1'
        option guest_ok 'yes'
        option inherit_owner 'yes'
        option create_mask '0666'
        option dir_mask '0777'

/etc/samba/smb.conf:

[global]
        netbios name = OpenWrt 
        interfaces = br-lan 
        server string = Samba on OpenWRT
        unix charset = UTF-8
        workgroup = WORKGROUP

        ## This global parameter allows the Samba admin to limit what interfaces on a machine will serve SMB requests.
        bind interfaces only = yes

        ## time for inactive connections to-be closed in minutes
        deadtime = 15

        ## disable core dumps
        enable core files = no

        ## set security (auto, user, domain, ads)
        security = user

        ## This parameter controls whether a remote client is allowed or required to use SMB encryption.
        ## It has different effects depending on whether the connection uses SMB1 or SMB2 and newer:
    ## If the connection uses SMB1, then this option controls the use of a Samba-specific extension to the SMB protocol introduced in Samba 3.2 that makes use of the Unix extensions.
        ## If the connection uses SMB2 or newer, then this option controls the use of the SMB-level encryption that is supported in SMB version 3.0 and above and available in Windows 8 and newer. 
        ## (default/auto,desired,required,off)
        #smb encrypt = default

        ## set invalid users
        invalid users = root

        ## map unknow users to guest
        map to guest = Bad User

        ## allow client access to accounts that have null passwords. 
        null passwords = yes

        ## The old plaintext passdb backend. Some Samba features will not work if this passdb backend is used. (NOTE: enabled for size reasons)
        ## (tdbsam,smbpasswd,ldapsam)
        passdb backend = smbpasswd

        ## Set location of smbpasswd ('smbd -b' will show default compiled location)
        #smb passwd file = /etc/samba/smbpasswd 

        ## LAN (IPTOS_LOWDELAY TCP_NODELAY) WAN (IPTOS_THROUGHPUT) WiFi (SO_KEEPALIVE) try&error for buffer sizes (SO_RCVBUF=65536 SO_SNDBUF=65536)
        socket options = IPTOS_LOWDELAY TCP_NODELAY

        ## If this integer parameter is set to a non-zero value, Samba will read from files asynchronously when the request size is bigger than this value.
        ## Note that it happens only for non-chained and non-chaining reads and when not using write cache.
        ## The only reasonable values for this parameter are 0 (no async I/O) and 1 (always do async I/O).
        ## (1/0)
        #aio read size = 0
        #aio write size = 0

        ## If Samba has been built with asynchronous I/O support, Samba will not wait until write requests are finished before returning the result to the client for files listed in this parameter.
        ## Instead, Samba will immediately return that the write request has been finished successfully, no matter if the operation will succeed or not.
        ## This might speed up clients without aio support, but is really dangerous, because data could be lost and files could be damaged. 
        #aio write behind = /*.tmp/

        ## lower CPU useage if supported and aio is disabled (aio read size = 0 ; aio write size = 0)
        ## is this still broken? issue is from 2019 (NOTE: see https://bugzilla.samba.org/show_bug.cgi?id=14095 )
        ## (no, yes)
        #use sendfile = yes

        ## samba will behave as previous versions of Samba would and will fail the lock request immediately if the lock range cannot be obtained.
        #blocking locks = No

        ## disable loading of all printcap printers by default (iprint, cups, lpstat)
        load printers = No
        printcap name = /dev/null

        ## Enabling this parameter will disable Samba's support for the SPOOLSS set of MS-RPC's.
        disable spoolss = yes

        ## This parameters controls how printer status information is interpreted on your system.
        ## (BSD, AIX, LPRNG, PLP, SYSV, HPUX, QNX, SOFTQ)
        printing = bsd

        ## Disable that nmbd is acting as a WINS server for unknow netbios names
        #dns proxy = No

        ## win/unix user mapping backend
        #idmap config * : backend = tdb

        ## Allows the server name that is advertised through MDNS to be set to the hostname rather than the Samba NETBIOS name.
        ## This allows an administrator to make Samba registered MDNS records match the case of the hostname rather than being in all capitals.
        ## (netbios, mdns)
        mdns name = mdns

        ## Clients that only support netbios won't be able to see your samba server when netbios support is disabled.
        #disable netbios = Yes

        ## Setting this value to no will cause nmbd never to become a local master browser.
        #local master = no

        ## (auto, yes) If this is set to yes, on startup, nmbd will force an election, and it will have a slight advantage in winning the election. It is recommended that this parameter is used in conjunction with domain master = yes, so that nmbd can guarantee becoming a domain master. 
        #preferred master = yes

        ## (445 139) Specifies which ports the server should listen on for SMB traffic.
        ## 139 is netbios/nmbd
        #smb ports = 445 139

        ## This is a list of files and directories that are neither visible nor accessible.
        ## Each entry in the list must be separated by a '/', which allows spaces to be included in the entry. '*' and '?' can be used to specify multiple files or directories as in DOS wildcards.
        veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/

        ## If a directory that is to be deleted contains nothing but veto files this deletion will fail unless you also set the delete veto files parameter to yes.
        delete veto files = yes

################ Filesystem and creation rules ################
        ## reported filesystem type (NTFS,Samba,FAT)
        #fstype = FAT

        ## Allows a user who has write access to the file (by whatever means, including an ACL permission) to modify the permissions (including ACL) on it.
        #dos filemode = Yes

        ## file/dir creating rules
        #create mask = 0666
        #directory mask = 0777
        #force group = root
        #force user = root
        #inherit owner = windows and unix
################################################################

######### Dynamic written config options #########

[test]
        path = /mnt/vfat
        force user = root
        force group = root
        create mask = 0666
        directory mask = 0777
        read only = no
        guest ok = yes
        inherit owner = yes
        fruit:encoding = native
        fruit:metadata = stream
        fruit:veto_appledouble = no
        vfs objects = catia fruit streams_xattr  io_uring

An error occurs when writing a single file. The file is created successfully, but the file content is not written and the size is 0 bytes:

image image

smbd log:

Mon Mar 18 18:25:02 2024 daemon.err smbd[8495]: [2024/03/18 18:25:02.749688,  0] ../../source3/modules/vfs_fruit.c:2693(fruit_pwrite_meta_stream)
Mon Mar 18 18:25:02 2024 daemon.err smbd[8495]:   fruit_pwrite_meta_stream: On-demand create [my_list.iptvcat.com.m3u8:AFP_AfpInfo] in write failed: No such file or directory

macOS did not report an error when copying a folder, and the files in the folder were written successfully:

image

But at this time smbd still generated an error log:

Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]: [2024/03/18 18:28:00.321461,  0] ../../source3/modules/vfs_fruit.c:2693(fruit_pwrite_meta_stream)
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]:   fruit_pwrite_meta_stream: On-demand create [mtk/MT7531_Reference_Manual_for_Development_Board.pdf:AFP_AfpInfo] in write failed: No such file or directory
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]: [2024/03/18 18:28:00.389464,  0] ../../source3/modules/vfs_fruit.c:2693(fruit_pwrite_meta_stream)
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]:   fruit_pwrite_meta_stream: On-demand create [mtk/mtk_wi-fi_softap_software_programming_guide_v4.6.pdf:AFP_AfpInfo] in write failed: No such file or directory
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]: [2024/03/18 18:28:00.393867,  0] ../../source3/modules/vfs_fruit.c:2693(fruit_pwrite_meta_stream)
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]:   fruit_pwrite_meta_stream: On-demand create [mtk:AFP_AfpInfo] in write failed: No such file or directory
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]: [2024/03/18 18:28:00.400523,  0] ../../source3/modules/vfs_fruit.c:2693(fruit_pwrite_meta_stream)
Mon Mar 18 18:28:00 2024 daemon.err smbd[8495]:   fruit_pwrite_meta_stream: On-demand create [mtk:AFP_AfpInfo] in write failed: No such file or directory

chmod 0777 /mnt/vfat does not change anything:

chmod 0777 /mnt/vfat
/etc/init.d/samba4 stop
/etc/init.d/samba4 start

This problem can be solved by unchecked the "Enable macOS compatible shares", but this means that macOS will create a lot of files starting with ._.

brada4 commented 7 months ago

streams_xattr

fat does not support that, you need ext4 or xfs to support that.

jjm2473 commented 7 months ago

@brada4 But streams_xattr is generated by openwrt. In addition, the developers also mentioned streams_xattr supports FAT https://github.com/openwrt/packages/issues/11369#issuecomment-788770703

brada4 commented 7 months ago

Well, manual does not sound convinced of your opinion. https://www.samba.org/samba/docs/current/man-html/vfs_streams_xattr.8.html