From 5c69f42d131473b95a4fb988ee84c97044d6626c Mon Sep 17 00:00:00 2001 From: Douglas Engert Date: Tue, 1 Jul 2003 20:44:12 +0000 Subject: [PATCH] STABLE12-winnt-enable-global-drive-mappings-20030701 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. (cherry picked from commit 4bda27a286acb45ce87131eb43d80dbcbe5e5b39) --- src/WINNT/afsd/afsd_service.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index ed4cedeeb..69419ca41 100644 --- a/src/WINNT/afsd/afsd_service.c +++ b/src/WINNT/afsd/afsd_service.c @@ -20,10 +20,10 @@ #include #include - -#ifdef DEBUG -//#define NOTSERVICE -#endif + +#ifdef DEBUG +//#define NOTSERVICE +#endif extern void afsi_log(char *pattern, ...); @@ -137,9 +137,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]; @@ -171,9 +172,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"); } @@ -194,7 +213,7 @@ void afsd_Main() WaitToTerminate = CreateEvent(NULL, TRUE, FALSE, NULL); -#ifndef NOTSERVICE +#ifndef NOTSERVICE StatusHandle = RegisterServiceCtrlHandler(AFS_DAEMON_SERVICE_NAME, (LPHANDLER_FUNCTION) afsd_ServiceControlHandler); @@ -251,7 +270,7 @@ void afsd_Main() } /* Check if we should mount a drive into AFS */ -/* CheckMountDrive();*/ + CheckMountDrive(); WaitForSingleObject(WaitToTerminate, INFINITE); -- 2.39.5