From 1547d8796e316f91817d43be5017219589a3194a Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 4 Jul 2006 23:43:24 +0000 Subject: [PATCH] DEVEL15-windows-cifs-20060704 a mixture of updates to cifs compliance (cherry picked from commit f720e922a982ec99d57adb0514878c65bafc4293) --- src/WINNT/afsd/smb.c | 10 ++++++++- src/WINNT/afsd/smb.h | 1 + src/WINNT/afsd/smb3.c | 47 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index d62ef7112..831f1bd42 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -35,7 +35,6 @@ /* These characters are illegal in Windows filenames */ static char *illegalChars = "\\/:*?\"<>|"; -BOOL isWindows2000 = FALSE; int smbShutdownFlag = 0; @@ -3135,6 +3134,7 @@ long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) int coreProtoIndex; int v3ProtoIndex; int NTProtoIndex; + int VistaProtoIndex; int protoIndex; /* index we're using */ int namex; int dbytes; @@ -3155,6 +3155,7 @@ long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) coreProtoIndex = -1; /* not found */ v3ProtoIndex = -1; NTProtoIndex = -1; + VistaProtoIndex = -1; while(namex < dbytes) { osi_Log1(smb_logp, "Protocol %s", osi_LogSaveString(smb_logp, namep+1)); @@ -3172,6 +3173,9 @@ long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) else if (smb_useV3 && strcmp("NT LM 0.12", namep+1) == 0) { NTProtoIndex = tcounter; } + else if (smb_useV3 && strcmp("SMB 2.001", namep+1) == 0) { + VistaProtoIndex = tcounter; + } /* compute size of protocol entry */ entryLength = (int)strlen(namep+1); @@ -3184,6 +3188,10 @@ long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) } lock_ObtainMutex(&vcp->mx); + if (VistaProtoIndex != -1) { + protoIndex = VistaProtoIndex; + vcp->flags |= (SMB_VCFLAG_USENT | SMB_VCFLAG_USEV3); + } if (NTProtoIndex != -1) { protoIndex = NTProtoIndex; vcp->flags |= (SMB_VCFLAG_USENT | SMB_VCFLAG_USEV3); diff --git a/src/WINNT/afsd/smb.h b/src/WINNT/afsd/smb.h index dfdd7ee3e..8b45a9018 100644 --- a/src/WINNT/afsd/smb.h +++ b/src/WINNT/afsd/smb.h @@ -81,6 +81,7 @@ typedef struct smb { #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B #define SMB_QUERY_FILE_UNIX_BASIC 0x200 #define SMB_QUERY_FILE_UNIX_LINK 0x201 +#define SMB_INFO_PASSTHROUGH 0x1000 #define SMB_SET_FILE_UNIX_BASIC 0x200 #define SMB_SET_FILE_UNIX_LINK 0x201 diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 667dad51e..b739b6bf8 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -1076,12 +1076,11 @@ long smb_ReceiveV3TreeConnectX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *o *tp++ = 'A'; *tp++ = ':'; *tp++ = 0; - *tp++ = 'N'; - *tp++ = 'T'; + *tp++ = 'A'; *tp++ = 'F'; *tp++ = 'S'; *tp++ = 0; - smb_SetSMBDataLength(outp, 8); + smb_SetSMBDataLength(outp, 7); } else { strcpy(tp, "IPC"); smb_SetSMBDataLength(outp, 4); @@ -2643,18 +2642,38 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t nbytesRequired = 22; else if (infoLevel == SMB_INFO_QUERY_EA_SIZE) nbytesRequired = 26; - else if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) + else if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) { +#ifdef COMMENT nbytesRequired = 40; - else if (infoLevel == SMB_QUERY_FILE_STANDARD_INFO) - nbytesRequired = 24; +#else + nbytesRequired = 34; +#endif + } + else if (infoLevel == SMB_QUERY_FILE_STANDARD_INFO) { +#ifdef COMMENT + nbytesRequired = 24; +#else + nbytesRequired = 22; +#endif + } else if (infoLevel == SMB_QUERY_FILE_EA_INFO) nbytesRequired = 4; +#if 0 + else if (infoLevel == SMB_QUERY_FILE_NAME_INFO) + nbytesRequired = ???; + else if (infoLevel == SMB_QUERY_FILE_ALL_INFO) + nbytesRequired = ???; +#endif else if (infoLevel == SMB_QUERY_FILE_ALT_NAME_INFO) nbytesRequired = 30; else { osi_Log2(smb_logp, "Bad Tran2 op 0x%x infolevel 0x%x", p->opcode, infoLevel); +#ifdef COMMENT smb_SendTran2Error(vcp, p, opx, CM_ERROR_INVAL); +#else + smb_SendTran2Error(vcp, p, opx, CM_ERROR_BADOP); +#endif return 0; } @@ -2816,6 +2835,11 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *((u_long *)op) = scp->length.LowPart; op += 4; /* alloc size */ attributes = smb_Attributes(scp); *((u_short *)op) = attributes; op += 2; /* attributes */ + + /* now, if we are being asked about extended attrs, return a 0 size */ + if (infoLevel == SMB_INFO_QUERY_EA_SIZE) { + *((u_long *)op) = 0; op += 4; + } } else if (infoLevel == SMB_QUERY_FILE_BASIC_INFO) { smb_LargeSearchTimeFromUnixTime(&ft, scp->clientModTime); @@ -2824,8 +2848,13 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *((FILETIME *)op) = ft; op += 8; /* last write time */ *((FILETIME *)op) = ft; op += 8; /* last change time */ extAttributes = smb_ExtAttributes(scp); +#ifdef COMMENT *((u_long *)op) = extAttributes; op += 4; /* extended attribs */ *((u_long *)op) = 0; op += 4; /* don't know what this is */ +#else + /* The CIFS Specs say */ + *((u_short *)op) = extAttributes; op += 2; /* extended attributes */ +#endif } else if (infoLevel == SMB_QUERY_FILE_STANDARD_INFO) { *((LARGE_INTEGER *)op) = scp->length; op += 8; /* alloc size */ @@ -2835,17 +2864,15 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op++ = ((scp->fileType == CM_SCACHETYPE_DIRECTORY || scp->fileType == CM_SCACHETYPE_MOUNTPOINT || scp->fileType == CM_SCACHETYPE_INVALID) ? 1 : 0); +#ifdef COMMENT *op++ = 0; *op++ = 0; +#endif } else if (infoLevel == SMB_QUERY_FILE_EA_INFO) { memset(op, 0, 4); op += 4; /* EA size */ } - /* now, if we are being asked about extended attrs, return a 0 size */ - if (infoLevel == SMB_INFO_QUERY_EA_SIZE) { - *((u_long *)op) = 0; op += 4; - } /* send and free the packets */ -- 2.39.5