From a4434297f19a3520d0f2ac242d4e99576d927ecc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 13 Nov 2012 12:34:35 -0800 Subject: [PATCH] smbd: Correctly set fsp->is_directory before dealing with ACLs Change set_nt_acl_no_snum() to correctly set up the fsp. This does a stat on a real fsp in set_nt_acl_no_snum. Reviewed by: Jeremy Allison --- source3/smbd/pysmbd.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 6a6a8120f3a..436e881b100 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -89,7 +89,7 @@ static NTSTATUS set_nt_acl_no_snum(const char *fname, NTSTATUS status = NT_STATUS_OK; files_struct *fsp; struct smb_filename *smb_fname = NULL; - int flags; + int flags, ret; mode_t saved_umask; if (!posix_locking_init(false)) { @@ -160,6 +160,29 @@ static NTSTATUS set_nt_acl_no_snum(const char *fname, return NT_STATUS_UNSUCCESSFUL; } + ret = SMB_VFS_FSTAT(fsp, &smb_fname->st); + if (ret == -1) { + /* If we have an fd, this stat should succeed. */ + DEBUG(0,("Error doing fstat on open file %s " + "(%s)\n", + smb_fname_str_dbg(smb_fname), + strerror(errno) )); + TALLOC_FREE(frame); + umask(saved_umask); + return map_nt_error_from_unix(errno); + } + + fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st); + fsp->vuid = UID_FIELD_INVALID; + fsp->file_pid = 0; + fsp->can_lock = True; + fsp->can_read = True; + fsp->can_write = True; + fsp->print_file = NULL; + fsp->modified = False; + fsp->sent_oplock_break = NO_BREAK_SENT; + fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode); + status = SMB_VFS_FSET_NT_ACL( fsp, security_info_sent, sd); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("set_nt_acl_no_snum: fset_nt_acl returned %s.\n", nt_errstr(status))); -- 2.11.4.GIT