]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
winnt-enable-global-drive-mappings-20030701
authorDouglas Engert <deengert@anl.gov>
Tue, 1 Jul 2003 20:43:08 +0000 (20:43 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 1 Jul 2003 20:43:08 +0000 (20:43 +0000)
FIXES 1614

This will allow access to AFS from system processes and scheduled tasks.
It also means that each user does not have to map AFS to his own
drive.

src/WINNT/afsd/afsd_service.c

index 2923a2ed2eea29e48b119064c3a88694a17a1d24..f0050d3de1481fa8ff110504753c972c911535e9 100644 (file)
 #include <winnt/osi_malloc.h>
 
 #include <osi.h>
-\r
-#ifdef DEBUG\r
-//#define NOTSERVICE\r
-#endif\r
+
+#ifdef DEBUG
+//#define NOTSERVICE
+#endif
 
 extern void afsi_log(char *pattern, ...);
 
@@ -138,9 +138,10 @@ doneTrace:
        }
 }
 
-#if 0
+#if 1
 /* This code was moved to Drivemap.cpp*/
 /* Mount a drive into AFS if the user wants us to */
+/* DEE Could check first if we are run as SYSTEM */
 void CheckMountDrive()
 {
         char szAfsPath[_MAX_PATH];
@@ -172,9 +173,27 @@ void CheckMountDrive()
                         }
                 }
                 
+#if 0
                 sprintf(szAfsPath, "\\Device\\LanmanRedirector\\%s\\%s-AFS\\%s", szDriveToMapTo, cm_HostName, szSubMount);
         
                 dwResult = DefineDosDevice(DDD_RAW_TARGET_PATH, szDriveToMapTo, szAfsPath);
+#else
+               {
+                   NETRESOURCE nr;
+                   memset (&nr, 0x00, sizeof(NETRESOURCE));
+                   sprintf(szAfsPath,"\\\\%s-AFS\\%s",cm_HostName,szSubMount);
+                   
+                   nr.dwScope = RESOURCE_GLOBALNET;
+                   nr.dwType=RESOURCETYPE_DISK;
+                   nr.lpLocalName=szDriveToMapTo;
+                   nr.lpRemoteName=szAfsPath;
+                   nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;
+                   nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;
+
+                   dwResult = WNetAddConnection2(&nr,NULL,NULL,FALSE);
+               }
+#endif
                 afsi_log("GlobalAutoMap of %s to %s %s", szDriveToMapTo, szSubMount, dwResult ? "succeeded" : "failed");
         }        
 
@@ -195,7 +214,7 @@ void afsd_Main()
 
        WaitToTerminate = CreateEvent(NULL, TRUE, FALSE, NULL);
 
-#ifndef NOTSERVICE\r
+#ifndef NOTSERVICE
        StatusHandle = RegisterServiceCtrlHandler(AFS_DAEMON_SERVICE_NAME,
                        (LPHANDLER_FUNCTION) afsd_ServiceControlHandler);
 
@@ -252,7 +271,7 @@ void afsd_Main()
        }
 
         /* Check if we should mount a drive into AFS */
-/*        CheckMountDrive();*/
+        CheckMountDrive();
 
        WaitForSingleObject(WaitToTerminate, INFINITE);