diff options
Diffstat (limited to 'net/samba420/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch')
-rw-r--r-- | net/samba420/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/net/samba420/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch b/net/samba420/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch new file mode 100644 index 000000000000..601a1c1c79d8 --- /dev/null +++ b/net/samba420/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch @@ -0,0 +1,182 @@ +https://bugzilla.samba.org/show_bug.cgi?id=15376 + +--- source3/modules/vfs_zfsacl.c 2023-11-27 13:09:10.612012900 +0100 ++++ source3/modules/vfs_zfsacl.c 2025-01-07 18:53:05.292522000 +0100 +@@ -169,6 +169,7 @@ + bool must_add_empty_ace = false; + struct zfsacl_config_data *config = NULL; + int fd; ++ char buf[PATH_MAX]; + + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct zfsacl_config_data, +@@ -235,22 +236,49 @@ + SMB_ASSERT(i == naces); + + /* store acl */ +- fd = fsp_get_pathref_fd(fsp); +- if (fd == -1) { ++ if (!fsp->fsp_flags.is_pathref) { ++ fd = fsp_get_io_fd(fsp); ++ ++ rv = facl(fd, ACE_SETACL, naces, acebuf); ++ if (rv != 0) { ++ DEBUG(8, ("zfs_process_smbacl(%s): Not PATHREF: facl(ACE_SETACL, %d): %s\n", ++ fsp_str_dbg(fsp), naces, ++ strerror(errno))); ++ return false; ++ } ++ DEBUG(10, ("zfs_process_smbacl(%s): Not PATHREF: facl(ACE_SETACL, %d) -> %d\n", ++ fsp_str_dbg(fsp), naces, ++ rv)); ++ ++ } else if (fsp->fsp_flags.have_proc_fds) { ++ fd = fsp_get_pathref_fd(fsp); ++ if (fd == -1) { ++ DEBUG(8, ("zfs_process_smbacl(%s): PATHREF(proc_fd): fsp_get_pathref_fd=-1: %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); + errno = EBADF; + return false; +- } +- rv = facl(fd, ACE_SETACL, naces, acebuf); +- if (rv != 0) { +- if(errno == ENOSYS) { +- DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not " +- "supported on the filesystem where the file " +- "reside", fsp_str_dbg(fsp))); +- } else { +- DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp_str_dbg(fsp), +- strerror(errno))); +- } ++ } ++ rv = acl(sys_proc_fd_path(fd, buf, sizeof(buf)), ACE_SETACL, naces, acebuf); ++ if (rv != 0) { ++ DEBUG(8, ("zfs_process_smbacl(%s): acl(ACE_SETACL, %d): %s\n", ++ fsp_str_dbg(fsp), naces, ++ strerror(errno))); + return false; ++ } ++ DEBUG(10, ("zfs_process_smbacl(%s): PATHREF(proc_fd): acl(ACE_SETACL, %d) -> %d\n", ++ fsp_str_dbg(fsp), naces, ++ rv)); ++ } else { ++ rv = acl(fsp->fsp_name->base_name, ACE_SETACL, naces, acebuf); ++ if (rv != 0) { ++ DEBUG(8, ("zfs_process_smbacl(%s): PATHREF(base_name): acl(ACE_SETACL, %d): %s\n", ++ fsp_str_dbg(fsp), naces, ++ strerror(errno))); ++ return false; ++ } ++ DEBUG(10, ("zfs_process_smbacl(%s): PATHREF(base_name): facl(ACE_SETACL, %d) -> %d\n", ++ fsp_str_dbg(fsp), naces, ++ rv)); + } + + return True; +@@ -282,25 +310,48 @@ + struct files_struct *fsp, + ace_t **outbuf) + { +- int naces, rv; ++ int naces, rv = -1, fd = -1; + ace_t *acebuf = NULL; +- int fd; + +- fd = fsp_get_pathref_fd(fsp); +- if (fd == -1) { ++ ++ char buf[PATH_MAX]; ++ ++ ++ if (!fsp->fsp_flags.is_pathref) { ++ fd = fsp_get_io_fd(fsp); ++ if (fd == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): Not PATHREF: fsp_get_io_fd=-1: %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); + errno = EBADF; + return -1; +- } +- naces = facl(fd, ACE_GETACLCNT, 0, NULL); +- if (naces == -1) { +- int dbg_level = 10; +- +- if (errno == ENOSYS) { +- dbg_level = 1; +- } +- DEBUG(dbg_level, ("facl(ACE_GETACLCNT, %s): %s ", ++ } ++ naces = facl(fd, ACE_GETACLCNT, 0, NULL); ++ if (naces == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): Not PATHREF: facl(ACE_GETACLCNT): %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); ++ return -1; ++ } ++ } else if (fsp->fsp_flags.have_proc_fds) { ++ fd = fsp_get_pathref_fd(fsp); ++ if (fd == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): PATHREF(proc_fd): fsp_get_pathref_fd=-1: %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); ++ errno = EBADF; ++ return -1; ++ } ++ naces = acl(sys_proc_fd_path(fd, buf, sizeof(buf)), ACE_GETACLCNT, 0, NULL); ++ if (naces == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): PATHREF(proc_fd): acl(ACE_GETACLCNT): %s\n", + fsp_str_dbg(fsp), strerror(errno))); +- return naces; ++ return -1; ++ } ++ } else { ++ naces = acl(fsp->fsp_name->base_name, ACE_GETACLCNT, 0, NULL); ++ if (naces == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): PATHREF(base_name): acl(ACE_GETACLCNT): %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); ++ return -1; ++ } + } + + acebuf = talloc_size(mem_ctx, sizeof(ace_t)*naces); +@@ -309,15 +360,37 @@ + return -1; + } + +- rv = facl(fd, ACE_GETACL, naces, acebuf); +- if (rv == -1) { +- DBG_DEBUG("acl(ACE_GETACL, %s): %s ", +- fsp_str_dbg(fsp), strerror(errno)); ++ if (!fsp->fsp_flags.is_pathref) { ++ rv = facl(fd, ACE_GETACL, naces, acebuf); ++ if (rv == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): Not PATHREF: facl(ACE_GETACL): %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); + return -1; ++ } ++ DEBUG(10, ("fget_zfsacl(%s): Not PATHREF: facl(ACE_GETACL) -> %d entries\n", ++ fsp_str_dbg(fsp), rv)); ++ } else if (fsp->fsp_flags.have_proc_fds) { ++ rv = acl(sys_proc_fd_path(fd, buf, sizeof(buf)), ACE_GETACL, naces, acebuf); ++ if (rv == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): PATHREF(proc_fd): acl(ACE_GETACL): %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); ++ return -1; ++ } ++ DEBUG(10, ("fget_zfsacl(%s): PATHREF(proc_fd): acl(ACE_GETACL) -> %d entries\n", ++ fsp_str_dbg(fsp), rv)); ++ } else { ++ rv = acl(fsp->fsp_name->base_name, ACE_GETACL, naces, acebuf); ++ if (rv == -1) { ++ DEBUG(8, ("fget_zfsacl(%s): PATHREF(base_name): acl(ACE_GETACL): %s\n", ++ fsp_str_dbg(fsp), strerror(errno))); ++ return -1; ++ } ++ DEBUG(10, ("fget_zfsacl(%s): PATHREF(base_name): acl(ACE_GETACL) -> %d entries\n", ++ fsp_str_dbg(fsp), rv)); + } +- ++ + *outbuf = acebuf; +- return naces; ++ return rv; + } + + static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, |