if (ntsEx == STATUS_SUCCESS) {
memcpy(vcp->encKey, lsaResp->ChallengeToClient, MSV1_0_CHALLENGE_LENGTH);
- LsaFreeReturnBuffer(lsaResp);
} else {
/*
* This will cause the subsequent authentication to fail but
*/
memset(vcp->encKey, 0, MSV1_0_CHALLENGE_LENGTH);
}
+ if (lsaResp)
+ LsaFreeReturnBuffer(lsaResp);
}
else
memset(vcp->encKey, 0, MSV1_0_CHALLENGE_LENGTH);
if (code == 0) {
clientchar_t temp[1024];
- cm_FsStringToClientString(ftemp, (int)cm_FsStrLen(ftemp), temp, 1024);
+ cm_FsStringToClientString(ftemp, -1, temp, 1024);
cm_ClientStrPrintfN(pathName, (int)lengthof(pathName),
rw ? _C("/.%S/") : _C("/%S/"), temp);
*pathNamep = cm_ClientStrDup(cm_ClientStrLwr(pathName));
if (!smb_lastDirSearchp)
smb_lastDirSearchp = (smb_dirSearch_t *) &dsp->q;
}
- lock_ObtainMutex(&dsp->mx);
dsp->refCount++;
- lock_ReleaseMutex(&dsp->mx);
break;
}
}
void smb_DeleteDirSearch(smb_dirSearch_t *dsp)
{
- lock_ObtainWrite(&smb_globalLock);
lock_ObtainMutex(&dsp->mx);
osi_Log3(smb_logp,"smb_DeleteDirSearch cookie %d dsp 0x%p scp 0x%p",
dsp->cookie, dsp, dsp->scp);
lock_ReleaseWrite(&dsp->scp->rw);
}
lock_ReleaseMutex(&dsp->mx);
- lock_ReleaseWrite(&smb_globalLock);
}
/* Must be called with the smb_globalLock held */
{
cm_scache_t *scp = NULL;
- lock_ObtainMutex(&dsp->mx);
osi_assertx(dsp->refCount-- > 0, "cm_scache_t refCount 0");
- if (dsp->refCount == 0 && (dsp->flags & SMB_DIRSEARCH_DELETE)) {
- if (&dsp->q == (osi_queue_t *) smb_lastDirSearchp)
- smb_lastDirSearchp = (smb_dirSearch_t *) osi_QPrev(&smb_lastDirSearchp->q);
- osi_QRemove((osi_queue_t **) &smb_firstDirSearchp, &dsp->q);
- lock_ReleaseMutex(&dsp->mx);
- lock_FinalizeMutex(&dsp->mx);
- scp = dsp->scp;
- osi_Log3(smb_logp,"smb_ReleaseDirSearch cookie %d dsp 0x%p scp 0x%p",
- dsp->cookie, dsp, scp);
- free(dsp);
- } else {
- lock_ReleaseMutex(&dsp->mx);
+ if (dsp->refCount == 0) {
+ lock_ObtainMutex(&dsp->mx);
+ if (dsp->flags & SMB_DIRSEARCH_DELETE) {
+ if (&dsp->q == (osi_queue_t *) smb_lastDirSearchp)
+ smb_lastDirSearchp = (smb_dirSearch_t *) osi_QPrev(&smb_lastDirSearchp->q);
+ osi_QRemove((osi_queue_t **) &smb_firstDirSearchp, &dsp->q);
+ lock_ReleaseMutex(&dsp->mx);
+ lock_FinalizeMutex(&dsp->mx);
+ scp = dsp->scp;
+ osi_Log3(smb_logp,"smb_ReleaseDirSearch cookie %d dsp 0x%p scp 0x%p",
+ dsp->cookie, dsp, scp);
+ free(dsp);
+ } else {
+ lock_ReleaseMutex(&dsp->mx);
+ }
}
/* do this now to avoid spurious locking hierarchy creation */
if (scp)
void smb_GCDirSearches(int isV3)
{
smb_dirSearch_t *prevp;
- smb_dirSearch_t *tp;
+ smb_dirSearch_t *dsp;
smb_dirSearch_t *victimsp[SMB_DIRSEARCH_GCMAX];
int victimCount;
int i;
victimCount = 0; /* how many have we got so far */
- for (tp = smb_lastDirSearchp; tp; tp=prevp) {
+ for (dsp = smb_lastDirSearchp; dsp; dsp=prevp) {
/* we'll move tp from queue, so
* do this early.
*/
- prevp = (smb_dirSearch_t *) osi_QPrev(&tp->q);
+ prevp = (smb_dirSearch_t *) osi_QPrev(&dsp->q);
/* if no one is using this guy, and we're either in the new protocol,
* or we're in the old one and this is a small enough ID to be useful
* to the old protocol, GC this guy.
*/
- if (tp->refCount == 0 && (isV3 || tp->cookie <= 255)) {
+ if (dsp->refCount == 0 && (isV3 || dsp->cookie <= 255)) {
/* hold and delete */
- lock_ObtainMutex(&tp->mx);
- tp->flags |= SMB_DIRSEARCH_DELETE;
- lock_ReleaseMutex(&tp->mx);
- victimsp[victimCount++] = tp;
- tp->refCount++;
+ lock_ObtainMutex(&dsp->mx);
+ dsp->flags |= SMB_DIRSEARCH_DELETE;
+ lock_ReleaseMutex(&dsp->mx);
+ victimsp[victimCount++] = dsp;
+ dsp->refCount++;
}
/* don't do more than this */
/* don't need to watch for refcount zero and deleted, since
* we haven't dropped the global lock.
*/
- lock_ObtainMutex(&dsp->mx);
dsp->refCount--;
- lock_ReleaseMutex(&dsp->mx);
++smb_dirSearchCounter;
continue;
}
osi_panic("afsd: invalid smb_vc_t detected in smb_allVCsp",
__FILE__, __LINE__);
+ /* on the first pass hold 'vcp' which was not held as 'nextp' */
+ if (vcp != nextp)
+ smb_HoldVCNoLock(vcp);
+
+ /*
+ * obtain a reference to 'nextp' now because we drop the
+ * smb_rctLock later and the list contents could change
+ * or 'vcp' could be destroyed when released.
+ */
nextp = vcp->nextp;
+ if (nextp)
+ smb_HoldVCNoLock(nextp);
- if (vcp->flags & SMB_VCFLAG_ALREADYDEAD)
+ if (vcp->flags & SMB_VCFLAG_ALREADYDEAD) {
+ smb_ReleaseVCNoLock(vcp);
continue;
+ }
- smb_HoldVCNoLock(vcp);
- if (nextp)
- smb_HoldVCNoLock(nextp);
smb_FormatResponsePacket(vcp, NULL, outp);
smbp = (smb_t *)outp;
outp->inCom = smbp->com = 0x2b /* Echo */;
lock_ObtainWrite(&smb_rctLock);
smb_ReleaseVCNoLock(vcp);
- if (nextp)
- smb_ReleaseVCNoLock(nextp);
}
lock_ReleaseWrite(&smb_rctLock);
smb_FreePacket(outp);
switch (scp->fileType) {
case CM_SCACHETYPE_DIRECTORY:
case CM_SCACHETYPE_MOUNTPOINT:
- case CM_SCACHETYPE_SYMLINK:
case CM_SCACHETYPE_INVALID:
attr = SMB_ATTR_DIRECTORY;
break;
+ case CM_SCACHETYPE_SYMLINK:
+ if (cm_TargetPerceivedAsDirectory(scp->mountPointStringp))
+ attr = SMB_ATTR_DIRECTORY;
+ else
+ attr = SMB_ATTR_NORMAL;
+ break;
default:
/* if we get here we either have a normal file
* or we have a file for which we have never
* received status info. In this case, we can
* check the even/odd value of the entry's vnode.
- * even means it is to be treated as a directory
- * and odd means it is to be treated as a file.
+ * odd means it is to be treated as a directory
+ * and even means it is to be treated as a file.
*/
if (mustFake && (scp->fid.vnode & 0x1))
attr = SMB_ATTR_DIRECTORY;
cm_SyncOpDone(newScp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
-#ifdef undef
- /* use smb_Attributes instead. Also the fact that a file is
- * in a readonly volume doesn't mean it shojuld be marked as RO
- */
- if (newScp->fileType == CM_SCACHETYPE_DIRECTORY ||
- newScp->fileType == CM_SCACHETYPE_MOUNTPOINT ||
- newScp->fileType == CM_SCACHETYPE_INVALID)
- attrs = SMB_ATTR_DIRECTORY;
- else
- attrs = 0;
- if ((newScp->unixModeBits & 0222) == 0 || (newScp->flags & CM_SCACHEFLAG_RO))
- attrs |= SMB_ATTR_READONLY; /* turn on read-only flag */
-#else
attrs = smb_Attributes(newScp);
-#endif
smb_SetSMBParm(outp, 0, attrs);
lock_ObtainMutex(&fidp->mx);
if (code == 0 && filter != 0 && (fidp->flags & SMB_FID_NTOPEN)
- && (fidp->NTopen_dscp->flags & CM_SCACHEFLAG_ANYWATCH)) {
+ && (fidp->NTopen_dscp->flags & CM_SCACHEFLAG_ANYWATCH))
+ {
+ lock_ReleaseMutex(&fidp->mx);
smb_NotifyChange(FILE_ACTION_MODIFIED, filter,
fidp->NTopen_dscp, fidp->NTopen_pathp,
NULL, TRUE);
- }
- lock_ReleaseMutex(&fidp->mx);
+ } else {
+ lock_ReleaseMutex(&fidp->mx);
+ }
if (code == 0) {
if (smb_AsyncStore > 0) {
if (code == NRC_NAMERR) {
/* An smb shutdown or Vista resume must have taken place */
- osi_Log2(smb_logp,
+ osi_Log1(smb_logp,
"NCBLISTEN lana=%d failed with NRC_NAMERR.",
- ncbp->ncb_lana_num, code);
+ ncbp->ncb_lana_num);
+ afsi_log("NCBLISTEN lana=%d failed with NRC_NAMERR.", ncbp->ncb_lana_num);
if (lock_TryMutex(&smb_StartedLock)) {
lana_list.lana[i] = LANA_INVALID;
osi_Log2(smb_logp,
"NCBLISTEN lana=%d failed with %s. Listener thread exiting.",
ncbp->ncb_lana_num, ncb_error_string(code));
+ afsi_log("NCBLISTEN lana=%d failed with %s. Listener thread exiting.",
+ ncbp->ncb_lana_num, ncb_error_string(code));
for (i = 0; i < lana_list.length; i++) {
if (lana_list.lana[i] == lana) {
memcpy(ncbp->ncb_name,smb_sharename,NCBNAMSZ);
code = Netbios(ncbp);
- afsi_log("Netbios NCBDELNAME lana=%d code=%d retcode=%d complete=%d",
+ afsi_log("StopListener: Netbios NCBDELNAME lana=%d code=%d retcode=%d complete=%d",
lana, code, ncbp->ncb_retcode, ncbp->ncb_cmd_cplt);
/* and then reset the LANA; this will cause the listener threads to exit */
if (code == 0)
code = ncbp->ncb_retcode;
if (code != 0) {
- afsi_log("Netbios NCBRESET lana %d error code %d", lana, code);
+ afsi_log("StopListener: Netbios NCBRESET lana %d error code %d", lana, code);
} else {
- afsi_log("Netbios NCBRESET lana %d succeeded", lana);
+ afsi_log("StopListener: Netbios NCBRESET lana %d succeeded", lana);
}
if (wait)
if (code == 0)
code = ncbp->ncb_retcode;
if (code != 0) {
- fprintf(stderr, "Netbios NCBDELNAME lana %d error code %d",
+ fprintf(stderr, "Shutdown: Netbios NCBDELNAME lana %d error code %d",
ncbp->ncb_lana_num, code);
}
fflush(stderr);
if (fidp->scp != NULL) {
cm_scache_t * scp;
+ lock_ReleaseWrite(&smb_rctLock);
lock_ObtainMutex(&fidp->mx);
if (fidp->scp != NULL) {
scp = fidp->scp;
cm_ReleaseSCache(scp);
}
lock_ReleaseMutex(&fidp->mx);
+ lock_ObtainWrite(&smb_rctLock);
}
}