Windows: XP do not mark rdr devices as secure
[openafs.git] / src / WINNT / afsrdr / kernel / fs / AFSRDRSupport.cpp
index 4fd6172..79598da 100644 (file)
@@ -48,10 +48,19 @@ AFSInitRDRDevice()
     AFSDeviceExt  *pDeviceExt = NULL;
     UNICODE_STRING uniFsRtlRegisterUncProviderEx;
     FsRtlRegisterUncProviderEx_t pFsRtlRegisterUncProviderEx = NULL;
+    RTL_OSVERSIONINFOW sysVersion;
+    ULONG ulDeviceCharacteristics = FILE_REMOTE_DEVICE;
 
     __Enter
     {
 
+       RtlZeroMemory( &sysVersion,
+                      sizeof( RTL_OSVERSIONINFOW));
+
+       sysVersion.dwOSVersionInfoSize = sizeof( RTL_OSVERSIONINFOW);
+
+       RtlGetVersion( &sysVersion);
+
         RtlInitUnicodeString( &uniDeviceName,
                               AFS_RDR_DEVICE_NAME);
 
@@ -60,21 +69,34 @@ AFSInitRDRDevice()
 
         pFsRtlRegisterUncProviderEx = (FsRtlRegisterUncProviderEx_t)MmGetSystemRoutineAddress(&uniFsRtlRegisterUncProviderEx);
 
+       //
+       // On 32-bit Windows XP, do not set FILE_DEVICE_SECURE_OPEN
+       // flag as it interferes with initial access to \\afs from
+       // limited user accounts.
+       //
+
+       if(!(sysVersion.dwMajorVersion == 5 &&
+            sysVersion.dwMinorVersion == 1))
+       {
+
+           ulDeviceCharacteristics |= FILE_DEVICE_SECURE_OPEN;
+       }
+
         ntStatus = IoCreateDevice( AFSDriverObject,
                                    sizeof( AFSDeviceExt),
                                    pFsRtlRegisterUncProviderEx ? NULL : &uniDeviceName,
                                    FILE_DEVICE_NETWORK_FILE_SYSTEM,
-                                   FILE_REMOTE_DEVICE,
+                                  ulDeviceCharacteristics,
                                    FALSE,
                                    &AFSRDRDeviceObject);
 
         if( !NT_SUCCESS( ntStatus))
         {
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
                           "AFSInitRDRDevice IoCreateDevice failure %08lX\n",
-                          ntStatus);
+                          ntStatus));
 
             try_return( ntStatus);
         }
@@ -117,10 +139,10 @@ AFSInitRDRDevice()
         if ( !NT_SUCCESS(ntStatus))
         {
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
                           "AFSInitRDRDevice AFSInitRdrFcb failure %08lX\n",
-                          ntStatus);
+                          ntStatus));
 
             try_return( ntStatus);
         }
@@ -132,6 +154,13 @@ AFSInitRDRDevice()
         AFSRDRDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
 
         //
+        // Increase the StackSize to support the extra stack frame required
+        // for use of IoCompletion routines.
+        //
+
+        AFSRDRDeviceObject->StackSize++;
+
+        //
         // Register this device with MUP with FilterMgr if Vista or above
         //
 
@@ -144,10 +173,10 @@ AFSInitRDRDevice()
                                                     0);
             if ( !NT_SUCCESS( ntStatus))
             {
-                AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                               AFS_TRACE_LEVEL_ERROR,
                               "AFSInitRDRDevice FsRtlRegisterUncProvider failure %08lX\n",
-                              ntStatus);
+                              ntStatus));
             }
         }
         else
@@ -164,10 +193,10 @@ AFSInitRDRDevice()
             }
             else
             {
-                AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                               AFS_TRACE_LEVEL_ERROR,
                               "AFSInitRDRDevice FsRtlRegisterUncProvider failure %08lX\n",
-                              ntStatus);
+                              ntStatus));
             }
         }
 
@@ -365,10 +394,10 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
         if( !NT_SUCCESS( ntStatus))
         {
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
                           "AFSInitializeRedirector AFSLoadLibrary failure %08lX\n",
-                          ntStatus);
+                          ntStatus));
 
             try_return( ntStatus);
         }
