⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 negprot.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		if (lp_host_msdfs())		capabilities |= CAP_DFS;		if (lp_security() >= SEC_USER)		secword |= NEGOTIATE_SECURITY_USER_LEVEL;	if (global_encrypted_passwords_negotiated)		secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;		if (lp_server_signing()) {	       	if (lp_security() >= SEC_USER) {			secword |= NEGOTIATE_SECURITY_SIGNATURES_ENABLED;			/* No raw mode with smb signing. */			capabilities &= ~CAP_RAW_MODE;			if (lp_server_signing() == Required)				secword |=NEGOTIATE_SECURITY_SIGNATURES_REQUIRED;			srv_set_signing_negotiated();		} else {			DEBUG(0,("reply_nt1: smb signing is incompatible with share level security !\n"));			if (lp_server_signing() == Required) {				exit_server("reply_nt1: smb signing required and share level security selected.");			}		}	}	set_message(outbuf,17,0,True);		SCVAL(outbuf,smb_vwv1,secword);		Protocol = PROTOCOL_NT1;		SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */	SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */	SIVAL(outbuf,smb_vwv3+1,max_recv); /* max buffer. LOTS! */	SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */	SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */	SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */	put_long_date(outbuf+smb_vwv11+1,t);	SSVALS(outbuf,smb_vwv15+1,set_server_zone_offset(t)/60);		p = q = smb_buf(outbuf);	if (!negotiate_spnego) {		/* Create a token value and add it to the outgoing packet. */		if (global_encrypted_passwords_negotiated) {			/* note that we do not send a challenge at all if			   we are using plaintext */			get_challenge(p);			SCVAL(outbuf,smb_vwv16+1,8);			p += 8;		}		p += srvstr_push(outbuf, p, lp_workgroup(), -1, 				 STR_UNICODE|STR_TERMINATE|STR_NOALIGN);		DEBUG(3,("not using SPNEGO\n"));	} else {		uint8 keylen;		int len = negprot_spnego(p, &keylen);				SCVAL(outbuf,smb_vwv16+1,keylen);		p += len;		DEBUG(3,("using SPNEGO\n"));	}		SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */	set_message_end(outbuf, p);		return (smb_len(outbuf)+4);}/* these are the protocol lists used for auto architecture detection:WinNT 3.51:protocol [PC NETWORK PROGRAM 1.0]protocol [XENIX CORE]protocol [MICROSOFT NETWORKS 1.03]protocol [LANMAN1.0]protocol [Windows for Workgroups 3.1a]protocol [LM1.2X002]protocol [LANMAN2.1]protocol [NT LM 0.12]Win95:protocol [PC NETWORK PROGRAM 1.0]protocol [XENIX CORE]protocol [MICROSOFT NETWORKS 1.03]protocol [LANMAN1.0]protocol [Windows for Workgroups 3.1a]protocol [LM1.2X002]protocol [LANMAN2.1]protocol [NT LM 0.12]Win2K:protocol [PC NETWORK PROGRAM 1.0]protocol [LANMAN1.0]protocol [Windows for Workgroups 3.1a]protocol [LM1.2X002]protocol [LANMAN2.1]protocol [NT LM 0.12]OS/2:protocol [PC NETWORK PROGRAM 1.0]protocol [XENIX CORE]protocol [LANMAN1.0]protocol [LM1.2X002]protocol [LANMAN2.1]*//*  * Modified to recognize the architecture of the remote machine better.  *  * This appears to be the matrix of which protocol is used by which  * MS product.       Protocol                       WfWg    Win95   WinNT  Win2K  OS/2       PC NETWORK PROGRAM 1.0          1       1       1      1      1       XENIX CORE                                      2             2       MICROSOFT NETWORKS 3.0          2       2              DOS LM1.2X002                   3       3              MICROSOFT NETWORKS 1.03                         3       DOS LANMAN2.1                   4       4              LANMAN1.0                                       4      2      3       Windows for Workgroups 3.1a     5       5       5      3       LM1.2X002                                       6      4      4       LANMAN2.1                                       7      5      5       NT LM 0.12                              6       8      6  *  *  tim@fsg.com 09/29/95  *  Win2K added by matty 17/7/99  */  #define ARCH_WFWG     0x3      /* This is a fudge because WfWg is like Win95 */#define ARCH_WIN95    0x2#define ARCH_WINNT    0x4#define ARCH_WIN2K    0xC      /* Win2K is like NT */#define ARCH_OS2      0x14     /* Again OS/2 is like NT */#define ARCH_SAMBA    0x20#define ARCH_CIFSFS   0x40 #define ARCH_ALL      0x7F /* List of supported protocols, most desired first */static const struct {	const char *proto_name;	const char *short_name;	int (*proto_reply_fn)(char *, char *);	int protocol_level;} supported_protocols[] = {	{"NT LANMAN 1.0",           "NT1",      reply_nt1,      PROTOCOL_NT1},	{"NT LM 0.12",              "NT1",      reply_nt1,      PROTOCOL_NT1},	{"POSIX 2",                 "NT1",      reply_nt1,      PROTOCOL_NT1},	{"LANMAN2.1",               "LANMAN2",  reply_lanman2,  PROTOCOL_LANMAN2},	{"LM1.2X002",               "LANMAN2",  reply_lanman2,  PROTOCOL_LANMAN2},	{"Samba",                   "LANMAN2",  reply_lanman2,  PROTOCOL_LANMAN2},	{"DOS LM1.2X002",           "LANMAN2",  reply_lanman2,  PROTOCOL_LANMAN2},	{"LANMAN1.0",               "LANMAN1",  reply_lanman1,  PROTOCOL_LANMAN1},	{"MICROSOFT NETWORKS 3.0",  "LANMAN1",  reply_lanman1,  PROTOCOL_LANMAN1},	{"MICROSOFT NETWORKS 1.03", "COREPLUS", reply_coreplus, PROTOCOL_COREPLUS},	{"PC NETWORK PROGRAM 1.0",  "CORE",     reply_corep,    PROTOCOL_CORE}, 	{NULL,NULL,NULL,0},};/**************************************************************************** Reply to a negprot.****************************************************************************/int reply_negprot(connection_struct *conn, 		  char *inbuf,char *outbuf, int dum_size, 		  int dum_buffsize){	int outsize = set_message(outbuf,1,0,True);	int Index=0;	int choice= -1;	int protocol;	char *p;	int bcc = SVAL(smb_buf(inbuf),-2);	int arch = ARCH_ALL;	static BOOL done_negprot = False;	START_PROFILE(SMBnegprot);	if (done_negprot) {		END_PROFILE(SMBnegprot);		exit_server("multiple negprot's are not permitted");	}	done_negprot = True;	p = smb_buf(inbuf)+1;	while (p < (smb_buf(inbuf) + bcc)) { 		Index++;		DEBUG(3,("Requested protocol [%s]\n",p));		if (strcsequal(p,"Windows for Workgroups 3.1a"))			arch &= ( ARCH_WFWG | ARCH_WIN95 | ARCH_WINNT | ARCH_WIN2K );		else if (strcsequal(p,"DOS LM1.2X002"))			arch &= ( ARCH_WFWG | ARCH_WIN95 );		else if (strcsequal(p,"DOS LANMAN2.1"))			arch &= ( ARCH_WFWG | ARCH_WIN95 );		else if (strcsequal(p,"NT LM 0.12"))			arch &= ( ARCH_WIN95 | ARCH_WINNT | ARCH_WIN2K | ARCH_CIFSFS);		else if (strcsequal(p,"LANMAN2.1"))			arch &= ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 );		else if (strcsequal(p,"LM1.2X002"))			arch &= ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 );		else if (strcsequal(p,"MICROSOFT NETWORKS 1.03"))			arch &= ARCH_WINNT;		else if (strcsequal(p,"XENIX CORE"))			arch &= ( ARCH_WINNT | ARCH_OS2 );		else if (strcsequal(p,"Samba")) {			arch = ARCH_SAMBA;			break;		} else if (strcsequal(p,"POSIX 2")) {			arch = ARCH_CIFSFS;			break;		} 		p += strlen(p) + 2;	}	/* CIFSFS can send one arch only, NT LM 0.12. */	if (Index == 1 && (arch & ARCH_CIFSFS)) {		arch = ARCH_CIFSFS;	}	switch ( arch ) {		case ARCH_CIFSFS:			set_remote_arch(RA_CIFSFS);			break;		case ARCH_SAMBA:			set_remote_arch(RA_SAMBA);			break;		case ARCH_WFWG:			set_remote_arch(RA_WFWG);			break;		case ARCH_WIN95:			set_remote_arch(RA_WIN95);			break;		case ARCH_WINNT:			if(SVAL(inbuf,smb_flg2)==FLAGS2_WIN2K_SIGNATURE)				set_remote_arch(RA_WIN2K);			else				set_remote_arch(RA_WINNT);			break;		case ARCH_WIN2K:			set_remote_arch(RA_WIN2K);			break;		case ARCH_OS2:			set_remote_arch(RA_OS2);			break;		default:			set_remote_arch(RA_UNKNOWN);		break;	} 	/* possibly reload - change of architecture */	reload_services(True);      		/* moved from the netbios session setup code since we don't have that 	   when the client connects to port 445.  Of course there is a small	   window where we are listening to messages   -- jerry */	claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);    	/* Check for protocols, most desirable first */	for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {		p = smb_buf(inbuf)+1;		Index = 0;		if ((supported_protocols[protocol].protocol_level <= lp_maxprotocol()) &&				(supported_protocols[protocol].protocol_level >= lp_minprotocol()))			while (p < (smb_buf(inbuf) + bcc)) { 				if (strequal(p,supported_protocols[protocol].proto_name))					choice = Index;				Index++;				p += strlen(p) + 2;			}		if(choice != -1)			break;	}  	SSVAL(outbuf,smb_vwv0,choice);	if(choice != -1) {		fstrcpy(remote_proto,supported_protocols[protocol].short_name);		reload_services(True);          		outsize = supported_protocols[protocol].proto_reply_fn(inbuf, outbuf);		DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));	} else {		DEBUG(0,("No protocol supported !\n"));	}	SSVAL(outbuf,smb_vwv0,choice);  	DEBUG( 5, ( "negprot index=%d\n", choice ) );	if ((lp_server_signing() == Required) && (Protocol < PROTOCOL_NT1)) {		exit_server("SMB signing is required and client negotiated a downlevel protocol");	}	END_PROFILE(SMBnegprot);	return(outsize);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -