smbd: Correctly set fsp->is_directory before dealing with ACLs
authorAndrew Bartlett <abartlet@samba.org>
Tue, 13 Nov 2012 20:34:35 +0000 (12:34 -0800)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 13 Nov 2012 21:48:19 +0000 (22:48 +0100)
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 <jra@samba.org>

source3/smbd/pysmbd.c

index 6a6a8120f3a2872938ee6f86a15c561a36952c3f..436e881b10058e8c558822435b145ceaa6a38d73 100644 (file)
@@ -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)));