Samba Share Problem

When I samba share /tmp, I can write and rename files.

When I samba share /var/run/OneDrive, I can seemingly create copies of files in the same folder, but I cannot rename files. I see this error message:

image

I see this samba log:

[2024/04/18 18:20:40.556605,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.556804,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(0) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:40.556858,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.557028,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.557097,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.557167,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:40.558980,  4] ../../source3/smbd/open.c:4138(open_file_ntcreate)
  calling open_file with flags=0x0 flags2=0x800 mode=0666, access_mask = 0x80, open_access_mask = 0x80
[2024/04/18 18:20:40.560301,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.560488,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(697695528) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:40.560545,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.560713,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.560774,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.560852,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:40.562364,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.562554,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(697695528) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:40.562610,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.562776,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.562837,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.562903,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:41.262385,  3] ../../source3/smbd/smb2_server.c:3962(smbd_smb2_request_error_ex)
  smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_NOT_SUPPORTED] || at ../../source3/smbd/smb2_create.c:340
[2024/04/18 18:20:41.264588,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:41.264801,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(697695528) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:41.264856,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:41.265021,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:41.265080,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:41.265143,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:41.266208,  3] ../../source3/smbd/smb2_server.c:3962(smbd_smb2_request_error_ex)
  smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_NOT_SUPPORTED] || at ../../source3/smbd/smb2_create.c:340

Here is my samba4 config:

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

config sambashare
        option name 'Scanned Documents'
        option path '/var/run/OneDrive'
        option read_only 'no'
        option guest_ok 'yes'
        option create_mask '0666'
        option dir_mask '0777'
[global]
        netbios name = |NAME|
        interfaces = |INTERFACES|
        server string = |DESCRIPTION|
        unix charset = |CHARSET|
        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
################################################################

I use this script to set up an rclone mount:

#!/bin/sh /etc/rc.common

export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export HOME=/root

exec &> /var/log/mount-onedrive.log

START=99
STOP=4

start() {
        rclone mkdir /var/run/OneDrive
        rclone mount "OneDrive:/Scanned Documents/" /var/run/OneDrive --use-mmap --buffer-size 0 --cache-dir /tmp --vfs-cache-mode writes --vfs-cache-max-age 0s --umask 000 --allow-other --daemon
}

stop() {
        fusermount -zu /var/run/OneDrive
        rclone rmdir /var/run/OneDrive
}
drwxrwxrwx    1 root     root           0 Apr 18 18:13 OneDrive

It is common for FUSE-based filesystems, such as the one created by rclone, to be somewhat deficient when it comes to advanced operations. And for security reasons, SAMBA uses advanced operations to make absolutely sure that it refers to the correct file even if an attacker tries to trick it into using the wrong one by quickly renaming files in the middle of operations.

Try adding the --track-renames option to your rclone command.

P.S. --use-mmap is unsafe, it can cause rclone to crash if a file is truncated in the middle of an upload.

1 Like

Looked promising and tried that, but no dice.

Does this rclone log reveal anything helpful:

2024/04/19 16:53:09 DEBUG : OneDrive root 'Scanned Documents': Checking for changes on remote
2024/04/19 16:53:09 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2024/04/19 16:53:10 DEBUG : /: Attr:
2024/04/19 16:53:10 DEBUG : /: >Attr: attr=valid=1s ino=0 size=0 mode=drwxrwxrwx, err=<nil>
2024/04/19 16:53:10 DEBUG : /: Lookup: name="y"
2024/04/19 16:53:10 DEBUG : /: >Lookup: node=y, err=<nil>
2024/04/19 16:53:10 DEBUG : y: Attr:
2024/04/19 16:53:10 DEBUG : y: >Attr: a=valid=1s ino=0 size=6 mode=-rw-rw-rw-, err=<nil>

I also just tried posting here on the rclone forum:

I'm beginning to think this is a samba/fuse issue.

Does this shed any light:

[2024/04/18 18:20:40.556605,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.556804,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(0) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:40.556858,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.557028,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.557097,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.557167,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:40.558980,  4] ../../source3/smbd/open.c:4138(open_file_ntcreate)
  calling open_file with flags=0x0 flags2=0x800 mode=0666, access_mask = 0x80, open_access_mask = 0x80
[2024/04/18 18:20:40.560301,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.560488,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(697695528) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:40.560545,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.560713,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.560774,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.560852,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:40.562364,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.562554,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(697695528) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:40.562610,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:40.562776,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.562837,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:40.562903,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:41.262385,  3] ../../source3/smbd/smb2_server.c:3962(smbd_smb2_request_error_ex)
  smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_NOT_SUPPORTED] || at ../../source3/smbd/smb2_create.c:340
[2024/04/18 18:20:41.264588,  4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2024/04/18 18:20:41.264801,  4] ../../source3/smbd/uid.c:566(push_conn_ctx)
  push_conn_ctx(697695528) : conn_ctx_stack_ndx = 0
[2024/04/18 18:20:41.264856,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2024/04/18 18:20:41.265021,  4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:41.265080,  4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2024/04/18 18:20:41.265143,  4] ../../source3/smbd/vfs.c:938(vfs_ChDir)
  vfs_ChDir to /tmp/run/OneDrive
[2024/04/18 18:20:41.266208,  3] ../../source3/smbd/smb2_server.c:3962(smbd_smb2_request_error_ex)
  smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_NOT_SUPPORTED] || at ../../source3/smbd/smb2_create.c:340

Could I need another fuse package? I have installed:

fuse-utils - 2.9.9-2
fuse3-utils - 3.10.5-2
kmod-fuse - 5.15.150-1
libfuse1 - 2.9.9-2
libfuse3-3 - 3.10.5-2

But not e.g.: kmod-fs-ext4 kmod-fs-exfat kmod-fs-ntfs3.

I finally figured out the issue based on this link:

https://forums.unraid.net/topic/51633-plugin-rclone/?do=findComment&comment=1093319

Setting this:

which results in this change to smb.conf:

<       vfs objects = io_uring
---
>       fruit:encoding = native
>       fruit:metadata = stream
>       fruit:veto_appledouble = no
>       vfs objects = catia fruit streams_xattr  io_uring

breaks things.

Simply deactiving this setting made everything work properly again (including on my iPhone 15!).

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.