Index: openafs/src/WINNT/afsd/afsd_init.c diff -c openafs/src/WINNT/afsd/afsd_init.c:1.40.2.11 openafs/src/WINNT/afsd/afsd_init.c:1.40.2.15 *** openafs/src/WINNT/afsd/afsd_init.c:1.40.2.11 Tue Dec 7 07:49:22 2004 --- openafs/src/WINNT/afsd/afsd_init.c Sun Jan 30 23:23:57 2005 *************** *** 388,400 **** long maxcpus; long ltt, ltto; long rx_mtu, rx_nojumbo; ! long virtualCache; char rootCellName[256]; struct rx_service *serverp; static struct rx_securityClass *nullServerSecurityClassp; struct hostent *thp; char *msgBuf; ! char buf[1024]; HKEY parmKey; DWORD dummyLen; DWORD regType; --- 388,400 ---- long maxcpus; long ltt, ltto; long rx_mtu, rx_nojumbo; ! long virtualCache = 0; char rootCellName[256]; struct rx_service *serverp; static struct rx_securityClass *nullServerSecurityClassp; struct hostent *thp; char *msgBuf; ! char buf[1024], *p, *q; HKEY parmKey; DWORD dummyLen; DWORD regType; *************** *** 622,630 **** } afsi_log("Cache path %s", cm_CachePath); } else { ! GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath)); ! cm_CachePath[2] = 0; /* get drive letter only */ ! StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache"); afsi_log("Default cache path %s", cm_CachePath); } --- 622,633 ---- } afsi_log("Cache path %s", cm_CachePath); } else { ! dummyLen = ExpandEnvironmentStrings("%TEMP%\\AFSCache", cm_CachePath, sizeof(cm_CachePath)); ! if (dummyLen > sizeof(cm_CachePath)) { ! afsi_log("Cache path [%%TEMP%%\\AFSCache] longer than %d after expanding env strings", ! sizeof(cm_CachePath)); ! osi_panic("CachePath too long", __FILE__, __LINE__); ! } afsi_log("Default cache path %s", cm_CachePath); } *************** *** 668,702 **** dummyLen = sizeof(buf); code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, buf, &dummyLen); ! if (code == ERROR_SUCCESS && buf[0]) { ! char * p, *q; ! afsi_log("Sys name %s", buf); ! for (p = q = buf; p < buf + dummyLen; p++) ! { ! if (*p == '\0' || isspace(*p)) { ! memcpy(cm_sysNameList[cm_sysNameCount],q,p-q); ! cm_sysNameList[cm_sysNameCount][p-q] = '\0'; ! cm_sysNameCount++; ! ! do { ! if (*p == '\0') ! goto done_sysname; ! ! p++; ! } while (*p == '\0' || isspace(*p)); ! q = p; ! p--; ! } } - done_sysname: - StringCbCopyA(cm_sysName, MAXSYSNAME, cm_sysNameList[0]); - } else { - cm_sysNameCount = 1; - StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40"); - StringCbCopyA(cm_sysNameList[0], MAXSYSNAME, "i386_nt40"); - afsi_log("Default sys name %s", cm_sysName); } dummyLen = sizeof(cryptall); code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL, --- 671,706 ---- dummyLen = sizeof(buf); code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, buf, &dummyLen); ! if (code != ERROR_SUCCESS || !buf[0]) { ! #if defined(_IA64_) ! StringCbCopyA(buf, sizeof(buf), "ia64_win64"); ! #elif defined(_AMD64) ! StringCbCopyA(buf, sizeof(buf), "amd64_win64"); ! #else /* assume x86 32-bit */ ! StringCbCopyA(buf, sizeof(buf), "x86_win32 i386_w2k i386_nt40"); ! #endif ! } ! afsi_log("Sys name %s", buf); ! /* breakup buf into individual search string entries */ ! for (p = q = buf; p < buf + dummyLen; p++) ! { ! if (*p == '\0' || isspace(*p)) { ! memcpy(cm_sysNameList[cm_sysNameCount],q,p-q); ! cm_sysNameList[cm_sysNameCount][p-q] = '\0'; ! cm_sysNameCount++; ! ! do { ! if (*p == '\0') ! goto done_sysname; ! p++; ! } while (*p == '\0' || isspace(*p)); ! q = p; ! p--; } } + done_sysname: + StringCbCopyA(cm_sysName, MAXSYSNAME, cm_sysNameList[0]); dummyLen = sizeof(cryptall); code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL, *************** *** 890,931 **** /* Ensure the AFS Netbios Name is registered to allow loopback access */ configureBackConnectionHostNames(); - /* initialize RX, and tell it to listen to port 7001, which is used for - * callback RPC messages. - */ - code = rx_Init(htons(7001)); - afsi_log("rx_Init code %x", code); - if (code != 0) { - *reasonP = "afsd: failed to init rx client on port 7001"; - return -1; - } - - /* Initialize the RPC server for session keys */ - RpcInit(); - - /* create an unauthenticated service #1 for callbacks */ - nullServerSecurityClassp = rxnull_NewServerSecurityObject(); - serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1, - RXAFSCB_ExecuteRequest); - afsi_log("rx_NewService addr %x", (int)serverp); - if (serverp == NULL) { - *reasonP = "unknown error"; - return -1; - } - - nullServerSecurityClassp = rxnull_NewServerSecurityObject(); - serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", - &nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest); - afsi_log("rx_NewService addr %x", (int)serverp); - if (serverp == NULL) { - *reasonP = "unknown error"; - return -1; - } - - /* start server threads, *not* donating this one to the pool */ - rx_StartServer(0); - afsi_log("rx_StartServer"); - /* init user daemon, and other packages */ cm_InitUser(); --- 894,899 ---- *************** *** 962,967 **** --- 930,968 ---- #endif #endif + /* initialize RX, and tell it to listen to port 7001, which is used for + * callback RPC messages. + */ + code = rx_Init(htons(7001)); + afsi_log("rx_Init code %x", code); + if (code != 0) { + *reasonP = "afsd: failed to init rx client on port 7001"; + return -1; + } + + /* create an unauthenticated service #1 for callbacks */ + nullServerSecurityClassp = rxnull_NewServerSecurityObject(); + serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1, + RXAFSCB_ExecuteRequest); + afsi_log("rx_NewService addr %x", (int)serverp); + if (serverp == NULL) { + *reasonP = "unknown error"; + return -1; + } + + nullServerSecurityClassp = rxnull_NewServerSecurityObject(); + serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", + &nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest); + afsi_log("rx_NewService addr %x", (int)serverp); + if (serverp == NULL) { + *reasonP = "unknown error"; + return -1; + } + + /* start server threads, *not* donating this one to the pool */ + rx_StartServer(0); + afsi_log("rx_StartServer"); + code = cm_GetRootCellName(rootCellName); afsi_log("cm_GetRootCellName code %d, cm_freelanceEnabled= %d, rcn= %s", code, cm_freelanceEnabled, (code ? "" : rootCellName)); *************** *** 988,993 **** --- 989,998 ---- if (cm_freelanceEnabled) cm_InitFreelance(); #endif + + /* Initialize the RPC server for session keys */ + RpcInit(); + return 0; } Index: openafs/src/WINNT/afsd/afsd_service.c diff -c openafs/src/WINNT/afsd/afsd_service.c:1.28.2.8 openafs/src/WINNT/afsd/afsd_service.c:1.28.2.12 *** openafs/src/WINNT/afsd/afsd_service.c:1.28.2.8 Tue Dec 7 01:02:46 2004 --- openafs/src/WINNT/afsd/afsd_service.c Sun Jan 30 23:09:28 2005 *************** *** 171,180 **** long code; switch (ctrlCode) { case SERVICE_CONTROL_STOP: ! /* Shutdown RPC */ ! RpcMgmtStopServerListening(NULL); /* Force trace if requested */ code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, --- 171,188 ---- long code; switch (ctrlCode) { + case SERVICE_CONTROL_SHUTDOWN: case SERVICE_CONTROL_STOP: ! ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; ! ServiceStatus.dwWin32ExitCode = NO_ERROR; ! ServiceStatus.dwCheckPoint = 1; ! ServiceStatus.dwWaitHint = 30000; ! ServiceStatus.dwControlsAccepted = 0; ! SetServiceStatus(StatusHandle, &ServiceStatus); + #ifdef FLUSH_VOLUME + afsd_ServiceFlushVolume((DWORD) lpEventData); + #endif /* Force trace if requested */ code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, *************** *** 195,214 **** } doneTrace: - ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; - ServiceStatus.dwWin32ExitCode = NO_ERROR; - ServiceStatus.dwCheckPoint = 1; - ServiceStatus.dwWaitHint = 10000; - ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; - SetServiceStatus(StatusHandle, &ServiceStatus); SetEvent(WaitToTerminate); break; case SERVICE_CONTROL_INTERROGATE: ServiceStatus.dwCurrentState = SERVICE_RUNNING; ServiceStatus.dwWin32ExitCode = NO_ERROR; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; ! ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; SetServiceStatus(StatusHandle, &ServiceStatus); break; /* XXX handle system shutdown */ --- 203,217 ---- } doneTrace: SetEvent(WaitToTerminate); break; + case SERVICE_CONTROL_INTERROGATE: ServiceStatus.dwCurrentState = SERVICE_RUNNING; ServiceStatus.dwWin32ExitCode = NO_ERROR; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; ! ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; SetServiceStatus(StatusHandle, &ServiceStatus); break; /* XXX handle system shutdown */ *************** *** 236,244 **** switch (ctrlCode) { case SERVICE_CONTROL_STOP: ! /* Shutdown RPC */ ! RpcMgmtStopServerListening(NULL); /* Force trace if requested */ code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, --- 239,256 ---- switch (ctrlCode) { + case SERVICE_CONTROL_SHUTDOWN: case SERVICE_CONTROL_STOP: ! ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; ! ServiceStatus.dwWin32ExitCode = NO_ERROR; ! ServiceStatus.dwCheckPoint = 1; ! ServiceStatus.dwWaitHint = 30000; ! ServiceStatus.dwControlsAccepted = 0; ! SetServiceStatus(StatusHandle, &ServiceStatus); ! ! #ifdef FLUSH_VOLUME ! afsd_ServiceFlushVolume((DWORD) lpEventData); ! #endif /* Force trace if requested */ code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, *************** *** 260,271 **** } doneTrace: - ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; - ServiceStatus.dwWin32ExitCode = NO_ERROR; - ServiceStatus.dwCheckPoint = 1; - ServiceStatus.dwWaitHint = 10000; - ServiceStatus.dwControlsAccepted = 0; - SetServiceStatus(StatusHandle, &ServiceStatus); SetEvent(WaitToTerminate); dwRet = NO_ERROR; break; --- 272,277 ---- *************** *** 275,281 **** ServiceStatus.dwWin32ExitCode = NO_ERROR; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; ! ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_POWEREVENT; SetServiceStatus(StatusHandle, &ServiceStatus); dwRet = NO_ERROR; break; --- 281,287 ---- ServiceStatus.dwWin32ExitCode = NO_ERROR; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; ! ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_POWEREVENT; SetServiceStatus(StatusHandle, &ServiceStatus); dwRet = NO_ERROR; break; *************** *** 966,972 **** RegisterServiceCtrlHandlerExFunc pRegisterServiceCtrlHandlerEx = NULL; RegisterServiceCtrlHandlerFunc pRegisterServiceCtrlHandler = NULL; ! void afsd_Main(DWORD argc, LPTSTR *argv) { long code; char *reason; --- 972,978 ---- RegisterServiceCtrlHandlerExFunc pRegisterServiceCtrlHandlerEx = NULL; RegisterServiceCtrlHandlerFunc pRegisterServiceCtrlHandler = NULL; ! VOID WINAPI afsd_Main(DWORD argc, LPTSTR *argv) { long code; char *reason; *************** *** 1155,1161 **** ServiceStatus.dwWaitHint = 0; /* accept Power events */ ! ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_POWEREVENT; SetServiceStatus(StatusHandle, &ServiceStatus); #endif { --- 1161,1167 ---- ServiceStatus.dwWaitHint = 0; /* accept Power events */ ! ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_POWEREVENT; SetServiceStatus(StatusHandle, &ServiceStatus); #endif { *************** *** 1181,1186 **** --- 1187,1194 ---- DismountGlobalDrives(); smb_Shutdown(); rx_Finalize(); + RpcShutdown(); + buf_Shutdown(); #ifdef REGISTER_POWER_NOTIFICATIONS /* terminate thread used to flush cache */ Index: openafs/src/WINNT/afsd/afsd_service.rc diff -c openafs/src/WINNT/afsd/afsd_service.rc:1.3 openafs/src/WINNT/afsd/afsd_service.rc:1.3.2.1 *** openafs/src/WINNT/afsd/afsd_service.rc:1.3 Thu Jun 19 15:00:46 2003 --- openafs/src/WINNT/afsd/afsd_service.rc Sun Jan 30 23:09:28 2005 *************** *** 13,17 **** --- 13,20 ---- #define AFS_VERINFO_NAME "afsd_service" #define AFS_VERINFO_FILENAME "afsd_service.exe" + 1 ICON afsd.ico + #include "AFS_component_version_number.h" #include "..\..\config\NTVersioninfo.rc" + Index: openafs/src/WINNT/afsd/afskfw.c diff -c openafs/src/WINNT/afsd/afskfw.c:1.8.2.5 openafs/src/WINNT/afsd/afskfw.c:1.8.2.7 *** openafs/src/WINNT/afsd/afskfw.c:1.8.2.5 Fri Nov 5 14:21:42 2004 --- openafs/src/WINNT/afsd/afskfw.c Sun Jan 30 23:08:57 2005 *************** *** 63,68 **** --- 63,69 ---- #include #include /* for life_to_time */ #include + #include /* * TIMING _____________________________________________________________________ *************** *** 2509,2515 **** * level */ ! if (status = pr_Initialize(1L, confname, aserver->cell, 0)) return status; if (status = pr_CreateUser(username, &id)) return status; --- 2510,2516 ---- * level */ ! if (status = pr_Initialize(1L, confname, aserver->cell)) return status; if (status = pr_CreateUser(username, &id)) return status; Index: openafs/src/WINNT/afsd/afslogon.c diff -c openafs/src/WINNT/afsd/afslogon.c:1.24.2.4 openafs/src/WINNT/afsd/afslogon.c:1.24.2.5 *** openafs/src/WINNT/afsd/afslogon.c:1.24.2.4 Tue Dec 7 07:49:23 2004 --- openafs/src/WINNT/afsd/afslogon.c Sun Jan 30 23:05:00 2005 *************** *** 254,259 **** --- 254,281 ---- return (Status.dwCurrentState == SERVICE_RUNNING); } + BOOL IsServiceStartPending (void) + { + SERVICE_STATUS Status; + SC_HANDLE hManager; + memset (&Status, 0x00, sizeof(Status)); + Status.dwCurrentState = SERVICE_STOPPED; + + if ((hManager = OpenSCManager (NULL, NULL, GENERIC_READ)) != NULL) + { + SC_HANDLE hService; + if ((hService = OpenService (hManager, TEXT("TransarcAFSDaemon"), GENERIC_READ)) != NULL) + { + QueryServiceStatus (hService, &Status); + CloseServiceHandle (hService); + } + + CloseServiceHandle (hManager); + } + DebugEvent("AFS AfsLogon - Test Service Start Pending","Return Code[%x] ?Start Pending[%d]",Status.dwCurrentState,(Status.dwCurrentState == SERVICE_START_PENDING)); + return (Status.dwCurrentState == SERVICE_RUNNING); + } + /* LOOKUPKEYCHAIN: macro to look up the value in the list of keys in order until it's found v:variable to receive value (reference type) t:type *************** *** 550,555 **** --- 572,581 ---- GetCPInfo(CP_ACP, &CodePageInfo); + if (CodePageInfo.MaxCharSize > 1) + // Only supporting non-Unicode strings + return FALSE; + if (uInputString.Buffer && ((LPBYTE) uInputString.Buffer)[1] == '\0') { // Looks like unicode, better translate it *************** *** 561,567 **** } else lpszOutputString[0] = '\0'; - return FALSE; } // UnicodeStringToANSI --- 587,592 ---- *************** *** 654,659 **** --- 679,687 ---- sleepInterval = opt.sleepInterval; *lpLogonScript = opt.logonScript; + if (retryInterval < sleepInterval) + sleepInterval = retryInterval; + DebugEvent("Got logon script: %S",opt.logonScript); afsWillAutoStart = AFSWillAutoStart(); *************** *** 687,693 **** /* We get the user's home directory path, if applicable, though we can't lookup the cell right away because the client service may not have started yet. This call also sets the AD_REALM flag in opt.flags if applicable. */ ! if(ISREMOTE(opt.flags)) { DebugEvent("Is Remote"); GetAdHomePath(homePath,MAX_PATH,lpLogonId,&opt); } --- 715,721 ---- /* We get the user's home directory path, if applicable, though we can't lookup the cell right away because the client service may not have started yet. This call also sets the AD_REALM flag in opt.flags if applicable. */ ! if (ISREMOTE(opt.flags)) { DebugEvent("Is Remote"); GetAdHomePath(homePath,MAX_PATH,lpLogonId,&opt); } *************** *** 698,706 **** DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]", opt.LogonOption,afsWillAutoStart); ! if(ISADREALM(opt.flags)) { code = GetFileCellName(homePath,cell,256); ! if(!code) { DebugEvent("profile path [%s] is in cell [%s]",homePath,cell); } /* Don't bail out if GetFileCellName failed. --- 726,734 ---- DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]", opt.LogonOption,afsWillAutoStart); ! if (ISADREALM(opt.flags)) { code = GetFileCellName(homePath,cell,256); ! if (!code) { DebugEvent("profile path [%s] is in cell [%s]",homePath,cell); } /* Don't bail out if GetFileCellName failed. *************** *** 728,756 **** *ctemp = tolower(*ctemp); } uppercased_name = FALSE; ! continue; } } else { /*JUST check to see if its running*/ if (IsServiceRunning()) break; ! code = KTC_NOCM; ! if (!afsWillAutoStart) break; } - /* is service started yet?*/ - DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]", - code,uname,cell); - - /* If we've failed because the client isn't running yet and the - * client is set to autostart (and therefore it makes sense for - * us to wait for it to start) then sleep a while and try again. - * If the error was something else, then give up. */ - if (code != KTC_NOCM && code != KTC_NOCMRPC || !afsWillAutoStart) - break; - /* If the retry interval has expired and we still aren't * logged in, then just give up if we are not in interactive * mode or the failSilently flag is set, otherwise let the --- 756,786 ---- *ctemp = tolower(*ctemp); } uppercased_name = FALSE; ! goto sleeping; } + + /* is service started yet?*/ + DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]", + code,uname,cell); + + /* If we've failed because the client isn't running yet and the + * client is set to autostart (and therefore it makes sense for + * us to wait for it to start) then sleep a while and try again. + * If the error was something else, then give up. */ + if (code != KTC_NOCM && code != KTC_NOCMRPC || !afsWillAutoStart) + break; } else { /*JUST check to see if its running*/ if (IsServiceRunning()) break; ! if (afsWillAutoStart && !IsServiceStartPending()) { ! code = KTC_NOCMRPC; ! reason = "AFS Service start failed"; break; + } } /* If the retry interval has expired and we still aren't * logged in, then just give up if we are not in interactive * mode or the failSilently flag is set, otherwise let the *************** *** 767,780 **** break; /* Wait just a little while and try again */ ! retryInterval = sleepInterval = DEFAULT_SLEEP_INTERVAL; } ! if (retryInterval < sleepInterval) ! sleepInterval = retryInterval; ! Sleep(sleepInterval * 1000); - retryInterval -= sleepInterval; } --- 797,807 ---- break; /* Wait just a little while and try again */ ! retryInterval = opt.retryInterval; } ! sleeping: Sleep(sleepInterval * 1000); retryInterval -= sleepInterval; } *************** *** 809,815 **** *lpLogonScript = NULL; if (!afsWillAutoStart) // its not running, so if not autostart or integrated logon then just skip code = 0; - } } --- 836,841 ---- Index: openafs/src/WINNT/afsd/afslogon.h diff -c openafs/src/WINNT/afsd/afslogon.h:1.5 openafs/src/WINNT/afsd/afslogon.h:1.5.2.1 *** openafs/src/WINNT/afsd/afslogon.h:1.5 Wed Aug 4 15:30:03 2004 --- openafs/src/WINNT/afsd/afslogon.h Sun Jan 30 23:05:01 2005 *************** *** 41,47 **** #define REG_CLIENT_TRACE_OPTION_PARM "TraceOption" #define REG_CLIENT_LOGON_OPTION_PARM "LogonOptions" #define REG_CLIENT_LOGON_SCRIPT_PARMW L"LogonScript" ! #define DEFAULT_RETRY_INTERVAL 30 /* seconds*/ #define DEFAULT_FAIL_SILENTLY FALSE #define DEFAULT_SLEEP_INTERVAL 5 /* seconds*/ #define DEFAULT_LOGON_OPTION 1 --- 41,47 ---- #define REG_CLIENT_TRACE_OPTION_PARM "TraceOption" #define REG_CLIENT_LOGON_OPTION_PARM "LogonOptions" #define REG_CLIENT_LOGON_SCRIPT_PARMW L"LogonScript" ! #define DEFAULT_RETRY_INTERVAL 60 /* seconds*/ #define DEFAULT_FAIL_SILENTLY FALSE #define DEFAULT_SLEEP_INTERVAL 5 /* seconds*/ #define DEFAULT_LOGON_OPTION 1 Index: openafs/src/WINNT/afsd/cm_aclent.c diff -c openafs/src/WINNT/afsd/cm_aclent.c:1.4 openafs/src/WINNT/afsd/cm_aclent.c:1.4.2.3 *** openafs/src/WINNT/afsd/cm_aclent.c:1.4 Sun Apr 4 22:16:11 2004 --- openafs/src/WINNT/afsd/cm_aclent.c Sun Jan 30 23:24:44 2005 *************** *** 28,75 **** * An aclent structure is free if it has no back vnode pointer. */ osi_rwlock_t cm_aclLock; /* lock for system's aclents */ ! cm_aclent_t *cm_aclLRUp; /* LRUQ for dudes in vnodes' lists */ ! cm_aclent_t *cm_aclLRUEndp; /* ditto */ ! /* * Get an acl cache entry for a particular user and file, or return that it doesn't exist. * Called with the scp locked. */ long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, long *rightsp) { ! cm_aclent_t *aclp; ! lock_ObtainWrite(&cm_aclLock); ! for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) { ! if (aclp->userp == userp) { ! if (aclp->tgtLifetime && aclp->tgtLifetime <= (long) osi_Time()) { ! /* ticket expired */ ! aclp->tgtLifetime = 0; ! *rightsp = 0; ! break; /* get a new acl from server */ ! } ! else { ! *rightsp = aclp->randomAccess; ! if (cm_aclLRUEndp == aclp) ! cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); ! ! /* move to the head of the LRU queue */ ! osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q); ! osi_QAddH((osi_queue_t **) &cm_aclLRUp, ! (osi_queue_t **) &cm_aclLRUEndp, ! &aclp->q); ! } ! lock_ReleaseWrite(&cm_aclLock); ! return 0; ! } ! } ! ! /* ! * If we make it here, this entry isn't present, so we're going to fail. ! */ ! lock_ReleaseWrite(&cm_aclLock); ! return -1; ! } /* --- 28,74 ---- * An aclent structure is free if it has no back vnode pointer. */ osi_rwlock_t cm_aclLock; /* lock for system's aclents */ ! cm_aclent_t *cm_aclLRUp; /* LRUQ for dudes in vnode's lists */ ! cm_aclent_t *cm_aclLRUEndp; /* ditto */ /* * Get an acl cache entry for a particular user and file, or return that it doesn't exist. * Called with the scp locked. */ long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, long *rightsp) { ! cm_aclent_t *aclp; ! long retval = -1; ! lock_ObtainWrite(&cm_aclLock); ! for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) { ! if (aclp->userp == userp) { ! if (aclp->tgtLifetime && aclp->tgtLifetime <= (long) osi_Time()) { ! /* ticket expired */ ! aclp->tgtLifetime = 0; ! *rightsp = 0; /* get a new acl from server */ ! ! /* Shouldn't we remove this entry from the scp? ! * 2005-01-25 - jaltman@secure-endpoints.com ! */ ! } else { ! *rightsp = aclp->randomAccess; ! if (cm_aclLRUEndp == aclp) ! cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); ! ! /* move to the head of the LRU queue */ ! osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q); ! osi_QAddH((osi_queue_t **) &cm_aclLRUp, ! (osi_queue_t **) &cm_aclLRUEndp, ! &aclp->q); ! retval = 0; /* success */ ! } ! break; ! } ! } ! ! lock_ReleaseWrite(&cm_aclLock); ! return retval; ! } /* *************** *** 78,115 **** */ static cm_aclent_t *GetFreeACLEnt(void) { ! cm_aclent_t *aclp; ! cm_aclent_t *taclp; ! cm_aclent_t **laclpp; ! ! if (cm_aclLRUp == NULL) ! osi_panic("empty aclent LRU", __FILE__, __LINE__); ! ! aclp = cm_aclLRUEndp; ! if (aclp == cm_aclLRUEndp) ! cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); ! osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q); ! if (aclp->backp) { ! /* ! * Remove the entry from the vnode's list ! */ ! laclpp = &aclp->backp->randomACLp; ! for (taclp = *laclpp; taclp; laclpp = &taclp->nextp, taclp = *laclpp) { ! if (taclp == aclp) ! break; ! } ! if (!taclp) ! osi_panic("GetFreeACLEnt race", __FILE__, __LINE__); ! *laclpp = aclp->nextp; /* remove from vnode list */ ! aclp->backp = NULL; ! } ! /* release the old user */ if (aclp->userp) { ! cm_ReleaseUser(aclp->userp); aclp->userp = NULL; ! } ! return aclp; } --- 77,114 ---- */ static cm_aclent_t *GetFreeACLEnt(void) { ! cm_aclent_t *aclp; ! cm_aclent_t *taclp; ! cm_aclent_t **laclpp; ! ! if (cm_aclLRUp == NULL) ! osi_panic("empty aclent LRU", __FILE__, __LINE__); ! ! aclp = cm_aclLRUEndp; ! if (aclp == cm_aclLRUEndp) ! cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); ! osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q); ! if (aclp->backp) { ! /* ! * Remove the entry from the vnode's list ! */ ! laclpp = &aclp->backp->randomACLp; ! for (taclp = *laclpp; taclp; laclpp = &taclp->nextp, taclp = *laclpp) { ! if (taclp == aclp) ! break; ! } ! if (!taclp) ! osi_panic("GetFreeACLEnt race", __FILE__, __LINE__); ! *laclpp = aclp->nextp; /* remove from vnode list */ ! aclp->backp = NULL; ! } ! /* release the old user */ if (aclp->userp) { ! cm_ReleaseUser(aclp->userp); aclp->userp = NULL; ! } ! return aclp; } *************** *** 121,156 **** */ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights) { ! register struct cm_aclent *aclp; ! lock_ObtainWrite(&cm_aclLock); ! for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) { ! if (aclp->userp == userp) { ! aclp->randomAccess = rights; ! if (aclp->tgtLifetime == 0) ! aclp->tgtLifetime = cm_TGTLifeTime(pag); ! lock_ReleaseWrite(&cm_aclLock); ! return 0; ! } ! } ! ! /* ! * Didn't find the dude we're looking for, so take someone from the LRUQ ! * and reuse. But first try the free list and see if there's already ! * someone there. ! */ ! aclp = GetFreeACLEnt(); /* can't fail, panics instead */ ! osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q); ! aclp->backp = scp; ! aclp->nextp = scp->randomACLp; ! scp->randomACLp = aclp; cm_HoldUser(userp); ! aclp->userp = userp; ! aclp->randomAccess = rights; ! aclp->tgtLifetime = cm_TGTLifeTime(userp); ! lock_ReleaseWrite(&cm_aclLock); ! return 0; } /* --- 120,155 ---- */ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights) { ! register struct cm_aclent *aclp; ! lock_ObtainWrite(&cm_aclLock); ! for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) { ! if (aclp->userp == userp) { ! aclp->randomAccess = rights; ! if (aclp->tgtLifetime == 0) ! aclp->tgtLifetime = cm_TGTLifeTime(pag); ! lock_ReleaseWrite(&cm_aclLock); ! return 0; ! } ! } ! ! /* ! * Didn't find the dude we're looking for, so take someone from the LRUQ ! * and reuse. But first try the free list and see if there's already ! * someone there. ! */ ! aclp = GetFreeACLEnt(); /* can't fail, panics instead */ ! osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q); ! aclp->backp = scp; ! aclp->nextp = scp->randomACLp; ! scp->randomACLp = aclp; cm_HoldUser(userp); ! aclp->userp = userp; ! aclp->randomAccess = rights; ! aclp->tgtLifetime = cm_TGTLifeTime(userp); ! lock_ReleaseWrite(&cm_aclLock); ! return 0; } /* *************** *** 158,189 **** */ long cm_InitACLCache(long size) { ! cm_aclent_t *aclp; ! long i; ! static osi_once_t once; ! ! ! if (osi_Once(&once)) { ! lock_InitializeRWLock(&cm_aclLock, "cm_aclLock"); ! osi_EndOnce(&once); ! } ! ! lock_ObtainWrite(&cm_aclLock); ! cm_aclLRUp = cm_aclLRUEndp = NULL; ! aclp = (cm_aclent_t *) malloc(size * sizeof(cm_aclent_t)); ! memset(aclp, 0, size * sizeof(cm_aclent_t)); ! ! /* ! * Put all of these guys on the LRU queue ! */ ! for (i = 0; i < size; i++) { ! osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, ! &aclp->q); ! aclp++; ! } ! ! lock_ReleaseWrite(&cm_aclLock); ! return 0; } --- 157,185 ---- */ long cm_InitACLCache(long size) { ! cm_aclent_t *aclp; ! long i; ! static osi_once_t once; ! ! if (osi_Once(&once)) { ! lock_InitializeRWLock(&cm_aclLock, "cm_aclLock"); ! osi_EndOnce(&once); ! } ! ! lock_ObtainWrite(&cm_aclLock); ! cm_aclLRUp = cm_aclLRUEndp = NULL; ! aclp = (cm_aclent_t *) malloc(size * sizeof(cm_aclent_t)); ! memset(aclp, 0, size * sizeof(cm_aclent_t)); ! ! /* ! * Put all of these guys on the LRU queue ! */ ! for (i = 0; i < size; i++) { ! osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q); ! aclp++; ! } ! lock_ReleaseWrite(&cm_aclLock); ! return 0; } *************** *** 194,215 **** */ void cm_FreeAllACLEnts(cm_scache_t *scp) { ! cm_aclent_t *aclp; ! cm_aclent_t *taclp; ! lock_ObtainWrite(&cm_aclLock); ! for (aclp = scp->randomACLp; aclp; aclp = taclp) { ! taclp = aclp->nextp; ! if (aclp->userp) { ! cm_ReleaseUser(aclp->userp); ! aclp->userp = NULL; ! } ! aclp->backp = (struct cm_scache *) 0; ! } ! ! scp->randomACLp = (struct cm_aclent *) 0; ! scp->anyAccess = 0; /* reset this, too */ ! lock_ReleaseWrite(&cm_aclLock); } --- 190,211 ---- */ void cm_FreeAllACLEnts(cm_scache_t *scp) { ! cm_aclent_t *aclp; ! cm_aclent_t *taclp; ! lock_ObtainWrite(&cm_aclLock); ! for (aclp = scp->randomACLp; aclp; aclp = taclp) { ! taclp = aclp->nextp; ! if (aclp->userp) { ! cm_ReleaseUser(aclp->userp); ! aclp->userp = NULL; ! } ! aclp->backp = (struct cm_scache *) 0; ! } ! ! scp->randomACLp = (struct cm_aclent *) 0; ! scp->anyAccess = 0; /* reset this, too */ ! lock_ReleaseWrite(&cm_aclLock); } *************** *** 220,238 **** */ void cm_InvalidateACLUser(cm_scache_t *scp, cm_user_t *userp) { ! cm_aclent_t *aclp; ! cm_aclent_t **laclpp; ! lock_ObtainWrite(&cm_aclLock); ! laclpp = &scp->randomACLp; ! for (aclp = *laclpp; aclp; laclpp = &aclp->nextp, aclp = *laclpp) { ! if (userp == aclp->userp) { /* One for a given user/scache */ ! *laclpp = aclp->nextp; cm_ReleaseUser(aclp->userp); aclp->userp = NULL; ! aclp->backp = (struct cm_scache *) 0; ! break; ! } ! } ! lock_ReleaseWrite(&cm_aclLock); } --- 216,234 ---- */ void cm_InvalidateACLUser(cm_scache_t *scp, cm_user_t *userp) { ! cm_aclent_t *aclp; ! cm_aclent_t **laclpp; ! lock_ObtainWrite(&cm_aclLock); ! laclpp = &scp->randomACLp; ! for (aclp = *laclpp; aclp; laclpp = &aclp->nextp, aclp = *laclpp) { ! if (userp == aclp->userp) { /* One for a given user/scache */ ! *laclpp = aclp->nextp; cm_ReleaseUser(aclp->userp); aclp->userp = NULL; ! aclp->backp = (struct cm_scache *) 0; ! break; ! } ! } ! lock_ReleaseWrite(&cm_aclLock); } Index: openafs/src/WINNT/afsd/cm_buf.c diff -c openafs/src/WINNT/afsd/cm_buf.c:1.13.2.5 openafs/src/WINNT/afsd/cm_buf.c:1.13.2.7 *** openafs/src/WINNT/afsd/cm_buf.c:1.13.2.5 Tue Dec 7 01:01:41 2004 --- openafs/src/WINNT/afsd/cm_buf.c Sun Jan 30 23:08:57 2005 *************** *** 86,91 **** --- 86,94 ---- static HANDLE CacheHandle; + static + VOID * ViewOfFile; + static SYSTEM_INFO sysInfo; #endif /* !DJGPP */ *************** *** 316,325 **** --- 319,338 ---- afsi_log("Error creating cache file \"%s\" error %d", cm_CachePath, GetLastError()); return CM_ERROR_INVAL; + } else if (GetLastError() == ERROR_ALREADY_EXISTS) { + BY_HANDLE_FILE_INFORMATION fileInfo; + + afsi_log("Cache File \"%s\" already exists", cm_CachePath); + if ( GetFileInformationByHandle(hf, &fileInfo) ) + afsi_log("Existing File Size: %08X:%08X", + fileInfo.nFileSizeHigh, + fileInfo.nFileSizeLow); } } else { /* buf_cacheType == CM_BUF_CACHETYPE_VIRTUAL */ hf = INVALID_HANDLE_VALUE; } + afsi_log("File Mapping Size: %08X", buf_nbuffers * buf_bufferSize); + CacheHandle = hf; hm = CreateFileMapping(hf, NULL, *************** *** 328,344 **** NULL); if (hm == NULL) { if (GetLastError() == ERROR_DISK_FULL) { ! afsi_log("Error creating cache file \"%s\" mapping: disk full", ! cm_CachePath); return CM_ERROR_TOOMANYBUFS; } return CM_ERROR_INVAL; } ! data = MapViewOfFile(hm, ! FILE_MAP_ALL_ACCESS, ! 0, 0, ! buf_nbuffers * buf_bufferSize); ! if (data == NULL) { afsi_log("Error mapping view of file: 0x%X", GetLastError()); if (hf != INVALID_HANDLE_VALUE) CloseHandle(hf); --- 341,356 ---- NULL); if (hm == NULL) { if (GetLastError() == ERROR_DISK_FULL) { ! afsi_log("Error creating cache file mapping: disk full"); return CM_ERROR_TOOMANYBUFS; } return CM_ERROR_INVAL; } ! ViewOfFile = MapViewOfFile(hm, ! FILE_MAP_ALL_ACCESS, ! 0, 0, ! buf_nbuffers * buf_bufferSize); ! if (ViewOfFile == NULL) { afsi_log("Error mapping view of file: 0x%X", GetLastError()); if (hf != INVALID_HANDLE_VALUE) CloseHandle(hf); *************** *** 346,351 **** --- 358,365 ---- return CM_ERROR_INVAL; } CloseHandle(hm); + + data = ViewOfFile; #else /* djgpp doesn't support memory mapped files */ data = malloc(buf_nbuffers * buf_bufferSize); *************** *** 406,411 **** --- 420,432 ---- return 0; } + void + buf_Shutdown(void) + { + UnmapViewOfFile(ViewOfFile); + CloseHandle(CacheHandle); + } + /* add nbuffers to the buffer pool, if possible. * Called with no locks held. */ Index: openafs/src/WINNT/afsd/cm_buf.h diff -c openafs/src/WINNT/afsd/cm_buf.h:1.4.2.3 openafs/src/WINNT/afsd/cm_buf.h:1.4.2.4 *** openafs/src/WINNT/afsd/cm_buf.h:1.4.2.3 Fri Nov 5 14:21:43 2004 --- openafs/src/WINNT/afsd/cm_buf.h Sun Jan 30 22:53:23 2005 *************** *** 142,147 **** --- 142,149 ---- extern long buf_Init(cm_buf_ops_t *); + extern void buf_Shutdown(void); + extern long buf_CountFreeList(void); extern void buf_Release(cm_buf_t *); Index: openafs/src/WINNT/afsd/cm_callback.c diff -c openafs/src/WINNT/afsd/cm_callback.c:1.20.2.6 openafs/src/WINNT/afsd/cm_callback.c:1.20.2.7 *** openafs/src/WINNT/afsd/cm_callback.c:1.20.2.6 Tue Dec 7 00:58:20 2004 --- openafs/src/WINNT/afsd/cm_callback.c Sun Jan 30 23:08:57 2005 *************** *** 775,787 **** */ lock_ReleaseMutex(&scp->mx); cm_CallbackNotifyChange(scp); lock_ObtainMutex(&scp->mx); } ! if (freeFlag) free(revp); } /* if we freed the list, zap the pointer to it */ ! if (freeFlag) cm_racingRevokesp = NULL; lock_ReleaseWrite(&cm_callbackLock); --- 775,791 ---- */ lock_ReleaseMutex(&scp->mx); cm_CallbackNotifyChange(scp); + lock_ReleaseWrite(&cm_callbackLock); lock_ObtainMutex(&scp->mx); + lock_ObtainWrite(&cm_callbackLock); } ! if (freeFlag) ! free(revp); } /* if we freed the list, zap the pointer to it */ ! if (freeFlag) ! cm_racingRevokesp = NULL; lock_ReleaseWrite(&cm_callbackLock); Index: openafs/src/WINNT/afsd/cm_cell.c diff -c openafs/src/WINNT/afsd/cm_cell.c:1.14.2.1 openafs/src/WINNT/afsd/cm_cell.c:1.14.2.3 *** openafs/src/WINNT/afsd/cm_cell.c:1.14.2.1 Tue Aug 17 13:16:02 2004 --- openafs/src/WINNT/afsd/cm_cell.c Sun Jan 30 23:08:49 2005 *************** *** 95,106 **** memset(cp, 0, sizeof(cm_cell_t)); } else { dns_expired = 1; ! /* must empty cp->vlServersp */ ! lock_ObtainWrite(&cp->mx); ! cm_FreeServerList(&cp->vlServersp); ! cp->vlServersp = NULL; ! lock_ReleaseWrite(&cp->mx); } code = cm_SearchCellFile(namep, fullname, cm_AddCellProc, cp); --- 95,119 ---- memset(cp, 0, sizeof(cm_cell_t)); } else { + cm_cell_t **cpp; + dns_expired = 1; ! if (cp->vlServersp) { ! /* must empty cp->vlServersp */ ! lock_ObtainMutex(&cp->mx); ! cm_FreeServerList(&cp->vlServersp); ! cp->vlServersp = NULL; ! lock_ReleaseMutex(&cp->mx); ! } ! /* remove the entry from the allCells list ! * we will re-insert it later ! */ ! for (cpp = &cm_allCellsp; *cpp; cpp=&(*cpp)->nextp) { ! if (*cpp == cp) { ! (*cpp) = cp->nextp; ! break; ! } ! } } code = cm_SearchCellFile(namep, fullname, cm_AddCellProc, cp); Index: openafs/src/WINNT/afsd/cm_conn.c diff -c openafs/src/WINNT/afsd/cm_conn.c:1.25.2.4 openafs/src/WINNT/afsd/cm_conn.c:1.25.2.5 *** openafs/src/WINNT/afsd/cm_conn.c:1.25.2.4 Fri Nov 5 14:21:43 2004 --- openafs/src/WINNT/afsd/cm_conn.c Sun Jan 30 23:08:57 2005 *************** *** 138,167 **** */ int cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, ! struct cm_fid *fidp, ! AFSVolSync *volSyncp, ! cm_serverRef_t * serversp, ! cm_callbackRequest_t *cbrp, long errorCode) { cm_server_t *serverp = 0; cm_serverRef_t **serverspp = 0; ! cm_serverRef_t *tsrp; ! cm_ucell_t *ucellp; int retry = 0; int free_svr_list = 0; ! int dead_session; long timeUsed, timeLeft; ! osi_Log2(afsd_logp, "cm_Analyze connp 0x%x, code %d", ! (long) connp, errorCode); ! /* no locking required, since connp->serverp never changes after ! * creation */ ! dead_session = (userp->cellInfop == NULL); ! if (connp) ! serverp = connp->serverp; ! /* Update callback pointer */ if (cbrp && serverp && errorCode == 0) { if (cbrp->serverp) { if ( cbrp->serverp != serverp ) { --- 138,167 ---- */ int cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp, ! struct cm_fid *fidp, ! AFSVolSync *volSyncp, ! cm_serverRef_t * serversp, ! cm_callbackRequest_t *cbrp, long errorCode) { cm_server_t *serverp = 0; cm_serverRef_t **serverspp = 0; ! cm_serverRef_t *tsrp; ! cm_ucell_t *ucellp; int retry = 0; int free_svr_list = 0; ! int dead_session; long timeUsed, timeLeft; ! osi_Log2(afsd_logp, "cm_Analyze connp 0x%x, code %d", ! (long) connp, errorCode); ! /* no locking required, since connp->serverp never changes after ! * creation */ ! dead_session = (userp->cellInfop == NULL); ! if (connp) ! serverp = connp->serverp; ! /* Update callback pointer */ if (cbrp && serverp && errorCode == 0) { if (cbrp->serverp) { if ( cbrp->serverp != serverp ) { *************** *** 178,216 **** lock_ReleaseWrite(&cm_callbackLock); } ! /* If not allowed to retry, don't */ ! if (reqp->flags & CM_REQ_NORETRY) ! goto out; ! /* if timeout - check that it did not exceed the SMB timeout * and retry */ ! /* timeleft - get if from reqp the same way as cmXonnByMServers does */ #ifndef DJGPP ! timeUsed = (GetCurrentTime() - reqp->startTime) / 1000; #else ! gettimeofday(&now, NULL); ! timeUsed = sub_time(now, reqp->startTime) / 1000; #endif ! /* leave 5 seconds margin for sleep */ ! timeLeft = RDRtimeout - timeUsed; if (errorCode == CM_ERROR_TIMEDOUT && timeLeft > 5 ) { ! thrd_Sleep(3000); ! cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL); ! retry = 1; ! } /* if all servers are offline, mark them non-busy and start over */ if (errorCode == CM_ERROR_ALLOFFLINE && timeLeft > 7) { ! osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE."); ! thrd_Sleep(5000); ! /* cm_ForceUpdateVolume marks all servers as non_busy */ ! /* No it doesn't and it won't do anything if all of the ! * the servers are marked as DOWN. So clear the DOWN ! * flag and reset the busy state as well. ! */ if (!serversp) { cm_GetServerList(fidp, userp, reqp, &serverspp); serversp = *serverspp; --- 178,216 ---- lock_ReleaseWrite(&cm_callbackLock); } ! /* If not allowed to retry, don't */ ! if (reqp->flags & CM_REQ_NORETRY) ! goto out; ! /* if timeout - check that it did not exceed the SMB timeout * and retry */ ! /* timeleft - get if from reqp the same way as cmXonnByMServers does */ #ifndef DJGPP ! timeUsed = (GetCurrentTime() - reqp->startTime) / 1000; #else ! gettimeofday(&now, NULL); ! timeUsed = sub_time(now, reqp->startTime) / 1000; #endif ! /* leave 5 seconds margin for sleep */ ! timeLeft = RDRtimeout - timeUsed; if (errorCode == CM_ERROR_TIMEDOUT && timeLeft > 5 ) { ! thrd_Sleep(3000); ! cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL); ! retry = 1; ! } /* if all servers are offline, mark them non-busy and start over */ if (errorCode == CM_ERROR_ALLOFFLINE && timeLeft > 7) { ! osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE."); ! thrd_Sleep(5000); ! /* cm_ForceUpdateVolume marks all servers as non_busy */ ! /* No it doesn't and it won't do anything if all of the ! * the servers are marked as DOWN. So clear the DOWN ! * flag and reset the busy state as well. ! */ if (!serversp) { cm_GetServerList(fidp, userp, reqp, &serverspp); serversp = *serverspp; *************** *** 233,239 **** if (fidp != NULL) /* Not a VLDB call */ cm_ForceUpdateVolume(fidp, userp, reqp); ! } /* if all servers are busy, mark them non-busy and start over */ if (errorCode == CM_ERROR_ALLBUSY && timeLeft > 7) { --- 233,239 ---- if (fidp != NULL) /* Not a VLDB call */ cm_ForceUpdateVolume(fidp, userp, reqp); ! } /* if all servers are busy, mark them non-busy and start over */ if (errorCode == CM_ERROR_ALLBUSY && timeLeft > 7) { *************** *** 258,384 **** /* special codes: VBUSY and VRESTARTING */ if (errorCode == VBUSY || errorCode == VRESTARTING) { ! if (!serversp) { ! cm_GetServerList(fidp, userp, reqp, &serverspp); ! serversp = *serverspp; ! free_svr_list = 1; ! } ! lock_ObtainWrite(&cm_serverLock); ! for (tsrp = serversp; tsrp; tsrp=tsrp->next) { ! if (tsrp->server == serverp ! && tsrp->status == not_busy) { ! tsrp->status = busy; ! break; ! } ! } ! lock_ReleaseWrite(&cm_serverLock); ! if (free_svr_list) { ! cm_FreeServerList(&serversp); ! *serverspp = serversp; ! } ! retry = 1; } /* special codes: missing volumes */ if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE ! || errorCode == VSALVAGE || errorCode == VNOSERVICE) { ! /* Log server being offline for this volume */ ! osi_Log4(afsd_logp, "cm_Analyze found server %d.%d.%d.%d marked offline for a volume", ! ((serverp->addr.sin_addr.s_addr & 0xff)), ! ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8), ! ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16), ! ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); ! /* Create Event Log message */ ! { ! HANDLE h; ! char *ptbuf[1]; ! char s[100]; ! h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME); ! sprintf(s, "cm_Analyze: Server %d.%d.%d.%d reported volume %d as missing.", ! ((serverp->addr.sin_addr.s_addr & 0xff)), ! ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8), ! ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16), ! ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24), ! fidp->volume); ! ptbuf[0] = s; ! ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL, ! 1, 0, ptbuf, NULL); ! DeregisterEventSource(h); ! } ! /* Mark server offline for this volume */ ! if (!serversp) { ! cm_GetServerList(fidp, userp, reqp, &serverspp); ! serversp = *serverspp; ! free_svr_list = 1; ! } ! for (tsrp = serversp; tsrp; tsrp=tsrp->next) { ! if (tsrp->server == serverp) ! tsrp->status = offline; ! } ! if (free_svr_list) { ! cm_FreeServerList(&serversp); ! *serverspp = serversp; ! } ! if ( timeLeft > 2 ) retry = 1; } /* RX codes */ if (errorCode == RX_CALL_TIMEOUT) { ! /* server took longer than hardDeadTime ! * don't mark server as down but don't retry ! * this is to prevent the SMB session from timing out ! * In addition, we log an event to the event log ! */ #ifndef DJGPP ! HANDLE h; ! char *ptbuf[1]; ! char s[100]; ! h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME); ! sprintf(s, "cm_Analyze: HardDeadTime exceeded."); ! ptbuf[0] = s; ! ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL, ! 1, 0, ptbuf, NULL); ! DeregisterEventSource(h); #endif /* !DJGPP */ ! retry = 0; ! osi_Log0(afsd_logp, "cm_Analyze: hardDeadTime exceeded"); } else if (errorCode >= -64 && errorCode < 0) { ! /* mark server as down */ ! lock_ObtainMutex(&serverp->mx); ! serverp->flags |= CM_SERVERFLAG_DOWN; ! lock_ReleaseMutex(&serverp->mx); if ( timeLeft > 2 ) ! retry = 1; ! } ! if (errorCode == RXKADEXPIRED && !dead_session) { ! lock_ObtainMutex(&userp->mx); ! ucellp = cm_GetUCell(userp, serverp->cellp); ! if (ucellp->ticketp) { ! free(ucellp->ticketp); ! ucellp->ticketp = NULL; ! } ! ucellp->flags &= ~CM_UCELLFLAG_RXKAD; ! ucellp->gen++; ! lock_ReleaseMutex(&userp->mx); ! if ( timeLeft > 2 ) ! retry = 1; ! } ! if (retry && dead_session) ! retry = 0; ! ! out: ! /* drop this on the way out */ ! if (connp) ! cm_PutConn(connp); ! /* retry until we fail to find a connection */ ! return retry; } long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp, --- 258,385 ---- /* special codes: VBUSY and VRESTARTING */ if (errorCode == VBUSY || errorCode == VRESTARTING) { ! if (!serversp) { ! cm_GetServerList(fidp, userp, reqp, &serverspp); ! serversp = *serverspp; ! free_svr_list = 1; ! } ! lock_ObtainWrite(&cm_serverLock); ! for (tsrp = serversp; tsrp; tsrp=tsrp->next) { ! if (tsrp->server == serverp ! && tsrp->status == not_busy) { ! tsrp->status = busy; ! break; ! } ! } ! lock_ReleaseWrite(&cm_serverLock); ! if (free_svr_list) { ! cm_FreeServerList(&serversp); ! *serverspp = serversp; ! } ! retry = 1; } /* special codes: missing volumes */ if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE ! || errorCode == VSALVAGE || errorCode == VNOSERVICE) ! { ! /* Log server being offline for this volume */ ! osi_Log4(afsd_logp, "cm_Analyze found server %d.%d.%d.%d marked offline for a volume", ! ((serverp->addr.sin_addr.s_addr & 0xff)), ! ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8), ! ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16), ! ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); ! /* Create Event Log message */ ! { ! HANDLE h; ! char *ptbuf[1]; ! char s[100]; ! h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME); ! sprintf(s, "cm_Analyze: Server %d.%d.%d.%d reported volume %d as missing.", ! ((serverp->addr.sin_addr.s_addr & 0xff)), ! ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8), ! ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16), ! ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24), ! fidp->volume); ! ptbuf[0] = s; ! ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL, ! 1, 0, ptbuf, NULL); ! DeregisterEventSource(h); ! } ! /* Mark server offline for this volume */ ! if (!serversp) { ! cm_GetServerList(fidp, userp, reqp, &serverspp); ! serversp = *serverspp; ! free_svr_list = 1; ! } ! for (tsrp = serversp; tsrp; tsrp=tsrp->next) { ! if (tsrp->server == serverp) ! tsrp->status = offline; ! } ! if (free_svr_list) { ! cm_FreeServerList(&serversp); ! *serverspp = serversp; ! } ! if ( timeLeft > 2 ) retry = 1; } /* RX codes */ if (errorCode == RX_CALL_TIMEOUT) { ! /* server took longer than hardDeadTime ! * don't mark server as down but don't retry ! * this is to prevent the SMB session from timing out ! * In addition, we log an event to the event log ! */ #ifndef DJGPP ! HANDLE h; ! char *ptbuf[1]; ! char s[100]; ! h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME); ! sprintf(s, "cm_Analyze: HardDeadTime exceeded."); ! ptbuf[0] = s; ! ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL, ! 1, 0, ptbuf, NULL); ! DeregisterEventSource(h); #endif /* !DJGPP */ ! retry = 0; ! osi_Log0(afsd_logp, "cm_Analyze: hardDeadTime exceeded"); } else if (errorCode >= -64 && errorCode < 0) { ! /* mark server as down */ ! lock_ObtainMutex(&serverp->mx); ! serverp->flags |= CM_SERVERFLAG_DOWN; ! lock_ReleaseMutex(&serverp->mx); if ( timeLeft > 2 ) ! retry = 1; ! } ! if (errorCode == RXKADEXPIRED && !dead_session) { ! lock_ObtainMutex(&userp->mx); ! ucellp = cm_GetUCell(userp, serverp->cellp); ! if (ucellp->ticketp) { ! free(ucellp->ticketp); ! ucellp->ticketp = NULL; ! } ! ucellp->flags &= ~CM_UCELLFLAG_RXKAD; ! ucellp->gen++; ! lock_ReleaseMutex(&userp->mx); ! if ( timeLeft > 2 ) ! retry = 1; ! } ! ! if (retry && dead_session) ! retry = 0; ! out: ! /* drop this on the way out */ ! if (connp) ! cm_PutConn(connp); ! /* retry until we fail to find a connection */ ! return retry; } long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp, Index: openafs/src/WINNT/afsd/cm_dcache.c diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.3 openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.5 *** openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.3 Mon Oct 18 00:09:26 2004 --- openafs/src/WINNT/afsd/cm_dcache.c Sun Jan 30 23:09:28 2005 *************** *** 1191,1198 **** afsStatus.ParentVnode = 0x1; afsStatus.ParentUnique = 0x1; afsStatus.ResidencyMask = 0; ! afsStatus.ClientModTime = FakeFreelanceModTime; ! afsStatus.ServerModTime = FakeFreelanceModTime; afsStatus.Group = 0; afsStatus.SyncCounter = 0; afsStatus.dataVersionHigh = 0; --- 1191,1198 ---- afsStatus.ParentVnode = 0x1; afsStatus.ParentUnique = 0x1; afsStatus.ResidencyMask = 0; ! afsStatus.ClientModTime = (afs_uint32)FakeFreelanceModTime; ! afsStatus.ServerModTime = (afs_uint32)FakeFreelanceModTime; afsStatus.Group = 0; afsStatus.SyncCounter = 0; afsStatus.dataVersionHigh = 0; Index: openafs/src/WINNT/afsd/cm_freelance.c diff -c openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.10 openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.11 *** openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.10 Tue Dec 7 01:14:52 2004 --- openafs/src/WINNT/afsd/cm_freelance.c Thu Dec 16 14:02:48 2004 *************** *** 477,484 **** rootCellName[0] = '.'; code = cm_GetRootCellName(&rootCellName[1]); if (code == 0) { ! cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell", 0, NULL); ! cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell", 1, NULL); dwMountPoints = 2; } } --- 477,484 ---- rootCellName[0] = '.'; code = cm_GetRootCellName(&rootCellName[1]); if (code == 0) { ! cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL); ! cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL); dwMountPoints = 2; } } *************** *** 660,667 **** rootCellName[0] = '.'; code = cm_GetRootCellName(&rootCellName[1]); if (code == 0) { ! cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell", 0, NULL); ! cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell", 1, NULL); } return 0; } --- 660,667 ---- rootCellName[0] = '.'; code = cm_GetRootCellName(&rootCellName[1]); if (code == 0) { ! cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL); ! cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL); } return 0; } Index: openafs/src/WINNT/afsd/cm_ioctl.c diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.7 openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.9 *** openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.7 Tue Dec 7 00:58:20 2004 --- openafs/src/WINNT/afsd/cm_ioctl.c Sun Jan 30 23:17:43 2005 *************** *** 1164,1180 **** long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp) { ! /* if we don't know our default cell, return failure */ ! if (cm_rootCellp == NULL) { ! return CM_ERROR_NOSUCHCELL; ! } ! /* return the default cellname to the caller */ ! StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep); ! ioctlp->outDatap += strlen(ioctlp->outDatap) +1; ! /* done: success */ ! return 0; } long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) --- 1164,1184 ---- long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp) { ! long code = 0; ! if (cm_freelanceEnabled) { ! StringCbCopyA(ioctlp->outDatap, 999999, "Freelance.Local.Root"); ! ioctlp->outDatap += strlen(ioctlp->outDatap) +1; ! } else if (cm_rootCellp) { ! /* return the default cellname to the caller */ ! StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep); ! ioctlp->outDatap += strlen(ioctlp->outDatap) +1; ! } else { ! /* if we don't know our default cell, return failure */ ! code = CM_ERROR_NOSUCHCELL; ! } ! return code; } long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) *************** *** 1561,1569 **** return code; } - extern long cm_AssembleLink(cm_scache_t *linkScp, char *pathSuffixp, - cm_scache_t **newRootScpp, cm_space_t **newSpaceBufferp, - cm_user_t *userp, cm_req_t *reqp); long cm_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp) { --- 1565,1570 ---- *************** *** 1607,1612 **** --- 1608,1614 ---- cm_FreeSpace(spacep); if (newRootScp != NULL) cm_ReleaseSCache(newRootScp); + code = 0; } return code; *************** *** 1936,1942 **** /* cell name is right here */ cellp = cm_GetCell(tp, 0); ! if (!cellp) return CM_ERROR_NOSUCHCELL; tp += strlen(tp) + 1; #ifndef DJGPP --- 1938,1945 ---- /* cell name is right here */ cellp = cm_GetCell(tp, 0); ! if (!cellp) ! return CM_ERROR_NOSUCHCELL; tp += strlen(tp) + 1; #ifndef DJGPP Index: openafs/src/WINNT/afsd/cm_rpc.c diff -c openafs/src/WINNT/afsd/cm_rpc.c:1.6 openafs/src/WINNT/afsd/cm_rpc.c:1.6.2.1 *** openafs/src/WINNT/afsd/cm_rpc.c:1.6 Sun Dec 7 17:49:13 2003 --- openafs/src/WINNT/afsd/cm_rpc.c Sun Jan 30 23:05:01 2005 *************** *** 40,54 **** extern void afsi_log(char *pattern, ...); typedef struct tokenEvent { ! afs_uuid_t uuid; ! char sessionKey[8]; ! struct tokenEvent *next; } tokenEvent_t; tokenEvent_t *tokenEvents = NULL; osi_mutex_t tokenEventLock; /* * Add a new uuid and session key to the list. */ --- 40,56 ---- extern void afsi_log(char *pattern, ...); typedef struct tokenEvent { ! afs_uuid_t uuid; ! char sessionKey[8]; ! struct tokenEvent *next; } tokenEvent_t; tokenEvent_t *tokenEvents = NULL; osi_mutex_t tokenEventLock; + EVENT_HANDLE rpc_ShutdownEvent = NULL; + /* * Add a new uuid and session key to the list. */ *************** *** 56,68 **** afs_uuid_t uuid, char sessionKey[8]) { ! tokenEvent_t *te = malloc(sizeof(tokenEvent_t)); ! te->uuid = uuid; ! memcpy(te->sessionKey, sessionKey, sizeof(te->sessionKey)); ! lock_ObtainMutex(&tokenEventLock); ! te->next = tokenEvents; ! tokenEvents = te; ! lock_ReleaseMutex(&tokenEventLock); } /* --- 58,70 ---- afs_uuid_t uuid, char sessionKey[8]) { ! tokenEvent_t *te = malloc(sizeof(tokenEvent_t)); ! te->uuid = uuid; ! memcpy(te->sessionKey, sessionKey, sizeof(te->sessionKey)); ! lock_ObtainMutex(&tokenEventLock); ! te->next = tokenEvents; ! tokenEvents = te; ! lock_ReleaseMutex(&tokenEventLock); } /* *************** *** 73,99 **** */ BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]) { ! RPC_STATUS status; ! tokenEvent_t *te; ! tokenEvent_t **ltep; ! ! lock_ObtainMutex(&tokenEventLock); ! te = tokenEvents; ! ltep = &tokenEvents; ! while (te) { ! if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) { ! *ltep = te->next; ! lock_ReleaseMutex(&tokenEventLock); ! memcpy(sessionKey, te->sessionKey, ! sizeof(te->sessionKey)); ! free(te); ! return TRUE; ! } ! ltep = &te->next; ! te = te->next; ! } ! lock_ReleaseMutex(&tokenEventLock); ! return FALSE; } /* --- 75,101 ---- */ BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]) { ! RPC_STATUS status; ! tokenEvent_t *te; ! tokenEvent_t **ltep; ! ! lock_ObtainMutex(&tokenEventLock); ! te = tokenEvents; ! ltep = &tokenEvents; ! while (te) { ! if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) { ! *ltep = te->next; ! lock_ReleaseMutex(&tokenEventLock); ! memcpy(sessionKey, te->sessionKey, ! sizeof(te->sessionKey)); ! free(te); ! return TRUE; ! } ! ltep = &te->next; ! te = te->next; ! } ! lock_ReleaseMutex(&tokenEventLock); ! return FALSE; } /* *************** *** 104,220 **** afs_uuid_t uuid, unsigned char __RPC_FAR sessionKey[8]) { ! cm_RegisterNewTokenEvent(uuid, sessionKey); ! return 0; } long AFSRPC_GetToken( afs_uuid_t uuid, unsigned char __RPC_FAR sessionKey[8]) { ! BOOL found; ! found = cm_FindTokenEvent(uuid, sessionKey); ! if (!found) ! return 1; ! return 0; } void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes) { ! return ((void __RPC_FAR *) malloc(cBytes)); } void __RPC_USER midl_user_free(void __RPC_FAR * p) { ! free(p); } void RpcListen() { ! RPC_STATUS status; ! char *task; ! RPC_BINDING_VECTOR *ptrBindingVector = NULL; ! BOOLEAN ifaceRegistered = FALSE; ! BOOLEAN epRegistered = FALSE; #ifdef NOOSIDEBUGSERVER /* Use All Protseqs already done in OSI */ ! status = RpcServerUseAllProtseqs(1, NULL); ! if (status != RPC_S_OK) { ! task = "Use All Protocol Sequences"; ! goto cleanup; ! } #endif /* NOOSIDEBUGSERVER */ ! status = RpcServerRegisterIf(afsrpc_v1_0_s_ifspec, NULL, NULL); ! if (status != RPC_S_OK) { ! task = "Register Interface"; ! goto cleanup; ! } ! ifaceRegistered = TRUE; ! ! status = RpcServerInqBindings(&ptrBindingVector); ! if (status != RPC_S_OK) { ! task = "Inquire Bindings"; ! goto cleanup; ! } ! ! status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL); ! if (status != RPC_S_OK) { ! task = "Register Authentication Info"; ! goto cleanup; ! } ! ! status = RpcEpRegister(afsrpc_v1_0_s_ifspec, ptrBindingVector, ! NULL, "AFS session key interface"); ! if (status != RPC_S_OK) { ! task = "Register Endpoints"; ! goto cleanup; ! } ! epRegistered = TRUE; ! ! afsi_log("RPC server listening"); ! ! status = RpcServerListen(OSI_MAXRPCCALLS, OSI_MAXRPCCALLS, 0); ! if (status != RPC_S_OK) { ! task = "Server Listen"; ! } cleanup: ! if (epRegistered) ! (void) RpcEpUnregister(afsrpc_v1_0_s_ifspec, ptrBindingVector, ! NULL); ! ! if (ptrBindingVector) ! (void) RpcBindingVectorFree(&ptrBindingVector); ! ! if (ifaceRegistered) ! (void) RpcServerUnregisterIf(afsrpc_v1_0_s_ifspec, NULL, FALSE); ! ! if (status != RPC_S_OK) ! afsi_log("RPC problem, code %d for %s", status, task); ! ! return; } long RpcInit() { ! LONG status = ERROR_SUCCESS; ! HANDLE listenThread; ! ULONG listenThreadID = 0; ! lock_InitializeMutex(&tokenEventLock, "token event lock"); ! listenThread = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)RpcListen, ! 0, 0, &listenThreadID); ! if (listenThread == NULL) { ! status = GetLastError(); ! } ! CloseHandle(listenThread); ! return status; } --- 106,242 ---- afs_uuid_t uuid, unsigned char __RPC_FAR sessionKey[8]) { ! cm_RegisterNewTokenEvent(uuid, sessionKey); ! return 0; } long AFSRPC_GetToken( afs_uuid_t uuid, unsigned char __RPC_FAR sessionKey[8]) { ! BOOL found; ! found = cm_FindTokenEvent(uuid, sessionKey); ! if (!found) ! return 1; ! return 0; } void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes) { ! return ((void __RPC_FAR *) malloc(cBytes)); } void __RPC_USER midl_user_free(void __RPC_FAR * p) { ! free(p); } void RpcListen() { ! RPC_STATUS status; ! char *task; ! RPC_BINDING_VECTOR *ptrBindingVector = NULL; ! BOOLEAN ifaceRegistered = FALSE; ! BOOLEAN epRegistered = FALSE; #ifdef NOOSIDEBUGSERVER /* Use All Protseqs already done in OSI */ ! status = RpcServerUseAllProtseqs(1, NULL); ! if (status != RPC_S_OK) { ! task = "Use All Protocol Sequences"; ! goto cleanup; ! } #endif /* NOOSIDEBUGSERVER */ ! status = RpcServerRegisterIf(afsrpc_v1_0_s_ifspec, NULL, NULL); ! if (status != RPC_S_OK) { ! task = "Register Interface"; ! goto cleanup; ! } ! ifaceRegistered = TRUE; ! ! status = RpcServerInqBindings(&ptrBindingVector); ! if (status != RPC_S_OK) { ! task = "Inquire Bindings"; ! goto cleanup; ! } ! ! status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL); ! if (status != RPC_S_OK) { ! task = "Register Authentication Info"; ! goto cleanup; ! } ! ! status = RpcEpRegister(afsrpc_v1_0_s_ifspec, ptrBindingVector, ! NULL, "AFS session key interface"); ! if (status != RPC_S_OK) { ! task = "Register Endpoints"; ! goto cleanup; ! } ! epRegistered = TRUE; ! ! afsi_log("RPC server listening"); ! ! status = RpcServerListen(OSI_MAXRPCCALLS, OSI_MAXRPCCALLS, 0); ! if (status != RPC_S_OK) { ! task = "Server Listen"; ! } cleanup: ! if (epRegistered) ! (void) RpcEpUnregister(afsrpc_v1_0_s_ifspec, ptrBindingVector, ! NULL); ! ! if (ptrBindingVector) ! (void) RpcBindingVectorFree(&ptrBindingVector); ! ! if (ifaceRegistered) ! (void) RpcServerUnregisterIf(afsrpc_v1_0_s_ifspec, NULL, FALSE); ! ! if (status != RPC_S_OK) ! afsi_log("RPC problem, code %d for %s", status, task); ! else ! afsi_log("RPC shutdown"); ! ! if (rpc_ShutdownEvent != NULL) ! thrd_SetEvent(rpc_ShutdownEvent); ! return; } long RpcInit() { ! LONG status = ERROR_SUCCESS; ! HANDLE listenThread; ! ULONG listenThreadID = 0; ! char * name = "afsd_rpc_ShutdownEvent"; ! ! lock_InitializeMutex(&tokenEventLock, "token event lock"); ! rpc_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name); ! if ( GetLastError() == ERROR_ALREADY_EXISTS ) ! afsi_log("Event Object Already Exists: %s", name); ! listenThread = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)RpcListen, ! 0, 0, &listenThreadID); ! if (listenThread == NULL) { ! status = GetLastError(); ! } ! CloseHandle(listenThread); ! return status; } + + void RpcShutdown(void) + { + RpcMgmtStopServerListening(NULL); + + if (rpc_ShutdownEvent != NULL) { + thrd_WaitForSingleObject_Event(rpc_ShutdownEvent, INFINITE); + CloseHandle(rpc_ShutdownEvent); + } + } + Index: openafs/src/WINNT/afsd/cm_rpc.h diff -c openafs/src/WINNT/afsd/cm_rpc.h:1.3 openafs/src/WINNT/afsd/cm_rpc.h:1.3.16.1 *** openafs/src/WINNT/afsd/cm_rpc.h:1.3 Mon Apr 30 02:48:05 2001 --- openafs/src/WINNT/afsd/cm_rpc.h Sun Jan 30 23:05:01 2005 *************** *** 19,24 **** void cm_RegisterNewTokenEvent(afs_uuid_t uuid, char sessionKey[8]); BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]); ! extern long RpcInit(); ! #endif /* __CM_RPC_H__ */ --- 19,24 ---- void cm_RegisterNewTokenEvent(afs_uuid_t uuid, char sessionKey[8]); BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]); ! extern long RpcInit(void); ! extern void RpcShutdown(void); #endif /* __CM_RPC_H__ */ Index: openafs/src/WINNT/afsd/cm_scache.c diff -c openafs/src/WINNT/afsd/cm_scache.c:1.14.2.3 openafs/src/WINNT/afsd/cm_scache.c:1.14.2.6 *** openafs/src/WINNT/afsd/cm_scache.c:1.14.2.3 Tue Dec 7 00:58:20 2004 --- openafs/src/WINNT/afsd/cm_scache.c Sun Jan 30 23:09:28 2005 *************** *** 344,350 **** scp->parentUnique = 0x1; scp->parentVnode=0x1; scp->group=0; ! scp->dataVersion=0x8; *outScpp = scp; lock_ReleaseWrite(&cm_scacheLock); /*afsi_log(" getscache done");*/ --- 344,350 ---- scp->parentUnique = 0x1; scp->parentVnode=0x1; scp->group=0; ! scp->dataVersion=cm_fakeDirVersion; *outScpp = scp; lock_ReleaseWrite(&cm_scacheLock); /*afsi_log(" getscache done");*/ *************** *** 853,860 **** statusp->ParentVnode = 0x1; statusp->ParentUnique = 0x1; statusp->ResidencyMask = 0; ! statusp->ClientModTime = FakeFreelanceModTime; ! statusp->ServerModTime = FakeFreelanceModTime; statusp->Group = 0; statusp->SyncCounter = 0; statusp->dataVersionHigh = 0; --- 853,860 ---- statusp->ParentVnode = 0x1; statusp->ParentUnique = 0x1; statusp->ResidencyMask = 0; ! statusp->ClientModTime = (afs_uint32)FakeFreelanceModTime; ! statusp->ServerModTime = (afs_uint32)FakeFreelanceModTime; statusp->Group = 0; statusp->SyncCounter = 0; statusp->dataVersionHigh = 0; *************** *** 982,988 **** void cm_HoldSCacheNoLock(cm_scache_t *scp) { #ifdef NOLOCK_ASSERT ! osi_assert(scp->refCount > 0); #endif scp->refCount++; } --- 982,988 ---- void cm_HoldSCacheNoLock(cm_scache_t *scp) { #ifdef NOLOCK_ASSERT ! osi_assert(scp->refCount >= 0); #endif scp->refCount++; } *************** *** 990,996 **** void cm_HoldSCache(cm_scache_t *scp) { lock_ObtainWrite(&cm_scacheLock); ! osi_assert(scp->refCount > 0); scp->refCount++; lock_ReleaseWrite(&cm_scacheLock); } --- 990,996 ---- void cm_HoldSCache(cm_scache_t *scp) { lock_ObtainWrite(&cm_scacheLock); ! osi_assert(scp->refCount >= 0); scp->refCount++; lock_ReleaseWrite(&cm_scacheLock); } Index: openafs/src/WINNT/afsd/cm_vnodeops.c diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.8 openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.9 *** openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.8 Mon Dec 13 09:13:08 2004 --- openafs/src/WINNT/afsd/cm_vnodeops.c Sun Jan 30 23:23:45 2005 *************** *** 995,1002 **** * that we stopped early, probably because we found the entry we're * looking for. Any other non-zero code is an error. */ ! if (code && code != CM_ERROR_STOPNOW) return code; getroot = (dscp==cm_rootSCachep) ; if (!rock.found) { --- 995,1013 ---- * that we stopped early, probably because we found the entry we're * looking for. Any other non-zero code is an error. */ ! if (code && code != CM_ERROR_STOPNOW) { ! /* if the cm_scache_t we are searching in is not a directory ! * we must return path not found because the error ! * is to describe the final component not an intermediary ! */ ! if (code == CM_ERROR_NOTDIR) { ! if (flags & CM_FLAG_CHECKPATH) ! return CM_ERROR_NOSUCHPATH; ! else ! return CM_ERROR_NOSUCHFILE; ! } return code; + } getroot = (dscp==cm_rootSCachep) ; if (!rock.found) { Index: openafs/src/WINNT/afsd/fs.c diff -c openafs/src/WINNT/afsd/fs.c:1.16.2.3 openafs/src/WINNT/afsd/fs.c:1.16.2.5 *** openafs/src/WINNT/afsd/fs.c:1.16.2.3 Mon Oct 18 00:09:27 2004 --- openafs/src/WINNT/afsd/fs.c Sun Jan 30 23:09:42 2005 *************** *** 18,27 **** --- 18,30 ---- #include #include #include + #include #include #include #include + #include + #include #include "fs.h" #include "fs_utils.h" *************** *** 31,40 **** --- 34,46 ---- #define MAXHOSTS 13 #define OMAXHOSTS 8 + #define MAXCELLHOSTS 8 #define MAXNAME 100 #define MAXSIZE 2048 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */ #define VMSGSIZE 128 /* size of msg buf in volume hdr */ + #define MAXCELLCHARS 64 + #define MAXHOSTCHARS 64 static char space[MAXSIZE]; static char tspace[1024]; *************** *** 43,70 **** static struct ubik_client *uclient; #endif /* not WIN32 */ ! static MemDumpCmd(struct cmd_syndesc *asp); ! static CSCPolicyCmd(struct cmd_syndesc *asp); extern afs_int32 VL_GetEntryByNameO(); static char pn[] = "fs"; static int rxInitDone = 0; - static GetCellName(); - - #define MAXCELLCHARS 64 - #define MAXHOSTCHARS 64 - #define MAXHOSTSPERCELL 8 - struct afsconf_cell { ! char name[MAXCELLCHARS]; ! short numServers; ! short flags; ! struct sockaddr_in hostAddr[MAXHOSTSPERCELL]; ! char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS]; ! char *linkedCell; ! }; /* --- 49,78 ---- static struct ubik_client *uclient; #endif /* not WIN32 */ ! static int GetClientAddrsCmd(struct cmd_syndesc *asp, char *arock); ! static int SetClientAddrsCmd(struct cmd_syndesc *asp, char *arock); ! static int FlushMountCmd(struct cmd_syndesc *asp, char *arock); ! static int RxStatProcCmd(struct cmd_syndesc *asp, char *arock); ! static int RxStatPeerCmd(struct cmd_syndesc *asp, char *arock); ! ! extern struct cmd_syndesc *cmd_CreateSyntax(); ! ! static int MemDumpCmd(struct cmd_syndesc *asp, char *arock); ! static int CSCPolicyCmd(struct cmd_syndesc *asp, char *arock); extern afs_int32 VL_GetEntryByNameO(); static char pn[] = "fs"; static int rxInitDone = 0; struct afsconf_cell { ! char name[MAXCELLCHARS]; ! short numServers; ! short flags; ! struct sockaddr_in hostAddr[MAXCELLHOSTS]; ! char hostName[MAXCELLHOSTS][MAXHOSTCHARS]; ! char *linkedCell; ! }; /* *************** *** 76,84 **** typedef char sec_rgy_name_t[1025]; /* A DCE definition */ struct Acl { ! int dfs; /* Originally true if a dfs acl; now also the type ! of the acl (1, 2, or 3, corresponding to object, ! initial dir, or initial object). */ sec_rgy_name_t cell; /* DFS cell name */ int nplus; int nminus; --- 84,92 ---- typedef char sec_rgy_name_t[1025]; /* A DCE definition */ struct Acl { ! int dfs; /* Originally true if a dfs acl; now also the type ! * of the acl (1, 2, or 3, corresponding to object, ! * initial dir, or initial object). */ sec_rgy_name_t cell; /* DFS cell name */ int nplus; int nminus; *************** *** 92,118 **** afs_int32 rights; }; ! void ZapAcl (acl) ! struct Acl *acl; { ZapList(acl->pluslist); ZapList(acl->minuslist); free(acl); } - foldcmp (a, b) - register char *a; - register char *b; { - register char t, u; - while (1) { - t = *a++; - u = *b++; - if (t >= 'A' && t <= 'Z') t += 0x20; - if (u >= 'A' && u <= 'Z') u += 0x20; - if (t != u) return 1; - if (t == 0) return 0; - } - } - /* * Mods for the AFS/DFS protocol translator. * --- 100,116 ---- afs_int32 rights; }; ! static void ! ZapAcl (struct Acl *acl) ! { ! if (!acl) ! return; ! ZapList(acl->pluslist); ZapList(acl->minuslist); free(acl); } /* * Mods for the AFS/DFS protocol translator. * *************** *** 144,158 **** * Offset of -id switch in command structure for various commands. * The -if switch is the next switch always. */ ! int parm_setacl_id, parm_copyacl_id, parm_listacl_id; /* * Determine whether either the -id or -if switches are present, and * return 0, 1 or 2, as appropriate. Abort if both switches are present. */ ! int getidf(as, id) ! struct cmd_syndesc *as; ! int id; /* Offset of -id switch; -if is next switch */ { int idf = 0; --- 142,156 ---- * Offset of -id switch in command structure for various commands. * The -if switch is the next switch always. */ ! static int parm_setacl_id, parm_copyacl_id, parm_listacl_id; /* * Determine whether either the -id or -if switches are present, and * return 0, 1 or 2, as appropriate. Abort if both switches are present. */ ! /* int id; Offset of -id switch; -if is next switch */ ! static int ! getidf(struct cmd_syndesc *as, int id) { int idf = 0; *************** *** 163,170 **** idf |= 2; } if (idf == 3) { ! fprintf ! (stderr, "%s: you may specify either -id or -if, but not both switches\n", pn); exit(1); --- 161,167 ---- idf |= 2; } if (idf == 3) { ! fprintf(stderr, "%s: you may specify either -id or -if, but not both switches\n", pn); exit(1); *************** *** 172,221 **** return idf; } ! void PRights (arights, dfs) ! register afs_int32 arights; ! int dfs; { if (!dfs) { ! if (arights & PRSFS_READ) printf("r"); ! if (arights & PRSFS_LOOKUP) printf("l"); ! if (arights & PRSFS_INSERT) printf("i"); ! if (arights & PRSFS_DELETE) printf("d"); ! if (arights & PRSFS_WRITE) printf("w"); ! if (arights & PRSFS_LOCK) printf("k"); ! if (arights & PRSFS_ADMINISTER) printf("a"); ! if (arights & PRSFS_USR0) printf("A"); ! if (arights & PRSFS_USR1) printf("B"); ! if (arights & PRSFS_USR2) printf("C"); ! if (arights & PRSFS_USR3) printf("D"); ! if (arights & PRSFS_USR4) printf("E"); ! if (arights & PRSFS_USR5) printf("F"); ! if (arights & PRSFS_USR6) printf("G"); ! if (arights & PRSFS_USR7) printf("H"); } else { ! if (arights & DFS_READ) printf("r"); else printf("-"); ! if (arights & DFS_WRITE) printf("w"); else printf("-"); ! if (arights & DFS_EXECUTE) printf("x"); else printf("-"); ! if (arights & DFS_CONTROL) printf("c"); else printf("-"); ! if (arights & DFS_INSERT) printf("i"); else printf("-"); ! if (arights & DFS_DELETE) printf("d"); else printf("-"); ! if (arights & (DFS_USRALL)) printf("+"); ! if (arights & DFS_USR0) printf("A"); ! if (arights & DFS_USR1) printf("B"); ! if (arights & DFS_USR2) printf("C"); ! if (arights & DFS_USR3) printf("D"); ! if (arights & DFS_USR4) printf("E"); ! if (arights & DFS_USR5) printf("F"); ! if (arights & DFS_USR6) printf("G"); ! if (arights & DFS_USR7) printf("H"); } } /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */ ! static int InAFS(apath) ! register char *apath; { struct ViceIoctl blob; ! register afs_int32 code; blob.in_size = 0; blob.out_size = MAXSIZE; --- 169,261 ---- return idf; } ! static int ! PRights(afs_int32 arights, int dfs) { if (!dfs) { ! if (arights & PRSFS_READ) ! printf("r"); ! if (arights & PRSFS_LOOKUP) ! printf("l"); ! if (arights & PRSFS_INSERT) ! printf("i"); ! if (arights & PRSFS_DELETE) ! printf("d"); ! if (arights & PRSFS_WRITE) ! printf("w"); ! if (arights & PRSFS_LOCK) ! printf("k"); ! if (arights & PRSFS_ADMINISTER) ! printf("a"); ! if (arights & PRSFS_USR0) ! printf("A"); ! if (arights & PRSFS_USR1) ! printf("B"); ! if (arights & PRSFS_USR2) ! printf("C"); ! if (arights & PRSFS_USR3) ! printf("D"); ! if (arights & PRSFS_USR4) ! printf("E"); ! if (arights & PRSFS_USR5) ! printf("F"); ! if (arights & PRSFS_USR6) ! printf("G"); ! if (arights & PRSFS_USR7) ! printf("H"); } else { ! if (arights & DFS_READ) ! printf("r"); ! else ! printf("-"); ! if (arights & DFS_WRITE) ! printf("w"); ! else ! printf("-"); ! if (arights & DFS_EXECUTE) ! printf("x"); ! else ! printf("-"); ! if (arights & DFS_CONTROL) ! printf("c"); ! else ! printf("-"); ! if (arights & DFS_INSERT) ! printf("i"); ! else ! printf("-"); ! if (arights & DFS_DELETE) ! printf("d"); ! else ! printf("-"); ! if (arights & (DFS_USRALL)) ! printf("+"); ! if (arights & DFS_USR0) ! printf("A"); ! if (arights & DFS_USR1) ! printf("B"); ! if (arights & DFS_USR2) ! printf("C"); ! if (arights & DFS_USR3) ! printf("D"); ! if (arights & DFS_USR4) ! printf("E"); ! if (arights & DFS_USR5) ! printf("F"); ! if (arights & DFS_USR6) ! printf("G"); ! if (arights & DFS_USR7) ! printf("H"); } + return 0; } /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */ ! static int ! InAFS(char *apath) ! { struct ViceIoctl blob; ! afs_int32 code; blob.in_size = 0; blob.out_size = MAXSIZE; *************** *** 223,237 **** code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1); if (code) { ! if ((errno == EINVAL) || (errno == ENOENT)) return 0; } return 1; } /* return a static pointer to a buffer */ ! static char *Parent(apath) ! char *apath; { ! register char *tp; strcpy(tspace, apath); tp = strrchr(tspace, '\\'); if (tp) { --- 263,279 ---- code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1); if (code) { ! if ((errno == EINVAL) || (errno == ENOENT)) ! return 0; } return 1; } /* return a static pointer to a buffer */ ! static char * ! Parent(char *apath) ! { ! char *tp; strcpy(tspace, apath); tp = strrchr(tspace, '\\'); if (tp) { *************** *** 246,259 **** enum rtype {add, destroy, deny}; ! afs_int32 Convert(arights, dfs, rtypep) ! register char *arights; ! int dfs; ! enum rtype *rtypep; { ! register int i, len; afs_int32 mode; ! register char tc; *rtypep = add; /* add rights, by default */ --- 288,299 ---- enum rtype {add, destroy, deny}; ! static afs_int32 ! Convert(char *arights, int dfs, enum rtype *rtypep) { ! int i, len; afs_int32 mode; ! char tc; *rtypep = add; /* add rights, by default */ *************** *** 262,275 **** *rtypep = deny; return 0; } ! if (!strcmp(arights,"read")) return DFS_READ | DFS_EXECUTE; ! if (!strcmp(arights, "write")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE; ! if (!strcmp(arights, "all")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE | DFS_CONTROL; } else { ! if (!strcmp(arights,"read")) return PRSFS_READ | PRSFS_LOOKUP; ! if (!strcmp(arights, "write")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK; ! if (!strcmp(arights, "mail")) return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP; ! if (!strcmp(arights, "all")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER; } if (!strcmp(arights, "none")) { *rtypep = destroy; /* Remove entire entry */ --- 302,326 ---- *rtypep = deny; return 0; } ! if (!strcmp(arights,"read")) ! return DFS_READ | DFS_EXECUTE; ! if (!strcmp(arights, "write")) ! return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | ! DFS_WRITE; ! if (!strcmp(arights, "all")) ! return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | ! DFS_WRITE | DFS_CONTROL; } else { ! if (!strcmp(arights,"read")) ! return PRSFS_READ | PRSFS_LOOKUP; ! if (!strcmp(arights, "write")) ! return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | ! PRSFS_WRITE | PRSFS_LOCK; ! if (!strcmp(arights, "mail")) ! return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP; ! if (!strcmp(arights, "all")) ! return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | ! PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER; } if (!strcmp(arights, "none")) { *rtypep = destroy; /* Remove entire entry */ *************** *** 280,322 **** for(i=0;iname, aname)) return alist; alist = alist->next; } return 0; } /* if no parm specified in a particular slot, set parm to be "." instead */ ! static void SetDotDefault(aitemp) ! struct cmd_item **aitemp; { ! register struct cmd_item *ti; ! if (*aitemp) return; /* already has value */ /* otherwise, allocate an item representing "." */ ti = (struct cmd_item *) malloc(sizeof(struct cmd_item)); ti->next = (struct cmd_item *) 0; ti->data = (char *) malloc(2); strcpy(ti->data, "."); *aitemp = ti; } ! void ChangeList (al, plus, aname, arights) ! struct Acl *al; ! char *aname; ! afs_int32 arights, plus; { struct AclEntry *tlist; tlist = (plus ? al->pluslist : al->minuslist); tlist = FindList (tlist, aname); --- 407,443 ---- return mode; } ! static struct AclEntry * ! FindList (struct AclEntry *alist, char *aname) ! { while (alist) { ! if (!strcasecmp(alist->name, aname)) ! return alist; alist = alist->next; } return 0; } /* if no parm specified in a particular slot, set parm to be "." instead */ ! static void ! SetDotDefault(struct cmd_item **aitemp) ! { ! struct cmd_item *ti; ! if (*aitemp) ! return; /* already has value */ /* otherwise, allocate an item representing "." */ ti = (struct cmd_item *) malloc(sizeof(struct cmd_item)); + assert(ti); ti->next = (struct cmd_item *) 0; ti->data = (char *) malloc(2); + assert(ti->data); strcpy(ti->data, "."); *aitemp = ti; } ! static void ! ChangeList (struct Acl *al, afs_int32 plus, char *aname, afs_int32 arights) ! { struct AclEntry *tlist; tlist = (plus ? al->pluslist : al->minuslist); tlist = FindList (tlist, aname); *************** *** 365,370 **** --- 452,458 ---- } /* Otherwise we make a new item and plug in the new data. */ tlist = (struct AclEntry *) malloc(sizeof (struct AclEntry)); + assert(tlist); strcpy(tlist->name, aname); tlist->rights = arights; if (plus) { *************** *** 373,399 **** al->nplus++; if (arights == 0 || arights == -1) al->nplus -= PruneList(&al->pluslist, al->dfs); ! } ! else { tlist->next = al->minuslist; al->minuslist = tlist; al->nminus++; ! if (arights == 0) al->nminus -= PruneList(&al->minuslist, al->dfs); } } ! void ZapList (alist) ! struct AclEntry *alist; { ! register struct AclEntry *tp, *np; for (tp = alist; tp; tp = np) { np = tp->next; free(tp); } } ! int PruneList (ae, dfs) ! struct AclEntry **ae; ! int dfs; { struct AclEntry **lp; struct AclEntry *te, *ne; --- 461,487 ---- al->nplus++; if (arights == 0 || arights == -1) al->nplus -= PruneList(&al->pluslist, al->dfs); ! } else { tlist->next = al->minuslist; al->minuslist = tlist; al->nminus++; ! if (arights == 0) ! al->nminus -= PruneList(&al->minuslist, al->dfs); } } ! static void ! ZapList (struct AclEntry *alist) ! { ! struct AclEntry *tp, *np; for (tp = alist; tp; tp = np) { np = tp->next; free(tp); } } ! static int ! PruneList (struct AclEntry **ae, int dfs) { struct AclEntry **lp; struct AclEntry *te, *ne; *************** *** 406,413 **** ne = te->next; free(te); ctr++; ! } ! else { ne = te->next; lp = &te->next; } --- 494,500 ---- ne = te->next; free(te); ctr++; ! } else { ne = te->next; lp = &te->next; } *************** *** 415,423 **** return ctr; } ! char *SkipLine (astr) ! register char *astr; { ! while (*astr !='\n') astr++; astr++; return astr; } --- 502,512 ---- return ctr; } ! static char * ! SkipLine (char *astr) ! { ! while (*astr !='\n') ! astr++; astr++; return astr; } *************** *** 429,441 **** * assume that the acl is AFS: for DFS, the user can always resort to * acl_edit, but for AFS there may be no other way out). */ ! struct Acl *EmptyAcl(astr) ! char *astr; { ! register struct Acl *tp; int junk; tp = (struct Acl *)malloc(sizeof (struct Acl)); tp->nplus = tp->nminus = 0; tp->pluslist = tp->minuslist = 0; tp->dfs = 0; --- 518,531 ---- * assume that the acl is AFS: for DFS, the user can always resort to * acl_edit, but for AFS there may be no other way out). */ ! static struct Acl * ! EmptyAcl(char *astr) { ! struct Acl *tp; int junk; tp = (struct Acl *)malloc(sizeof (struct Acl)); + assert(tp); tp->nplus = tp->nminus = 0; tp->pluslist = tp->minuslist = 0; tp->dfs = 0; *************** *** 443,456 **** return tp; } ! struct Acl *ParseAcl (astr) ! char *astr; { int nplus, nminus, i, trights; char tname[MAXNAME]; struct AclEntry *first, *last, *tl; struct Acl *ta; ta = (struct Acl *) malloc (sizeof (struct Acl)); ta->dfs = 0; sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell); astr = SkipLine(astr); --- 533,548 ---- return tp; } ! static struct Acl * ! ParseAcl (char *astr) ! { int nplus, nminus, i, trights; char tname[MAXNAME]; struct AclEntry *first, *last, *tl; struct Acl *ta; ta = (struct Acl *) malloc (sizeof (struct Acl)); + assert(ta); ta->dfs = 0; sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell); astr = SkipLine(astr); *************** *** 466,476 **** sscanf(astr, "%100s %d", tname, &trights); astr = SkipLine(astr); tl = (struct AclEntry *) malloc(sizeof (struct AclEntry)); ! if (!first) first = tl; strcpy(tl->name, tname); tl->rights = trights; tl->next = 0; ! if (last) last->next = tl; last = tl; } ta->pluslist = first; --- 558,571 ---- sscanf(astr, "%100s %d", tname, &trights); astr = SkipLine(astr); tl = (struct AclEntry *) malloc(sizeof (struct AclEntry)); ! assert(tl); ! if (!first) ! first = tl; strcpy(tl->name, tname); tl->rights = trights; tl->next = 0; ! if (last) ! last->next = tl; last = tl; } ta->pluslist = first; *************** *** 481,491 **** sscanf(astr, "%100s %d", tname, &trights); astr = SkipLine(astr); tl = (struct AclEntry *) malloc(sizeof (struct AclEntry)); ! if (!first) first = tl; strcpy(tl->name, tname); tl->rights = trights; tl->next = 0; ! if (last) last->next = tl; last = tl; } ta->minuslist = first; --- 576,589 ---- sscanf(astr, "%100s %d", tname, &trights); astr = SkipLine(astr); tl = (struct AclEntry *) malloc(sizeof (struct AclEntry)); ! assert(tl); ! if (!first) ! first = tl; strcpy(tl->name, tname); tl->rights = trights; tl->next = 0; ! if (last) ! last->next = tl; last = tl; } ta->minuslist = first; *************** *** 493,518 **** return ta; } ! void PrintStatus(status, name, motd, offmsg) ! VolumeStatus *status; ! char *name; ! char *motd; ! char *offmsg; { printf("Volume status for vid = %u named %s\n",status->Vid, name); if (*offmsg != 0) printf("Current offline message is %s\n",offmsg); if (*motd != 0) printf("Current message of the day is %s\n",motd); printf("Current disk quota is "); ! if (status->MaxQuota != 0) printf("%d\n", status->MaxQuota); ! else printf("unlimited\n"); printf("Current blocks used are %d\n",status->BlocksInUse); ! printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks); } ! void QuickPrintStatus(status, name) ! VolumeStatus *status; ! char *name; { double QuotaUsed =0.0; double PartUsed =0.0; int WARN = 0; --- 591,618 ---- return ta; } ! static int ! PrintStatus(VolumeStatus *status, char *name, char *motd, char *offmsg) ! { printf("Volume status for vid = %u named %s\n",status->Vid, name); if (*offmsg != 0) printf("Current offline message is %s\n",offmsg); if (*motd != 0) printf("Current message of the day is %s\n",motd); printf("Current disk quota is "); ! if (status->MaxQuota != 0) ! printf("%d\n", status->MaxQuota); ! else ! printf("unlimited\n"); printf("Current blocks used are %d\n",status->BlocksInUse); ! printf("The partition has %d blocks available out of %d\n\n", ! status->PartBlocksAvail, status->PartMaxBlocks); ! return 0; } ! static int ! QuickPrintStatus(VolumeStatus *status, char *name) ! { double QuotaUsed =0.0; double PartUsed =0.0; int WARN = 0; *************** *** 527,549 **** if (QuotaUsed > 90.0){ printf(" %5.0f%%<<", QuotaUsed); WARN = 1; ! } ! else printf(" %5.0f%% ", QuotaUsed); PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0)); if (PartUsed > 97.0){ printf(" %9.0f%%<<", PartUsed); WARN = 1; ! } ! else printf(" %9.0f%% ", PartUsed); if (WARN){ ! printf("\t< 90.0){ printf(" %5.0f%%<<", QuotaUsed); WARN = 1; ! } else ! printf(" %5.0f%% ", QuotaUsed); PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0)); if (PartUsed > 97.0){ printf(" %9.0f%%<<", PartUsed); WARN = 1; ! } else ! printf(" %9.0f%% ", PartUsed); if (WARN){ ! printf(" < 90.0){ printf(" %4.0f%%<<", PartUsed); WARN = 1; ! } ! else printf(" %4.0f%% ", PartUsed); if (WARN){ ! printf("\t<dfs) sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell); ! else dfsstring[0] = '\0'; sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus); ! for(tp = acl->pluslist;tp;tp=tp->next) { sprintf(tstring, "%s %d\n", tp->name, tp->rights); strcat(mydata, tstring); } ! for(tp = acl->minuslist;tp;tp=tp->next) { sprintf(tstring, "%s %d\n", tp->name, tp->rights); strcat(mydata, tstring); } --- 655,687 ---- if (PartUsed > 90.0){ printf(" %4.0f%%<<", PartUsed); WARN = 1; ! } else ! printf(" %4.0f%% ", PartUsed); if (WARN){ ! printf(" <dfs) ! sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell); ! else ! dfsstring[0] = '\0'; sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus); ! for (tp = acl->pluslist;tp;tp=tp->next) { sprintf(tstring, "%s %d\n", tp->name, tp->rights); strcat(mydata, tstring); } ! for (tp = acl->minuslist;tp;tp=tp->next) { sprintf(tstring, "%s %d\n", tp->name, tp->rights); strcat(mydata, tstring); } *************** *** 631,637 **** --- 736,744 ---- } psidAdmin = (PSID)malloc(dwSize); memset(psidAdmin,0,dwSize); + assert(psidAdmin); pszRefDomain = (char *)malloc(dwSize2); + assert(pszRefDomain); if (!LookupAccountName(NULL, pszAdminGroup, psidAdmin, &dwSize, pszRefDomain, &dwSize2, &snu)) { /* We can't lookup the group now even though we looked it up earlier. *************** *** 655,660 **** --- 762,768 ---- GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize); pGroups = (PTOKEN_GROUPS)malloc(dwSize); + assert(pGroups); /* Allocate that buffer, and read in the list of groups. */ if (GetTokenInformation (hToken, TokenGroups, pGroups, dwSize, &dwSize)) *************** *** 687,692 **** --- 795,801 ---- GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize); pTokenUser = (PTOKEN_USER)malloc(dwSize); + assert(pTokenUser); if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize)) gle = GetLastError(); *************** *** 718,736 **** return fAdmin; } ! static SetACLCmd(as) ! struct cmd_syndesc *as; { ! register afs_int32 code; struct ViceIoctl blob; ! struct Acl *ta; ! register struct cmd_item *ti, *ui; int plusp; afs_int32 rights; int clear; int idf = getidf(as, parm_setacl_id); ! if (as->parms[2].items) clear=1; ! else clear=0; plusp = !(as->parms[3].items); for(ti=as->parms[0].items; ti;ti=ti->next) { blob.out_size = MAXSIZE; --- 827,850 ---- return fAdmin; } ! static int ! SetACLCmd(struct cmd_syndesc *as, char *arock) ! { ! afs_int32 code; struct ViceIoctl blob; ! struct Acl *ta = 0; ! struct cmd_item *ti, *ui; int plusp; afs_int32 rights; int clear; int idf = getidf(as, parm_setacl_id); ! int error = 0; ! ! if (as->parms[2].items) ! clear = 1; ! else ! clear = 0; plusp = !(as->parms[3].items); for(ti=as->parms[0].items; ti;ti=ti->next) { blob.out_size = MAXSIZE; *************** *** 739,772 **** code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); ! return 1; } ta = ParseAcl(space); if (!plusp && ta->dfs) { fprintf(stderr, "fs: %s: you may not use the -negative switch with DFS acl's.\n%s", ti->data, "(you may specify \"null\" to revoke all rights, however)\n"); ! return 1; } ! if (clear) ta = EmptyAcl(space); ! else ta = ParseAcl(space); ! CleanAcl(ta); for(ui=as->parms[1].items; ui; ui=ui->next->next) { enum rtype rtype; if (!ui->next) { ! fprintf(stderr,"%s: Missing second half of user/access pair.\n", pn); return 1; } rights = Convert(ui->next->data, ta->dfs, &rtype); if (rtype == destroy && !ta->dfs) { ! if (!FindList(ta->pluslist, ui->data)) { ! fprintf(stderr,"%s: Invalid arg (%s doesn't exist in the current acl)\n", pn, ui->data); ! return 1; ! } } ! if (rtype == deny && !ta->dfs) plusp = 0; ! if (rtype == destroy && ta->dfs) rights = -1; ChangeList(ta, plusp, ui->data, rights); } blob.in = AclToString(ta); --- 853,899 ---- code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); ! error = 1; ! continue; } + if (ta) + ZapAcl(ta); ta = ParseAcl(space); if (!plusp && ta->dfs) { fprintf(stderr, "fs: %s: you may not use the -negative switch with DFS acl's.\n%s", ti->data, "(you may specify \"null\" to revoke all rights, however)\n"); ! error = 1; ! continue; } ! if (ta) ! ZapAcl(ta); ! if (clear) ! ta = EmptyAcl(space); ! else ! ta = ParseAcl(space); ! CleanAcl(ta, ti->data); for(ui=as->parms[1].items; ui; ui=ui->next->next) { enum rtype rtype; if (!ui->next) { ! fprintf(stderr, ! "%s: Missing second half of user/access pair.\n", pn); ! ZapAcl(ta); return 1; } rights = Convert(ui->next->data, ta->dfs, &rtype); if (rtype == destroy && !ta->dfs) { ! struct AclEntry *tlist; ! ! tlist = (plusp ? ta->pluslist : ta->minuslist); ! if (!FindList(tlist, ui->data)) ! continue; } ! if (rtype == deny && !ta->dfs) ! plusp = 0; ! if (rtype == destroy && ta->dfs) ! rights = -1; ChangeList(ta, plusp, ui->data, rights); } blob.in = AclToString(ta); *************** *** 810,844 **** " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n"); } } else { ! fprintf(stderr,"%s: Invalid argument, possible reasons include:\n", pn); fprintf(stderr,"\t-File not in AFS\n"); ! fprintf(stderr,"\t-Too many users on access control list\n"); ! fprintf(stderr,"\t-Tried to add non-existent user to access control list\n"); } ! return 1; ! } ! else { Die(errno, ti->data); ! continue; ! } ! } } ! return 0; } ! ! static CopyACLCmd(as) ! struct cmd_syndesc *as; { ! register afs_int32 code; struct ViceIoctl blob; ! struct Acl *fa, *ta; struct AclEntry *tp; ! register struct cmd_item *ti; int clear; int idf = getidf(as, parm_copyacl_id); ! if (as->parms[2].items) clear=1; ! else clear=0; blob.out_size = MAXSIZE; blob.in_size = idf; blob.in = blob.out = space; --- 937,978 ---- " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n"); } } else { ! fprintf(stderr, ! "%s: Invalid argument, possible reasons include:\n", ! pn); fprintf(stderr,"\t-File not in AFS\n"); ! fprintf(stderr, ! "\t-Too many users on access control list\n"); ! fprintf(stderr, ! "\t-Tried to add non-existent user to access control list\n"); } ! } else { Die(errno, ti->data); ! } ! error = 1; ! } } ! if (ta) ! ZapAcl(ta); ! return error; } ! static int ! CopyACLCmd(struct cmd_syndesc *as, char *arock) ! { ! afs_int32 code; struct ViceIoctl blob; ! struct Acl *fa, *ta = 0; struct AclEntry *tp; ! struct cmd_item *ti; int clear; int idf = getidf(as, parm_copyacl_id); + int error = 0; ! if (as->parms[2].items) ! clear=1; ! else ! clear=0; blob.out_size = MAXSIZE; blob.in_size = idf; blob.in = blob.out = space; *************** *** 848,854 **** return 1; } fa = ParseAcl(space); ! CleanAcl(fa); for (ti=as->parms[1].items; ti;ti=ti->next) { blob.out_size = MAXSIZE; blob.in_size = idf; --- 982,988 ---- return 1; } fa = ParseAcl(space); ! CleanAcl(fa, as->parms[0].items->data); for (ti=as->parms[1].items; ti;ti=ti->next) { blob.out_size = MAXSIZE; blob.in_size = idf; *************** *** 856,874 **** code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); ! return 1; } ! if (clear) ta = EmptyAcl(space); ! else ta = ParseAcl(space); ! CleanAcl(ta); if (ta->dfs != fa->dfs) { ! fprintf(stderr, "fs: incompatible file system types: acl not copied to %s; aborted\n", ti->data); ! goto next; } if (ta->dfs) { if (! clear && strcmp(ta->cell, fa->cell) != 0) { ! fprintf(stderr, "fs: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", ti->data); ! goto next; } strcpy(ta->cell, fa->cell); } --- 990,1019 ---- code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); ! error = 1; ! continue; } ! if (ta) ! ZapAcl(ta); ! if (clear) ! ta = EmptyAcl(space); ! else ! ta = ParseAcl(space); ! CleanAcl(ta, ti->data); if (ta->dfs != fa->dfs) { ! fprintf(stderr, ! "%s: incompatible file system types: acl not copied to %s; aborted\n", ! pn, ti->data); ! error = 1; ! continue; } if (ta->dfs) { if (! clear && strcmp(ta->cell, fa->cell) != 0) { ! fprintf(stderr, ! "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", ! pn, ti->data); ! error = 1; ! continue; } strcpy(ta->cell, fa->cell); } *************** *** 882,921 **** code = pioctl(ti->data, VIOCSETAL, &blob, 1); if (code) { if (errno == EINVAL) { ! fprintf(stderr,"%s: Invalid argument, possible reasons include:\n", pn); fprintf(stderr,"\t-File not in AFS\n"); ! return 1; ! } ! else { Die(errno, ti->data); - goto next; } } ! next: ZapAcl(ta); ! } ! return 0; } ! /* tell if a name is 23 or -45 (digits or minus digits), which are bad names we must prune */ ! static BadName(aname) ! register char *aname; { ! register int tc; ! while(tc = *aname++) { /* all must be '-' or digit to be bad */ ! if (tc != '-' && (tc < '0' || tc > '9')) return 0; } ! return 1; } /* clean up an access control list of its bad entries; return 1 if we made any changes to the list, and 0 otherwise */ ! int CleanAcl(aa) ! struct Acl *aa; { ! register struct AclEntry *te, **le, *ne; int changes; /* Don't correct DFS ACL's for now */ --- 1027,1099 ---- code = pioctl(ti->data, VIOCSETAL, &blob, 1); if (code) { if (errno == EINVAL) { ! fprintf(stderr, ! "%s: Invalid argument, possible reasons include:\n", pn); fprintf(stderr,"\t-File not in AFS\n"); ! } else { Die(errno, ti->data); } + error = 1; } ! } ! if (ta) ZapAcl(ta); ! ZapAcl(fa); ! return error; } + /* pioctl() call to get the cellname of a pathname */ + static afs_int32 + GetCell(char *fname, char *cellname) + { + afs_int32 code; + struct ViceIoctl blob; + + blob.in_size = 0; + blob.out_size = MAXCELLCHARS; + blob.out = cellname; + + code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1); + return code ? errno : 0; + } + /* Check if a username is valid: If it contains only digits (or a + * negative sign), then it might be bad. We then query the ptserver + * to see. + */ + static int + BadName(char *aname, char *fname) + { + afs_int32 tc, code, id; + char *nm; + char cell[MAXCELLCHARS]; ! for ( nm = aname; tc = *nm; nm++) { /* all must be '-' or digit to be bad */ ! if (tc != '-' && (tc < '0' || tc > '9')) ! return 0; } ! ! /* Go to the PRDB and see if this all number username is valid */ ! code = GetCell(fname, cell); ! if (code) ! return 0; ! ! pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell); ! code = pr_SNameToId(aname, &id); ! pr_End(); ! ! /* 1=>Not-valid; 0=>Valid */ ! return ((!code && (id == ANONYMOUSID)) ? 1 : 0); } /* clean up an access control list of its bad entries; return 1 if we made any changes to the list, and 0 otherwise */ ! static int ! CleanAcl(struct Acl *aa, char *fname) ! { ! struct AclEntry *te, **le, *ne; int changes; /* Don't correct DFS ACL's for now */ *************** *** 927,954 **** le = &aa->pluslist; for(te = aa->pluslist; te; te=ne) { ne = te->next; ! if (BadName(te->name)) { /* zap this dude */ *le = te->next; aa->nplus--; free(te); changes++; ! } ! else { le = &te->next; } } le = &aa->minuslist; for(te = aa->minuslist; te; te=ne) { ne = te->next; ! if (BadName(te->name)) { /* zap this dude */ *le = te->next; aa->nminus--; free(te); changes++; ! } ! else { le = &te->next; } } --- 1105,1130 ---- le = &aa->pluslist; for(te = aa->pluslist; te; te=ne) { ne = te->next; ! if (BadName(te->name, fname)) { /* zap this dude */ *le = te->next; aa->nplus--; free(te); changes++; ! } else { le = &te->next; } } le = &aa->minuslist; for(te = aa->minuslist; te; te=ne) { ne = te->next; ! if (BadName(te->name, fname)) { /* zap this dude */ *le = te->next; aa->nminus--; free(te); changes++; ! } else { le = &te->next; } } *************** *** 957,970 **** /* clean up an acl to not have bogus entries */ ! static CleanACLCmd(as) ! register struct cmd_syndesc *as; { ! register afs_int32 code; ! register struct Acl *ta; struct ViceIoctl blob; int changes; ! register struct cmd_item *ti; ! register struct AclEntry *te; SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { --- 1133,1148 ---- /* clean up an acl to not have bogus entries */ ! static int ! CleanACLCmd(struct cmd_syndesc *as, char *arock) ! { ! afs_int32 code; ! struct Acl *ta = 0; struct ViceIoctl blob; int changes; ! struct cmd_item *ti; ! struct AclEntry *te; ! int error = 0; SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { *************** *** 974,991 **** code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); continue; } ta = ParseAcl(space); if (ta->dfs) { fprintf(stderr, "%s: cleanacl is not supported for DFS access lists.\n", pn); ! return 1; } ! changes = CleanAcl(ta); if (changes) { /* now set the acl */ --- 1152,1173 ---- code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); + error = 1; continue; } + if (ta) + ZapAcl(ta); ta = ParseAcl(space); if (ta->dfs) { fprintf(stderr, "%s: cleanacl is not supported for DFS access lists.\n", pn); ! error = 1; ! continue; } ! changes = CleanAcl(ta, ti->data); if (changes) { /* now set the acl */ *************** *** 995,1015 **** code = pioctl(ti->data, VIOCSETAL, &blob, 1); if (code) { if (errno == EINVAL) { ! fprintf(stderr,"%s: Invalid argument, possible reasons include\n", pn); fprintf(stderr,"%s: File not in vice or\n", pn); ! fprintf(stderr,"%s: Too many users on access control list or\n", pn); ! return 1; ! } ! else { Die(errno, ti->data); - continue; } } /* now list the updated acl */ printf("Access list for %s is now\n", ti->data); if (ta->nplus > 0) { ! if (!ta->dfs) printf("Normal rights:\n"); for(te = ta->pluslist;te;te=te->next) { printf(" %s ", te->name); PRights(te->rights, ta->dfs); --- 1177,1201 ---- code = pioctl(ti->data, VIOCSETAL, &blob, 1); if (code) { if (errno == EINVAL) { ! fprintf(stderr, ! "%s: Invalid argument, possible reasons include\n", ! pn); fprintf(stderr,"%s: File not in vice or\n", pn); ! fprintf(stderr, ! "%s: Too many users on access control list or\n", ! pn); ! } else { Die(errno, ti->data); } + error = 1; + continue; } /* now list the updated acl */ printf("Access list for %s is now\n", ti->data); if (ta->nplus > 0) { ! if (!ta->dfs) ! printf("Normal rights:\n"); for(te = ta->pluslist;te;te=te->next) { printf(" %s ", te->name); PRights(te->rights, ta->dfs); *************** *** 1024,1045 **** printf("\n"); } } ! if (ti->next) printf("\n"); ! } ! else printf("Access list for %s is fine.\n", ti->data); } ! return 0; } ! static ListACLCmd(as) ! register struct cmd_syndesc *as; { ! register afs_int32 code; ! register struct Acl *ta; struct ViceIoctl blob; struct AclEntry *te; ! register struct cmd_item *ti; int idf = getidf(as, parm_listacl_id); SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { --- 1210,1235 ---- printf("\n"); } } ! if (ti->next) ! printf("\n"); ! } else printf("Access list for %s is fine.\n", ti->data); } ! if (ta) ! ZapAcl(ta); ! return error; } ! static int ! ListACLCmd(struct cmd_syndesc *as, char *arock) ! { ! afs_int32 code; ! struct Acl *ta = 0; struct ViceIoctl blob; struct AclEntry *te; ! struct cmd_item *ti; int idf = getidf(as, parm_listacl_id); + int error = 0; SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { *************** *** 1050,1055 **** --- 1240,1246 ---- code = pioctl(ti->data, VIOCGETAL, &blob, 1); if (code) { Die(errno, ti->data); + error = 1; continue; } ta = ParseAcl(space); *************** *** 1072,1078 **** } separator = ta->dfs? DFS_SEPARATOR : ' '; if (ta->nplus > 0) { ! if (!ta->dfs) printf("Normal rights:\n"); for(te = ta->pluslist;te;te=te->next) { printf(" %s%c", te->name, separator); PRights(te->rights, ta->dfs); --- 1263,1270 ---- } separator = ta->dfs? DFS_SEPARATOR : ' '; if (ta->nplus > 0) { ! if (!ta->dfs) ! printf("Normal rights:\n"); for(te = ta->pluslist;te;te=te->next) { printf(" %s%c", te->name, separator); PRights(te->rights, ta->dfs); *************** *** 1087,1159 **** printf("\n"); } } ! if (ti->next) printf("\n"); } ! return 0; } ! static FlushVolumeCmd(as) ! register struct cmd_syndesc *as; { ! register afs_int32 code; struct ViceIoctl blob; ! register struct cmd_item *ti; for(ti=as->parms[0].items; ti; ti=ti->next) { blob.in_size = blob.out_size = 0; code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0); if (code) { ! fprintf(stderr, "Error flushing volume\n"); ! Die(errno,ti->data); continue; } } ! return 0; } ! static FlushCmd(as) ! register struct cmd_syndesc *as; { ! register afs_int32 code; struct ViceIoctl blob; ! int error; ! register struct cmd_item *ti; - error = 0; for(ti=as->parms[0].items; ti; ti=ti->next) { blob.in_size = blob.out_size = 0; code = pioctl(ti->data, VIOCFLUSH, &blob, 0); if (code) { - error = 1; if (errno == EMFILE) { ! fprintf(stderr,"%s: Can't flush active file %s\n", pn, ti->data); ! continue; ! } ! else { ! fprintf(stderr, "Error flushing file\n"); ! Die(errno,ti->data); ! continue; } } } return error; } /* all this command does is repackage its args and call SetVolCmd */ ! static SetQuotaCmd(as) ! register struct cmd_syndesc *as; { struct cmd_syndesc ts; /* copy useful stuff from our command slot; we may later have to reorder */ memcpy(&ts, as, sizeof(ts)); /* copy whole thing */ ! return SetVolCmd(&ts); } ! static SetVolCmd(as) ! register struct cmd_syndesc *as; { ! register afs_int32 code; struct ViceIoctl blob; ! register struct cmd_item *ti; struct VolumeStatus *status; char *motd, *offmsg, *input; SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { --- 1279,1358 ---- printf("\n"); } } ! if (ti->next) ! printf("\n"); ! ZapAcl(ta); } ! return error; } ! static int ! FlushVolumeCmd(struct cmd_syndesc *as, char *arock) ! { ! afs_int32 code; struct ViceIoctl blob; ! struct cmd_item *ti; ! int error = 0; + SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { blob.in_size = blob.out_size = 0; code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0); if (code) { ! fprintf(stderr, "Error flushing volume "); ! perror(ti->data); ! error = 1; continue; } } ! return error; } ! static int ! FlushCmd(struct cmd_syndesc *as, char *arock) ! { ! afs_int32 code; struct ViceIoctl blob; ! struct cmd_item *ti; ! ! int error = 0; for(ti=as->parms[0].items; ti; ti=ti->next) { blob.in_size = blob.out_size = 0; code = pioctl(ti->data, VIOCFLUSH, &blob, 0); if (code) { if (errno == EMFILE) { ! fprintf(stderr, "%s: Can't flush active file %s\n", pn, ! ti->data); ! } else { ! fprintf(stderr, "%s: Error flushing file ", pn); ! perror(ti->data); } + error = 1; + continue; } } return error; } /* all this command does is repackage its args and call SetVolCmd */ ! static int ! SetQuotaCmd(struct cmd_syndesc *as, char *arock) { struct cmd_syndesc ts; /* copy useful stuff from our command slot; we may later have to reorder */ memcpy(&ts, as, sizeof(ts)); /* copy whole thing */ ! return SetVolCmd(&ts, arock); } ! static int ! SetVolCmd(struct cmd_syndesc *as, char *arock) { ! afs_int32 code; struct ViceIoctl blob; ! struct cmd_item *ti; struct VolumeStatus *status; char *motd, *offmsg, *input; + int error = 0; SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { *************** *** 1164,1224 **** blob.in = space; status = (VolumeStatus *)space; status->MinQuota = status->MaxQuota = -1; ! motd = offmsg = (char *) 0; if (as->parms[1].items) { code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota); if (code) { ! fprintf(stderr,"fs: bad integer specified for quota.\n"); ! return code; } } ! if (as->parms[2].items) motd = as->parms[2].items->data; ! if (as->parms[3].items) offmsg = as->parms[3].items->data; input = (char *)status + sizeof(*status); *(input++) = '\0'; /* never set name: this call doesn't change vldb */ if(offmsg) { ! if (strlen(offmsg) >= VMSGSIZE) { ! fprintf(stderr,"fs: message must be shorter than %d characters\n", ! VMSGSIZE); ! return code; ! } strcpy(input,offmsg); blob.in_size += strlen(offmsg); input += strlen(offmsg) + 1; ! } ! else *(input++) = '\0'; if(motd) { ! if (strlen(motd) >= VMSGSIZE) { ! fprintf(stderr,"fs: message must be shorter than %d characters\n", ! VMSGSIZE); ! return code; ! } strcpy(input,motd); blob.in_size += strlen(motd); input += strlen(motd) + 1; ! } ! else *(input++) = '\0'; code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1); if (code) { ! Die(errno, ti->data); ! return 1; } } ! return 0; } ! static ExamineCmd(as) ! register struct cmd_syndesc *as; { ! register afs_int32 code; struct ViceIoctl blob; ! register struct cmd_item *ti; struct VolumeStatus *status; char *name, *offmsg, *motd; ! int error; - error = 0; SetDotDefault(&as->parms[0].items); for(ti=as->parms[0].items; ti; ti=ti->next) { /* once per file */ blob.out_size = MAXSIZE; blob.in_size = 0; --- 1363,1440 ---- blob.in = space; status = (VolumeStatus *)space; status->MinQuota = status->MaxQuota = -1; ! motd = offmsg = NULL; if (as->parms[1].items) { code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota); if (code) { ! fprintf(stderr,"%s: bad integer specified for quota.\n", pn); ! error = 1; ! continue; } } ! if (as->parms[2].items) ! motd = as->parms[2].items->data; ! if (as->parms[3].items) ! offmsg = as->p