@@ -397,9 +426,9 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
         if( AFSDumpFileLocation.Buffer == NULL)
         {
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
-                          "AFSInitializeRedirector AFS_GENERIC_MEMORY_23_TAG allocation error\n");
+                          "AFSInitializeRedirector AFS_GENERIC_MEMORY_23_TAG allocation error\n"));
 
             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
         }
@@ -511,6 +540,12 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
         }
 
         //
+       // Global Reparse Point Policy
+       //
+
+       pDevExt->Specific.RDR.ReparsePointPolicy = RedirInitInfo->GlobalReparsePointPolicy;
+
+       //
         // Are we performing direct to service IO?
         //
 
@@ -577,10 +612,10 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
                 RedirInitInfo->CacheFileNameLength == 0)
             {
 
-                AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                               AFS_TRACE_LEVEL_ERROR,
                               "AFSInitializeRedirector Unable to initialize cache file %08lX\n",
-                              ntStatus);
+                              ntStatus));
 
                 try_return( ntStatus);
             }
@@ -591,9 +626,9 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
                 if( RedirInitInfo->CacheFileNameLength == 0)
                 {
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                    AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                                   AFS_TRACE_LEVEL_ERROR,
-                                  "AFSInitializeRedirector CacheMdl == NULL\n");
+                                  "AFSInitializeRedirector CacheMdl == NULL\n"));
 
                     try_return( ntStatus = STATUS_INVALID_PARAMETER);
                 }
@@ -612,9 +647,9 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
                 if( pDevExt->Specific.RDR.CacheFile.Buffer == NULL)
                 {
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                    AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                                   AFS_TRACE_LEVEL_ERROR,
-                                  "AFSInitializeRedirector AFS_GENERIC_MEMORY_24_TAG allocation failure\n");
+                                  "AFSInitializeRedirector AFS_GENERIC_MEMORY_24_TAG allocation failure\n"));
 
                     try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
                 }
@@ -647,10 +682,10 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
                 if( !NT_SUCCESS( ntStatus))
                 {
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                    AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                                   AFS_TRACE_LEVEL_ERROR,
                                   "AFSInitializeRedirector ZwOpenFile failure %08lX\n",
-                                  ntStatus);
+                                  ntStatus));
 
                     try_return( ntStatus);
                 }
@@ -669,10 +704,10 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
                 if( !NT_SUCCESS( ntStatus))
                 {
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+                    AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                                   AFS_TRACE_LEVEL_ERROR,
                                   "AFSInitializeRedirector ObReferenceObjectByHandle failure %08lX\n",
-                                  ntStatus);
+                                  ntStatus));
 
                     try_return( ntStatus);
                 }
@@ -692,10 +727,10 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
 
         if ( !NT_SUCCESS( ntStatus))
         {
-            AFSDbgLogMsg( AFS_SUBSYSTEM_INIT_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_INIT_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
                           "AFSInitializeRedirector AFSInitializeLibrary failure %08lX\n",
-                          ntStatus);
+                          ntStatus));
         }
 
 try_exit:
@@ -878,9 +913,9 @@ AFSInitRdrFcb( OUT AFSFcb **RdrFcb)
         if( pFcb == NULL)
         {
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
-                          "AFSInitRdrFcb Failed to allocate the root fcb\n");
+                          "AFSInitRdrFcb Failed to allocate the root fcb\n"));
 
             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
         }
@@ -898,9 +933,9 @@ AFSInitRdrFcb( OUT AFSFcb **RdrFcb)
         if( pNPFcb == NULL)
         {
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+            AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
                           AFS_TRACE_LEVEL_ERROR,
-                          "AFSInitRdrFcb Failed to allocate the non-paged fcb\n");
+                          "AFSInitRdrFcb Failed to allocate the non-paged fcb\n"));
 
             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
         }
@@ -922,11 +957,11 @@ AFSInitRdrFcb( OUT AFSFcb **RdrFcb)
 
         ExInitializeResourceLite( &pNPFcb->Resource);
 
-        AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+        AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
                       AFS_TRACE_LEVEL_VERBOSE,
                       "AFSInitRootFcb Acquiring Fcb lock %p EXCL %08lX\n",
                       &pNPFcb->Resource,
-                      PsGetCurrentThread());
+                      PsGetCurrentThread()));
 
         ExInitializeResourceLite( &pNPFcb->PagingResource);