#pragma warning(disable: 4005)
#include <ntstatus.h>
#pragma warning(pop)
+#include <sddl.h>
#include <stddef.h>
#include <stdlib.h>
#include <malloc.h>
#include <WINNT\afsreg.h>
#include "smb.h"
+#include "msrpc.h"
#include "lanahelper.h"
#define STRSAFE_NO_DEPRECATE
smb_dirSearch_t *smb_firstDirSearchp;
smb_dirSearch_t *smb_lastDirSearchp;
+/* Initial mode bits for files and directories. Set to 0 to use
+ defaults. */
+int smb_unixModeDefaultFile = 0666;
+int smb_unixModeDefaultDir = 0777;
+
/* hide dot files? */
int smb_hideDotFiles;
*/
time_t smb_localZero = 0;
-#define USE_NUMERIC_TIME_CONV 1
-
-#ifndef USE_NUMERIC_TIME_CONV
-/* Time difference for converting to kludge-GMT */
-afs_uint32 smb_NowTZ;
-#endif /* USE_NUMERIC_TIME_CONV */
-
char *smb_localNamep = NULL;
smb_vc_t *smb_allVCsp;
smb_waitingLockRequest_t *smb_allWaitingLocks;
-DWORD smb_TlsRequestSlot = -1;
-
/* forward decl */
void smb_DispatchPacket(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp,
NCB *ncbp, raw_write_cont_t *rwcp);
reqp->flags |= CM_REQ_SOURCE_SMB;
}
-void smb_ResetServerPriority()
-{
- void * p = TlsGetValue(smb_TlsRequestSlot);
- if (p) {
- free(p);
- TlsSetValue(smb_TlsRequestSlot, NULL);
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
- }
-}
-
-void smb_SetRequestStartTime()
-{
- time_t * tp = TlsGetValue(smb_TlsRequestSlot);
- if (!tp)
- tp = malloc(sizeof(time_t));
- if (tp) {
- *tp = osi_Time();
-
- if (!TlsSetValue(smb_TlsRequestSlot, tp))
- free(tp);
- }
-}
-
-void smb_UpdateServerPriority()
-{
- time_t *tp = TlsGetValue(smb_TlsRequestSlot);
-
- if (tp) {
- time_t now = osi_Time();
-
- /* Give one priority boost for each 15 seconds */
- SetThreadPriority(GetCurrentThread(), (int)((now - *tp) / 15));
- }
-}
-
-
const char * ncb_error_string(int code)
{
const char * s;
case 63:
return "RAP(63)NetWkStaGetInfo";
}
-}
+}
+
+char * myCrt_NmpipeDispatch(int i)
+{
+ switch(i) {
+ case SMB_TRANS_SET_NMPIPE_STATE:
+ return "SET NMPIPE STATE";
+
+ case SMB_TRANS_RAW_READ_NMPIPE:
+ return "RAW READ NMPIPE";
+
+ case SMB_TRANS_QUERY_NMPIPE_STATE:
+ return "QUERY NMPIPE STATE";
+
+ case SMB_TRANS_QUERY_NMPIPE_INFO:
+ return "QUERY NMPIPE INFO";
+
+ case SMB_TRANS_PEEK_NMPIPE:
+ return "PEEK NMPIPE";
+
+ case SMB_TRANS_TRANSACT_NMPIPE:
+ return "TRANSACT NMPIPE";
+
+ case SMB_TRANS_RAW_WRITE_NMPIPE:
+ return "WRITE NMPIPE";
+
+ case SMB_TRANS_READ_NMPIPE:
+ return "READ NMPIPE";
+
+ case SMB_TRANS_WRITE_NMPIPE:
+ return "WRITE NMPIPE";
+
+ case SMB_TRANS_WAIT_NMPIPE:
+ return "WAIT NMPIPE";
+
+ case SMB_TRANS_CALL_NMPIPE:
+ return "CALL NMPIPE";
+ }
+ return "(Unknown)";
+}
/* scache must be locked */
unsigned int smb_Attributes(cm_scache_t *scp)
* turns out to be impolitic in NT. See defect 10007.
*/
#ifdef notdef
- if ((scp->unixModeBits & 0222) == 0 || (scp->flags & CM_SCACHEFLAG_RO))
+ if ((scp->unixModeBits & 0200) == 0 || (scp->flags & CM_SCACHEFLAG_RO))
attrs |= SMB_ATTR_READONLY; /* turn on read-only flag */
#else
- if ((scp->unixModeBits & 0222) == 0)
+ if ((scp->unixModeBits & 0200) == 0)
attrs |= SMB_ATTR_READONLY; /* turn on read-only flag */
#endif
return attrs;
}
+void smb_SetInitialModeBitsForFile(int smb_attr, cm_attr_t * attr)
+{
+ if (smb_unixModeDefaultFile != 0) {
+ attr->mask |= CM_ATTRMASK_UNIXMODEBITS;
+ attr->unixModeBits = smb_unixModeDefaultFile;
+ if (smb_attr & SMB_ATTR_READONLY)
+ attr->unixModeBits &= ~0222;
+ }
+}
+
+void smb_SetInitialModeBitsForDir(int smb_attr, cm_attr_t * attr)
+{
+ if (smb_unixModeDefaultDir != 0) {
+ attr->mask |= CM_ATTRMASK_UNIXMODEBITS;
+ attr->unixModeBits = smb_unixModeDefaultDir;
+ }
+}
+
/* Check if the named file/dir is a dotfile/dotdir */
/* String pointed to by lastComp can have leading slashes, but otherwise should have
no other patch components */
FILETIME ft;
WORD wDate, wTime;
- smb_LargeSearchTimeFromUnixTime(&ft, unixTime);
+ cm_LargeSearchTimeFromUnixTime(&ft, unixTime);
if (!FileTimeToDosDateTime(&ft, &wDate, &wTime))
osi_Log1(smb_logp, "Failed to convert filetime to dos datetime: %d", GetLastError());
*pLastWriteTime -= (-bias * 60); /* Convert bias to seconds */
}
-#ifndef USE_NUMERIC_TIME_CONV
-/*
- * Calculate the difference (in seconds) between local time and GMT.
- * This enables us to convert file times to kludge-GMT.
- */
-static void
-smb_CalculateNowTZ()
-{
- time_t t;
- struct tm gmt_tm, local_tm;
- int days, hours, minutes, seconds;
-
- t = time(NULL);
- gmt_tm = *(gmtime(&t));
- local_tm = *(localtime(&t));
-
- days = local_tm.tm_yday - gmt_tm.tm_yday;
- hours = 24 * days + local_tm.tm_hour - gmt_tm.tm_hour;
- minutes = 60 * hours + local_tm.tm_min - gmt_tm.tm_min;
- seconds = 60 * minutes + local_tm.tm_sec - gmt_tm.tm_sec;
-
- smb_NowTZ = seconds;
-}
-#endif /* USE_NUMERIC_TIME_CONV */
-
-#ifdef USE_NUMERIC_TIME_CONV
-void smb_LargeSearchTimeFromUnixTime(FILETIME *largeTimep, time_t unixTime)
-{
- // Note that LONGLONG is a 64-bit value
- LONGLONG ll;
-
- ll = Int32x32To64(unixTime, 10000000) + 116444736000000000;
- largeTimep->dwLowDateTime = (DWORD)(ll & 0xFFFFFFFF);
- largeTimep->dwHighDateTime = (DWORD)(ll >> 32);
-}
-#else
-void smb_LargeSearchTimeFromUnixTime(FILETIME *largeTimep, time_t unixTime)
-{
- struct tm *ltp;
- SYSTEMTIME stm;
- struct tm localJunk;
- time_t ersatz_unixTime;
-
- /*
- * Must use kludge-GMT instead of real GMT.
- * kludge-GMT is computed by adding time zone difference to localtime.
- *
- * real GMT would be:
- * ltp = gmtime(&unixTime);
- */
- ersatz_unixTime = unixTime - smb_NowTZ;
- ltp = localtime(&ersatz_unixTime);
-
- /* if we fail, make up something */
- if (!ltp) {
- ltp = &localJunk;
- localJunk.tm_year = 89 - 20;
- localJunk.tm_mon = 4;
- localJunk.tm_mday = 12;
- localJunk.tm_hour = 0;
- localJunk.tm_min = 0;
- localJunk.tm_sec = 0;
- }
-
- stm.wYear = ltp->tm_year + 1900;
- stm.wMonth = ltp->tm_mon + 1;
- stm.wDayOfWeek = ltp->tm_wday;
- stm.wDay = ltp->tm_mday;
- stm.wHour = ltp->tm_hour;
- stm.wMinute = ltp->tm_min;
- stm.wSecond = ltp->tm_sec;
- stm.wMilliseconds = 0;
-
- SystemTimeToFileTime(&stm, largeTimep);
-}
-#endif /* USE_NUMERIC_TIME_CONV */
-
-#ifdef USE_NUMERIC_TIME_CONV
-void smb_UnixTimeFromLargeSearchTime(time_t *unixTimep, FILETIME *largeTimep)
-{
- // Note that LONGLONG is a 64-bit value
- LONGLONG ll;
-
- ll = largeTimep->dwHighDateTime;
- ll <<= 32;
- ll += largeTimep->dwLowDateTime;
-
- ll -= 116444736000000000;
- ll /= 10000000;
-
- *unixTimep = (DWORD)ll;
-}
-#else /* USE_NUMERIC_TIME_CONV */
-void smb_UnixTimeFromLargeSearchTime(time_t *unixTimep, FILETIME *largeTimep)
-{
- SYSTEMTIME stm;
- struct tm lt;
- long save_timezone;
-
- FileTimeToSystemTime(largeTimep, &stm);
-
- lt.tm_year = stm.wYear - 1900;
- lt.tm_mon = stm.wMonth - 1;
- lt.tm_wday = stm.wDayOfWeek;
- lt.tm_mday = stm.wDay;
- lt.tm_hour = stm.wHour;
- lt.tm_min = stm.wMinute;
- lt.tm_sec = stm.wSecond;
- lt.tm_isdst = -1;
-
- save_timezone = _timezone;
- _timezone += smb_NowTZ;
- *unixTimep = mktime(<);
- _timezone = save_timezone;
-}
-#endif /* USE_NUMERIC_TIME_CONV */
-
-void smb_SearchTimeFromUnixTime(afs_uint32 *searchTimep, time_t unixTime)
-{
- struct tm *ltp;
- int dosDate;
- int dosTime;
- struct tm localJunk;
- time_t t = unixTime;
-
- ltp = localtime(&t);
-
- /* if we fail, make up something */
- if (!ltp) {
- ltp = &localJunk;
- localJunk.tm_year = 89 - 20;
- localJunk.tm_mon = 4;
- localJunk.tm_mday = 12;
- localJunk.tm_hour = 0;
- localJunk.tm_min = 0;
- localJunk.tm_sec = 0;
- }
-
- dosDate = ((ltp->tm_year-80)<<9) | ((ltp->tm_mon+1) << 5) | (ltp->tm_mday);
- dosTime = (ltp->tm_hour<<11) | (ltp->tm_min << 5) | (ltp->tm_sec / 2);
- *searchTimep = (dosDate<<16) | dosTime;
-}
-
-void smb_UnixTimeFromSearchTime(time_t *unixTimep, afs_uint32 searchTime)
-{
- unsigned short dosDate;
- unsigned short dosTime;
- struct tm localTm;
-
- dosDate = (unsigned short) (searchTime & 0xffff);
- dosTime = (unsigned short) ((searchTime >> 16) & 0xffff);
-
- localTm.tm_year = 80 + ((dosDate>>9) & 0x3f);
- localTm.tm_mon = ((dosDate >> 5) & 0xf) - 1; /* January is 0 in localTm */
- localTm.tm_mday = (dosDate) & 0x1f;
- localTm.tm_hour = (dosTime>>11) & 0x1f;
- localTm.tm_min = (dosTime >> 5) & 0x3f;
- localTm.tm_sec = (dosTime & 0x1f) * 2;
- localTm.tm_isdst = -1; /* compute whether DST in effect */
-
- *unixTimep = mktime(&localTm);
-}
-
void smb_DosUTimeFromUnixTime(afs_uint32 *dosUTimep, time_t unixTime)
{
time_t diff_t = unixTime - smb_localZero;
free(tidp);
}
}
+ if (vcp)
+ smb_ReleaseVCNoLock(vcp);
if (!locked)
lock_ReleaseWrite(&smb_rctLock);
if (userp)
cm_ReleaseUser(userp);
- if (vcp)
- smb_ReleaseVCNoLock(vcp);
}
smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags)
return uidp;
}
+afs_int32 smb_userIsLocalSystem(smb_user_t *uidp)
+{
+ SID *pSid = NULL;
+ DWORD dwSize1 = 0, dwSize2 = 0;
+ wchar_t *pszRefDomain = NULL;
+ SID_NAME_USE snu = SidTypeGroup;
+ clientchar_t * secSidString = NULL;
+ DWORD gle;
+ afs_int32 isSystem = 0;
+
+ if (uidp->unp->flags & SMB_USERNAMEFLAG_SID) {
+ isSystem = !cm_ClientStrCmp(NTSID_LOCAL_SYSTEM, uidp->unp->name);
+ return isSystem;
+ }
+
+ /*
+ * The input name is not a SID for the user. See if we can
+ * obtain the SID for the specified name. If we can, use
+ * that instead of the name provided for the comparison.
+ */
+
+ LookupAccountNameW( NULL /* System Name to begin Search */,
+ uidp->unp->name,
+ NULL, &dwSize1,
+ NULL, &dwSize2,
+ &snu);
+ gle = GetLastError();
+ if (gle == ERROR_INSUFFICIENT_BUFFER) {
+ pSid = malloc(dwSize1);
+ /*
+ * Although dwSize2 is supposed to include the terminating
+ * NUL character, on Win7 it does not.
+ */
+ pszRefDomain = malloc((dwSize2 + 1) * sizeof(wchar_t));
+ }
+
+ if ( pSid && pszRefDomain ) {
+ memset(pSid, 0, dwSize1);
+
+ if (LookupAccountNameW( NULL /* System Name to begin Search */,
+ uidp->unp->name,
+ pSid, &dwSize1,
+ pszRefDomain, &dwSize2,
+ &snu))
+ ConvertSidToStringSidW(pSid, &secSidString);
+ }
+
+ if (secSidString) {
+ isSystem = !cm_ClientStrCmp(NTSID_LOCAL_SYSTEM, secSidString);
+ LocalFree(secSidString);
+ }
+
+ if (pSid)
+ free(pSid);
+ if (pszRefDomain)
+ free(pszRefDomain);
+
+ return isSystem;
+}
+
smb_username_t *smb_FindUserByName(clientchar_t *usern, clientchar_t *machine,
afs_uint32 flags)
{
smb_fid_t *fidp;
int newFid = 0;
- if (fid == 0 && !(flags & SMB_FLAG_CREATE))
- return NULL;
-
- lock_ObtainWrite(&smb_rctLock);
- /* figure out if we need to allocate a new file ID */
if (fid == 0) {
+ if (!(flags & SMB_FLAG_CREATE))
+ return NULL;
newFid = 1;
- fid = vcp->fidCounter;
}
+ lock_ObtainWrite(&smb_rctLock);
+ if (newFid)
+ fid = vcp->fidCounter;
retry:
+
for(fidp = vcp->fidsp; fidp; fidp = (smb_fid_t *) osi_QNext(&fidp->q)) {
if (fidp->refCount == 0 && fidp->deleteOk) {
fidp->refCount++;
lock_ReleaseWrite(&smb_rctLock);
smb_ReleaseFID(fidp);
lock_ObtainWrite(&smb_rctLock);
+ /*
+ * We dropped the smb_rctLock so the fid value we are using
+ * may now be used by another thread. Start over with the
+ * current vcp->fidCounter.
+ */
+ if (newFid)
+ fid = vcp->fidCounter;
goto retry;
}
if (fid == fidp->fid) {
if (newFid) {
+ osi_Log1(smb_logp, "smb_FindFID New Fid Requested. fid %d found -- retrying ...", fid);
fid++;
if (fid == 0xFFFF) {
osi_Log1(smb_logp,
if (!fidp && (flags & SMB_FLAG_CREATE)) {
char eventName[MAX_PATH];
EVENT_HANDLE event;
+
+ if (!newFid)
+ osi_Log1(smb_logp, "smb_FindFID New Fid Not Requested, Fid %d Not Found and CREATE flag set.", fid);
+ else
+ osi_Log1(smb_logp, "smb_FindFID New Fid Requested. Creating fid %d", fid);
+
sprintf(eventName,"fid_t event vcp=%d fid=%d", vcp->vcID, fid);
event = thrd_CreateEvent(NULL, FALSE, TRUE, eventName);
if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
if (ioctlp->ioctl.outAllocp)
free(ioctlp->ioctl.outAllocp);
free(ioctlp);
- }
+ }
+
+ smb_CleanupRPCFid(fidp);
+
lock_ReleaseMutex(&fidp->mx);
lock_FinalizeMutex(&fidp->mx);
free(fidp);
return 1;
}
- if (cm_ClientStrCmpIA(shareName, _C("IPC$")) == 0 ||
- cm_ClientStrCmpIA(shareName, _C("srvsvc")) == 0 ||
- cm_ClientStrCmpIA(shareName, _C("wkssvc")) == 0 ||
+ if (MSRPC_IsWellKnownService(shareName) ||
cm_ClientStrCmpIA(shareName, _C(SMB_IOCTL_FILENAME_NOSLASH)) == 0 ||
cm_ClientStrCmpIA(shareName, _C("DESKTOP.INI")) == 0
) {
fschar_t ftemp[1024];
clientchar_t * p = shareName;
int rw = 0;
+ cm_scache_t * rscp;
+ cm_user_t *userp;
/* attempt to locate a partial match in root.afs. This is because
when using the ANSI RAP calls, the share name is limited to 13 chars
vrock.match = NULL;
vrock.matchType = 0;
- cm_HoldSCache(cm_data.rootSCachep);
- code = cm_ApplyDir(cm_data.rootSCachep, smb_FindShareProc, &vrock, &thyper,
- (uidp? (uidp->unp ? uidp->unp->userp : NULL) : NULL), &req, NULL);
- cm_ReleaseSCache(cm_data.rootSCachep);
+ userp = (uidp? (uidp->unp ? uidp->unp->userp : cm_rootUserp) : cm_rootUserp);
+ rscp = cm_RootSCachep(userp, &req);
+ cm_HoldSCache(rscp);
+ code = cm_ApplyDir(rscp, smb_FindShareProc, &vrock, &thyper,
+ userp, &req, NULL);
+ cm_ReleaseSCache(rscp);
free(vrock.shareName);
vrock.shareName = NULL;
}
/* Get the full name for this cell */
cellname = cm_ClientStringToFsStringAlloc(p, -1, NULL);
- code = cm_SearchCellFile(cellname, ftemp, 0, 0);
-#ifdef AFS_AFSDB_ENV
+ code = cm_SearchCellRegistry(1, cellname, ftemp, 0, 0, 0);
+ if (code && code != CM_ERROR_FORCE_DNS_LOOKUP)
+ code = cm_SearchCellFile(cellname, ftemp, 0, 0);
if (code && cm_dnsEnabled) {
int ttl;
code = cm_SearchCellByDNS(cellname, ftemp, &ttl, 0, 0);
}
-#endif
if (cellname)
free(cellname);
HKEY hkCSCPolicy;
int retval = CSC_POLICY_MANUAL;
- RegCreateKeyEx( HKEY_LOCAL_MACHINE,
- AFSREG_CLT_OPENAFS_SUBKEY "\\CSCPolicy",
- 0,
- "AFS",
- REG_OPTION_NON_VOLATILE,
- KEY_READ,
- NULL,
- &hkCSCPolicy,
- NULL );
+ if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+ AFSREG_CLT_OPENAFS_SUBKEY "\\CSCPolicy",
+ 0,
+ "AFS",
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ,
+ NULL,
+ &hkCSCPolicy,
+ NULL ) != ERROR_SUCCESS)
+ retval = cm_ClientStrCmpIA(_C("all"),shareName) ? CSC_POLICY_MANUAL : CSC_POLICY_DISABLE;
len = sizeof(policy);
if ( RegQueryValueExW( hkCSCPolicy, shareName, 0, &dwType, (LPBYTE) policy, &len ) ||
len == 0) {
retval = cm_ClientStrCmpIA(_C("all"),shareName) ? CSC_POLICY_MANUAL : CSC_POLICY_DISABLE;
}
+ else if (cm_ClientStrCmpIA(policy, _C("manual")) == 0)
+ {
+ retval = CSC_POLICY_MANUAL;
+ }
else if (cm_ClientStrCmpIA(policy, _C("documents")) == 0)
{
retval = CSC_POLICY_DOCUMENTS;
clientchar_t *inPathp)
{
clientchar_t *lastSlashp;
-
+ clientchar_t *streamp = NULL;
+ clientchar_t *typep = NULL;
+
lastSlashp = cm_ClientStrRChr(inPathp, '\\');
- if (lastComponentp)
+ if (lastComponentp) {
*lastComponentp = lastSlashp;
+ }
if (lastSlashp) {
+ /*
+ * If the name contains a stream name and a type
+ * and the stream name is the nul-string and the
+ * type is $DATA, then strip "::$DATA" from the
+ * last component string that is returned.
+ *
+ * Otherwise, return the full path name and allow
+ * the file name to be rejected because it contains
+ * a colon.
+ */
+ typep = cm_ClientStrRChr(lastSlashp, L':');
+ if (typep && cm_ClientStrCmpI(typep, L":$DATA") == 0) {
+ *typep = '\0';
+ streamp = cm_ClientStrRChr(lastSlashp, L':');
+ if (streamp && cm_ClientStrCmpI(streamp, L":") == 0) {
+ *streamp = '\0';
+ } else
+ *typep = ':';
+ osi_Log2(smb_logp, "smb_StripLastComponent found stream [%S] type [%S]",
+ osi_LogSaveClientString(smb_logp,streamp),
+ osi_LogSaveClientString(smb_logp,typep));
+ }
+
while (1) {
if (inPathp == lastSlashp)
break;
localNCB = 1;
}
- memset((char *)ncbp, 0, sizeof(NCB));
+ memset(ncbp, 0, sizeof(NCB));
extra = 2 * (*inp->wctp); /* space used by parms, in bytes */
tp = inp->wctp + 1+ extra; /* points to count of data bytes */
NTStatus = 0;
}
else if (code == CM_ERROR_NOSUCHCELL) {
- NTStatus = 0xC000000FL; /* No such file */
+ NTStatus = 0xC0000034L; /* Name not found */
}
else if (code == CM_ERROR_NOSUCHVOLUME) {
- NTStatus = 0xC000000FL; /* No such file */
+ NTStatus = 0xC0000034L; /* Name not found */
}
else if (code == CM_ERROR_TIMEDOUT) {
#ifdef COMMENT
NTStatus = 0xC00000CFL; /* Sharing Paused */
-#else
+
+ /* Do not send Timeout to the SMB redirector.
+ * It causes the redirector to drop the connection */
NTStatus = 0x00000102L; /* Timeout */
+ /* do not send Retry to the SMB redirector.
+ * It believes the error comes from the transport
+ * layer not from the SMB server. */
+ NTStatus = 0xC000022DL; /* Retry */
+#else
+ NTStatus = 0xC00000B5L; /* I/O Timeout */
#endif
}
else if (code == CM_ERROR_RETRY) {
+#ifdef COMMENT
NTStatus = 0xC000022DL; /* Retry */
+#else
+ NTStatus = 0xC00000B5L; /* I/O Timeout */
+#endif
}
else if (code == CM_ERROR_NOACCESS) {
NTStatus = 0xC0000022L; /* Access denied */
}
else if (code == CM_ERROR_NOSUCHFILE ||
code == CM_ERROR_BPLUS_NOMATCH) {
- NTStatus = 0xC000000FL; /* No such file */
+ NTStatus = 0xC0000034L; /* Name not found */
}
else if (code == CM_ERROR_NOSUCHPATH) {
NTStatus = 0xC000003AL; /* Object path not found */
else if (code == CM_ERROR_BADFDOP) {
NTStatus = 0xC0000022L; /* Access denied */
}
+ else if (code == CM_ERROR_UNKNOWN) {
+ NTStatus = 0xC0000022L; /* Access denied */
+ }
else if (code == CM_ERROR_EXISTS) {
NTStatus = 0xC0000035L; /* Object name collision */
}
NTStatus = 0xC000013DL; /* Remote Resources */
#endif
}
- else if (code == CM_ERROR_CLOCKSKEW) {
+ else if (code == CM_ERROR_CLOCKSKEW ||
+ code == RXKADNOAUTH) {
NTStatus = 0xC0000133L; /* Time difference at DC */
}
else if (code == CM_ERROR_BADTID) {
else if (code == CM_ERROR_BUFFERTOOSMALL) {
NTStatus = 0xC0000023L; /* Buffer too small */
}
+ else if (code == CM_ERROR_BUFFER_OVERFLOW) {
+ NTStatus = 0x80000005L; /* Buffer overflow */
+ }
else if (code == CM_ERROR_AMBIGUOUS_FILENAME) {
NTStatus = 0xC0000035L; /* Object name collision */
}
NTStatus = 0xC0000257L; /* Path Not Covered */
}
else if (code == CM_ERROR_ALLBUSY) {
+#ifdef COMMENT
NTStatus = 0xC000022DL; /* Retry */
- }
+#else
+ NTStatus = 0xC0020018L; /* RPC_NT_SERVER_TOO_BUSY */
+#endif
+ }
else if (code == CM_ERROR_ALLOFFLINE || code == CM_ERROR_ALLDOWN) {
+#ifdef COMMENT
NTStatus = 0xC000003AL; /* Path not found */
- }
+#else
+ NTStatus = 0xC0020017L; /* RPC_NT_SERVER_UNAVAILABLE */
+#endif
+ }
else if (code >= ERROR_TABLE_BASE_RXK && code < ERROR_TABLE_BASE_RXK + 256) {
NTStatus = 0xC0000322L; /* No Kerberos key */
}
}
else if (code == CM_ERROR_LOCK_NOT_GRANTED) {
NTStatus = 0xC0000055L; /* Lock Not Granted */
- } else if (code == ENOMEM) {
+ }
+ else if (code == ENOMEM) {
NTStatus = 0xC0000017L; /* Out of Memory */
- } else {
+ }
+ else if (code == CM_ERROR_RPC_MOREDATA) {
+ NTStatus = 0x80000005L; /* Buffer overflow */
+ }
+ else {
NTStatus = 0xC0982001L; /* SMB non-specific error */
}
osi_Log2(smb_logp, "SMB SEND code %lX as NT %lX", code, NTStatus);
}
+/*
+ * NTSTATUS <-> Win32 Error Translation
+ * http://support.microsoft.com/kb/113996
+ */
+void smb_MapWin32Error(long code, unsigned long *Win32Ep)
+{
+ unsigned long Win32E;
+
+ /* map CM_ERROR_* errors to Win32 32-bit error codes */
+ if (code == 0) {
+ Win32E = 0;
+ }
+ else if (code == CM_ERROR_NOSUCHCELL) {
+ Win32E = ERROR_FILE_NOT_FOUND; /* No such file */
+ }
+ else if (code == CM_ERROR_NOSUCHVOLUME) {
+ Win32E = ERROR_FILE_NOT_FOUND; /* No such file */
+ }
+ else if (code == CM_ERROR_TIMEDOUT) {
+#ifdef COMMENT
+ Win32E = ERROR_SHARING_PAUSED; /* Sharing Paused */
+#else
+ Win32E = ERROR_UNEXP_NET_ERR; /* Timeout */
+#endif
+ }
+ else if (code == CM_ERROR_RETRY) {
+ Win32E = ERROR_RETRY; /* Retry */
+ }
+ else if (code == CM_ERROR_NOACCESS) {
+ Win32E = ERROR_ACCESS_DENIED; /* Access denied */
+ }
+ else if (code == CM_ERROR_READONLY) {
+ Win32E = ERROR_WRITE_PROTECT; /* Write protected */
+ }
+ else if (code == CM_ERROR_NOSUCHFILE ||
+ code == CM_ERROR_BPLUS_NOMATCH) {
+ Win32E = ERROR_FILE_NOT_FOUND; /* No such file */
+ }
+ else if (code == CM_ERROR_NOSUCHPATH) {
+ Win32E = ERROR_PATH_NOT_FOUND; /* Object path not found */
+ }
+ else if (code == CM_ERROR_TOOBIG) {
+ Win32E = ERROR_BAD_EXE_FORMAT; /* Invalid image format */
+ }
+ else if (code == CM_ERROR_INVAL) {
+ Win32E = ERROR_INVALID_PARAMETER;/* Invalid parameter */
+ }
+ else if (code == CM_ERROR_BADFD) {
+ Win32E = ERROR_INVALID_HANDLE; /* Invalid handle */
+ }
+ else if (code == CM_ERROR_BADFDOP) {
+ Win32E = ERROR_ACCESS_DENIED; /* Access denied */
+ }
+ else if (code == CM_ERROR_UNKNOWN) {
+ Win32E = ERROR_ACCESS_DENIED; /* Access denied */
+ }
+ else if (code == CM_ERROR_EXISTS) {
+ Win32E = ERROR_ALREADY_EXISTS; /* Object name collision */
+ }
+ else if (code == CM_ERROR_NOTEMPTY) {
+ Win32E = ERROR_DIR_NOT_EMPTY; /* Directory not empty */
+ }
+ else if (code == CM_ERROR_CROSSDEVLINK) {
+ Win32E = ERROR_NOT_SAME_DEVICE; /* Not same device */
+ }
+ else if (code == CM_ERROR_NOTDIR) {
+ Win32E = ERROR_DIRECTORY; /* Not a directory */
+ }
+ else if (code == CM_ERROR_ISDIR) {
+ Win32E = ERROR_ACCESS_DENIED; /* File is a directory */
+ }
+ else if (code == CM_ERROR_BADOP) {
+ Win32E = ERROR_NOT_SUPPORTED; /* Not supported */
+ }
+ else if (code == CM_ERROR_BADSHARENAME) {
+ Win32E = ERROR_BAD_NETPATH; /* Bad network path (server valid, share bad) */
+ }
+ else if (code == CM_ERROR_NOIPC) {
+#ifdef COMMENT
+ Win32E = ERROR_ACCESS_DENIED; /* Access Denied */
+#else
+ Win32E = ERROR_REM_NOT_LIST; /* Remote Resources */
+#endif
+ }
+ else if (code == CM_ERROR_CLOCKSKEW ||
+ code == RXKADNOAUTH) {
+ Win32E = ERROR_TIME_SKEW; /* Time difference at DC */
+ }
+ else if (code == CM_ERROR_BADTID) {
+ Win32E = ERROR_FILE_NOT_FOUND; /* SMB bad TID */
+ }
+ else if (code == CM_ERROR_USESTD) {
+ Win32E = ERROR_ACCESS_DENIED; /* SMB use standard */
+ }
+ else if (code == CM_ERROR_QUOTA) {
+ Win32E = ERROR_NOT_ENOUGH_QUOTA;/* Quota exceeded */
+ }
+ else if (code == CM_ERROR_SPACE) {
+ Win32E = ERROR_DISK_FULL; /* Disk full */
+ }
+ else if (code == CM_ERROR_ATSYS) {
+ Win32E = ERROR_INVALID_NAME; /* Object name invalid */
+ }
+ else if (code == CM_ERROR_BADNTFILENAME) {
+ Win32E = ERROR_INVALID_NAME; /* Object name invalid */
+ }
+ else if (code == CM_ERROR_WOULDBLOCK) {
+ Win32E = WAIT_TIMEOUT; /* Can't wait */
+ }
+ else if (code == CM_ERROR_SHARING_VIOLATION) {
+ Win32E = ERROR_SHARING_VIOLATION; /* Sharing violation */
+ }
+ else if (code == CM_ERROR_LOCK_CONFLICT) {
+ Win32E = ERROR_LOCK_VIOLATION; /* Lock conflict */
+ }
+ else if (code == CM_ERROR_PARTIALWRITE) {
+ Win32E = ERROR_DISK_FULL; /* Disk full */
+ }
+ else if (code == CM_ERROR_BUFFERTOOSMALL) {
+ Win32E = ERROR_INSUFFICIENT_BUFFER; /* Buffer too small */
+ }
+ else if (code == CM_ERROR_AMBIGUOUS_FILENAME) {
+ Win32E = ERROR_ALREADY_EXISTS; /* Object name collision */
+ }
+ else if (code == CM_ERROR_BADPASSWORD) {
+ Win32E = ERROR_LOGON_FAILURE; /* unknown username or bad password */
+ }
+ else if (code == CM_ERROR_BADLOGONTYPE) {
+ Win32E = ERROR_INVALID_LOGON_TYPE; /* logon type not granted */
+ }
+ else if (code == CM_ERROR_GSSCONTINUE) {
+ Win32E = ERROR_MORE_DATA; /* more processing required */
+ }
+ else if (code == CM_ERROR_TOO_MANY_SYMLINKS) {
+#ifdef COMMENT
+ Win32E = ERROR_CANT_RESOLVE_FILENAME; /* reparse point not resolved */
+#else
+ Win32E = ERROR_ACCESS_DENIED; /* Access Denied */
+#endif
+ }
+ else if (code == CM_ERROR_PATH_NOT_COVERED) {
+ Win32E = ERROR_HOST_UNREACHABLE; /* Path Not Covered */
+ }
+ else if (code == CM_ERROR_ALLBUSY) {
+ Win32E = ERROR_RETRY; /* Retry */
+ }
+ else if (code == CM_ERROR_ALLOFFLINE || code == CM_ERROR_ALLDOWN) {
+ Win32E = ERROR_HOST_UNREACHABLE; /* Path not found */
+ }
+ else if (code >= ERROR_TABLE_BASE_RXK && code < ERROR_TABLE_BASE_RXK + 256) {
+ Win32E = SEC_E_NO_KERB_KEY; /* No Kerberos key */
+ }
+ else if (code == CM_ERROR_BAD_LEVEL) {
+ Win32E = ERROR_INVALID_LEVEL; /* Invalid Level */
+ }
+ else if (code == CM_ERROR_RANGE_NOT_LOCKED) {
+ Win32E = ERROR_NOT_LOCKED; /* Range Not Locked */
+ }
+ else if (code == CM_ERROR_NOSUCHDEVICE) {
+ Win32E = ERROR_FILE_NOT_FOUND; /* No Such Device */
+ }
+ else if (code == CM_ERROR_LOCK_NOT_GRANTED) {
+ Win32E = ERROR_LOCK_VIOLATION; /* Lock Not Granted */
+ }
+ else if (code == ENOMEM) {
+ Win32E = ERROR_NOT_ENOUGH_MEMORY; /* Out of Memory */
+ }
+ else if (code == CM_ERROR_RPC_MOREDATA) {
+ Win32E = ERROR_MORE_DATA; /* Buffer overflow */
+ }
+ else {
+ Win32E = ERROR_GEN_FAILURE; /* SMB non-specific error */
+ }
+
+ *Win32Ep = Win32E;
+ osi_Log2(smb_logp, "SMB SEND code %lX as Win32 %lX", code, Win32E);
+}
+
void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
unsigned char *classp)
{
fd, offset.HighPart, offset.LowPart, count);
fidp = smb_FindFID(vcp, fd, 0);
- if (!fidp)
+ if (!fidp) {
+ osi_Log2(smb_logp, "smb_ReceiveCoreReadRaw Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fd);
goto send1;
-
+ }
lock_ObtainMutex(&fidp->mx);
if (!fidp->scp) {
lock_ReleaseMutex(&fidp->mx);
send1:
ncbp = outp->ncbp;
- memset((char *)ncbp, 0, sizeof(NCB));
+ memset(ncbp, 0, sizeof(NCB));
ncbp->ncb_length = (unsigned short) finalCount;
ncbp->ncb_lsn = (unsigned char) vcp->lsn;
smb_SetSMBParmLong(outp, 9, caps);
time(&unixTime);
- smb_SearchTimeFromUnixTime(&dosTime, unixTime);
+ cm_SearchTimeFromUnixTime(&dosTime, unixTime);
smb_SetSMBParmLong(outp, 11, LOWORD(dosTime));/* server time */
smb_SetSMBParmLong(outp, 13, HIWORD(dosTime));/* server date */
smb_SetSMBParm(outp, 6, 1); /* next 2: session key */
smb_SetSMBParm(outp, 7, 1);
time(&unixTime);
- smb_SearchTimeFromUnixTime(&dosTime, unixTime);
+ cm_SearchTimeFromUnixTime(&dosTime, unixTime);
smb_SetSMBParm(outp, 8, LOWORD(dosTime)); /* server time */
smb_SetSMBParm(outp, 9, HIWORD(dosTime)); /* server date */
myTime.tm_sec = 0;
smb_localZero = mktime(&myTime);
-#ifndef USE_NUMERIC_TIME_CONV
- smb_CalculateNowTZ();
-#endif /* USE_NUMERIC_TIME_CONV */
#ifdef AFS_FREELANCE
if ( smb_localZero != old_localZero )
- cm_noteLocalMountPointChange();
+ cm_noteLocalMountPointChange(FALSE);
#endif
smb_CheckVCs();
*dptr++ = attr;
/* get dos time */
- smb_SearchTimeFromUnixTime(&dosTime, scp->clientModTime);
+ cm_SearchTimeFromUnixTime(&dosTime, scp->clientModTime);
/* copy out time */
shortTemp = (unsigned short) (dosTime & 0xffff);
cm_ClientStrCpy(dsp->tidPath, lengthof(dsp->tidPath), tidPathp ? tidPathp : _C("/"));
cm_ClientStrCpy(dsp->relPath, lengthof(dsp->relPath), spacep->wdata);
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata,
caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
if (code == 0) {
#ifdef DFS_SUPPORT
bufferp = NULL;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &bufferp);
+ code = buf_Get(scp, &thyper, &req, &bufferp);
lock_ObtainMutex(&dsp->mx);
/* now, if we're doing a star match, do bulk fetching of all of
osi_Log1(smb_logp, "SMB receive check path %S",
osi_LogSaveClientString(smb_logp, pathp));
- rootScp = cm_data.rootSCachep;
-
userp = smb_GetUserFromVCP(vcp, inp);
+ rootScp = cm_RootSCachep(userp, &req);
+
caseFold = CM_FLAG_CASEFOLD;
code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
osi_Log2(smb_logp, "SMB receive setfile attributes time %d, attr 0x%x",
dosTime, attribute);
- rootScp = cm_data.rootSCachep;
-
userp = smb_GetUserFromVCP(vcp, inp);
+ rootScp = cm_RootSCachep(userp, &req);
+
caseFold = CM_FLAG_CASEFOLD;
code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
attr.mask |= CM_ATTRMASK_CLIENTMODTIME;
smb_UnixTimeFromDosUTime(&attr.clientModTime, dosTime);
}
- if ((newScp->unixModeBits & 0222) && (attribute & SMB_ATTR_READONLY) != 0) {
+ if ((newScp->unixModeBits & 0200) && (attribute & SMB_ATTR_READONLY) != 0) {
/* we're told to make a writable file read-only */
attr.unixModeBits = newScp->unixModeBits & ~0222;
attr.mask |= CM_ATTRMASK_UNIXMODEBITS;
}
- else if ((newScp->unixModeBits & 0222) == 0 && (attribute & SMB_ATTR_READONLY) == 0) {
+ else if ((newScp->unixModeBits & 0200) == 0 && (attribute & SMB_ATTR_READONLY) == 0) {
/* we're told to make a read-only file writable */
attr.unixModeBits = newScp->unixModeBits | 0222;
attr.mask |= CM_ATTRMASK_UNIXMODEBITS;
osi_Log1(smb_logp, "SMB receive getfile attributes path %S",
osi_LogSaveClientString(smb_logp, pathp));
- rootScp = cm_data.rootSCachep;
-
userp = smb_GetUserFromVCP(vcp, inp);
+ rootScp = cm_RootSCachep(userp, &req);
+
/* we shouldn't need this for V3 requests, but we seem to */
caseFold = CM_FLAG_CASEFOLD;
}
#endif
+ share = smb_GetSMBParm(inp, 0);
+ attribute = smb_GetSMBParm(inp, 1);
+
+ spacep = inp->spacep;
+ /* smb_StripLastComponent will strip "::$DATA" if present */
+ smb_StripLastComponent(spacep->wdata, &lastNamep, pathp);
+
if (!cm_IsValidClientString(pathp)) {
#ifdef DEBUG
clientchar_t * hexp;
return CM_ERROR_BADNTFILENAME;
}
- share = smb_GetSMBParm(inp, 0);
- attribute = smb_GetSMBParm(inp, 1);
-
- spacep = inp->spacep;
- smb_StripLastComponent(spacep->wdata, &lastNamep, pathp);
if (lastNamep && cm_ClientStrCmp(lastNamep, _C(SMB_IOCTL_FILENAME)) == 0) {
/* special case magic file name for receiving IOCTL requests
* (since IOCTL calls themselves aren't getting through).
cm_ReleaseUser(userp);
return CM_ERROR_NOSUCHPATH;
}
- code = cm_NameI(cm_data.rootSCachep, pathp, caseFold | CM_FLAG_FOLLOW, userp,
+ code = cm_NameI(cm_RootSCachep(userp, &req), pathp, caseFold | CM_FLAG_FOLLOW, userp,
tidPathp, &req, &scp);
if (code) {
cm_ReleaseUser(userp);
return CM_ERROR_NOSUCHPATH;
}
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold, userp, tidPathp,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold, userp, tidPathp,
&req, &dscp);
if (code) {
cm_ReleaseUser(userp);
smb_StripLastComponent(spacep->wdata, &oldLastNamep, oldPathp);
caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold,
userp, tidPathp, &req, &oldDscp);
if (code) {
cm_ReleaseUser(userp);
#endif /* DFS_SUPPORT */
smb_StripLastComponent(spacep->wdata, &newLastNamep, newPathp);
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold,
userp, tidPathp, &req, &newDscp);
if (code) {
spacep = inp->spacep;
smb_StripLastComponent(spacep->wdata, &oldLastNamep, oldPathp);
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold,
userp, tidPathp, &req, &oldDscp);
if (code) {
cm_ReleaseUser(userp);
#endif /* DFS_SUPPORT */
smb_StripLastComponent(spacep->wdata, &newLastNamep, newPathp);
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold,
userp, tidPathp, &req, &newDscp);
if (code) {
cm_ReleaseSCache(oldDscp);
cm_ReleaseUser(userp);
return CM_ERROR_NOSUCHPATH;
}
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold | CM_FLAG_FOLLOW,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold | CM_FLAG_FOLLOW,
userp, tidPathp, &req, &dscp);
if (code) {
fid = smb_ChainFID(fid, inp);
fidp = smb_FindFID(vcp, fid, 0);
- if (!fidp)
+ if (!fidp) {
+ osi_Log2(smb_logp, "smb_ReceiveCoreFlush Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fid);
return CM_ERROR_BADFD;
-
+ }
userp = smb_GetUserFromVCP(vcp, inp);
lock_ObtainMutex(&fidp->mx);
cm_scache_t * scp = fidp->scp;
cm_HoldSCache(scp);
lock_ReleaseMutex(&fidp->mx);
- code = cm_FSync(scp, userp, &req);
+ code = cm_FSync(scp, userp, &req, FALSE);
cm_ReleaseSCache(scp);
} else {
lock_ReleaseMutex(&fidp->mx);
if (!userp) {
lock_ObtainMutex(&fidp->mx);
- if (!fidp->userp && !(fidp->flags & SMB_FID_IOCTL)) {
+ if (!fidp->userp && !(fidp->flags & (SMB_FID_IOCTL|
+ SMB_FID_RPC))) {
lock_ReleaseMutex(&fidp->mx);
osi_Log0(smb_logp, " No user specified. Not closing fid");
return CM_ERROR_BADFD;
(fidp->flags & (SMB_FID_OPENWRITE | SMB_FID_DELONCLOSE))
== SMB_FID_OPENWRITE) {
if (dosTime != 0 && dosTime != -1) {
+ lock_ObtainWrite(&fidp->scp->rw);
scp->mask |= CM_SCACHEMASK_CLIENTMODTIME;
/* This fixes defect 10958 */
CompensateForSmbClientLastWriteTimeBugs(&dosTime);
smb_UnixTimeFromDosUTime(&scp->clientModTime, dosTime);
+ lock_ReleaseWrite(&fidp->scp->rw);
}
if (smb_AsyncStore != 2) {
lock_ReleaseMutex(&fidp->mx);
- code = cm_FSync(scp, userp, &req);
+ code = cm_FSync(scp, userp, &req, FALSE);
lock_ObtainMutex(&fidp->mx);
}
}
fid = smb_ChainFID(fid, inp);
fidp = smb_FindFID(vcp, fid, 0);
if (!fidp) {
+ osi_Log2(smb_logp, "smb_ReceiveCoreClose Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fid);
return CM_ERROR_BADFD;
}
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &bufferp);
+ code = buf_Get(scp, &thyper, &req, &bufferp);
lock_ObtainWrite(&scp->rw);
if (code) goto done;
osi_hyper_t writeBackOffset;/* offset of region to write back when I/O is done */
DWORD filter = 0;
cm_req_t req;
+ int needSyncOpDone = 0;
osi_Log3(smb_logp, "smb_WriteData fid %d, off 0x%x, size 0x%x",
fidp->fid, offsetp->LowPart, count);
/* now, copy the data one buffer at a time, until we've filled the
* request packet */
- while (1) {
- /* if we've copied all the data requested, we're done */
- if (count <= 0)
- break;
+ while (count != 0) {
/* handle over quota or out of space */
if (scp->flags & (CM_SCACHEFLAG_OVERQUOTA | CM_SCACHEFLAG_OUTOFSPACE)) {
if (!bufferp || !LargeIntegerEqualTo(thyper, bufferOffset)) {
/* wrong buffer */
if (bufferp) {
+ if (needSyncOpDone) {
+ cm_SyncOpDone(scp, bufferp,
+ CM_SCACHESYNC_NEEDCALLBACK
+ | CM_SCACHESYNC_WRITE
+ | CM_SCACHESYNC_BUFLOCKED);
+ needSyncOpDone = 0;
+ }
lock_ReleaseMutex(&bufferp->mx);
buf_Release(bufferp);
bufferp = NULL;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &bufferp);
+ code = buf_Get(scp, &thyper, &req, &bufferp);
lock_ObtainMutex(&bufferp->mx);
lock_ObtainWrite(&scp->rw);
bufferOffset = thyper;
/* now get the data in the cache */
- while (1) {
- code = cm_SyncOp(scp, bufferp, userp, &req, 0,
- CM_SCACHESYNC_NEEDCALLBACK
- | CM_SCACHESYNC_WRITE
- | CM_SCACHESYNC_BUFLOCKED);
- if (code)
- goto done;
-
- cm_SyncOpDone(scp, bufferp,
- CM_SCACHESYNC_NEEDCALLBACK
- | CM_SCACHESYNC_WRITE
- | CM_SCACHESYNC_BUFLOCKED);
+ while (code == 0) {
+ if (!needSyncOpDone) {
+ code = cm_SyncOp(scp, bufferp, userp, &req, 0,
+ CM_SCACHESYNC_NEEDCALLBACK
+ | CM_SCACHESYNC_WRITE
+ | CM_SCACHESYNC_BUFLOCKED);
+ if (code)
+ goto done;
+
+ needSyncOpDone = 1;
+ }
/* If we're overwriting the entire buffer, or
* if we're writing at or past EOF, mark the
* Use minLength instead of scp->length, since
* the latter has already been updated by this
* call.
+ *
+ * The scp lock has been dropped multiple times
+ * so the minLength must be refreshed before it
+ * is used.
*/
+
+ minLength = scp->length;
+ if (LargeIntegerGreaterThan(minLength, scp->serverLength))
+ minLength = scp->serverLength;
+
if (LargeIntegerGreaterThanOrEqualTo(bufferp->offset, minLength)
|| LargeIntegerEqualTo(offset, bufferp->offset)
&& (count >= cm_data.buf_blockSize
if (cm_HaveBuffer(scp, bufferp, 1)) break;
/* otherwise, load the buffer and try again */
+ cm_SyncOpDone(scp, bufferp,
+ CM_SCACHESYNC_NEEDCALLBACK
+ | CM_SCACHESYNC_WRITE
+ | CM_SCACHESYNC_BUFLOCKED);
+ needSyncOpDone = 0;
+
lock_ReleaseMutex(&bufferp->mx);
code = cm_GetBuffer(scp, bufferp, NULL, userp,
&req);
lock_ReleaseWrite(&scp->rw);
lock_ObtainMutex(&bufferp->mx);
lock_ObtainWrite(&scp->rw);
- if (code) break;
}
- if (code) {
- lock_ReleaseMutex(&bufferp->mx);
- buf_Release(bufferp);
- bufferp = NULL;
+ if (code)
goto done;
- }
} /* if (wrong buffer) ... */
/* now we have the right buffer loaded. Copy out the
op += nbytes;
count -= nbytes;
written += nbytes;
- thyper.LowPart = nbytes;
- thyper.HighPart = 0;
- offset = LargeIntegerAdd(thyper, offset);
- } /* while 1 */
+ offset = LargeIntegerAdd(offset, ConvertLongToLargeInteger(nbytes));
+ } /* while count != 0 */
done:
+ if (bufferp && needSyncOpDone) {
+ cm_SyncOpDone(scp, bufferp,
+ CM_SCACHESYNC_NEEDCALLBACK
+ | CM_SCACHESYNC_WRITE
+ | CM_SCACHESYNC_BUFLOCKED);
+ }
+
lock_ReleaseWrite(&scp->rw);
if (bufferp) {
fd = smb_ChainFID(fd, inp);
fidp = smb_FindFID(vcp, fd, 0);
if (!fidp) {
- osi_Log0(smb_logp, "smb_ReceiveCoreWrite fid not found");
+ osi_Log2(smb_logp, "smb_ReceiveCoreWrite Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fd);
return CM_ERROR_BADFD;
}
return code;
}
+ if (fidp->flags & SMB_FID_RPC) {
+ lock_ReleaseMutex(&fidp->mx);
+ code = smb_RPCWrite(fidp, vcp, inp, outp);
+ smb_ReleaseFID(fidp);
+ osi_Log1(smb_logp, "smb_ReceiveCoreWrite RPC code 0x%x", code);
+ return code;
+ }
+
if (!fidp->scp) {
lock_ReleaseMutex(&fidp->mx);
smb_ReleaseFID(fidp);
*/
lock_ObtainMutex(&fidp->mx);
if ((fidp->flags & SMB_FID_MTIMESETDONE) != SMB_FID_MTIMESETDONE) {
+ lock_ObtainWrite(&fidp->scp->rw);
fidp->scp->mask |= CM_SCACHEMASK_CLIENTMODTIME;
fidp->scp->clientModTime = time(NULL);
+ lock_ReleaseWrite(&fidp->scp->rw);
}
lock_ReleaseMutex(&fidp->mx);
fd = smb_ChainFID(fd, inp);
fidp = smb_FindFID(vcp, fd, 0);
- if (!fidp)
+ if (!fidp) {
+ osi_Log2(smb_logp, "smb_ReceiveCoreWriteRaw Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fd);
return CM_ERROR_BADFD;
-
+ }
lock_ObtainMutex(&fidp->mx);
if (!fidp->scp) {
lock_ReleaseMutex(&fidp->mx);
*/
lock_ObtainMutex(&fidp->mx);
if ((fidp->flags & SMB_FID_LOOKSLIKECOPY) != SMB_FID_LOOKSLIKECOPY) {
+ lock_ObtainWrite(&fidp->scp->rw);
fidp->scp->mask |= CM_SCACHEMASK_CLIENTMODTIME;
fidp->scp->clientModTime = time(NULL);
+ lock_ReleaseWrite(&fidp->scp->rw);
}
lock_ReleaseMutex(&fidp->mx);
fd = smb_ChainFID(fd, inp);
fidp = smb_FindFID(vcp, fd, 0);
- if (!fidp)
+ if (!fidp) {
+ osi_Log2(smb_logp, "smb_ReceiveCoreRead Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fd);
return CM_ERROR_BADFD;
-
+ }
lock_ObtainMutex(&fidp->mx);
if (fidp->flags & SMB_FID_IOCTL) {
lock_ReleaseMutex(&fidp->mx);
return code;
}
+ if (fidp->flags & SMB_FID_RPC) {
+ lock_ReleaseMutex(&fidp->mx);
+ code = smb_RPCRead(fidp, vcp, inp, outp);
+ smb_ReleaseFID(fidp);
+ return code;
+ }
+
if (!fidp->scp) {
lock_ReleaseMutex(&fidp->mx);
smb_ReleaseFID(fidp);
return CM_ERROR_NOSUCHPATH;
}
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata,
caseFold | CM_FLAG_FOLLOW | CM_FLAG_CHECKPATH,
userp, tidPathp, &req, &dscp);
setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
setAttr.clientModTime = time(NULL);
+ smb_SetInitialModeBitsForDir(0, &setAttr);
+
code = cm_MakeDir(dscp, lastNamep, 0, &setAttr, userp, &req, NULL);
if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
smb_NotifyChange(FILE_ACTION_ADDED,
cm_scache_t *dscp; /* dir we're dealing with */
cm_scache_t *scp; /* file we're creating */
cm_attr_t setAttr;
- int initialModeBits;
smb_fid_t *fidp;
int attributes;
clientchar_t *lastNamep;
attributes = smb_GetSMBParm(inp, 0);
dosTime = smb_GetSMBParm(inp, 1) | (smb_GetSMBParm(inp, 2) << 16);
- /* compute initial mode bits based on read-only flag in attributes */
- initialModeBits = 0666;
- if (attributes & SMB_ATTR_READONLY)
- initialModeBits &= ~0222;
-
tp = smb_GetSMBData(inp, NULL);
pathp = smb_ParseASCIIBlock(inp, tp, &tp, SMB_STRF_ANSIPATH);
if (!pathp)
return CM_ERROR_BADSMB;
+ spacep = inp->spacep;
+ /* smb_StripLastComponent will strip "::$DATA" if present */
+ smb_StripLastComponent(spacep->wdata, &lastNamep, pathp);
+
if (!cm_IsValidClientString(pathp)) {
#ifdef DEBUG
clientchar_t * hexp;
return CM_ERROR_BADNTFILENAME;
}
- spacep = inp->spacep;
- smb_StripLastComponent(spacep->wdata, &lastNamep, pathp);
-
userp = smb_GetUserFromVCP(vcp, inp);
caseFold = CM_FLAG_CASEFOLD;
cm_ReleaseUser(userp);
return CM_ERROR_NOSUCHPATH;
}
- code = cm_NameI(cm_data.rootSCachep, spacep->wdata, caseFold | CM_FLAG_FOLLOW,
+ code = cm_NameI(cm_RootSCachep(userp, &req), spacep->wdata, caseFold | CM_FLAG_FOLLOW,
userp, tidPathp, &req, &dscp);
if (code) {
else {
setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
smb_UnixTimeFromDosUTime(&setAttr.clientModTime, dosTime);
+ smb_SetInitialModeBitsForFile(attributes, &setAttr);
+
code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp,
&req);
if (code == 0) {
/* try to find the file descriptor */
fd = smb_ChainFID(fd, inp);
fidp = smb_FindFID(vcp, fd, 0);
- if (!fidp)
+ if (!fidp) {
+ osi_Log2(smb_logp, "smb_ReceiveCoreSeek Unknown SMB Fid vcp 0x%p fid %d",
+ vcp, fd);
return CM_ERROR_BADFD;
-
+ }
lock_ObtainMutex(&fidp->mx);
if (!fidp->scp || (fidp->flags & SMB_FID_IOCTL)) {
lock_ReleaseMutex(&fidp->mx);
smbp = (smb_t *) inp;
osi_Log5(smb_logp,"Dispatch %s mid 0x%x vcp 0x%p lana %d lsn %d",
- opName, smbp->mid, vcp,vcp->lana,vcp->lsn);
+ opName, smbp->mid, vcp, vcp->lana, vcp->lsn);
if (inp->inCom == 0x1d) {
/* Raw Write */
code = smb_ReceiveCoreWriteRaw (vcp, inp, outp, rwcp);
code = (*(dp->procp)) (vcp, inp, outp);
}
osi_Log5(smb_logp,"Dispatch return code 0x%x mid 0x%x vcp 0x%p lana %d lsn %d",
- code, smbp->mid, vcp,vcp->lana,vcp->lsn);
+ code, smbp->mid, vcp, vcp->lana, vcp->lsn);
newTime = GetTickCount();
osi_Log3(smb_logp, "Dispatch %s mid 0x%x duration %d ms",
}
}
+typedef struct _monitored_task {
+ osi_queue_t q;
+ INT_PTR task_id;
+ LARGE_INTEGER start_time;
+ BOOL started;
+ BOOL trace_timer_hit;
+ BOOL dump_timer_hit;
+} monitored_task;
+
+typedef struct osi_queueHT {
+ osi_queue_t * headp;
+ osi_queue_t * tailp;
+} osi_queueHT_t;
+
+static osi_queue_t *smb_monitored_tasks = NULL;
+static osi_queue_t *smb_free_monitored_tasks = NULL;
+
+static osi_mutex_t _monitor_mx;
+
+static HANDLE h_monitored_task_queue = NULL;
+static HANDLE h_monitored_task_shutdown = NULL;
+
+static time_t smb_last_dump_time = 0;
+
+DWORD smb_monitorReqs = 0;
+
+/* FILETIME comparison fuzz */
+#define MONITOR_FUZZ_TIMEOUT (1 * 10000000i64)
+
+/* Trace timeout is at 60 seconds */
+#define MONITOR_TRACE_TIMEOUT (60 * 10000000i64)
+
+/* Dump timeout is at 120 seconds */
+#define MONITOR_DUMP_TIMEOUT (120 * 10000000i64)
+
+/* Time before another dump is performed in seconds*/
+#define MONITOR_DUMP_RESET_TIMEOUT (600)
+
+static void smb_PurgeOldTaskMonitors(osi_queueHT_t * taskmq)
+{
+ FILETIME now;
+ LARGE_INTEGER earliest;
+ monitored_task * t;
+
+ GetSystemTimeAsFileTime(&now);
+ earliest.LowPart = now.dwLowDateTime;
+ earliest.HighPart = now.dwHighDateTime;
+ earliest.QuadPart -= MONITOR_FUZZ_TIMEOUT + MONITOR_DUMP_TIMEOUT;
+
+ while ((t = (monitored_task *) taskmq->headp) != NULL &&
+
+ (t->start_time.QuadPart < earliest.QuadPart ||
+
+ t->dump_timer_hit)) {
+
+ osi_QRemoveHT(&taskmq->headp,
+ &taskmq->tailp,
+ &t->q);
+
+ lock_ObtainMutex(&_monitor_mx);
+ osi_QAdd(&smb_free_monitored_tasks, &t->q);
+ lock_ReleaseMutex(&_monitor_mx);
+ }
+
+#ifdef INVARIANT_CHECK
+ {
+ LARGE_INTEGER last;
+
+ last.QuadPart = 0;
+
+ for (t = (monitored_task *) taskmq->headp;
+ t;
+ t = (monitored_task *) osi_QNext(&t->q)) {
+ osi_assert(last.QuadPart <= t->start_time.QuadPart);
+ last.QuadPart = t->start_time.QuadPart;
+ }
+ }
+#endif
+}
+
+static void smb_SlurpNewTaskMonitors(osi_queueHT_t * taskmq)
+{
+ monitored_task * task;
+ monitored_task * tasks;
+
+ lock_ObtainMutex(&_monitor_mx);
+ tasks = (monitored_task *) smb_monitored_tasks;
+ smb_monitored_tasks = NULL;
+ lock_ReleaseMutex(&_monitor_mx);
+
+ while (tasks) {
+
+ task = tasks;
+ osi_QRemove((osi_queue_t **) &tasks, &task->q);
+
+ if (task->started) {
+
+ osi_queue_t q;
+ osi_queue_t *p;
+
+ q.nextp = NULL;
+ q.prevp = taskmq->tailp;
+
+ /* Insertion sort by start_time. Earliest request is
+ first. Since we are likely to receive new requests
+ later, we start inserting from the back. */
+ for (p = &q;
+ osi_QPrev(p) &&
+ ((monitored_task *) osi_QPrev(p))->start_time.QuadPart > task->start_time.QuadPart;
+ p = osi_QPrev(p));
+
+ if (p == &q)
+ osi_QAddT(&taskmq->headp, &taskmq->tailp, &task->q);
+ else if (p->prevp == NULL)
+ osi_QAddH(&taskmq->headp, &taskmq->tailp, &task->q);
+ else {
+ osi_queue_t *o = p->prevp;
+
+ osi_assert(o->nextp == p);
+
+ task->q.nextp = p;
+ task->q.prevp = o;
+ p->prevp = &task->q;
+ o->nextp = &task->q;
+ }
+
+ } else {
+ /* Some task ending */
+
+ osi_queue_t * p;
+
+ for (p = taskmq->headp;
+ p != NULL;
+ p = osi_QNext(p)) {
+
+ monitored_task * mt = (monitored_task *) p;
+
+ if (mt->task_id == task->task_id) {
+
+ osi_QRemoveHT(&taskmq->headp,
+ &taskmq->tailp, p);
+
+ lock_ObtainMutex(&_monitor_mx);
+ osi_QAdd(&smb_free_monitored_tasks, p);
+ lock_ReleaseMutex(&_monitor_mx);
+
+ break;
+ }
+ }
+
+ lock_ObtainMutex(&_monitor_mx);
+ osi_QAdd(&smb_free_monitored_tasks, &task->q);
+ lock_ReleaseMutex(&_monitor_mx);
+ }
+ }
+
+#ifdef INVARIANT_CHECK
+ {
+ LARGE_INTEGER last;
+ monitored_task * t;
+
+ last.QuadPart = 0;
+
+ for (t = (monitored_task *) taskmq->headp;
+ t;
+ t = (monitored_task *) osi_QNext(&t->q)) {
+ osi_assert(last.QuadPart <= t->start_time.QuadPart);
+ last.QuadPart = t->start_time.QuadPart;
+ }
+ }
+#endif
+}
+
+static void smb_HandleTaskMonitorEvent(monitored_task * task)
+{
+ if (!task->trace_timer_hit) {
+
+ task->trace_timer_hit = TRUE;
+
+ osi_LogEnable(afsd_logp);
+ rx_DebugOnOff(TRUE);
+
+ } else if (!task->dump_timer_hit) {
+ time_t now;
+
+ time(&now);
+
+ if (smb_last_dump_time + MONITOR_DUMP_RESET_TIMEOUT < now) {
+ task->dump_timer_hit = TRUE;
+ smb_last_dump_time = now;
+
+ GenerateMiniDump(NULL);
+ }
+ }
+}
+
+/**
+ * Server request monitoring
+ *
+ * The server monitor runs in a separate thread and monitors server
+ * requests for potential timeouts. It examines notifcations queued
+ * by smb_NotifyRequestEvent() and waits for potential timeout events:
+ *
+ * - After MONITOR_TRACE_TIMEOUT threshold elapses, the monitor
+ * enables trace logging.
+ *
+ * - After MONITOR_DUMP_TIMEOUT threshold elapses, the monitor writes
+ * out a dump file that will hopefully contain enough evidence to
+ * figure out why the timeout event occurred.
+ *
+ */
+void smb_ServerMonitor(VOID * parmp)
+{
+ osi_queueHT_t in_progress = { NULL, NULL };
+ HANDLE h_timer = NULL;
+
+ HANDLE h_all[3];
+
+ h_monitored_task_queue = CreateEvent(NULL, FALSE, FALSE, "Local\\OpenAFSTaskMonitor");
+ h_monitored_task_shutdown = CreateEvent(NULL, FALSE, FALSE, "Local\\OpenAFSTaskMonitorShutdown");
+ h_timer = CreateWaitableTimer(NULL, FALSE, "Local\\OpenAFSTaskMonitorTimer");
+
+ lock_InitializeMutex(&_monitor_mx, "Request monitor lock", LOCK_HIERARCHY_SMB_MONITOR);
+
+ h_all[0] = h_monitored_task_queue;
+ h_all[1] = h_timer;
+ h_all[2] = h_monitored_task_shutdown;
+
+ while(1) {
+ DWORD rv;
+
+ rv = WaitForMultipleObjects(3, h_all, FALSE, INFINITE);
+
+ if (rv == WAIT_OBJECT_0) {
+
+ smb_SlurpNewTaskMonitors(&in_progress);
+
+ } else if (rv == WAIT_OBJECT_0 + 1) {
+
+ smb_HandleTaskMonitorEvent((monitored_task *) in_progress.headp);
+
+ } else {
+
+ break;
+
+ }
+
+ /* refresh timers */
+ {
+ monitored_task * t;
+
+ smb_PurgeOldTaskMonitors(&in_progress);
+ t = (monitored_task *) in_progress.headp;
+
+ if (t && !t->trace_timer_hit) {
+ LARGE_INTEGER due;
+
+ due = t->start_time;
+ due.QuadPart += MONITOR_TRACE_TIMEOUT;
+
+ SetWaitableTimer(h_timer, &due, 0, NULL, NULL, FALSE);
+ } else if (t && !t->dump_timer_hit) {
+
+ LARGE_INTEGER due;
+
+ due = t->start_time;
+ due.QuadPart += MONITOR_DUMP_TIMEOUT;
+
+ SetWaitableTimer(h_timer, &due, 0, NULL, NULL, FALSE);
+ } else {
+ CancelWaitableTimer(h_timer);
+
+ /* CancelWaitableTimer() doesn't reset the timer if it
+ was already signalled. */
+ WaitForSingleObject(h_timer, 0);
+ }
+ }
+ }
+
+ {
+ HANDLE h;
+
+ h = h_monitored_task_queue;
+ h_monitored_task_queue = NULL;
+ CloseHandle(h);
+
+ h = h_monitored_task_shutdown;
+ h_monitored_task_shutdown = NULL;
+ CloseHandle(h);
+
+ CloseHandle(h_timer);
+
+ lock_FinalizeMutex(&_monitor_mx);
+ }
+
+ {
+ monitored_task * task;
+
+ while (in_progress.headp) {
+ task = (monitored_task *) in_progress.headp;
+ osi_QRemoveHT(&in_progress.headp, &in_progress.tailp, &task->q);
+ free(task);
+ }
+
+ for (task = (monitored_task *) smb_free_monitored_tasks;
+ task; task = (monitored_task *) smb_free_monitored_tasks) {
+ osi_QRemove(&smb_free_monitored_tasks, &task->q);
+ free(task);
+ }
+
+ for (task = (monitored_task *) smb_monitored_tasks;
+ task; task = (monitored_task *) smb_monitored_tasks) {
+ osi_QRemove(&smb_monitored_tasks, &task->q);
+ free(task);
+ }
+ }
+}
+
+void smb_NotifyRequestEvent(INT_PTR task_id, BOOL started)
+{
+ monitored_task * task;
+
+ lock_ObtainMutex(&_monitor_mx);
+ task = (monitored_task *) smb_free_monitored_tasks;
+ if (task)
+ osi_QRemove(&smb_free_monitored_tasks, &task->q);
+ lock_ReleaseMutex(&_monitor_mx);
+
+ if (task == NULL)
+ task = malloc(sizeof(monitored_task));
+ memset(task, 0, sizeof(*task));
+
+ task->task_id = task_id;
+ task->started = started;
+
+ {
+ FILETIME now;
+
+ GetSystemTimeAsFileTime(&now);
+ task->start_time.HighPart = now.dwHighDateTime;
+ task->start_time.LowPart = now.dwLowDateTime;
+ }
+
+ lock_ObtainMutex(&_monitor_mx);
+ osi_QAdd(&smb_monitored_tasks, &task->q);
+ lock_ReleaseMutex(&_monitor_mx);
+
+ SetEvent(h_monitored_task_queue);
+}
+
+void smb_ShutdownMonitor()
+{
+ SetEvent(h_monitored_task_shutdown);
+}
+
/*
* The top level loop for handling SMB request messages. Each server thread
* has its own NCB and buffer for sending replies (outncbp, outbufp), but the
vcp = NULL;
}
- smb_ResetServerPriority();
+ cm_ResetServerPriority();
code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBreturns[myIdx],
FALSE, INFINITE);
continue;
}
- smb_SetRequestStartTime();
+ cm_SetRequestStartTime();
+ if (smb_monitorReqs) {
+ smb_NotifyRequestEvent(GetCurrentThreadId(), TRUE);
+ }
vcp->errorCount = 0;
bufp = (struct smb_packet *) ncbp->ncb_buffer;
}
#endif
+ if (smb_monitorReqs) {
+ smb_NotifyRequestEvent(GetCurrentThreadId(), FALSE);
+ }
smb_concurrentCalls--;
doneWithNCB:
{
dwType = REG_DWORD;
dwSize = sizeof(dwValue);
- dwValue = 600; /* 10 minutes */
+ dwValue = 300; /* 5 minutes */
RegSetValueEx( hkLanMan, "ExtendedSessTimeout", 0, dwType, (const BYTE *)&dwValue, dwSize);
}
RegCloseKey(hkLanMan);
configureBackConnectionHostNames();
/* Configure Extended SMB Session Timeouts */
- configureExtendedSMBSessionTimeouts();
+ if (msftSMBRedirectorSupportsExtendedTimeouts()) {
+ afsi_log("Microsoft SMB Redirector supports Extended Timeouts");
+ configureExtendedSMBSessionTimeouts();
+ }
smb_ListenerState = SMB_LISTENER_STARTED;
cm_VolStatus_Network_Started(cm_NetbiosName
{
thread_t phandle;
int lpid;
- INT_PTR i;
+ UINT_PTR i;
struct tm myTime;
EVENT_HANDLE retHandle;
char eventName[MAX_PATH];
int startListeners = 0;
- smb_TlsRequestSlot = TlsAlloc();
-
smb_MBfunc = aMBfunc;
smb_useV3 = useV3;
myTime.tm_sec = 0;
smb_localZero = mktime(&myTime);
-#ifndef USE_NUMERIC_TIME_CONV
- /* Initialize kludge-GMT */
- smb_CalculateNowTZ();
-#endif /* USE_NUMERIC_TIME_CONV */
#ifdef AFS_FREELANCE_CLIENT
/* Make sure the root.afs volume has the correct time */
- cm_noteLocalMountPointChange();
+ cm_noteLocalMountPointChange(FALSE);
#endif
/* initialize the remote debugging log */
osi_assertx(phandle != NULL, "smb_WaitingLocksDaemon thread creation failure");
thrd_CloseHandle(phandle);
+ if (smb_monitorReqs) {
+ phandle = thrd_Create(NULL, 65536, (ThreadFunc) smb_ServerMonitor,
+ NULL, 0, &lpid, "smb_ServerMonitor");
+ osi_assertx(phandle != NULL, "smb_ServerMonitor thread creation failure");
+ thrd_CloseHandle(phandle);
+ }
+
lock_ReleaseMutex(&smb_StartedLock);
return;
}
smbShutdownFlag = 1;
/* Hang up all sessions */
- memset((char *)ncbp, 0, sizeof(NCB));
+ memset(ncbp, 0, sizeof(NCB));
for (i = 1; i < numSessions; i++)
{
if (dead_sessions[i])
}
/* Delete Netbios name */
- memset((char *)ncbp, 0, sizeof(NCB));
+ memset(ncbp, 0, sizeof(NCB));
for (i = 0; i < lana_list.length; i++) {
if (lana_list.lana[i] == LANA_INVALID) continue;
ncbp->ncb_command = NCBDELNAME;
}
lock_ReleaseWrite(&smb_rctLock);
smb_FreeNCB(ncbp);
- TlsFree(smb_TlsRequestSlot);
+
+ if (smb_monitorReqs) {
+ smb_ShutdownMonitor();
+ }
}
/* Get the UNC \\<servername>\<sharename> prefix. */