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)
committerKarolin Seeger <kseeger@samba.org>
Mon, 3 Dec 2012 11:47:04 +0000 (12:47 +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>
(cherry picked from commit a4434297f19a3520d0f2ac242d4e99576d927ecc)

source3/smbd/pysmbd.c

index 14893550e28f4dc4ae6152376f0f9adb80b75715..78c2bcb17505195845adcd50f0803c393278fa08 100644 (file)
@@ -88,7 +88,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)) {
@@ -159,6 +159,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)));