diff --git a/README-NT b/README-NT index 40e4103fb6..7507062ddd 100644 --- a/README-NT +++ b/README-NT @@ -42,14 +42,14 @@ The Microsoft development tools require anywhere from 660 MB to 1.8GB of storage depending on which compilers are selected. The following versions are supported: - Microsoft Visual .NET + Microsoft Visual Studio .NET available via a MSDN subscription - Microsoft Visual .NET 2003 (recommended) + Microsoft Visual Studio .NET 2003 (recommended) available via a MSDN subscription - Microsoft Visual C++ Toolkit 2003 (same as .NET 2003) - http://msdn.microsoft.com/visualc/vctoolkit2003/ + Microsoft Visual Studio .NET 2005 (do not use for production) + available via a MSDN subscription The following Microsoft SDK is required: @@ -129,8 +129,8 @@ The AFS base directory should look something like the following: STEP B. Install compiler and development tools. -Install a copy of Microsoft Visual .NET, Visual .NET 2003, Visual C++ -Toolkit 2003. The "Typical" install setting is sufficient. +Install a copy of Microsoft Visual Studio .NET, Visual Studio .NET 2003, +or Visual Studio .NET 2005. The "Typical" install setting is sufficient. (1) You can reduce the installation size by selecting "Custom" install and remove all but the following Options: @@ -176,9 +176,9 @@ customized for use on your development system. The following variables must be defined to match your configuration: AFSVER_CL: Set to 1200 if using MS Visual C++ 6.0 - Set to 1300 if using MS Visual .NET - Set to 1310 if using MS Visual .NET 2003 - Set to 1400 if using MS Visual .NET 2005 + Set to 1300 if using MS Visual Studio .NET + Set to 1310 if using MS Visual Studio .NET 2003 + Set to 1400 if using MS Visual Studio .NET 2005 MSVCDIR: Set to the short name version of the directory into which the visual C++ compiler was installed regardless of version diff --git a/doc/txt/winnotes/afs-changes-since-1.2.txt b/doc/txt/winnotes/afs-changes-since-1.2.txt index 6f10f591d4..6378242aac 100644 --- a/doc/txt/winnotes/afs-changes-since-1.2.txt +++ b/doc/txt/winnotes/afs-changes-since-1.2.txt @@ -1,3 +1,10 @@ +Since 1.3.74: + * Added support for VL_GetEntryByNameN(). Still need to add + support for VL_GetEntryByNameU() for multi-homed support. + + * Fix a deadlock situation in afscreds.exe when canceling an + auto-generated Obtain Tokens dialog + Since 1.3.72/73: * Fix the locking of objects during Directory Searches in the SMB/CIFS server. The failure to properly lock the reference diff --git a/doc/txt/winnotes/afs-issues.txt b/doc/txt/winnotes/afs-issues.txt index 55b8a9b333..8bf80df301 100644 --- a/doc/txt/winnotes/afs-issues.txt +++ b/doc/txt/winnotes/afs-issues.txt @@ -142,6 +142,9 @@ directories. or by the new AFS Client Service Administration tool when executed by an authorized user. +(31) Add support for multi-homed servers + + ------------------------------------------------------------------------- List of unfunded projects: @@ -220,3 +223,5 @@ List of unfunded projects: 24. Add support for storing Extended Attributes on files 25. Add support for storing Windows ACLs on files 26. Remove submount creation as a side effect of drive creation + 27. Finish conversion from string.h to strsafe.h + 28. Add support for multi-homed servers diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index 8c3456849b..e7911fa3df 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -250,7 +250,7 @@ configureBackConnectionHostNames(void) DWORD dwType; DWORD dwSize; DWORD dwValue; - PBYTE pHostNames = NULL, pName; + PBYTE pHostNames = NULL, pName = NULL; BOOL bNameFound = FALSE; if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, @@ -273,12 +273,14 @@ configureBackConnectionHostNames(void) } if ( !bNameFound ) { + int size = strlen(cm_NetbiosName) + 2; if ( !pHostNames ) { - pName = pHostNames = malloc(strlen(cm_NetbiosName) + 2); + pHostNames = malloc(size); dwSize = 1; } - strcpy(pName, cm_NetbiosName); - pName += strlen(cm_NetbiosName) + 1; + pName = pHostNames; + StringCbCopyA(pName, size, strlen(cm_NetbiosName)); + pName += size - 1; *pName = '\0'; /* add a second nul terminator */ dwType = REG_MULTI_SZ; diff --git a/src/WINNT/afsd/afsicf.cpp b/src/WINNT/afsd/afsicf.cpp index 08ebec6fc0..5aec746317 100644 --- a/src/WINNT/afsd/afsicf.cpp +++ b/src/WINNT/afsd/afsicf.cpp @@ -135,6 +135,7 @@ HRESULT icf_CheckAndAddPorts(INetFwProfile * fwProfile, global_afs_port_t * port INetFwOpenPort * fwPort = NULL; HRESULT hr; HRESULT rhr = S_OK; /* return value */ + int i = 0; hr = fwProfile->get_GloballyOpenPorts(&fwPorts); if (FAILED(hr)) { @@ -145,7 +146,7 @@ HRESULT icf_CheckAndAddPorts(INetFwProfile * fwProfile, global_afs_port_t * port } // go through the supplied ports - for (int i=0; ihashp) + for (bp = buf_hashTablepp[i]; bp; bp=bp->hashp) { if (bp->refCount) { - sprintf(output, "%s bp=0x%08X, hash=%d, fid (cell=%d, volume=%d," - "vnode=%d, unique=%d), size=%d refCount=%d\n", + StringCbPrintfA(output, sizeof(output), "vnode=%d, unique=%d), size=%d refCount=%d\n", cookie, (void *)bp, i, bp->fid.cell, bp->fid.volume, bp->fid.vnode, bp->fid.unique, bp->size, bp->refCount); WriteFile(outputFile, output, strlen(output), &zilch, NULL); @@ -1482,7 +1481,7 @@ int cm_DumpBufHashTable(FILE *outputFile, char *cookie) } } - sprintf(output, "%s - Done dumping buf_HashTable.\n", cookie); + StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_HashTable.\n", cookie); WriteFile(outputFile, output, strlen(output), &zilch, NULL); lock_ReleaseRead(&buf_globalLock); diff --git a/src/WINNT/afsd/cm_freelance.c b/src/WINNT/afsd/cm_freelance.c index 0894791a1a..6ea93601fa 100644 --- a/src/WINNT/afsd/cm_freelance.c +++ b/src/WINNT/afsd/cm_freelance.c @@ -619,26 +619,6 @@ long cm_InitLocalMountPoints() { // open the ini file for reading fp = fopen(hdir, "r"); - // if we fail to open the file, create an empty one - if (!fp) { - fp = fopen(hdir, "w"); - code = cm_GetRootCellName(rootCellName); - if (code == 0) { - fputs("1\n", fp); - fprintf(fp,"%s#%s:root.cell.\n",rootCellName,rootCellName); - fprintf(fp,".%s%%%s:root.cell.\n",rootCellName,rootCellName); - fclose(fp); - fp = fopen(hdir, "r"); - } else { - fputs("0\n", fp); - fclose(fp); - return 0; /* success */ - } - } - - // we successfully opened the file - osi_Log0(afsd_logp,"opened afs_freelance.ini"); - #if !defined(DJGPP) RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\OpenAFS\\Client\\Freelance", @@ -652,6 +632,22 @@ long cm_InitLocalMountPoints() { dwIndex = 0; #endif + if (!fp) { +#if !defined(DJGPP); + RegCloseKey(hkFreelance); +#endif + 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; + } + + // we successfully opened the file + osi_Log0(afsd_logp,"opened afs_freelance.ini"); + // now we read the first line to see how many entries // there are fgets(line, sizeof(line), fp); @@ -668,9 +664,11 @@ long cm_InitLocalMountPoints() { // that we read cm_noLocalMountPoints = atoi(line); - // create space to store the local mount points - cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints); - aLocalMountPoint = cm_localMountPoints; + if (cm_noLocalMountPoints > 0) { + // create space to store the local mount points + cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints); + aLocalMountPoint = cm_localMountPoints; + } // now we read n lines and parse them into local mount points // where n is the number of local mount points there are, as @@ -688,6 +686,11 @@ long cm_InitLocalMountPoints() { return -1; } + /* find the trailing dot; null terminate after it */ + t2 = strrchr(line, '.'); + if (t2) + *(t2+1) = '\0'; + #if !defined(DJGPP) if ( hkFreelance ) { char szIndex[16]; @@ -714,8 +717,8 @@ long cm_InitLocalMountPoints() { *(aLocalMountPoint->namep + (t-line)) = 0; aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1); - memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2); - *(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0; + memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-1); + *(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-1)) = 0; osi_Log2(afsd_logp,"found mount point: name %s, string %s", aLocalMountPoint->namep, @@ -816,9 +819,9 @@ long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize); break; } else { - int len = strlen(filename); - if ( dwType == REG_SZ && !strncmp(filename, szMount, len) && - (szMount[len] == '%' || szMount[len] == '#')) { + int len = strlen(filename); + if ( dwType == REG_SZ && !strncmp(filename, szMount, len) && + (szMount[len] == '%' || szMount[len] == '#')) { /* Replace the existing value */ dwType = REG_SZ; dwSize = strlen(line) + 1; diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index bb60b77e6b..b50205294a 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -259,7 +259,7 @@ void cm_SkipIoctlPath(smb_ioctl_t *ioctlp) * easier (because we can always jump past the initial "/afs" to find * the AFS path that should be written into afsdsbmt.ini). */ -void cm_NormalizeAfsPath (char *outpathp, char *inpathp) +void cm_NormalizeAfsPath(char *outpathp, long outlen, char *inpathp) { char *cp; char bslash_mountRoot[256]; @@ -268,13 +268,13 @@ void cm_NormalizeAfsPath (char *outpathp, char *inpathp) bslash_mountRoot[0] = '\\'; if (!strnicmp (inpathp, cm_mountRoot, strlen(cm_mountRoot))) - lstrcpy (outpathp, inpathp); + StringCbCopy(outpathp, outlen, inpathp); else if (!strnicmp (inpathp, bslash_mountRoot, strlen(bslash_mountRoot))) - lstrcpy (outpathp, inpathp); + StringCbCopy(outpathp, outlen, inpathp); else if ((inpathp[0] == '/') || (inpathp[0] == '\\')) - sprintf (outpathp, "%s%s", cm_mountRoot, inpathp); + StringCbPrintfA(outpathp, outlen, "%s%s", cm_mountRoot, inpathp); else // inpathp looks like "/usr" - sprintf (outpathp, "%s/%s", cm_mountRoot, inpathp); + StringCbPrintfA(outpathp, outlen, "%s/%s", cm_mountRoot, inpathp); for (cp = outpathp; *cp != 0; ++cp) { if (*cp == '\\') @@ -286,10 +286,11 @@ void cm_NormalizeAfsPath (char *outpathp, char *inpathp) } if (!strcmpi (outpathp, cm_mountRoot)) { - strcpy (outpathp, cm_mountRoot); + StringCbCopy(outpathp, outlen, cm_mountRoot); } } +#define LEAF_SIZE 256 /* parse the passed-in file name and do a namei on its parent. If we fail, * return an error code, otherwise return the vnode located in *scpp. */ @@ -301,7 +302,7 @@ long cm_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp, char *tp, *jp; cm_scache_t *substRootp; - strcpy(tbuffer, ioctlp->inDatap); + StringCbCopyA(tbuffer, sizeof(tbuffer), ioctlp->inDatap); tp = strrchr(tbuffer, '\\'); jp = strrchr(tbuffer, '/'); if (!tp) @@ -309,14 +310,14 @@ long cm_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp, else if (jp && (tp - tbuffer) < (jp - tbuffer)) tp = jp; if (!tp) { - strcpy(tbuffer, "\\"); + StringCbCopyA(tbuffer, sizeof(tbuffer), "\\"); if (leafp) - strcpy(leafp, ioctlp->inDatap); + StringCbCopyA(leafp, LEAF_SIZE, ioctlp->inDatap); } else { *tp = 0; if (leafp) - strcpy(leafp, tp+1); + StringCbCopyA(leafp, LEAF_SIZE, tp+1); } if (tbuffer[0] == tbuffer[1] && @@ -463,7 +464,7 @@ long cm_IoctlGetFileCellName(struct smb_ioctl *ioctlp, struct cm_user *userp) scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID && scp->fid.vnode==0x1 && scp->fid.unique==0x1 ) { - strcpy(ioctlp->outDatap, "Freelance.Local.Root"); + StringCbCopyA(ioctlp->outDatap, 999999, "Freelance.Local.Root"); ioctlp->outDatap += strlen(ioctlp->outDatap) + 1; code = 0; } else @@ -471,7 +472,7 @@ long cm_IoctlGetFileCellName(struct smb_ioctl *ioctlp, struct cm_user *userp) { cellp = cm_FindCellByID(scp->fid.cell); if (cellp) { - strcpy(ioctlp->outDatap, cellp->namep); + StringCbCopyA(ioctlp->outDatap, 999999, cellp->namep); ioctlp->outDatap += strlen(ioctlp->outDatap) + 1; code = 0; } @@ -620,11 +621,11 @@ long cm_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp) cp = ioctlp->inDatap; memcpy((char *)&volStat, cp, sizeof(AFSFetchVolumeStatus)); cp += sizeof(AFSFetchVolumeStatus); - strcpy(volName, cp); + StringCbCopyA(volName, sizeof(volName), cp); cp += strlen(volName)+1; - strcpy(offLineMsg, cp); + StringCbCopyA(offLineMsg, sizeof(offLineMsg), cp); cp += strlen(offLineMsg)+1; - strcpy(motd, cp); + StringCbCopyA(motd, sizeof(motd), cp); storeStat.Mask = 0; if (volStat.MinQuota != -1) { storeStat.MinQuota = volStat.MinQuota; @@ -660,11 +661,11 @@ long cm_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp) cp = ioctlp->outDatap; memcpy(cp, (char *)&volStat, sizeof(VolumeStatus)); cp += sizeof(VolumeStatus); - strcpy(cp, volName); + StringCbCopyA(cp, 999999, volName); cp += strlen(volName)+1; - strcpy(cp, offLineMsg); + StringCbCopyA(cp, 999999, offLineMsg); cp += strlen(offLineMsg)+1; - strcpy(cp, motd); + StringCbCopyA(cp, 999999, motd); cp += strlen(motd)+1; /* now return updated return data pointer */ @@ -716,11 +717,11 @@ long cm_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp) cp = ioctlp->outDatap; memcpy(cp, (char *)&volStat, sizeof(AFSFetchVolumeStatus)); cp += sizeof(AFSFetchVolumeStatus); - strcpy(cp, volName); + StringCbCopyA(cp, 999999, volName); cp += strlen(volName)+1; - strcpy(cp, offLineMsg); + StringCbCopyA(cp, 999999, offLineMsg); cp += strlen(offLineMsg)+1; - strcpy(cp, motd); + StringCbCopyA(cp, 999999, motd); cp += strlen(motd)+1; /* return new size */ @@ -811,7 +812,7 @@ long cm_IoctlStatMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp) code = cm_ReadMountPoint(scp, userp, &req); if (code == 0) { cp = ioctlp->outDatap; - strcpy(cp, scp->mountPointStringp); + StringCbCopyA(cp, 999999, scp->mountPointStringp); cp += strlen(cp) + 1; ioctlp->outDatap = cp; } @@ -1096,7 +1097,7 @@ long cm_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp) } lock_ReleaseRead(&cm_serverLock); cp = basep + max * sizeof(afs_int32); - strcpy(cp, tcellp->namep); + StringCbCopyA(cp, 999999, tcellp->namep); cp += strlen(tcellp->namep)+1; ioctlp->outDatap = cp; } @@ -1169,7 +1170,7 @@ long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp) } /* return the default cellname to the caller */ - strcpy(ioctlp->outDatap, cm_rootCellp->namep); + StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep); ioctlp->outDatap += strlen(ioctlp->outDatap) +1; /* done: success */ @@ -1218,7 +1219,7 @@ long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) osi_panic("cm_IoctlSysName: !cm_sysName\n", __FILE__, __LINE__); if (!setSysName) { /* user just wants the info */ - strcpy(outname, cm_sysName); + StringCbCopyA(outname, sizeof(outname), cm_sysName); foundname = cm_sysNameCount; *sysnamelist = cm_sysNameList; } else { @@ -1226,8 +1227,8 @@ long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) /* clear @sys entries from the dnlc, once afs_lookup can * do lookups of @sys entries and thinks it can trust them */ /* privs ok, store the entry, ... */ - strcpy(cm_sysName, inname); - strcpy(cm_sysNameList[0], inname); + StringCbCopyA(cm_sysName, sizeof(cm_sysName), inname); + StringCbCopyA(cm_sysNameList[0], MAXSYSNAME, inname); if (setSysName > 1) { /* ... or list */ cp = ioctlp->inDatap; for (count = 1; count < setSysName; ++count) { @@ -1235,7 +1236,7 @@ long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) osi_panic("cm_IoctlSysName: no cm_sysNameList entry to write\n", __FILE__, __LINE__); t = strlen(cp); - strcpy(cm_sysNameList[count], cp); + StringCbCopyA(cm_sysNameList[count], MAXSYSNAME, cp); cp += t + 1; } } @@ -1248,7 +1249,7 @@ long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) memcpy(cp, (char *)&foundname, sizeof(afs_int32)); cp += sizeof(afs_int32); /* skip found flag */ if (foundname) { - strcpy(cp, outname); + StringCbCopyA(cp, 999999, outname); cp += strlen(outname) + 1; /* skip name and terminating null char */ for ( count=1; count < foundname ; ++count) { /* ... or list */ if ( !(*sysnamelist)[count] ) @@ -1258,7 +1259,7 @@ long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp) if (t >= MAXSYSNAME) osi_panic("cm_IoctlSysName: sysname entry garbled\n", __FILE__, __LINE__); - strcpy(cp, (*sysnamelist)[count]); + StringCbCopyA(cp, 999999, (*sysnamelist)[count]); cp += t + 1; } } @@ -1426,7 +1427,7 @@ long cm_IoctlStoreBehind(struct smb_ioctl *ioctlp, struct cm_user *userp) long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp) { - char leaf[256]; + char leaf[LEAF_SIZE]; long code; cm_scache_t *dscp; cm_attr_t tattr; @@ -1453,12 +1454,12 @@ long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp) */ /* Extract the possibly partial cell name */ - strcpy(cell, ioctlp->inDatap + 1); /* Skip the mp type character */ + StringCbCopyA(cell, sizeof(cell), ioctlp->inDatap + 1); /* Skip the mp type character */ if (cp = strchr(cell, ':')) { /* Extract the volume name */ *cp = 0; - strcpy(volume, cp + 1); + StringCbCopyA(volume, sizeof(volume), cp + 1); /* Get the full name for this cell */ code = cm_SearchCellFile(cell, fullCell, 0, 0); @@ -1469,10 +1470,10 @@ long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp) if (code) return CM_ERROR_NOSUCHCELL; - sprintf(mpInfo, "%c%s:%s", *ioctlp->inDatap, fullCell, volume); + StringCbPrintfA(mpInfo, sizeof(mpInfo), "%c%s:%s", *ioctlp->inDatap, fullCell, volume); } else { /* No cell name specified */ - strcpy(mpInfo, ioctlp->inDatap); + StringCbCopyA(mpInfo, sizeof(mpInfo), ioctlp->inDatap); } #ifdef AFS_FREELANCE_CLIENT @@ -1504,7 +1505,7 @@ long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp) long cm_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp) { - char leaf[256]; + char leaf[LEAF_SIZE]; long code; cm_scache_t *dscp; cm_attr_t tattr; @@ -1596,11 +1597,11 @@ long cm_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp) if (code == 0) { cp = ioctlp->outDatap; if (newRootScp != NULL) { - strcpy(cp, cm_mountRoot); - strcat(cp, "/"); + StringCbCopyA(cp, 999999, cm_mountRoot); + StringCbCatA(cp, 999999, "/"); cp += strlen(cp); } - strcpy(cp, spacep->data); + StringCbCopyA(cp, 999999, spacep->data); cp += strlen(cp) + 1; ioctlp->outDatap = cp; cm_FreeSpace(spacep); @@ -1814,7 +1815,8 @@ long cm_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp) ucellp->kvno = ct.AuthHandle; ucellp->expirationTime = ct.EndTimestamp; ucellp->gen++; - if (uname) strcpy(ucellp->userName, uname); + if (uname) + StringCbCopyA(ucellp->userName, MAXKTCNAMELEN, uname); ucellp->flags |= CM_UCELLFLAG_RXKAD; lock_ReleaseMutex(&userp->mx); @@ -1900,11 +1902,11 @@ long cm_IoctlGetTokenIter(struct smb_ioctl *ioctlp, struct cm_user *userp) cp += sizeof(temp); /* cell name */ - strcpy(cp, ucellp->cellp->namep); + StringCbCopyA(cp, 999999, ucellp->cellp->namep); cp += strlen(cp) + 1; /* user name */ - strcpy(cp, ucellp->userName); + StringCbCopyA(cp, 999999, ucellp->userName); cp += strlen(cp) + 1; ioctlp->outDatap = cp; @@ -1988,11 +1990,11 @@ long cm_IoctlGetToken(struct smb_ioctl *ioctlp, struct cm_user *userp) cp += sizeof(temp); /* cell name */ - strcpy(cp, ucellp->cellp->namep); + StringCbCopyA(cp, 999999, ucellp->cellp->namep); cp += strlen(cp) + 1; /* user name */ - strcpy(cp, ucellp->userName); + StringCbCopyA(cp, 999999, ucellp->userName); cp += strlen(cp) + 1; ioctlp->outDatap = cp; @@ -2084,7 +2086,7 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) /* Parse the input parameters--first the required afs path, * then the requested submount name (which may be ""). */ - cm_NormalizeAfsPath (afspath, ioctlp->inDatap); + cm_NormalizeAfsPath (afspath, sizeof(afspath), ioctlp->inDatap); submountreqp = ioctlp->inDatap + (strlen(ioctlp->inDatap)+1); /* If the caller supplied a suggested submount name, see if @@ -2125,9 +2127,9 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) strlen(&afspath[strlen(cm_mountRoot)])+1:2); RegCloseKey( hkSubmounts ); - strcpy(ioctlp->outDatap, submountreqp); - ioctlp->outDatap += strlen(ioctlp->outDatap) +1; - lock_ReleaseMutex(&cm_Afsdsbmt_Lock); + StringCbCopyA(ioctlp->outDatap, 999999, submountreqp); + ioctlp->outDatap += strlen(ioctlp->outDatap) +1; + lock_ReleaseMutex(&cm_Afsdsbmt_Lock); return 0; } @@ -2135,9 +2137,9 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) * supplied path matches the submount's path, we can still * use the suggested submount name. */ - cm_NormalizeAfsPath (submountPathNormalized, submountPath); + cm_NormalizeAfsPath (submountPathNormalized, sizeof(submountPathNormalized), submountPath); if (!strcmp (submountPathNormalized, afspath)) { - strcpy(ioctlp->outDatap, submountreqp); + StringCbCopyA(ioctlp->outDatap, 999999, submountreqp); ioctlp->outDatap += strlen(ioctlp->outDatap) +1; RegCloseKey( hkSubmounts ); lock_ReleaseMutex(&cm_Afsdsbmt_Lock); @@ -2204,9 +2206,9 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) * that our caller specified. If so, we can return * this submount. */ - cm_NormalizeAfsPath (submountPathNormalized, submountPath); + cm_NormalizeAfsPath (submountPathNormalized, sizeof(submountPathNormalized), submountPath); if (!strcmp (submountPathNormalized, afspath)) { - strcpy(ioctlp->outDatap, submountName); + StringCbCopyA(ioctlp->outDatap, 999999, submountName); ioctlp->outDatap += strlen(ioctlp->outDatap) +1; RegCloseKey(hkSubmounts); lock_ReleaseMutex(&cm_Afsdsbmt_Lock); @@ -2221,7 +2223,7 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) * when writing out the submount. */ - sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount); + StringCbPrintfA(ioctlp->outDatap, 999999, "auto%ld", nextAutoSubmount); RegSetValueEx( hkSubmounts, ioctlp->outDatap, diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index cfd3c382cc..b5e2a7626f 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -1007,8 +1007,6 @@ int cm_FindFileType(cm_fid_t *fidp) lock_ObtainWrite(&cm_scacheLock); for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) { if (cm_FidCmp(fidp, &scp->fid) == 0) { - /*scp->refCount++;*/ - /*cm_AdjustLRU(scp);*/ lock_ReleaseWrite(&cm_scacheLock); return scp->fileType; } diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index c784a35451..932b9b809b 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -39,123 +39,212 @@ void cm_InitVolume(void) /* * Update a volume. Caller holds volume's lock (volp->mx). + * + * + * shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU} 01:38 (JHutz) + * Yes, we support multihomed fileservers. + * Since before we got the code from IBM. + * But to find out about multiple addresses on a multihomed server, you need + * to use VL_GetEntryByNameU and VL_GetAddrsU. If you use + * VL_GetEntryByNameO or VL_GetEntryByNameN, the vlserver just gives you one + * address per server. + * shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU} 01:39 (JHutz) + * see src/afs/afs_volume.c, paying particular attention to + * afs_NewVolumeByName, afs_SetupVolume, and InstallUVolumeEntry + * shadow / openafs / jaltman {ANDREW.CMU.EDU} 01:40 (Jeffrey Altman) + * thanks. The windows client calls the 0 versions. + * shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU} 01:51 (JHutz) + * Oh. Ew. + * By not using the N versions, you only get up to 8 sites instead of 13. + * By not using the U versions, you don't get to know about multihomed serve + * shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU} 01:52 (JHutz) + * Of course, you probably want to support the older versions for backward + * compatibility. If you do that, you need to call the newest interface + * first, and fall back to successively older versions if you get + * RXGEN_OPCODE. */ long cm_UpdateVolume(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *reqp, cm_volume_t *volp) { cm_conn_t *connp; int i; - cm_serverRef_t *tsrp; + cm_serverRef_t *tsrp; cm_server_t *tsp; struct sockaddr_in tsockAddr; long tflags; u_long tempAddr; - struct vldbentry vldbEntry; /* don't use NVLDB yet; they're not common */ - int ROcount = 0; - long code; + struct vldbentry vldbEntry; + struct nvldbentry nvldbEntry; +#ifdef MULTIHOMED + struct uvldbentry uvldbEntry; +#endif + int type = -1; + int ROcount = 0; + long code; - /* clear out old bindings */ + /* clear out old bindings */ cm_FreeServerList(&volp->rwServersp); cm_FreeServerList(&volp->roServersp); cm_FreeServerList(&volp->bkServersp); /* now we have volume structure locked and held; make RPC to fill it */ do { - code = cm_ConnByMServers(cellp->vlServersp, userp, reqp, - &connp); - if (code) continue; - osi_Log1(afsd_logp, "CALL VL_GetEntryByNameO name %s", - volp->namep); - code = VL_GetEntryByNameO(connp->callp, volp->namep, &vldbEntry); - } while (cm_Analyze(connp, userp, reqp, NULL, NULL, cellp->vlServersp, NULL, code)); + code = cm_ConnByMServers(cellp->vlServersp, userp, reqp, &connp); + if (code) + continue; + osi_Log1(afsd_logp, "CALL VL_GetEntryByName{UNO} name %s", volp->namep); +#ifdef MULTIHOMED + code = VL_GetEntryByNameU(connp->callp, volp->namep, &uvldbEntry); + if ( code == RXGEN_OPCODE ) +#endif + { + code = VL_GetEntryByNameN(connp->callp, volp->namep, &nvldbEntry); + type = 1; + } + if ( code == RXGEN_OPCODE ) { + code = VL_GetEntryByNameO(connp->callp, volp->namep, &vldbEntry); + type = 0; + } + } while (cm_Analyze(connp, userp, reqp, NULL, NULL, cellp->vlServersp, NULL, code)); code = cm_MapVLRPCError(code, reqp); if (code == 0) { - /* decode the response */ - lock_ObtainWrite(&cm_volumeLock); - if (vldbEntry.flags & VLF_RWEXISTS) - volp->rwID = vldbEntry.volumeId[0]; - else + afs_int32 flags; + afs_int32 nServers; + afs_int32 rwID; + afs_int32 roID; + afs_int32 bkID; + afs_int32 serverNumber[NMAXNSERVERS]; + afs_int32 serverFlags[NMAXNSERVERS]; + + switch ( type ) { + case 0: + flags = vldbEntry.flags; + nServers = vldbEntry.nServers; + rwID = vldbEntry.volumeId[0]; + roID = vldbEntry.volumeId[1]; + bkID = vldbEntry.volumeId[2]; + for ( i=0; irwID = rwID; + else volp->rwID = 0; - if (vldbEntry.flags & VLF_ROEXISTS) - volp->roID = vldbEntry.volumeId[1]; + if (flags & VLF_ROEXISTS) + volp->roID = roID; else volp->roID = 0; - if (vldbEntry.flags & VLF_BACKEXISTS) - volp->bkID = vldbEntry.volumeId[2]; - else + if (flags & VLF_BACKEXISTS) + volp->bkID = bkID; + else volp->bkID = 0; - lock_ReleaseWrite(&cm_volumeLock); - for(i=0; icellp ) - tsp->cellp = cellp; + /* if this server was created by fs setserverprefs */ + if ( !tsp->cellp ) + tsp->cellp = cellp; osi_assert(tsp != NULL); /* and add it to the list(s). */ - /* + /* * Each call to cm_NewServerRef() increments the * ref count of tsp. These reference will be dropped, - * if and when the volume is reset; see reset code - * earlier in this function. - */ - if ((tflags & VLSF_RWVOL) - && (vldbEntry.flags & VLF_RWEXISTS)) { - tsrp = cm_NewServerRef(tsp); + * if and when the volume is reset; see reset code + * earlier in this function. + */ + if ((tflags & VLSF_RWVOL) && (flags & VLF_RWEXISTS)) { + tsrp = cm_NewServerRef(tsp); cm_InsertServerList(&volp->rwServersp, tsrp); lock_ObtainWrite(&cm_serverLock); tsrp->refCount--; /* drop allocation reference */ lock_ReleaseWrite(&cm_serverLock); - } - if ((tflags & VLSF_ROVOL) - && (vldbEntry.flags & VLF_ROEXISTS)) { - tsrp = cm_NewServerRef(tsp); - cm_InsertServerList(&volp->roServersp, tsrp); + } + if ((tflags & VLSF_ROVOL) && (flags & VLF_ROEXISTS)) { + tsrp = cm_NewServerRef(tsp); + cm_InsertServerList(&volp->roServersp, tsrp); lock_ObtainWrite(&cm_serverLock); tsrp->refCount--; /* drop allocation reference */ lock_ReleaseWrite(&cm_serverLock); - ROcount++; + ROcount++; } - /* We don't use VLSF_BACKVOL !?! */ - if ((tflags & VLSF_RWVOL) - && (vldbEntry.flags & VLF_BACKEXISTS)) { - tsrp = cm_NewServerRef(tsp); + /* We don't use VLSF_BACKVOL !?! */ + if ((tflags & VLSF_RWVOL) && (flags & VLF_BACKEXISTS)) { + tsrp = cm_NewServerRef(tsp); cm_InsertServerList(&volp->bkServersp, tsrp); lock_ObtainWrite(&cm_serverLock); tsrp->refCount--; /* drop allocation reference */ lock_ReleaseWrite(&cm_serverLock); - } - /* Drop the reference obtained by cm_FindServer() */ - cm_PutServer(tsp); - } + } + /* Drop the reference obtained by cm_FindServer() */ + cm_PutServer(tsp); + } - /* - * Randomize RO list - * - * If the first n servers have the same ipRank, then we - * randomly pick one among them and move it to the beginning. - * We don't bother to re-order the whole list because - * the rest of the list is used only if the first server is - * down. We only do this for the RO list; we assume the other - * lists are length 1. - */ - if (ROcount > 1) { - cm_RandomizeServer(&volp->roServersp); - } - } - return code; + /* + * Randomize RO list + * + * If the first n servers have the same ipRank, then we + * randomly pick one among them and move it to the beginning. + * We don't bother to re-order the whole list because + * the rest of the list is used only if the first server is + * down. We only do this for the RO list; we assume the other + * lists are length 1. + */ + if (ROcount > 1) { + cm_RandomizeServer(&volp->roServersp); + } + } + return code; } long cm_GetVolumeByID(cm_cell_t *cellp, long volumeID, cm_user_t *userp, diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 980da2c5a2..50df833eef 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -21,7 +21,6 @@ #include #include #include - #include #include "afsd.h" diff --git a/src/WINNT/client_creds/creds.cpp b/src/WINNT/client_creds/creds.cpp index ff568ca18e..47312c911a 100644 --- a/src/WINNT/client_creds/creds.cpp +++ b/src/WINNT/client_creds/creds.cpp @@ -446,7 +446,7 @@ int GetDefaultCell (LPTSTR pszCell) } else if (IsServiceRunning()) { - char szCellA[ 256 ] = ""; + char szCellA[ cchRESOURCE ] = ""; int rc; HKEY hk; @@ -463,8 +463,8 @@ int GetDefaultCell (LPTSTR pszCell) } else { rc = 0; } - if (rc == 0) - CopyAnsiToString(pszCell, szCellA); + if (rc == 0) + CopyAnsiToString(pszCell, szCellA); } return rc; } diff --git a/src/WINNT/client_creds/credstab.cpp b/src/WINNT/client_creds/credstab.cpp index 2ab0949fba..d9ac53ea41 100644 --- a/src/WINNT/client_creds/credstab.cpp +++ b/src/WINNT/client_creds/credstab.cpp @@ -389,6 +389,10 @@ void NewCreds_OnCancel (HWND hDlg) pszCell = (LPTSTR)GetWindowLong (hDlg, DWL_USER); if (pszCell) { + HWND hTab = GetDlgItem (g.hMain, IDC_TABS); + LPTSTR pszTab = (LPTSTR)GetTabParam (hTab, TabCtrl_GetCurSel(hTab)); + HWND hChildDlg = NULL; + lock_ObtainMutex(&g.credsLock); for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds) { @@ -399,17 +403,16 @@ void NewCreds_OnCancel (HWND hDlg) // Check the active tab, and fix its checkbox if necessary // - HWND hTab = GetDlgItem (g.hMain, IDC_TABS); - LPTSTR pszTab = (LPTSTR)GetTabParam (hTab, TabCtrl_GetCurSel(hTab)); if (pszTab && HIWORD(pszTab) && (!lstrcmpi (pszTab, pszCell))) { - HWND hDlg = GetTabChild (hTab); - if (hDlg) - CheckDlgButton (hDlg, IDC_CREDS_REMIND, FALSE); + hChildDlg = GetTabChild (hTab); } } } lock_ReleaseMutex(&g.credsLock); - } + + if (hChildDlg) + CheckDlgButton (hChildDlg, IDC_CREDS_REMIND, FALSE); + } }