check the creation options where the client can require a path to be a
authorAndrew Tridgell <tridge@samba.org>
Tue, 20 May 2008 01:58:47 +0000 (11:58 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 20 May 2008 01:58:47 +0000 (11:58 +1000)
file or a directory
(This used to be commit c05b58940f06b01b9770c218eb0708cb621215ef)

source4/ntvfs/posix/pvfs_open.c

index c9c1c56f148ebd52039a850eccd3f85b8d1c7aa1..67937324ccfa9afcae974b8232ad3eebe01624fe 100644 (file)
@@ -1117,6 +1117,20 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
                return status;
        }
 
+       /* if the client specified that it must not be a directory then
+          check that it isn't */
+       if (name->exists && (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+           (io->generic.in.create_options & NTCREATEX_OPTIONS_NON_DIRECTORY_FILE)) {
+               return NT_STATUS_FILE_IS_A_DIRECTORY;
+       }
+
+       /* if the client specified that it must be a directory then
+          check that it is */
+       if (name->exists && !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+           (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)) {
+               return NT_STATUS_NOT_A_DIRECTORY;
+       }
+
        /* directory opens are handled separately */
        if ((name->exists && (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) ||
            (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)) {