I tried to update my Samba server on my FreeBSD 14.0-STABLE server from net/samba416 to net/samba419 (from samba416-4.16.11_4 to samba419-4.19.5_1) with pkg. After the update, some operations from my Windows 11 client started to fail. I can create a file but cannot change the filename or modify the file contents. The "log.hostname" log file reports a lot of similar errors concatenated without line breaks like this (while testing with "tmp/test.txt" on the share): facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp): Function not implemented facl(ACE_GETACLCNT, .): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented facl(ACE_GETACLCNT, tmp/test.txt): Function not implemented open_file: Could not set fd to blocking: Bad file descriptor I'm using vfs_zfsacl with a ZFS dataset for the share. An essential part of my smb4.conf is as follows (some network configuration with IP addresses is omitted): ------------ [global] log file = /var/log/samba4/log.%m log level = 1 security = user local master = no invalid users = root dns proxy = no mdns name = mdns min protocol = SMB3 smb encrypt = required unix extensions = no [homes] strict allocate = no path = /usr/home/%S/samba writable = yes valid users = %S browseable = no guest ok = no read only = no follow symlinks = yes wide links = yes ea support = yes vfs objects = zfsacl streams_xattr nfs4:mode = simple nfs4:acedup = merge streams_xattr:prefix = user. streams_xattr:store_stream_type = no map archive = no dos filemode = yes map acl inherit = yes ------------ I use the same smb4.conf for samba416 and have no such problems. vfs_zfsacl.c in net/samba419 is patched by files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch, which does not exist in net/samba416. I believe the patched part emitted these error messages. % uname -a FreeBSD elvenbow.nc.kyushu-u.ac.jp 14.0-STABLE FreeBSD 14.0-STABLE #4 stable/14-n266915-8d22744f5be1: Thu Feb 29 14:25:53 JST 2024 root@elvenbow.nc.kyushu-u.ac.jp:/usr/obj/usr/src/amd64.amd64/sys/ELVENBOW amd64
I've tried your smb4.conf and I have no problem with a win10 client.
Thank you for checking. I may be doing something wrong with my setup, but I'm unsure where to look. facl() in libsunacl.a hides the actual errno produced by acl_get_fd_np(), so maybe I'll try to patch that to see what is happening more closely...
What if you remove "zfsacl" from "vfs objects"?
Even after removing "zfsacl" from "vfs objects," I couldn't modify the file on the share, so I guess the problem is not in zfsacl but somewhere else. The same configuration worked with samba416. I'm more confused. Anyway, I think this PR should be closed. Sorry for the noise.
I'm still trying to find the reason why the same smb4.conf works with samba416 and not with samba419. I emptied "vfs objects," but still, I cannot modify files. I noticed that when I try to overwrite a text file with notepad, "The handle is invalid" error occurred. The log with debug level=10 shows: [2024/04/04 11:43:22.915701, 1, pid=80375, effective(1001, 1001), real(0, 0)] ../../source3/smbd/open.c:1508(open_file) open_file: Could not set fd to blocking: Bad file descriptor [2024/04/04 11:43:22.915720, 10, pid=80375, effective(1001, 1001), real(0, 0), class=locking] ../../source3/locking/posix.c:482(delete_lock_ref_count) delete_lock_ref_count for file tmp/test2/a.txt [2024/04/04 11:43:22.915741, 10, pid=80375, effective(1001, 1001), real(0, 0)] ../../source3/smbd/open.c:6465(create_file_unixpath) create_file_unixpath: NT_STATUS_INVALID_HANDLE I don't understand why open_file() fails like this. There is something wrong with file descriptor handling. Then, I noticed that "files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch" modified proc_fd_patterns in source3/lib/system.c: --- source3/lib/system.c 2023-01-18 16:32:24.174553200 +0100 +++ source3/lib/system.c 2023-06-19 23:35:30.132465000 +0200 @@ -1022,6 +1022,8 @@ } proc_fd_patterns[] = { /* Linux */ { "/proc/self/fd/%d", "/proc/self/fd/0" }, + /* FreeBSD */ + { "/compat/linux/dev/fd/%d", "/compat/linux/dev/fd/0" }, { NULL, NULL }, }; Linux emulation is enabled on my server, so I have /compat/linux/dev/fd mounted. I unmounted /compat/linux/dev/fd and /compat/linux/dev (because /compat/linux/dev contains another "fd" directory), and samba419 began to work properly. Could you please review this patch more closely? I don't like this patch because it silently introduces (broken) dependency with the Linux emulator.
After reading https://bugzilla.samba.org/show_bug.cgi?id=15376, mounting fdescfs seems expected, but it is not working well on my system. I tried the attached test program in the bug report, and the result was erratic, as mentioned in the comment. Sometimes, acl and extattr were not working properly, consistent with my issues with samba419. After I added -s option to stat() the fdescfd path, the test seemed to work. Then, I found bug #272127. The test still failed just after mounting fdescfs on my system. I tried the rdlnk option and acl and extattr errors disappeared, but open_file still failed with "Bad file descriptor".
Created attachment 249703 [details] v0 Can you test the attached patch, it should restore the 4.16 behavior
With the patch, samba419 seems to work properly. There is no facl() error logged now.
Created attachment 249849 [details] v1 The previous patch broke acls on zfs. Can you give this one a shot? It also update samba to 4.19.6 Thanks.
With the new patch, I can rename a file and change DOS attributes (no facl or extattr error), but I cannot overwrite an existing file. The error message is the same. [2024/04/10 14:07:03.246827, 1] ../../source3/smbd/open.c:1497(open_file) open_file: Could not set fd to blocking: Bad file descriptor