Fix bug #7733 - Invalid client DOS attributes on create can cause incorrect unix...
authorJeremy Allison <jra@samba.org>
Fri, 15 Oct 2010 20:30:07 +0000 (13:30 -0700)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:36 +0000 (14:34 +0100)
It turns out a client can send an NTCreateX call for a new file, but specify
FILE_ATTRIBUTE_DIRECTORY in the attribute list. Windows silently strips this,
but we don't - causing the unix_mode() function to go through the "mode bits
for new directory" codepath, instead of the "mode bits for new file" codepath.

Jeremy.
(cherry picked from commit 92adb686372a9b67e47efb5b051bc351212f1780)
(cherry picked from commit 6b4141e92151adaa0d2ef036657783a99ef517c6)

source3/smbd/open.c

index 1bf7e235c15e8ef0d3b6fe42ae9ad46bd50f6418..fa647544571086999829ff73c0e35beabfc4cc7a 100644 (file)
@@ -1478,6 +1478,12 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
        ZERO_STRUCT(id);
 
+       /* Windows allows a new file to be created and
+          silently removes a FILE_ATTRIBUTE_DIRECTORY
+          sent by the client. Do the same. */
+
+       new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
+
        if (conn->printer) {
                /*
                 * Printers are handled completely differently.
@@ -2439,6 +2445,9 @@ static NTSTATUS open_directory(connection_struct *conn,
 
        SMB_ASSERT(!is_ntfs_stream_smb_fname(smb_dname));
 
+       /* Ensure we have a directory attribute. */
+       file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
+
        DEBUG(5,("open_directory: opening directory %s, access_mask = 0x%x, "
                 "share_access = 0x%x create_options = 0x%x, "
                 "create_disposition = 0x%x, file_attributes = 0x%x\n",