可写的 Samba 共享最终变为只读

可写的 Samba 共享最终变为只读

我在服务器 (Pi4) 上设置 docker samba 服务器 (dperspon/samba) 时遇到问题。可写的 samba 共享似乎是只读的。然而,这种行为很奇怪。当我使用 MacOS Finder 将文件放入共享时,会创建一个文件,但它保持为空。操作失败,并显示以下提示由于发生未知错误(错误 -50),操作无法完成。使用 CLI 一切正常。存储 (/media/data) 是 ExFat 格式。以下撰写文件有什么问题?

  samba:
    image: dperson/samba
    container_name: samba
    command: -g "log level = 2" -u "root;PASSWORD" -s "all;/smb/all;yes;no;no;root"
    volumes:
      - /media/data:/smb/all
    environment:
      - TZ=Europe/Berlin
      - WORKGROUP=media
      #- USERID=0
      #- GROUPID=0
    ports:
      - 139:139
      - 445:445
    restart: unless-stopped

这是容器中最终的配置。


   pam password change = yes
   map to guest = bad user
   usershare allow guests = yes
   create mask = 0664
   force create mode = 0664
   directory mask = 0775
   force directory mode = 0775
   force user = smbuser
   force group = smb
   follow symlinks = yes
   load printers = no
   printing = bsd
   printcap name = /dev/null
   disable spoolss = yes
   strict locking = no
   aio read size = 0
   aio write size = 0
   vfs objects = catia fruit recycle streams_xattr
   recycle:keeptree = yes
   recycle:maxsize = 0
   recycle:repository = .deleted
   recycle:versions = yes

   # Security
   client ipc max protocol = SMB3
   client ipc min protocol = SMB2_10
   client max protocol = SMB3
   client min protocol = SMB2_10
   server max protocol = SMB3
   server min protocol = SMB2_10

   # Time Machine
   fruit:delete_empty_adfiles = yes
   fruit:time machine = yes
   fruit:veto_appledouble = no
   fruit:wipe_intentionally_left_blank_rfork = yes


[all]
   path = /smb/all
   browsable = yes
   read only = no
   guest ok = no
   veto files = /.apdisk/.DS_Store/.TemporaryItems/.Trashes/desktop.ini/ehthumbs.db/Network Trash Fold
   delete veto files = yes
   valid users = root

答案1

问题在于配置行:

vfs objects = catia fruit recycle streams_xattr

注意VFS 模块 streams_xattr

启用此模块共享的文件系统必须支持 xattrs。

删除后streams_xattr至少写入一次有效。但是删除并再次写入会产生问题。删除fruit所有文件后,尽管仅从 Mac 客户端使用 Samba,文件操作仍按预期工作。

答案2

我也在使用带有 exFAT 挂载的 dperson/samba,在 Windows 10 客户端上也遇到了类似的问题,每当我尝试重命名/移动/删除时都会出现此错误(但创建文件有效)

错误 0x80070032:不支持该请求。

正如你所说,修复方法是从 /etc/samba/smb.conf 中的 vfs 对象行中删除 fruit 和 streams_xattr

vfs objects = catia recycle
$ docker exec -it samba bash
$ vi /etc/samba/smb.conf
# in vi, delete fruit and streams_xattr from vfs objects = 
$ exit
$ docker restart samba

相关内容