From 516614090190f34cb74ec741cf06f86384bff4d1 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 26 Jan 2005 15:49:14 +0000 Subject: [PATCH] windows-misc-20050126 * The list of ACL entries was becoming corrupted because the function which obtained a free entry was doing so without the appropriate lock being held. * Changed the default @sys name list to "x86_win32 i386_w2k i386_nt40" for 32-bit x86 systems. The default for itanium will be "ia64_win64" and "amd64_win64" for amd 64-bit processors. --- src/WINNT/afsd/afsd_init.c | 55 ++++++++++----------- src/WINNT/afsd/cm_aclent.c | 118 +++++++++------------------------------------ 2 files changed, 51 insertions(+), 122 deletions(-) diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index 1bb9d9f..e2ff15a 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -394,7 +394,7 @@ int afsd_InitCM(char **reasonP) static struct rx_securityClass *nullServerSecurityClassp; struct hostent *thp; char *msgBuf; - char buf[1024]; + char buf[1024], *p, *q; HKEY parmKey; DWORD dummyLen; DWORD regType; @@ -671,35 +671,36 @@ int afsd_InitCM(char **reasonP) 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); + 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); - 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--; - } + /* 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]); - } 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); } + done_sysname: + StringCbCopyA(cm_sysName, MAXSYSNAME, cm_sysNameList[0]); dummyLen = sizeof(cryptall); code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL, diff --git a/src/WINNT/afsd/cm_aclent.c b/src/WINNT/afsd/cm_aclent.c index bbaf4ff..5898045 100644 --- a/src/WINNT/afsd/cm_aclent.c +++ b/src/WINNT/afsd/cm_aclent.c @@ -28,7 +28,8 @@ * 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. @@ -51,13 +52,13 @@ long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, long *rightsp) */ } else { *rightsp = aclp->randomAccess; - if (cm_data.aclLRUEndp == aclp) - cm_data.aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); + 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_data.aclLRUp, &aclp->q); - osi_QAddH((osi_queue_t **) &cm_data.aclLRUp, - (osi_queue_t **) &cm_data.aclLRUEndp, + 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 */ } @@ -80,14 +81,14 @@ static cm_aclent_t *GetFreeACLEnt(void) cm_aclent_t *taclp; cm_aclent_t **laclpp; - if (cm_data.aclLRUp == NULL) + if (cm_aclLRUp == NULL) osi_panic("empty aclent LRU", __FILE__, __LINE__); lock_ObtainWrite(&cm_aclLock); - aclp = cm_data.aclLRUEndp; - if (aclp == cm_data.aclLRUEndp) - cm_data.aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q); - osi_QRemove((osi_queue_t **) &cm_data.aclLRUp, &aclp->q); + 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 @@ -140,7 +141,7 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights) * someone there. */ aclp = GetFreeACLEnt(); /* can't fail, panics instead */ - osi_QAddH((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q); + osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q); aclp->backp = scp; aclp->nextp = scp->randomACLp; scp->randomACLp = aclp; @@ -153,73 +154,10 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights) return 0; } -long cm_ShutdownACLCache(void) -{ - return 0; -} - -long cm_ValidateACLCache(void) -{ - long size = cm_data.stats * 2; - long count; - cm_aclent_t * aclp; - - for ( aclp = cm_data.aclLRUp, count = 0; aclp; - aclp = (cm_aclent_t *) osi_QNext(&aclp->q), count++ ) { - if (aclp->magic != CM_ACLENT_MAGIC) { - afsi_log("cm_ValidateACLCache failure: acpl->magic != CM_ACLENT_MAGIC"); - fprintf(stderr, "cm_ValidateACLCache failure: acpl->magic != CM_ACLENT_MAGIC\n"); - return -1; - } - if (aclp->nextp && aclp->nextp->magic != CM_ACLENT_MAGIC) { - afsi_log("cm_ValidateACLCache failure: acpl->nextp->magic != CM_ACLENT_MAGIC"); - fprintf(stderr,"cm_ValidateACLCache failure: acpl->nextp->magic != CM_ACLENT_MAGIC\n"); - return -2; - } - if (aclp->backp && aclp->backp->magic != CM_SCACHE_MAGIC) { - afsi_log("cm_ValidateACLCache failure: acpl->backp->magic != CM_SCACHE_MAGIC"); - fprintf(stderr,"cm_ValidateACLCache failure: acpl->backp->magic != CM_SCACHE_MAGIC\n"); - return -3; - } - if (count != 0 && aclp == cm_data.aclLRUp || count > size) { - afsi_log("cm_ValidateACLCache failure: loop in cm_data.aclLRUp list"); - fprintf(stderr, "cm_ValidateACLCache failure: loop in cm_data.aclLRUp list\n"); - return -4; - } - } - - for ( aclp = cm_data.aclLRUEndp, count = 0; aclp; - aclp = (cm_aclent_t *) osi_QPrev(&aclp->q), count++ ) { - if (aclp->magic != CM_ACLENT_MAGIC) { - afsi_log("cm_ValidateACLCache failure: aclp->magic != CM_ACLENT_MAGIC"); - fprintf(stderr, "cm_ValidateACLCache failure: aclp->magic != CM_ACLENT_MAGIC\n"); - return -5; - } - if (aclp->nextp && aclp->nextp->magic != CM_ACLENT_MAGIC) { - afsi_log("cm_ValidateACLCache failure: aclp->nextp->magic != CM_ACLENT_MAGIC"); - fprintf(stderr, "cm_ValidateACLCache failure: aclp->nextp->magic != CM_ACLENT_MAGIC\n"); - return -6; - } - if (aclp->backp && aclp->backp->magic != CM_SCACHE_MAGIC) { - afsi_log("cm_ValidateACLCache failure: aclp->backp->magic != CM_SCACHE_MAGIC"); - fprintf(stderr, "cm_ValidateACLCache failure: aclp->backp->magic != CM_SCACHE_MAGIC\n"); - return -7; - } - - if (count != 0 && aclp == cm_data.aclLRUEndp || count > size) { - afsi_log("cm_ValidateACLCache failure: loop in cm_data.aclLRUEndp list"); - fprintf(stderr, "cm_ValidateACLCache failure: loop in cm_data.aclLRUEndp list\n"); - return -8; - } - } - - return 0; -} - /* * Initialize the cache to have an entries. Called during system startup. */ -long cm_InitACLCache(int newFile, long size) +long cm_InitACLCache(long size) { cm_aclent_t *aclp; long i; @@ -231,26 +169,16 @@ long cm_InitACLCache(int newFile, long size) } lock_ObtainWrite(&cm_aclLock); - if ( newFile ) { - cm_data.aclLRUp = cm_data.aclLRUEndp = NULL; - aclp = (cm_aclent_t *) cm_data.aclBaseAddress; - memset(aclp, 0, size * sizeof(cm_aclent_t)); + 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++) { - aclp->magic = CM_ACLENT_MAGIC; - osi_QAddH((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q); - aclp++; - } - } else { - aclp = (cm_aclent_t *) cm_data.aclBaseAddress; - for (i = 0; i < size; i++) { - aclp->userp = NULL; - aclp->tgtLifetime = 0; - aclp++; - } + /* + * 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; -- 1.9.4