Windows: afs root is always a directory
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 14 Jan 2012 00:32:16 +0000 (19:32 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 18 Jan 2012 15:33:40 +0000 (07:33 -0800)
If the root is opened with the FILE_NON_DIRECTORY_FILE option,
fail the request with STATUS_FILE_IS_A_DIRECTORY.

Change-Id: Ic7d29f9032c2a19617276138833938fcf304838e
Reviewed-on: http://gerrit.openafs.org/6552
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp

index 5698162..9814049 100644 (file)
@@ -1416,6 +1416,7 @@ AFSOpenRoot( IN PIRP Irp,
     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
     PACCESS_MASK pDesiredAccess = NULL;
     USHORT usShareAccess;
+    ULONG ulOptions;
     BOOLEAN bAllocatedCcb = FALSE;
     BOOLEAN bReleaseFcb = FALSE;
     AFSFileOpenCB   stOpenCB;
@@ -1428,9 +1429,24 @@ AFSOpenRoot( IN PIRP Irp,
 
         pDesiredAccess = &pIrpSp->Parameters.Create.SecurityContext->DesiredAccess;
         usShareAccess = pIrpSp->Parameters.Create.ShareAccess;
+        ulOptions = pIrpSp->Parameters.Create.Options;
 
         pFileObject = pIrpSp->FileObject;
 
+        if( BooleanFlagOn( ulOptions, FILE_NON_DIRECTORY_FILE))
+        {
+
+            ntStatus = STATUS_FILE_IS_A_DIRECTORY;
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                          AFS_TRACE_LEVEL_ERROR,
+                          "AFSOpenRoot (%08lX) Attempt to open root as file Status %08lX\n",
+                          Irp,
+                          ntStatus);
+
+            try_return( ntStatus);
+        }
+
         //
         // Check if we should go and retrieve updated information for the node
         //