From 4c5c26b1ef4be862fc2037dd5fcc120cb35bacca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 07:15:54 +0000 Subject: now that we have no global arrays we can start to split up the monster server.c without breaking things. this splits off netprot.c and fileio.c for negprot and read/write/seek handling respectively. (This used to be commit b3d7014643ec9f2eef6e6f598f5b9db1fe2f930d) --- source3/smbd/negprot.c | 415 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 415 insertions(+) create mode 100644 source3/smbd/negprot.c (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c new file mode 100644 index 0000000000..8e996cac21 --- /dev/null +++ b/source3/smbd/negprot.c @@ -0,0 +1,415 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + negprot reply code + Copyright (C) Andrew Tridgell 1992-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +extern int DEBUGLEVEL; +extern int Protocol; +extern int max_recv; +extern fstring global_myworkgroup; +extern fstring remote_machine; +extern pstring myhostname; + +/**************************************************************************** +reply for the core protocol +****************************************************************************/ +static int reply_corep(char *outbuf) +{ + int outsize = set_message(outbuf,1,0,True); + + Protocol = PROTOCOL_CORE; + + return outsize; +} + + +/**************************************************************************** +reply for the coreplus protocol +****************************************************************************/ +static int reply_coreplus(char *outbuf) +{ + int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); + int outsize = set_message(outbuf,13,0,True); + SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support + readbraw and writebraw (possibly) */ + CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */ + + Protocol = PROTOCOL_COREPLUS; + + return outsize; +} + + +/**************************************************************************** +reply for the lanman 1.0 protocol +****************************************************************************/ +static int reply_lanman1(char *outbuf) +{ + int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); + int secword=0; + BOOL doencrypt = SMBENCRYPT(); + time_t t = time(NULL); + + if (lp_security()>=SEC_USER) secword |= 1; + if (doencrypt) secword |= 2; + + set_message(outbuf,13,doencrypt?8:0,True); + SSVAL(outbuf,smb_vwv1,secword); + /* Create a token value and add it to the outgoing packet. */ + if (doencrypt) + generate_next_challenge(smb_buf(outbuf)); + + Protocol = PROTOCOL_LANMAN1; + + CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + SSVAL(outbuf,smb_vwv2,max_recv); + SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ + SSVAL(outbuf,smb_vwv4,1); + SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support + readbraw writebraw (possibly) */ + SIVAL(outbuf,smb_vwv6,getpid()); + SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); + + put_dos_date(outbuf,smb_vwv8,t); + + return (smb_len(outbuf)+4); +} + + +/**************************************************************************** +reply for the lanman 2.0 protocol +****************************************************************************/ +static int reply_lanman2(char *outbuf) +{ + int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); + int secword=0; + BOOL doencrypt = SMBENCRYPT(); + time_t t = time(NULL); + struct cli_state *cli = NULL; + char cryptkey[8]; + char crypt_len = 0; + + if (lp_security() == SEC_SERVER) { + cli = server_cryptkey(); + } + + if (cli) { + DEBUG(3,("using password server validation\n")); + doencrypt = ((cli->sec_mode & 2) != 0); + } + + if (lp_security()>=SEC_USER) secword |= 1; + if (doencrypt) secword |= 2; + + if (doencrypt) { + crypt_len = 8; + if (!cli) { + generate_next_challenge(cryptkey); + } else { + memcpy(cryptkey, cli->cryptkey, 8); + set_challenge(cli->cryptkey); + } + } + + set_message(outbuf,13,crypt_len,True); + SSVAL(outbuf,smb_vwv1,secword); + SIVAL(outbuf,smb_vwv6,getpid()); + if (doencrypt) + memcpy(smb_buf(outbuf), cryptkey, 8); + + Protocol = PROTOCOL_LANMAN2; + + CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + SSVAL(outbuf,smb_vwv2,max_recv); + SSVAL(outbuf,smb_vwv3,lp_maxmux()); + SSVAL(outbuf,smb_vwv4,1); + SSVAL(outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ + SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); + put_dos_date(outbuf,smb_vwv8,t); + + return (smb_len(outbuf)+4); +} + + +/**************************************************************************** +reply for the nt protocol +****************************************************************************/ +static int reply_nt1(char *outbuf) +{ + /* dual names + lock_and_read + nt SMBs + remote API calls */ + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS |CAP_NT_SMBS; + +/* + other valid capabilities which we may support at some time... + CAP_LARGE_FILES| + CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; + */ + + int secword=0; + BOOL doencrypt = SMBENCRYPT(); + time_t t = time(NULL); + int data_len; + struct cli_state *cli = NULL; + char cryptkey[8]; + char crypt_len = 0; + + if (lp_security() == SEC_SERVER) { + cli = server_cryptkey(); + } + + if (cli) { + DEBUG(3,("using password server validation\n")); + doencrypt = ((cli->sec_mode & 2) != 0); + } + + if (doencrypt) { + crypt_len = 8; + if (!cli) { + generate_next_challenge(cryptkey); + } else { + memcpy(cryptkey, cli->cryptkey, 8); + set_challenge(cli->cryptkey); + } + } + + if (lp_readraw() && lp_writeraw()) { + capabilities |= CAP_RAW_MODE; + } + + if (lp_security() >= SEC_USER) secword |= 1; + if (doencrypt) secword |= 2; + + /* decide where (if) to put the encryption challenge, and + follow it with the OEM'd domain name + */ + data_len = crypt_len + strlen(global_myworkgroup) + 1; + + set_message(outbuf,17,data_len,True); + pstrcpy(smb_buf(outbuf)+crypt_len, global_myworkgroup); + + CVAL(outbuf,smb_vwv1) = secword; + SSVALS(outbuf,smb_vwv16+1,crypt_len); + if (doencrypt) + memcpy(smb_buf(outbuf), cryptkey, 8); + + Protocol = PROTOCOL_NT1; + + SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */ + SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */ + SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */ + SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */ + SIVAL(outbuf,smb_vwv7+1,getpid()); /* session key */ + SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */ + put_long_date(outbuf+smb_vwv11+1,t); + SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60); + SSVAL(outbuf,smb_vwv17,data_len); /* length of challenge+domain strings */ + + 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] + +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 OS/2 + PC NETWORK PROGRAM 1.0 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 3 + Windows for Workgroups 3.1a 5 5 5 + LM1.2X002 6 4 + LANMAN2.1 7 5 + NT LM 0.12 6 8 + * + * tim@fsg.com 09/29/95 + */ + +#define ARCH_WFWG 0x3 /* This is a fudge because WfWg is like Win95 */ +#define ARCH_WIN95 0x2 +#define ARCH_OS2 0xC /* Again OS/2 is like NT */ +#define ARCH_WINNT 0x8 +#define ARCH_SAMBA 0x10 + +#define ARCH_ALL 0x1F + +/* List of supported protocols, most desired first */ +static struct { + char *proto_name; + char *short_name; + int (*proto_reply_fn)(char *); + int protocol_level; +} supported_protocols[] = { + {"NT LANMAN 1.0", "NT1", reply_nt1, PROTOCOL_NT1}, + {"NT LM 0.12", "NT1", reply_nt1, PROTOCOL_NT1}, + {"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}, +}; + + +/**************************************************************************** + 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; + + 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 ); + 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 ); + else if (strcsequal(p,"LANMAN2.1")) + arch &= ( ARCH_WINNT | ARCH_OS2 ); + else if (strcsequal(p,"LM1.2X002")) + arch &= ( ARCH_WINNT | 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; + } + + p += strlen(p) + 2; + } + + switch ( arch ) { + 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: + set_remote_arch(RA_WINNT); + 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); + + /* a special case to stop password server loops */ + if (Index == 1 && strequal(remote_machine,myhostname) && + (lp_security()==SEC_SERVER || lp_security()==SEC_DOMAIN)) + exit_server("Password server loop!"); + + /* Check for protocols, most desirable first */ + for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) + { + p = smb_buf(inbuf)+1; + Index = 0; + if (lp_maxprotocol() >= supported_protocols[protocol].protocol_level) + 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) { + extern fstring remote_proto; + fstrcpy(remote_proto,supported_protocols[protocol].short_name); + reload_services(True); + outsize = supported_protocols[protocol].proto_reply_fn(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 ) ); + + return(outsize); +} + -- cgit From 98f524bde4801bd0b013a6bc79c5552ef62b59f8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 5 Sep 1998 03:14:40 +0000 Subject: Bugfix for leak in reference counted file struct. Added "nt smb support" parameter to allow NT SMB's to be turned off. Jeremy. (This used to be commit 63f65f5027d5022153fa2757b49c56829db1725b) --- source3/smbd/negprot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 8e996cac21..b1e8a65c94 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -156,7 +156,8 @@ reply for the nt protocol static int reply_nt1(char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ - int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS |CAP_NT_SMBS; + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS | + lp_nt_smb_support() ? CAP_NT_SMBS : 0; /* other valid capabilities which we may support at some time... -- cgit From aab0323d294770f80c6514389e5f84d3abf82429 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Sep 1998 00:35:10 +0000 Subject: Improved stat cache code by uppercasing any search name that gets added to it if we're in case insensitive mode, and then doing a memcmp rather than a StrnCaseCmp (which is *horribly* slow) on every lookup. Fixed bug with refusing NT SMB's (use *brackets* where needed :-). Jeremy. (This used to be commit 02b3fddce33a58a4db2102670b502fc0c6f45fab) --- source3/smbd/negprot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b1e8a65c94..6a9cc9fb9b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -156,8 +156,8 @@ reply for the nt protocol static int reply_nt1(char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ - int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS | - lp_nt_smb_support() ? CAP_NT_SMBS : 0; + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| + (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0); /* other valid capabilities which we may support at some time... -- cgit From 27d0bef143fbc4d7547c022046c094bbdbd0bfc1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Sep 1998 19:14:27 +0000 Subject: Ok - this is the 'expose 64 bit to the clients' checkin. I have tested it by creating a 'holey' 20GB file - checking that it shows up correctl in the NT file view (it does) and am busily copying it to NULL: on the NT box. All good so far.... :-). Also implemented NT 'delete on close' semantics. Jeremy. (This used to be commit 1654faee80648583e6a47ab7eda990fefdf85124) --- source3/smbd/negprot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 6a9cc9fb9b..e9dd4614c4 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -157,11 +157,15 @@ static int reply_nt1(char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| - (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0); + (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | +#ifdef LARGE_SMB_OFF_T + (sizeof(SMB_OFF_T) == 8 ? CAP_LARGE_FILES : 0); +#else + 0; +#endif /* other valid capabilities which we may support at some time... - CAP_LARGE_FILES| CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; */ -- cgit From b8b67f4fab4a6fd686c5796c2701882197a7bd9d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Sep 1998 23:06:57 +0000 Subject: configure configure.in: Added checks for statvfs64. Last bit of 64 bit widening (I hope :-). include/config.h.in: Added #undef STAT_STATVFS64. include/includes.h: Added SMB_STRUCT_STATVFS type, Changed SMB_BIG_INTEGER to SMB_BIG_UINT and SMB_BIG_INT types. include/smb.h: Added flag defines from CIFS spec. lib/debug.c: Fixed one more mode_t issue. lib/system.c: Added sys_statvfs wrapper. lib/util.c: Changed trim_string to use size_t. param/loadparm.c: Moved "blocking locks" into locking section. Alphabetised locking options. Question - shuld we do this for all options ? passdb/ldap.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/nispass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/smbpass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. smbd/dfree.c: Changed to use 64 bit types if available. Moved to use unsigned types. smbd/dosmode.c: Fixed one more mode_t issue. smbd/negprot.c: Changed literals to be FLAG_ #defines. smbd/nttrans.c: Removed dead code. smbd/open.c: Changed disk_free call. smbd/process.c: Changed literals to be FLAG_ #defines. smbd/reply.c: Changed disk_free call. smbd/trans2.c: Fixed but in SMB_QUERY_FS_VOLUME_INFO call. Was using UNICODE - should use ascii. tests/summary.c: Added STAT_STATVFS64 check. Jeremy. (This used to be commit c512b1b91fb7f2a7a93b9033a33e06d966daadb4) --- source3/smbd/negprot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e9dd4614c4..e79743cfd4 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -50,7 +50,8 @@ static int reply_coreplus(char *outbuf) int outsize = set_message(outbuf,13,0,True); SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support readbraw and writebraw (possibly) */ - CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */ Protocol = PROTOCOL_COREPLUS; @@ -80,7 +81,8 @@ static int reply_lanman1(char *outbuf) Protocol = PROTOCOL_LANMAN1; - CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); SSVAL(outbuf,smb_vwv2,max_recv); SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ SSVAL(outbuf,smb_vwv4,1); @@ -138,7 +140,8 @@ static int reply_lanman2(char *outbuf) Protocol = PROTOCOL_LANMAN2; - CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); SSVAL(outbuf,smb_vwv2,max_recv); SSVAL(outbuf,smb_vwv3,lp_maxmux()); SSVAL(outbuf,smb_vwv4,1); @@ -417,4 +420,3 @@ int reply_negprot(connection_struct *conn, return(outsize); } - -- cgit From c7da9992cb39fc84a6a915dd2158beaf5e616617 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Sep 1998 03:00:20 +0000 Subject: gto ri of a bunch more #ifdef LARGE_SMB_OFF_T checks by introducing a SOFF_T() macro for setting an SMB_OFF_T variable also limited mmap based reads to MAX_MMAP_SIZE. We really can't mmap 2^50 bytes due to virtual address space problems. (This used to be commit 4e784b18899eddd2399a51fa7d8c219560432922) --- source3/smbd/negprot.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e79743cfd4..d4e6180261 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -161,11 +161,8 @@ static int reply_nt1(char *outbuf) /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | -#ifdef LARGE_SMB_OFF_T - (sizeof(SMB_OFF_T) == 8 ? CAP_LARGE_FILES : 0); -#else - 0; -#endif + (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); + /* other valid capabilities which we may support at some time... -- cgit From 89d51caba5bed5c3329b3776e15fce2bb41f7592 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 1 May 1999 01:41:28 +0000 Subject: added server ntlmv2 false/auto/true parameter, defaults to off. (This used to be commit 209944dabc764c6ea0c471e7868306c7d8d020d4) --- source3/smbd/negprot.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index d4e6180261..e66bf9f163 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -159,16 +159,6 @@ reply for the nt protocol static int reply_nt1(char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ - int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| - (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | - (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); - - -/* - other valid capabilities which we may support at some time... - CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; - */ - int secword=0; BOOL doencrypt = SMBENCRYPT(); time_t t = time(NULL); @@ -177,9 +167,26 @@ static int reply_nt1(char *outbuf) char cryptkey[8]; char crypt_len = 0; - if (lp_security() == SEC_SERVER) { - cli = server_cryptkey(); - } + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ; + + if (lp_nt_smb_support()) + { + capabilities |= CAP_NT_SMBS | CAP_RPC_REMOTE_APIS; + } + + if (SMB_OFF_T_BITS == 64) + { + capabilities |= CAP_LARGE_FILES; + } +/* + other valid capabilities which we may support at some time... + CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; + */ + + if (lp_security() == SEC_SERVER) + { + cli = server_cryptkey(); + } if (cli) { DEBUG(3,("using password server validation\n")); -- cgit From 8f1404739fe75464fe1500c3f6e6d39d4878ec1e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 12 Jul 1999 18:46:15 +0000 Subject: Jean-Francois Micouleau's rewritten DFS patch, originally written by Nigel Williams. despite the data format being *exactly* the same as NT's, this still doesn't work yet. more work needed. (This used to be commit 270981960bb5aab52d2f8e494827101ece6729c4) --- source3/smbd/negprot.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e66bf9f163..51ec963b8c 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -27,6 +27,7 @@ extern int max_recv; extern fstring global_myworkgroup; extern fstring remote_machine; extern pstring myhostname; +extern dfs_internal dfs_struct; /**************************************************************************** reply for the core protocol @@ -178,6 +179,12 @@ static int reply_nt1(char *outbuf) { capabilities |= CAP_LARGE_FILES; } + + if (dfs_struct.ready==True) + { + capabilities |= CAP_DFS; + } + /* other valid capabilities which we may support at some time... CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; -- cgit From 701f9ed2c97ad50a4258e278a3674b8f5a747d8e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 16 Sep 1999 22:46:45 +0000 Subject: reading in smb server domain name from SMBnegprot response (This used to be commit 25025f450531c66c0fd9f7eed886cb288d76d025) --- source3/smbd/negprot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 51ec963b8c..0b48b0e2b2 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -218,12 +218,13 @@ static int reply_nt1(char *outbuf) if (doencrypt) secword |= 2; /* decide where (if) to put the encryption challenge, and - follow it with the OEM'd domain name + follow it with the OEM'd domain name in Unicode. */ - data_len = crypt_len + strlen(global_myworkgroup) + 1; + data_len = crypt_len + (strlen(global_myworkgroup)+1)*2; set_message(outbuf,17,data_len,True); - pstrcpy(smb_buf(outbuf)+crypt_len, global_myworkgroup); + ascii_to_unibuf(smb_buf(outbuf)+crypt_len, global_myworkgroup, + (strlen(global_myworkgroup)+1)*2); CVAL(outbuf,smb_vwv1) = secword; SSVALS(outbuf,smb_vwv16+1,crypt_len); -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/smbd/negprot.c | 95 ++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 49 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 0b48b0e2b2..b2366b0a37 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -26,8 +26,6 @@ extern int Protocol; extern int max_recv; extern fstring global_myworkgroup; extern fstring remote_machine; -extern pstring myhostname; -extern dfs_internal dfs_struct; /**************************************************************************** reply for the core protocol @@ -160,6 +158,16 @@ reply for the nt protocol static int reply_nt1(char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| + (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | + (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); + + +/* + other valid capabilities which we may support at some time... + CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; + */ + int secword=0; BOOL doencrypt = SMBENCRYPT(); time_t t = time(NULL); @@ -168,32 +176,9 @@ static int reply_nt1(char *outbuf) char cryptkey[8]; char crypt_len = 0; - int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ; - - if (lp_nt_smb_support()) - { - capabilities |= CAP_NT_SMBS | CAP_RPC_REMOTE_APIS; - } - - if (SMB_OFF_T_BITS == 64) - { - capabilities |= CAP_LARGE_FILES; - } - - if (dfs_struct.ready==True) - { - capabilities |= CAP_DFS; - } - -/* - other valid capabilities which we may support at some time... - CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; - */ - - if (lp_security() == SEC_SERVER) - { - cli = server_cryptkey(); - } + if (lp_security() == SEC_SERVER) { + cli = server_cryptkey(); + } if (cli) { DEBUG(3,("using password server validation\n")); @@ -218,13 +203,12 @@ static int reply_nt1(char *outbuf) if (doencrypt) secword |= 2; /* decide where (if) to put the encryption challenge, and - follow it with the OEM'd domain name in Unicode. + follow it with the OEM'd domain name */ - data_len = crypt_len + (strlen(global_myworkgroup)+1)*2; + data_len = crypt_len + strlen(global_myworkgroup) + 1; set_message(outbuf,17,data_len,True); - ascii_to_unibuf(smb_buf(outbuf)+crypt_len, global_myworkgroup, - (strlen(global_myworkgroup)+1)*2); + pstrcpy(smb_buf(outbuf)+crypt_len, global_myworkgroup); CVAL(outbuf,smb_vwv1) = secword; SSVALS(outbuf,smb_vwv16+1,crypt_len); @@ -268,6 +252,14 @@ 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] @@ -281,29 +273,31 @@ protocol [LANMAN2.1] * * This appears to be the matrix of which protocol is used by which * MS product. - Protocol WfWg Win95 WinNT OS/2 - PC NETWORK PROGRAM 1.0 1 1 1 1 - XENIX CORE 2 2 + 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 3 - Windows for Workgroups 3.1a 5 5 5 - LM1.2X002 6 4 - LANMAN2.1 7 5 - NT LM 0.12 6 8 + 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_OS2 0xC /* Again OS/2 is like NT */ -#define ARCH_WINNT 0x8 -#define ARCH_SAMBA 0x10 +#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_ALL 0x1F +#define ARCH_ALL 0x3F /* List of supported protocols, most desired first */ static struct { @@ -346,17 +340,17 @@ int reply_negprot(connection_struct *conn, Index++; DEBUG(3,("Requested protocol [%s]\n",p)); if (strcsequal(p,"Windows for Workgroups 3.1a")) - arch &= ( ARCH_WFWG | ARCH_WIN95 | ARCH_WINNT ); + 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 &= ( ARCH_WIN95 | ARCH_WINNT | ARCH_WIN2K ); else if (strcsequal(p,"LANMAN2.1")) - arch &= ( ARCH_WINNT | ARCH_OS2 ); + arch &= ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 ); else if (strcsequal(p,"LM1.2X002")) - arch &= ( ARCH_WINNT | ARCH_OS2 ); + arch &= ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 ); else if (strcsequal(p,"MICROSOFT NETWORKS 1.03")) arch &= ARCH_WINNT; else if (strcsequal(p,"XENIX CORE")) @@ -382,6 +376,9 @@ int reply_negprot(connection_struct *conn, case ARCH_WINNT: set_remote_arch(RA_WINNT); break; + case ARCH_WIN2K: + set_remote_arch(RA_WIN2K); + break; case ARCH_OS2: set_remote_arch(RA_OS2); break; @@ -394,7 +391,7 @@ int reply_negprot(connection_struct *conn, reload_services(True); /* a special case to stop password server loops */ - if (Index == 1 && strequal(remote_machine,myhostname) && + if (Index == 1 && strequal(remote_machine,myhostname()) && (lp_security()==SEC_SERVER || lp_security()==SEC_DOMAIN)) exit_server("Password server loop!"); -- cgit From fab3e0eb08ce3f479131eaea040f3d9215caa038 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 8 Jan 2000 02:16:15 +0000 Subject: smbd/mangle.c smbd/negprot.c: Tidyup of static initializers. smbd/server.c: Fix -l option. Jeremy. (This used to be commit d120f22fefde21b38e43ea5ad0180bf27304d2eb) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b2366b0a37..3cabc6b229 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -315,7 +315,7 @@ static struct { {"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,NULL,NULL,0}, }; -- cgit From 952799d9afe028d822181831715b85521c89a7ef Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Wed, 8 Mar 2000 22:14:30 +0000 Subject: dded Microsoft Dfs services. * added a new msdfs/ directory under source/ * added msdfs sources under this directory. * modified configure setup to add a --with-msdfs configure time option Modified Files: Makefile.in acconfig.h configure configure.in include/config.h.in include/includes.h include/proto.h include/smb.h include/smb_macros.h param/loadparm.c smbd/negprot.c smbd/nttrans.c smbd/process.c smbd/reply.c smbd/server.c smbd/trans2.c Added Files: include/msdfs.h msdfs/README msdfs/msdfs.c msdfs/msdfs_tdb.c msdfs/parse_dfs_map.c ---------------------------------------------------------------------- (This used to be commit 4684b4a188b54493dbe7f0de2909a8d3c5c3ebf9) --- source3/smbd/negprot.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 3cabc6b229..47a82c6e31 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -199,6 +199,11 @@ static int reply_nt1(char *outbuf) capabilities |= CAP_RAW_MODE; } +#ifdef MS_DFS + if(lp_host_msdfs()) + capabilities |= CAP_DFS; +#endif + if (lp_security() >= SEC_USER) secword |= 1; if (doencrypt) secword |= 2; -- cgit From 01d88573ea1b3809a3e264989e1e04cd397528f7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2000 20:05:18 +0000 Subject: include/smb.h: smbd/negprot.c: smbd/reply.c: Fixes to recognise Win2k. param/loadparm.c: Put debug timestamp parameter back to correct default. smbd/nttrans.c: Fix to detect Win2k unicode bug with transact create. Jeremy. (This used to be commit bb100352ab2f98fab3978008d269920e03efcf6d) --- source3/smbd/negprot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 47a82c6e31..adef4a57f3 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -379,7 +379,10 @@ int reply_negprot(connection_struct *conn, set_remote_arch(RA_WIN95); break; case ARCH_WINNT: - set_remote_arch(RA_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); -- cgit From 693ffb8466ada58ecc59fde754ba79fc6f51528d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 May 2000 02:23:41 +0000 Subject: Added sys_fork() and sys_getpid() functions to stop the overhead of doing a system call every time we want to just get our pid. Jeremy. (This used to be commit 148628b616b5c29ba6340d65fc3ddbcabba6e67a) --- source3/smbd/negprot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index adef4a57f3..e8302a43e6 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -87,7 +87,7 @@ static int reply_lanman1(char *outbuf) SSVAL(outbuf,smb_vwv4,1); SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support readbraw writebraw (possibly) */ - SIVAL(outbuf,smb_vwv6,getpid()); + SIVAL(outbuf,smb_vwv6,sys_getpid()); SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); put_dos_date(outbuf,smb_vwv8,t); @@ -133,7 +133,7 @@ static int reply_lanman2(char *outbuf) set_message(outbuf,13,crypt_len,True); SSVAL(outbuf,smb_vwv1,secword); - SIVAL(outbuf,smb_vwv6,getpid()); + SIVAL(outbuf,smb_vwv6,sys_getpid()); if (doencrypt) memcpy(smb_buf(outbuf), cryptkey, 8); @@ -226,7 +226,7 @@ static int reply_nt1(char *outbuf) SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */ SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */ SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */ - SIVAL(outbuf,smb_vwv7+1,getpid()); /* session key */ + 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,TimeDiff(t)/60); -- cgit From 49a0e6d5989656c1b3c9c063a20308ca4ee5d73b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 May 2000 10:41:59 +0000 Subject: more merging voodoo this adds "#define OLD_NTDOMAIN 1" in lots of places. Don't panic - this isn't permanent, it should go after another few merge steps have been done (This used to be commit 92109d7b3c06f240452d39f669ecb8c9c86ab610) --- source3/smbd/negprot.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e8302a43e6..60af2924b2 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -1,3 +1,5 @@ +#define OLD_NTDOMAIN 1 + /* Unix SMB/Netbios implementation. Version 1.9. @@ -437,3 +439,5 @@ int reply_negprot(connection_struct *conn, return(outsize); } + +#undef OLD_NTDOMAIN -- cgit From 8a86541e282424c4e0ea5626b26e818779ba0375 Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Fri, 26 May 2000 17:10:40 +0000 Subject: Changed MS_DFS to WITH_MSDFS throughout. Fixed trans2 calls on IPC$ to let dfs referral calls through. (This used to be commit e0965a80bdca5239886b11ef55dc29fed261bfc0) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 60af2924b2..362d571ff1 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -201,7 +201,7 @@ static int reply_nt1(char *outbuf) capabilities |= CAP_RAW_MODE; } -#ifdef MS_DFS +#ifdef WITH_MSDFS if(lp_host_msdfs()) capabilities |= CAP_DFS; #endif -- cgit From 8719c27726d3412edd0781beb956f48f76a62fb6 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 11 Oct 2000 05:31:39 +0000 Subject: changes to sync with 2.2. tree .cvsignore remove config.h - not in this directory include/profile.h profile changes lib/messages.c added message to return debug level libsmb/clierror.c cast to get rid of compiler warning libsmb/smbencrypt.c cast to get rid of compiler warning profile/profile.c add flush profile stats changes for profile struct rpc_parse/parse_samr.c fix for compiler warning rpc_server/srv_samr.c cast to get rid of compiler warning smbd/ipc.c profile stats message.c profile stats smbd/negprot.c profile stats smbd/nttrans.c profile stats smbd/trans2.c profile stats utils/smbcontrol.c new flush stats command (This used to be commit bbb24daa25dca4e4b6b1f8942cd84ee3aa1bed8e) --- source3/smbd/negprot.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 362d571ff1..1029c8db62 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -340,6 +340,7 @@ int reply_negprot(connection_struct *conn, char *p; int bcc = SVAL(smb_buf(inbuf),-2); int arch = ARCH_ALL; + START_PROFILE(SMBnegprot); p = smb_buf(inbuf)+1; while (p < (smb_buf(inbuf) + bcc)) @@ -437,6 +438,7 @@ int reply_negprot(connection_struct *conn, DEBUG( 5, ( "negprot index=%d\n", choice ) ); + END_PROFILE(SMBnegprot); return(outsize); } -- cgit From 6f58dd587124c8b85fc62177b26129aaea5819b0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Nov 2000 00:59:18 +0000 Subject: Ok - fixed a bug in our levelII oplock code. We need to break a level II on a byte range lock (write lock only, but Win2k breaks on read lock also so I do the same) - if you think about why, this is obvious. Also fixed our client code to do level II oplocks, if requested, and fixed the code where we would assume the client wanted level II if it advertised itself as being level II capable - it may not want that. Jeremy. (This used to be commit 213cd0b5192307cd4b0026cae94b2f52fb1b0c02) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 1029c8db62..41e95b816d 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -160,7 +160,7 @@ reply for the nt protocol static int reply_nt1(char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ - int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_LEVEL_II_OPLOCKS| (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); -- cgit From 0bfc10011bd5cacecda8b59c36e80f676e5c7fa3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 9 Mar 2001 18:59:16 +0000 Subject: merge of 'lanman auth' and 'min protocol' from 2.2 (This used to be commit 1d84da779a0fe3219d77686a493d2b2fa1f8072a) --- source3/smbd/negprot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 41e95b816d..74d8eb3983 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -411,7 +411,8 @@ int reply_negprot(connection_struct *conn, { p = smb_buf(inbuf)+1; Index = 0; - if (lp_maxprotocol() >= supported_protocols[protocol].protocol_level) + 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)) -- cgit From b08b70faf873455ff14dcd633a7c9eb860ba4b28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Mar 2001 11:38:27 +0000 Subject: started support for unicode on the wire in smbd. Using a very similar method to what was used in the client I now have session setup and tconx working. Currently this is enabled with SMBD_USE_UNICODE environment variable. Once the code is complete this will become a smb.conf option. (This used to be commit 7684c1e67294266d018c6f0cab58f1a9d797174f) --- source3/smbd/negprot.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 74d8eb3983..c2026f46f9 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -201,6 +201,12 @@ static int reply_nt1(char *outbuf) capabilities |= CAP_RAW_MODE; } + + /* until the unicode conversion is complete have it disabled by default */ + if (getenv("SMBD_USE_UNICODE")) { + capabilities |= CAP_UNICODE; + } + #ifdef WITH_MSDFS if(lp_host_msdfs()) capabilities |= CAP_DFS; -- cgit From da3053048c3d224a20d6383ac6682d31059cd46c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 00:32:10 +0000 Subject: Merge of new 2.2 code into HEAD (Gerald I hate you :-) :-). Allows new SAMR RPC code to merge with new passdb code. Currently rpcclient doesn't compile. I'm working on it... Jeremy. (This used to be commit 0be41d5158ea4e645e93e8cd30617c038416e549) --- source3/smbd/negprot.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index c2026f46f9..e15af3f3ae 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -1,5 +1,3 @@ -#define OLD_NTDOMAIN 1 - /* Unix SMB/Netbios implementation. Version 1.9. @@ -448,5 +446,3 @@ int reply_negprot(connection_struct *conn, END_PROFILE(SMBnegprot); return(outsize); } - -#undef OLD_NTDOMAIN -- cgit From c9b8da47a68c98d72d59d25d1e2d8f3069300f40 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 16 Mar 2001 02:31:24 +0000 Subject: enable unicode on the wire by default in smbd the unicode support isn't complete, but it is good enough to be usable for a test server. (This used to be commit e787fc1daf4a46c182e87bf0697eec80ff0ce87a) --- source3/smbd/negprot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e15af3f3ae..ffc5d5e398 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -200,8 +200,8 @@ static int reply_nt1(char *outbuf) } - /* until the unicode conversion is complete have it disabled by default */ - if (getenv("SMBD_USE_UNICODE")) { + /* allow for disabling unicode */ + if (lp_unicode()) { capabilities |= CAP_UNICODE; } -- cgit From 4d86a2841cd3941c8b67e3f2dc1670562b6874a6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 May 2001 18:47:52 +0000 Subject: This is *very* cool. I'm pretty convinced we can just set the CAP_LARGE_READX|CAP_LARGE_WRITEX bits on negprot and out W2K performance goes through the roof...... And as we *always* offer 64 buffers we can do this with this simple change..... Jeremy. (This used to be commit c328dda0fa081e79049d7a9ddac06e80cc8b331b) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index ffc5d5e398..6c45e37654 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -160,6 +160,7 @@ static int reply_nt1(char *outbuf) /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_LEVEL_II_OPLOCKS| (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | + CAP_LARGE_READX | CAP_LARGE_WRITEX | (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); -- cgit From 3414c71f6de04d0ba26841bceac381498f43ecad Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Jun 2001 03:02:34 +0000 Subject: Extra stuff for large readwrite support. Jeremy. (This used to be commit 4338ee78c3d7bcf4b9fac383ff2f572d882ab97c) --- source3/smbd/negprot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 6c45e37654..83c809de1c 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -160,7 +160,8 @@ static int reply_nt1(char *outbuf) /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_LEVEL_II_OPLOCKS| (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | - CAP_LARGE_READX | CAP_LARGE_WRITEX | + ((lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) ? + CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS : 0) | (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); -- cgit From 4ff011d88ef5b79b92d2cea1abe32c93bc03f724 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jun 2001 05:38:28 +0000 Subject: Added STR_NOALIGN flags to clistr and srvstr fns. Yes, NT actually does send unaligned unicode strings sometimes! Fixed our handling of the workgroup name tacked on the end of the NT1 negprot response (a unaligned unicode) fixed a couple of places where we should be using the message_end fns instead of pre-calculated buffer lengths (This used to be commit 86613493a9b2e56523153486931d0bf8d39beb7a) --- source3/smbd/negprot.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 83c809de1c..2c6575d643 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -177,6 +177,7 @@ static int reply_nt1(char *outbuf) struct cli_state *cli = NULL; char cryptkey[8]; char crypt_len = 0; + char *p; if (lp_security() == SEC_SERVER) { cli = server_cryptkey(); @@ -215,18 +216,10 @@ static int reply_nt1(char *outbuf) if (lp_security() >= SEC_USER) secword |= 1; if (doencrypt) secword |= 2; - /* decide where (if) to put the encryption challenge, and - follow it with the OEM'd domain name - */ - data_len = crypt_len + strlen(global_myworkgroup) + 1; - - set_message(outbuf,17,data_len,True); - pstrcpy(smb_buf(outbuf)+crypt_len, global_myworkgroup); + set_message(outbuf,17,0,True); CVAL(outbuf,smb_vwv1) = secword; SSVALS(outbuf,smb_vwv16+1,crypt_len); - if (doencrypt) - memcpy(smb_buf(outbuf), cryptkey, 8); Protocol = PROTOCOL_NT1; @@ -240,6 +233,13 @@ static int reply_nt1(char *outbuf) SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60); SSVAL(outbuf,smb_vwv17,data_len); /* length of challenge+domain strings */ + p = smb_buf(outbuf); + if (doencrypt) memcpy(p, cryptkey, 8); + p += 8; + p += srvstr_push(outbuf, p, global_myworkgroup, -1, + STR_UNICODE|STR_CONVERT|STR_TERMINATE|STR_NOALIGN); + set_message_end(outbuf, p); + return (smb_len(outbuf)+4); } -- cgit From 247acd5521f28a4f932105c9c76699c62f3f95f9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 1 Jul 2001 10:39:37 +0000 Subject: - fix bug in reply_nt- fix bug in reply_nt1 (This used to be commit 200110a3b4caeb0d8be87f02476af29165e35ada) --- source3/smbd/negprot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 2c6575d643..11400af710 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -173,11 +173,10 @@ static int reply_nt1(char *outbuf) int secword=0; BOOL doencrypt = SMBENCRYPT(); time_t t = time(NULL); - int data_len; struct cli_state *cli = NULL; char cryptkey[8]; char crypt_len = 0; - char *p; + char *p, *q; if (lp_security() == SEC_SERVER) { cli = server_cryptkey(); @@ -231,13 +230,14 @@ static int reply_nt1(char *outbuf) SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */ put_long_date(outbuf+smb_vwv11+1,t); SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60); - SSVAL(outbuf,smb_vwv17,data_len); /* length of challenge+domain strings */ - p = smb_buf(outbuf); + p = q = smb_buf(outbuf); if (doencrypt) memcpy(p, cryptkey, 8); p += 8; p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_UNICODE|STR_CONVERT|STR_TERMINATE|STR_NOALIGN); + + SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ set_message_end(outbuf, p); return (smb_len(outbuf)+4); -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 11400af710..de6f5d789f 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -235,7 +235,7 @@ static int reply_nt1(char *outbuf) if (doencrypt) memcpy(p, cryptkey, 8); p += 8; p += srvstr_push(outbuf, p, global_myworkgroup, -1, - STR_UNICODE|STR_CONVERT|STR_TERMINATE|STR_NOALIGN); + STR_UNICODE|STR_TERMINATE|STR_NOALIGN); SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ set_message_end(outbuf, p); -- cgit From 986372901e85a79343ba32f590a4a3e7658d2565 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Aug 2001 13:09:23 +0000 Subject: This is my 'Authentication Rewrite' version 1.01, mostly as submitted to samba-technical a few weeks ago. The idea here is to standardize the checking of user names and passwords, thereby ensuring that all authtentications pass the same standards. The interface currently implemented in as nt_status = check_password(user_info, server_info) where user_info contains (mostly) the authentication data, and server_info contains things like the user-id they got, and their resolved user name. The current ugliness with the way the structures are created will be killed the next revision, when they will be created and malloced by creator functions. This patch also includes the first implementation of NTLMv2 in HEAD, but which needs some more testing. We also add a hack to allow plaintext passwords to be compared with smbpasswd, not the system password database. Finally, this patch probably reintroduces the PAM accounts bug we had in 2.2.0, I'll fix that once this hits the tree. (I've just finished testing it on a wide variety of platforms, so I want to get this patch in). (This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42) --- source3/smbd/negprot.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index de6f5d789f..6410aa2da6 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -179,7 +179,10 @@ static int reply_nt1(char *outbuf) char *p, *q; if (lp_security() == SEC_SERVER) { + DEBUG(5,("attempting password server validation\n")); cli = server_cryptkey(); + } else { + DEBUG(5,("attempting local password validation\n")); } if (cli) { -- cgit From 0897979a8b0976e03a84ccaf6a70cbaa62bbd195 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Aug 2001 03:25:47 +0000 Subject: Some better debugs for our security=server code. I want to track down why we occasionally don't make the connection to the server. (This used to be commit 08e99f4c12ad8747a8fd0e47ed4165cea428128d) --- source3/smbd/negprot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 6410aa2da6..5bc3522506 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -182,12 +182,14 @@ static int reply_nt1(char *outbuf) DEBUG(5,("attempting password server validation\n")); cli = server_cryptkey(); } else { - DEBUG(5,("attempting local password validation\n")); + DEBUG(5,("not attempting password server validation\n")); } if (cli) { DEBUG(3,("using password server validation\n")); doencrypt = ((cli->sec_mode & 2) != 0); + } else { + DEBUG(3,("not using password server validation\n")); } if (doencrypt) { -- cgit From e8e98c9ea0690e3acf1126b50882e59e1056c7b3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 08:19:43 +0000 Subject: converted smbd to use NTSTATUS by default major changes include: - added NSTATUS type - added automatic mapping between dos and nt error codes - changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT() these calls auto-translate to the client error code system - got rid of the cached error code and the writebmpx code We eventually will need to also: - get rid of BOOL, so we don't lose error info - replace all ERROR_DOS() calls with ERROR_NT() calls but that is too much for one night (This used to be commit 83d9896c1ea8be796192b51a4678c2a3b87f7518) --- source3/smbd/negprot.c | 176 +++++++++++++++++++++++++------------------------ 1 file changed, 89 insertions(+), 87 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 5bc3522506..6eda7e39db 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -157,95 +157,97 @@ reply for the nt protocol ****************************************************************************/ static int reply_nt1(char *outbuf) { - /* dual names + lock_and_read + nt SMBs + remote API calls */ - int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_LEVEL_II_OPLOCKS| - (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | - ((lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) ? - CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS : 0) | - (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); - - -/* - other valid capabilities which we may support at some time... - CAP_LARGE_READX|CAP_STATUS32|CAP_LEVEL_II_OPLOCKS; - */ - - int secword=0; - BOOL doencrypt = SMBENCRYPT(); - time_t t = time(NULL); - struct cli_state *cli = NULL; - char cryptkey[8]; - char crypt_len = 0; - char *p, *q; - - if (lp_security() == SEC_SERVER) { - DEBUG(5,("attempting password server validation\n")); - cli = server_cryptkey(); - } else { - DEBUG(5,("not attempting password server validation\n")); - } - - if (cli) { - DEBUG(3,("using password server validation\n")); - doencrypt = ((cli->sec_mode & 2) != 0); - } else { - DEBUG(3,("not using password server validation\n")); - } - - if (doencrypt) { - crypt_len = 8; - if (!cli) { - generate_next_challenge(cryptkey); - } else { - memcpy(cryptkey, cli->cryptkey, 8); - set_challenge(cli->cryptkey); - } - } - - if (lp_readraw() && lp_writeraw()) { - capabilities |= CAP_RAW_MODE; - } - - - /* allow for disabling unicode */ - if (lp_unicode()) { - capabilities |= CAP_UNICODE; - } - + /* dual names + lock_and_read + nt SMBs + remote API calls */ + int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| + CAP_LEVEL_II_OPLOCKS|CAP_STATUS32; + + int secword=0; + BOOL doencrypt = SMBENCRYPT(); + time_t t = time(NULL); + struct cli_state *cli = NULL; + char cryptkey[8]; + char crypt_len = 0; + char *p, *q; + + if (lp_security() == SEC_SERVER) { + DEBUG(5,("attempting password server validation\n")); + cli = server_cryptkey(); + } else { + DEBUG(5,("not attempting password server validation\n")); + } + + if (cli) { + DEBUG(3,("using password server validation\n")); + doencrypt = ((cli->sec_mode & 2) != 0); + } else { + DEBUG(3,("not using password server validation\n")); + } + + if (doencrypt) { + crypt_len = 8; + if (!cli) { + generate_next_challenge(cryptkey); + } else { + memcpy(cryptkey, cli->cryptkey, 8); + set_challenge(cli->cryptkey); + } + } + + if (lp_nt_smb_support()) { + capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; + } + + if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) { + capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS; + } + + if (SMB_OFF_T_BITS == 64) { + capabilities |= CAP_LARGE_FILES; + } + + if (lp_readraw() && lp_writeraw()) { + capabilities |= CAP_RAW_MODE; + } + + /* allow for disabling unicode */ + if (lp_unicode()) { + capabilities |= CAP_UNICODE; + } + #ifdef WITH_MSDFS - if(lp_host_msdfs()) - capabilities |= CAP_DFS; + if(lp_host_msdfs()) + capabilities |= CAP_DFS; #endif - - if (lp_security() >= SEC_USER) secword |= 1; - if (doencrypt) secword |= 2; - - set_message(outbuf,17,0,True); - - CVAL(outbuf,smb_vwv1) = secword; - SSVALS(outbuf,smb_vwv16+1,crypt_len); - - Protocol = PROTOCOL_NT1; - - SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */ - SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */ - SIVAL(outbuf,smb_vwv3+1,0xffff); /* 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,TimeDiff(t)/60); - - p = q = smb_buf(outbuf); - if (doencrypt) memcpy(p, cryptkey, 8); - p += 8; - p += srvstr_push(outbuf, p, global_myworkgroup, -1, - STR_UNICODE|STR_TERMINATE|STR_NOALIGN); - - SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ - set_message_end(outbuf, p); - - return (smb_len(outbuf)+4); + + if (lp_security() >= SEC_USER) secword |= 1; + if (doencrypt) secword |= 2; + + set_message(outbuf,17,0,True); + + CVAL(outbuf,smb_vwv1) = secword; + SSVALS(outbuf,smb_vwv16+1,crypt_len); + + Protocol = PROTOCOL_NT1; + + SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */ + SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */ + SIVAL(outbuf,smb_vwv3+1,0xffff); /* 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,TimeDiff(t)/60); + + p = q = smb_buf(outbuf); + if (doencrypt) memcpy(p, cryptkey, 8); + p += 8; + p += srvstr_push(outbuf, p, global_myworkgroup, -1, + STR_UNICODE|STR_TERMINATE|STR_NOALIGN); + + 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: -- cgit From 39d7983a470cc3470dd7126de35697d965817cb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Sep 2001 03:08:51 +0000 Subject: - enable MSDFS by default, there seems no reason not to have it enabled by default in Samba 3.x - got rid of some unused parameters in Makefile.in - declare DEBUGLEVEL in debug.h rather than in each file (This used to be commit b8651acb9c0d7248a6a2e82c33b1e43633fd83fd) --- source3/smbd/negprot.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 6eda7e39db..9ebb0b7350 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -214,10 +214,8 @@ static int reply_nt1(char *outbuf) capabilities |= CAP_UNICODE; } -#ifdef WITH_MSDFS - if(lp_host_msdfs()) + if (lp_host_msdfs()) capabilities |= CAP_DFS; -#endif if (lp_security() >= SEC_USER) secword |= 1; if (doencrypt) secword |= 2; -- cgit From 4eb7ef6b612a98e1d71a2a0dfde7d695223a4360 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 23 Sep 2001 05:16:03 +0000 Subject: Fix up NT_STATUS return for session setups, Win2k objects to anything other than NT_STATUS_LOGON_FAILURE. This also brings us (almost) back in line with their implementation. Kill off SMBENCRYPT() macro Kill off 'nt smb support' paramater - tridge okayed this one. Andrew Bartlett (This used to be commit 67947bf6e31ee9758f8a2186f83031ba21b716f2) --- source3/smbd/negprot.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 9ebb0b7350..b065cab53e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -66,7 +66,7 @@ static int reply_lanman1(char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; - BOOL doencrypt = SMBENCRYPT(); + BOOL doencrypt = lp_encrypted_passwords(); time_t t = time(NULL); if (lp_security()>=SEC_USER) secword |= 1; @@ -103,7 +103,7 @@ static int reply_lanman2(char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; - BOOL doencrypt = SMBENCRYPT(); + BOOL doencrypt = lp_encrypted_passwords(); time_t t = time(NULL); struct cli_state *cli = NULL; char cryptkey[8]; @@ -162,7 +162,7 @@ static int reply_nt1(char *outbuf) CAP_LEVEL_II_OPLOCKS|CAP_STATUS32; int secword=0; - BOOL doencrypt = SMBENCRYPT(); + BOOL doencrypt = lp_encrypted_passwords(); time_t t = time(NULL); struct cli_state *cli = NULL; char cryptkey[8]; @@ -193,9 +193,7 @@ static int reply_nt1(char *outbuf) } } - if (lp_nt_smb_support()) { - capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; - } + capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) { capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS; -- cgit From 41821943daef5a4fd077e38068539ae4e24121b3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 26 Sep 2001 13:55:59 +0000 Subject: Kill of the reply.c end of the workstaion trust account mess. Fix the NT errror codes, this time in line with WinXP/2k. - Return the normal error codes, expect for bad user/bad password. These map to logon failure, as a quick security hack. We follow suit. Simplfy some of the password extraction code, the auth subsytem has the intelegence to sort this stuff out, no need to do it here. Move to 'global_encrypted_passwords_negotiated' to determine the use of unencrypted hacks, replacing the current mess. Andrew Bartlett (This used to be commit c04f063573c61d8ef3f43815bbb9b6b076dc23eb) --- source3/smbd/negprot.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b065cab53e..82222e6725 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -26,6 +26,7 @@ extern int Protocol; extern int max_recv; extern fstring global_myworkgroup; extern fstring remote_machine; +BOOL global_encrypted_passwords_negotiated; /**************************************************************************** reply for the core protocol @@ -66,16 +67,17 @@ static int reply_lanman1(char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; - BOOL doencrypt = lp_encrypted_passwords(); time_t t = time(NULL); + global_encrypted_passwords_negotiated = lp_encrypted_passwords(); + if (lp_security()>=SEC_USER) secword |= 1; - if (doencrypt) secword |= 2; + if (global_encrypted_passwords_negotiated) secword |= 2; - set_message(outbuf,13,doencrypt?8:0,True); + set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); SSVAL(outbuf,smb_vwv1,secword); /* Create a token value and add it to the outgoing packet. */ - if (doencrypt) + if (global_encrypted_passwords_negotiated) generate_next_challenge(smb_buf(outbuf)); Protocol = PROTOCOL_LANMAN1; @@ -103,25 +105,26 @@ static int reply_lanman2(char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; - BOOL doencrypt = lp_encrypted_passwords(); time_t t = time(NULL); struct cli_state *cli = NULL; char cryptkey[8]; char crypt_len = 0; + global_encrypted_passwords_negotiated = lp_encrypted_passwords(); + if (lp_security() == SEC_SERVER) { cli = server_cryptkey(); } if (cli) { DEBUG(3,("using password server validation\n")); - doencrypt = ((cli->sec_mode & 2) != 0); + global_encrypted_passwords_negotiated = ((cli->sec_mode & 2) != 0); } if (lp_security()>=SEC_USER) secword |= 1; - if (doencrypt) secword |= 2; + if (global_encrypted_passwords_negotiated) secword |= 2; - if (doencrypt) { + if (global_encrypted_passwords_negotiated) { crypt_len = 8; if (!cli) { generate_next_challenge(cryptkey); @@ -134,7 +137,7 @@ static int reply_lanman2(char *outbuf) set_message(outbuf,13,crypt_len,True); SSVAL(outbuf,smb_vwv1,secword); SIVAL(outbuf,smb_vwv6,sys_getpid()); - if (doencrypt) + if (global_encrypted_passwords_negotiated) memcpy(smb_buf(outbuf), cryptkey, 8); Protocol = PROTOCOL_LANMAN2; @@ -162,13 +165,14 @@ static int reply_nt1(char *outbuf) CAP_LEVEL_II_OPLOCKS|CAP_STATUS32; int secword=0; - BOOL doencrypt = lp_encrypted_passwords(); time_t t = time(NULL); struct cli_state *cli = NULL; char cryptkey[8]; char crypt_len = 0; char *p, *q; + global_encrypted_passwords_negotiated = lp_encrypted_passwords(); + if (lp_security() == SEC_SERVER) { DEBUG(5,("attempting password server validation\n")); cli = server_cryptkey(); @@ -178,12 +182,12 @@ static int reply_nt1(char *outbuf) if (cli) { DEBUG(3,("using password server validation\n")); - doencrypt = ((cli->sec_mode & 2) != 0); + global_encrypted_passwords_negotiated = ((cli->sec_mode & 2) != 0); } else { DEBUG(3,("not using password server validation\n")); } - if (doencrypt) { + if (global_encrypted_passwords_negotiated) { crypt_len = 8; if (!cli) { generate_next_challenge(cryptkey); @@ -216,7 +220,7 @@ static int reply_nt1(char *outbuf) capabilities |= CAP_DFS; if (lp_security() >= SEC_USER) secword |= 1; - if (doencrypt) secword |= 2; + if (global_encrypted_passwords_negotiated) secword |= 2; set_message(outbuf,17,0,True); @@ -235,7 +239,7 @@ static int reply_nt1(char *outbuf) SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60); p = q = smb_buf(outbuf); - if (doencrypt) memcpy(p, cryptkey, 8); + if (global_encrypted_passwords_negotiated) memcpy(p, cryptkey, 8); p += 8; p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN); -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/smbd/negprot.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 82222e6725..e3a6701dce 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -21,7 +21,6 @@ #include "includes.h" -extern int DEBUGLEVEL; extern int Protocol; extern int max_recv; extern fstring global_myworkgroup; -- cgit From 81f56139b6964ddbe2c03232475f87f474136490 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 11 Oct 2001 07:42:52 +0000 Subject: initial kerberos/ADS/SPNEGO support in libsmb and smbclient. To activate you need to: - install krb5 libraries - run configure - build smbclient - run kinit to get a TGT - run smbclient with the -k option to choose kerberos auth (This used to be commit d33057585644e1337bac743e25ed7653bfb39eef) --- source3/smbd/negprot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e3a6701dce..d20f713113 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -128,8 +128,8 @@ static int reply_lanman2(char *outbuf) if (!cli) { generate_next_challenge(cryptkey); } else { - memcpy(cryptkey, cli->cryptkey, 8); - set_challenge(cli->cryptkey); + memcpy(cryptkey, cli->secblob.data, 8); + set_challenge(cryptkey); } } @@ -191,8 +191,8 @@ static int reply_nt1(char *outbuf) if (!cli) { generate_next_challenge(cryptkey); } else { - memcpy(cryptkey, cli->cryptkey, 8); - set_challenge(cli->cryptkey); + memcpy(cryptkey, cli->secblob.data, 8); + set_challenge(cryptkey); } } -- cgit From b728042334f67738fd1a6fdd03e619bdb78fe06a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Oct 2001 08:54:19 +0000 Subject: added basic NTLMSSP support in smbd. This is still quite rough, and loses things like username mapping. I wanted to get this in then discuss it a bit to see how we want to split up the existing session setup code (This used to be commit b74fda69bf23207c26d8b2af23910d8f2eb89875) --- source3/smbd/negprot.c | 75 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 14 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index d20f713113..cf14640a72 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -30,7 +30,7 @@ BOOL global_encrypted_passwords_negotiated; /**************************************************************************** reply for the core protocol ****************************************************************************/ -static int reply_corep(char *outbuf) +static int reply_corep(char *inbuf, char *outbuf) { int outsize = set_message(outbuf,1,0,True); @@ -43,7 +43,7 @@ static int reply_corep(char *outbuf) /**************************************************************************** reply for the coreplus protocol ****************************************************************************/ -static int reply_coreplus(char *outbuf) +static int reply_coreplus(char *inbuf, char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int outsize = set_message(outbuf,13,0,True); @@ -62,7 +62,7 @@ static int reply_coreplus(char *outbuf) /**************************************************************************** reply for the lanman 1.0 protocol ****************************************************************************/ -static int reply_lanman1(char *outbuf) +static int reply_lanman1(char *inbuf, char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; @@ -100,7 +100,7 @@ static int reply_lanman1(char *outbuf) /**************************************************************************** reply for the lanman 2.0 protocol ****************************************************************************/ -static int reply_lanman2(char *outbuf) +static int reply_lanman2(char *inbuf, char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; @@ -154,10 +154,44 @@ static int reply_lanman2(char *outbuf) } + +/* + generate the spnego negprot reply blob. Return the number of bytes used +*/ +static int negprot_spnego(char *p, uint8 cryptkey[8]) +{ + DATA_BLOB blob; + extern pstring global_myname; + uint8 guid[16]; + const char *OIDs[] = {OID_NTLMSSP, +#if 0 + /* not till we add kerberos in the server */ + OID_KERBEROS5_OLD, +#endif + NULL}; + char *principle; + int len; + + memset(guid, 0, 16); + safe_strcpy(guid, global_myname, 16); + strlower(guid); + + asprintf(&principle, "%s$@%s", guid, lp_realm()); + blob = spnego_gen_negTokenInit(guid, OIDs, principle); + free(principle); + + memcpy(p, blob.data, blob.length); + len = blob.length; + data_blob_free(&blob); + return len; +} + + + /**************************************************************************** reply for the nt protocol ****************************************************************************/ -static int reply_nt1(char *outbuf) +static int reply_nt1(char *inbuf, char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| @@ -166,10 +200,10 @@ static int reply_nt1(char *outbuf) int secword=0; time_t t = time(NULL); struct cli_state *cli = NULL; - char cryptkey[8]; - char crypt_len = 0; + uint8 cryptkey[8]; char *p, *q; - + BOOL negotiate_spnego = False; + global_encrypted_passwords_negotiated = lp_encrypted_passwords(); if (lp_security() == SEC_SERVER) { @@ -177,6 +211,14 @@ static int reply_nt1(char *outbuf) cli = server_cryptkey(); } else { DEBUG(5,("not attempting password server validation\n")); + /* do spnego in user level security if the client + supports it and we can do encrypted passwords */ + if (global_encrypted_passwords_negotiated && + lp_security() == SEC_USER && + (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { + negotiate_spnego = True; + capabilities |= CAP_EXTENDED_SECURITY; + } } if (cli) { @@ -187,7 +229,6 @@ static int reply_nt1(char *outbuf) } if (global_encrypted_passwords_negotiated) { - crypt_len = 8; if (!cli) { generate_next_challenge(cryptkey); } else { @@ -224,7 +265,6 @@ static int reply_nt1(char *outbuf) set_message(outbuf,17,0,True); CVAL(outbuf,smb_vwv1) = secword; - SSVALS(outbuf,smb_vwv16+1,crypt_len); Protocol = PROTOCOL_NT1; @@ -238,8 +278,15 @@ static int reply_nt1(char *outbuf) SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60); p = q = smb_buf(outbuf); - if (global_encrypted_passwords_negotiated) memcpy(p, cryptkey, 8); - p += 8; + if (!negotiate_spnego) { + if (global_encrypted_passwords_negotiated) memcpy(p, cryptkey, 8); + SSVALS(outbuf,smb_vwv16+1,8); + p += 8; + } else { + int len = negprot_spnego(p, cryptkey); + SSVALS(outbuf,smb_vwv16+1,len); + p += len; + } p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN); @@ -322,7 +369,7 @@ protocol [LANMAN2.1] static struct { char *proto_name; char *short_name; - int (*proto_reply_fn)(char *); + int (*proto_reply_fn)(char *, char *); int protocol_level; } supported_protocols[] = { {"NT LANMAN 1.0", "NT1", reply_nt1, PROTOCOL_NT1}, @@ -441,7 +488,7 @@ int reply_negprot(connection_struct *conn, extern fstring remote_proto; fstrcpy(remote_proto,supported_protocols[protocol].short_name); reload_services(True); - outsize = supported_protocols[protocol].proto_reply_fn(outbuf); + outsize = supported_protocols[protocol].proto_reply_fn(inbuf, outbuf); DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name)); } else { -- cgit From 5ad7448359c7bc1d3b1579f105b7324290bf21ec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Oct 2001 10:26:06 +0000 Subject: the beginnings of kerberos support in smbd. It doesn't work yet, but it should give something for others to hack on and possibly find what I'm doing wrong. (This used to be commit 353c290f059347265b9be2aa1010c2956da06485) --- source3/smbd/negprot.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index cf14640a72..678156b528 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -164,10 +164,7 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) extern pstring global_myname; uint8 guid[16]; const char *OIDs[] = {OID_NTLMSSP, -#if 0 - /* not till we add kerberos in the server */ OID_KERBEROS5_OLD, -#endif NULL}; char *principle; int len; -- cgit From 93645be91f7fd12dfee75b6f09dda6799f0ac902 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 20 Oct 2001 06:50:24 +0000 Subject: better krb5 error handling (thanks andrewb!) (This used to be commit fd3a3daef3b8f7140e7006d30d23d739ac3aad2f) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 678156b528..2eea6fa281 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -163,7 +163,7 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) DATA_BLOB blob; extern pstring global_myname; uint8 guid[16]; - const char *OIDs[] = {OID_NTLMSSP, + const char *OIDs[] = {OID_NTLMSSP, OID_KERBEROS5_OLD, NULL}; char *principle; -- cgit From cbe31055f8deb5844b34e8f1b32e27c830d134ed Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 21 Oct 2001 00:11:22 +0000 Subject: support both old and new kerberos OIDs (This used to be commit eac164c7e650a8f855e7b662b126a5dfc5516927) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 2eea6fa281..6926e50402 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -164,7 +164,7 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) extern pstring global_myname; uint8 guid[16]; const char *OIDs[] = {OID_NTLMSSP, - OID_KERBEROS5_OLD, + OID_KERBEROS5, NULL}; char *principle; int len; -- cgit From 42a4e6890cfb35a0a01f29a48ffa99bcf0d409a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 21 Oct 2001 03:26:24 +0000 Subject: change smbd to use HOST/hostname principle form until I work out how to use the other form in netjoin (This used to be commit 58cfa13d6576bd34ceed7ba6ad52bced96e50544) --- source3/smbd/negprot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 6926e50402..dc19e2bdfb 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -173,7 +173,9 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) safe_strcpy(guid, global_myname, 16); strlower(guid); - asprintf(&principle, "%s$@%s", guid, lp_realm()); + /* win2000 uses host$@REALM, which we will probably use eventually, + but for now this works */ + asprintf(&principle, "HOST/%s@%s", guid, lp_realm()); blob = spnego_gen_negTokenInit(guid, OIDs, principle); free(principle); -- cgit From cfd68eaac48a29dec245dc6de03aae0d58698862 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 21 Oct 2001 20:51:27 +0000 Subject: Ok, I know it's a language thing and it shouldn't matter.... but a kerberos name is a "principal", not a principle. English majors will complain :-). Jeremy. (This used to be commit b668d7d656cdd066820fb8044f24bcd4fda29524) --- source3/smbd/negprot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index dc19e2bdfb..ecc6e7ee51 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -166,7 +166,7 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) const char *OIDs[] = {OID_NTLMSSP, OID_KERBEROS5, NULL}; - char *principle; + char *principal; int len; memset(guid, 0, 16); @@ -175,9 +175,9 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ - asprintf(&principle, "HOST/%s@%s", guid, lp_realm()); - blob = spnego_gen_negTokenInit(guid, OIDs, principle); - free(principle); + asprintf(&principal, "HOST/%s@%s", guid, lp_realm()); + blob = spnego_gen_negTokenInit(guid, OIDs, principal); + free(principal); memcpy(p, blob.data, blob.length); len = blob.length; -- cgit From fba157123ed1d6f59d40aa9161218fbfcf71253f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 22 Oct 2001 05:04:33 +0000 Subject: - fixed link order of krb5 libs - accept a wide range of principal names in session setup (This used to be commit 672df66296f540b606aa43effab5f021b8978e4b) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index ecc6e7ee51..097cb79e67 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -165,6 +165,7 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) uint8 guid[16]; const char *OIDs[] = {OID_NTLMSSP, OID_KERBEROS5, + OID_KERBEROS5_OLD, NULL}; char *principal; int len; -- cgit From 3ea349271355b39f7b877ce67530cc58e7db0ee8 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 23 Oct 2001 19:10:30 +0000 Subject: get rid of compiler warnings (casts and delete unused variables) (This used to be commit 51cb4411df61d1caec9d84809b1a53a6a632f808) --- source3/smbd/negprot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 097cb79e67..16d315f1d8 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -129,7 +129,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) generate_next_challenge(cryptkey); } else { memcpy(cryptkey, cli->secblob.data, 8); - set_challenge(cryptkey); + set_challenge((unsigned char *)cryptkey); } } @@ -171,8 +171,8 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) int len; memset(guid, 0, 16); - safe_strcpy(guid, global_myname, 16); - strlower(guid); + safe_strcpy((char *)guid, global_myname, 16); + strlower((char *)guid); /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ @@ -230,7 +230,7 @@ static int reply_nt1(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) { if (!cli) { - generate_next_challenge(cryptkey); + generate_next_challenge((char *)cryptkey); } else { memcpy(cryptkey, cli->secblob.data, 8); set_challenge(cryptkey); -- cgit From 1f829e19eb3b81ad1c4451fe9a90617e6cee7dd7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 30 Oct 2001 13:54:54 +0000 Subject: Spnego on the 'server' end of security=server just does not work, so set the flags so we just do a 'normal' session setup. Also add some parinoia code to detect when sombody attempts to do a 'normal' session setup when spnego had been negoitiated. Andrew Bartlett (This used to be commit 190898586fa218c952fbd5bea56155d04e6f248b) --- source3/smbd/negprot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 16d315f1d8..e4285cb27c 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -25,7 +25,8 @@ extern int Protocol; extern int max_recv; extern fstring global_myworkgroup; extern fstring remote_machine; -BOOL global_encrypted_passwords_negotiated; +BOOL global_encrypted_passwords_negotiated = False; +BOOL global_spnego_negotiated = False; /**************************************************************************** reply for the core protocol @@ -170,6 +171,8 @@ static int negprot_spnego(char *p, uint8 cryptkey[8]) char *principal; int len; + global_spnego_negotiated = True; + memset(guid, 0, 16); safe_strcpy((char *)guid, global_myname, 16); strlower((char *)guid); -- cgit From d8f0f3a6d4c6fedf5cad364afb33d9cb92bc1336 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 31 Oct 2001 06:24:25 +0000 Subject: SPNEGO works perfectly well with security=domain, so don't exclude it. (This used to be commit 26a9479ad450a5135e54b45d659bf3558892d9e6) --- source3/smbd/negprot.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e4285cb27c..045e16a9bb 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -159,7 +159,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) /* generate the spnego negprot reply blob. Return the number of bytes used */ -static int negprot_spnego(char *p, uint8 cryptkey[8]) +static int negprot_spnego(char *p) { DATA_BLOB blob; extern pstring global_myname; @@ -217,7 +217,8 @@ static int reply_nt1(char *inbuf, char *outbuf) /* do spnego in user level security if the client supports it and we can do encrypted passwords */ if (global_encrypted_passwords_negotiated && - lp_security() == SEC_USER && + (lp_security() == SEC_USER || + lp_security() == SEC_DOMAIN) && (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { negotiate_spnego = True; capabilities |= CAP_EXTENDED_SECURITY; @@ -285,10 +286,13 @@ static int reply_nt1(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) memcpy(p, cryptkey, 8); SSVALS(outbuf,smb_vwv16+1,8); p += 8; + DEBUG(3,("not using SPNEGO\n")); } else { - int len = negprot_spnego(p, cryptkey); + int len = negprot_spnego(p); + SSVALS(outbuf,smb_vwv16+1,len); p += len; + DEBUG(3,("using SPNEGO\n")); } p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN); -- cgit From d0a2faf78d316fec200497f5f7997df4c477a1e1 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 24 Nov 2001 12:12:38 +0000 Subject: This is another rather major change to the samba authenticaion subystem. The particular aim is to modularized the interface - so that we can have arbitrary password back-ends. This code adds one such back-end, a 'winbind' module to authenticate against the winbind_auth_crap functionality. While fully-functional this code is mainly useful as a demonstration, because we don't get back the info3 as we would for direct ntdomain authentication. This commit introduced the new 'auth methods' parameter, in the spirit of the 'auth order' discussed on the lists. It is renamed because not all the methods may be consulted, even if previous methods fail - they may not have a suitable challenge for example. Also, we have a 'local' authentication method, for old-style 'unix if plaintext, sam if encrypted' authentication and a 'guest' module to handle guest logins in a single place. While this current design is not ideal, I feel that it does provide a better infrastructure than the current design, and can be built upon. The following parameters have changed: - use rhosts = This has been replaced by the 'rhosts' authentication method, and can be specified like 'auth methods = guest rhosts' - hosts equiv = This needs both this parameter and an 'auth methods' entry to be effective. (auth methods = guest hostsequiv ....) - plaintext to smbpasswd = This is replaced by specifying 'sam' rather than 'local' in the auth methods. The security = parameter is unchanged, and now provides defaults for the 'auth methods' parameter. The available auth methods are: guest rhosts hostsequiv sam (passdb direct hash access) unix (PAM, crypt() etc) local (the combination of the above, based on encryption) smbserver (old security=server) ntdomain (old security=domain) winbind (use winbind to cache DC connections) Assistance in testing, or the production of new and interesting authentication modules is always appreciated. Andrew Bartlett (This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99) --- source3/smbd/negprot.c | 102 ++++++++++++++++++------------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 045e16a9bb..d080c23332 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -27,6 +27,7 @@ extern fstring global_myworkgroup; extern fstring remote_machine; BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; +auth_authsupplied_info *negprot_global_auth_info = NULL; /**************************************************************************** reply for the core protocol @@ -68,6 +69,7 @@ static int reply_lanman1(char *inbuf, char *outbuf) int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; time_t t = time(NULL); + DATA_BLOB cryptkey; global_encrypted_passwords_negotiated = lp_encrypted_passwords(); @@ -77,8 +79,14 @@ static int reply_lanman1(char *inbuf, char *outbuf) set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); SSVAL(outbuf,smb_vwv1,secword); /* Create a token value and add it to the outgoing packet. */ - if (global_encrypted_passwords_negotiated) - generate_next_challenge(smb_buf(outbuf)); + if (global_encrypted_passwords_negotiated) { + if (!make_auth_info_subsystem(&negprot_global_auth_info)) { + smb_panic("cannot make_negprot_global_auth_info!\n"); + } + cryptkey = auth_get_challange(negprot_global_auth_info); + memcpy(smb_buf(outbuf), cryptkey.data, 8); + data_blob_free(&cryptkey); + } Protocol = PROTOCOL_LANMAN1; @@ -106,40 +114,26 @@ static int reply_lanman2(char *inbuf, char *outbuf) int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; time_t t = time(NULL); - struct cli_state *cli = NULL; - char cryptkey[8]; - char crypt_len = 0; + DATA_BLOB cryptkey; global_encrypted_passwords_negotiated = lp_encrypted_passwords(); - - if (lp_security() == SEC_SERVER) { - cli = server_cryptkey(); - } - - if (cli) { - DEBUG(3,("using password server validation\n")); - global_encrypted_passwords_negotiated = ((cli->sec_mode & 2) != 0); - } - + if (lp_security()>=SEC_USER) secword |= 1; if (global_encrypted_passwords_negotiated) secword |= 2; + set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); + SSVAL(outbuf,smb_vwv1,secword); + SIVAL(outbuf,smb_vwv6,sys_getpid()); + if (global_encrypted_passwords_negotiated) { - crypt_len = 8; - if (!cli) { - generate_next_challenge(cryptkey); - } else { - memcpy(cryptkey, cli->secblob.data, 8); - set_challenge((unsigned char *)cryptkey); + if (!make_auth_info_subsystem(&negprot_global_auth_info)) { + smb_panic("cannot make_negprot_global_auth_info!\n"); } + cryptkey = auth_get_challange(negprot_global_auth_info); + memcpy(smb_buf(outbuf), cryptkey.data, 8); + data_blob_free(&cryptkey); } - set_message(outbuf,13,crypt_len,True); - SSVAL(outbuf,smb_vwv1,secword); - SIVAL(outbuf,smb_vwv6,sys_getpid()); - if (global_encrypted_passwords_negotiated) - memcpy(smb_buf(outbuf), cryptkey, 8); - Protocol = PROTOCOL_LANMAN2; /* Reply, SMBlockread, SMBwritelock supported. */ @@ -202,45 +196,22 @@ static int reply_nt1(char *inbuf, char *outbuf) int secword=0; time_t t = time(NULL); - struct cli_state *cli = NULL; - uint8 cryptkey[8]; + DATA_BLOB cryptkey; char *p, *q; BOOL negotiate_spnego = False; global_encrypted_passwords_negotiated = lp_encrypted_passwords(); - if (lp_security() == SEC_SERVER) { - DEBUG(5,("attempting password server validation\n")); - cli = server_cryptkey(); - } else { - DEBUG(5,("not attempting password server validation\n")); - /* do spnego in user level security if the client - supports it and we can do encrypted passwords */ - if (global_encrypted_passwords_negotiated && - (lp_security() == SEC_USER || - lp_security() == SEC_DOMAIN) && - (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { - negotiate_spnego = True; - capabilities |= CAP_EXTENDED_SECURITY; - } - } + /* do spnego in user level security if the client + supports it and we can do encrypted passwords */ - if (cli) { - DEBUG(3,("using password server validation\n")); - global_encrypted_passwords_negotiated = ((cli->sec_mode & 2) != 0); - } else { - DEBUG(3,("not using password server validation\n")); + if (global_encrypted_passwords_negotiated && + (lp_security() != SEC_SHARE) && + (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { + negotiate_spnego = True; + capabilities |= CAP_EXTENDED_SECURITY; } - if (global_encrypted_passwords_negotiated) { - if (!cli) { - generate_next_challenge((char *)cryptkey); - } else { - memcpy(cryptkey, cli->secblob.data, 8); - set_challenge(cryptkey); - } - } - capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) { @@ -283,7 +254,14 @@ static int reply_nt1(char *inbuf, char *outbuf) p = q = smb_buf(outbuf); if (!negotiate_spnego) { - if (global_encrypted_passwords_negotiated) memcpy(p, cryptkey, 8); + if (global_encrypted_passwords_negotiated) { + if (!make_auth_info_subsystem(&negprot_global_auth_info)) { + smb_panic("cannot make_negprot_global_auth_info!\n"); + } + cryptkey = auth_get_challange(negprot_global_auth_info); + memcpy(p, cryptkey.data, 8); + data_blob_free(&cryptkey); + } SSVALS(outbuf,smb_vwv16+1,8); p += 8; DEBUG(3,("not using SPNEGO\n")); @@ -467,11 +445,6 @@ int reply_negprot(connection_struct *conn, /* possibly reload - change of architecture */ reload_services(True); - /* a special case to stop password server loops */ - if (Index == 1 && strequal(remote_machine,myhostname()) && - (lp_security()==SEC_SERVER || lp_security()==SEC_DOMAIN)) - exit_server("Password server loop!"); - /* Check for protocols, most desirable first */ for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) { @@ -508,3 +481,4 @@ int reply_negprot(connection_struct *conn, END_PROFILE(SMBnegprot); return(outsize); } + -- cgit From 481c644b7b32aa876c69153760fe8a460eea0e69 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 25 Nov 2001 23:05:13 +0000 Subject: added 'security=ADS' (This used to be commit 5a735a88e472a48cd4329832998dc31c1e230ecb) --- source3/smbd/negprot.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index d080c23332..8a01a59bf2 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -171,6 +171,13 @@ static int negprot_spnego(char *p) safe_strcpy((char *)guid, global_myname, 16); strlower((char *)guid); + /* strangely enough, NT does not sent the single OID NTLMSSP when + not a ADS member, it sends no OIDs at all */ + if (lp_security() != SEC_ADS) { + memcpy(p, guid, 16); + return 16; + } + /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ asprintf(&principal, "HOST/%s@%s", guid, lp_realm()); -- cgit From 03439e183686567f632fa9c085691c4bb8d3e365 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Nov 2001 00:43:37 +0000 Subject: fixed spnego, non-kerberos negprot (This used to be commit 2e916222a915c27f919a9841bde5ba0967af2190) --- source3/smbd/negprot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 8a01a59bf2..a2666ae24e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -271,6 +271,8 @@ static int reply_nt1(char *inbuf, char *outbuf) } SSVALS(outbuf,smb_vwv16+1,8); p += 8; + p += srvstr_push(outbuf, p, global_myworkgroup, -1, + STR_UNICODE|STR_TERMINATE|STR_NOALIGN); DEBUG(3,("not using SPNEGO\n")); } else { int len = negprot_spnego(p); @@ -279,8 +281,6 @@ static int reply_nt1(char *inbuf, char *outbuf) p += len; DEBUG(3,("using SPNEGO\n")); } - p += srvstr_push(outbuf, p, global_myworkgroup, -1, - STR_UNICODE|STR_TERMINATE|STR_NOALIGN); SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ set_message_end(outbuf, p); -- cgit From 178f6a64b26d828db6b516392d7072e9c29f6233 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 26 Nov 2001 04:05:28 +0000 Subject: challange -> challenge (This used to be commit d6318add27f6bca5be00cbedf2226b642341297a) --- source3/smbd/negprot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index a2666ae24e..9cbe0fdb0a 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -83,7 +83,7 @@ static int reply_lanman1(char *inbuf, char *outbuf) if (!make_auth_info_subsystem(&negprot_global_auth_info)) { smb_panic("cannot make_negprot_global_auth_info!\n"); } - cryptkey = auth_get_challange(negprot_global_auth_info); + cryptkey = auth_get_challenge(negprot_global_auth_info); memcpy(smb_buf(outbuf), cryptkey.data, 8); data_blob_free(&cryptkey); } @@ -129,7 +129,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) if (!make_auth_info_subsystem(&negprot_global_auth_info)) { smb_panic("cannot make_negprot_global_auth_info!\n"); } - cryptkey = auth_get_challange(negprot_global_auth_info); + cryptkey = auth_get_challenge(negprot_global_auth_info); memcpy(smb_buf(outbuf), cryptkey.data, 8); data_blob_free(&cryptkey); } @@ -265,7 +265,7 @@ static int reply_nt1(char *inbuf, char *outbuf) if (!make_auth_info_subsystem(&negprot_global_auth_info)) { smb_panic("cannot make_negprot_global_auth_info!\n"); } - cryptkey = auth_get_challange(negprot_global_auth_info); + cryptkey = auth_get_challenge(negprot_global_auth_info); memcpy(p, cryptkey.data, 8); data_blob_free(&cryptkey); } -- cgit From 5e25ba6fecfdd477fec046660bf20c90970c4e58 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Nov 2001 23:41:14 +0000 Subject: always send an OID list until we handle raw (unwrapped) NTLMSSP packets in session setup (This used to be commit 3b3f8a935064811906cba221d386697e699af18c) --- source3/smbd/negprot.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 9cbe0fdb0a..9a03e1ba96 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -158,10 +158,11 @@ static int negprot_spnego(char *p) DATA_BLOB blob; extern pstring global_myname; uint8 guid[16]; - const char *OIDs[] = {OID_NTLMSSP, - OID_KERBEROS5, - OID_KERBEROS5_OLD, - NULL}; + const char *OIDs_krb5[] = {OID_NTLMSSP, + OID_KERBEROS5, + OID_KERBEROS5_OLD, + NULL}; + const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; char *principal; int len; @@ -171,17 +172,25 @@ static int negprot_spnego(char *p) safe_strcpy((char *)guid, global_myname, 16); strlower((char *)guid); +#if 0 /* strangely enough, NT does not sent the single OID NTLMSSP when - not a ADS member, it sends no OIDs at all */ + not a ADS member, it sends no OIDs at all + + we can't do this until we teach our sesssion setup parser to know + about raw NTLMSSP (clients send no ASN.1 wrapping if we do this) + */ if (lp_security() != SEC_ADS) { memcpy(p, guid, 16); return 16; } +#endif /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ asprintf(&principal, "HOST/%s@%s", guid, lp_realm()); - blob = spnego_gen_negTokenInit(guid, OIDs, principal); + blob = spnego_gen_negTokenInit(guid, + lp_security()==SEC_ADS ? OIDs_krb5 : OIDs_plain, + principal); free(principal); memcpy(p, blob.data, blob.length); -- cgit From fe64484824d8169bf66822ebf7f6a9180a238e6e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 29 Nov 2001 06:21:56 +0000 Subject: Make better use of the ads_init() function to get the kerberos relam etc. This allows us to use automagically obtained values in future, and the value from krb5.conf now. Also fix mem leaks etc. Andrew Bartlett (This used to be commit 8f9ce717819235d98a1463f20ac659cb4b4ebbd2) --- source3/smbd/negprot.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 9a03e1ba96..78d4da3a75 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -184,15 +184,19 @@ static int negprot_spnego(char *p) return 16; } #endif - - /* win2000 uses host$@REALM, which we will probably use eventually, - but for now this works */ - asprintf(&principal, "HOST/%s@%s", guid, lp_realm()); - blob = spnego_gen_negTokenInit(guid, - lp_security()==SEC_ADS ? OIDs_krb5 : OIDs_plain, - principal); - free(principal); - + { + ADS_STRUCT *ads; + ads = ads_init(NULL, NULL, NULL); + + /* win2000 uses host$@REALM, which we will probably use eventually, + but for now this works */ + asprintf(&principal, "HOST/%s@%s", guid, ads->realm); + blob = spnego_gen_negTokenInit(guid, + lp_security()==SEC_ADS ? OIDs_krb5 : OIDs_plain, + principal); + free(principal); + ads_destroy(&ads); + } memcpy(p, blob.data, blob.length); len = blob.length; data_blob_free(&blob); -- cgit From 9421ad4a7a900b219f87754bc20fa14f2f22fd35 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Dec 2001 09:46:53 +0000 Subject: added a REALLY gross hack into kerberos_kinit_password so that winbindd can do a kinit this will be removed once we have code that gets a tgt and puts it in a place where cyrus-sasl can see it (This used to be commit 7d94f1b7365215a020d3678d03d820a7d086174f) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 78d4da3a75..b99d239540 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -186,7 +186,7 @@ static int negprot_spnego(char *p) #endif { ADS_STRUCT *ads; - ads = ads_init(NULL, NULL, NULL); + ads = ads_init(NULL, NULL, NULL, NULL); /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ -- cgit From 99c431695ce723fcdd77c455e8363a355519929b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Dec 2001 01:01:10 +0000 Subject: added a "use spnego" option you need to set "use spnego = no" for w2k to be able to join a samba domain. Otherwise the w2k box will assume we can do kerberos as a KDC (This used to be commit b5cb57a367a6d9a82e082e2838e83e0997eb4930) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b99d239540..d3afa19d00 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -227,6 +227,7 @@ static int reply_nt1(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated && (lp_security() != SEC_SHARE) && + lp_use_spnego() && (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { negotiate_spnego = True; capabilities |= CAP_EXTENDED_SECURITY; -- cgit From 2e28f8ff0e3bb50ac5b2742c7678c39cb65bcd95 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 5 Jan 2002 04:55:41 +0000 Subject: I've decided to move the auth code around a bit more... The auth_authsupplied_info typedef is now just a plain struct - auth_context, but it has been modified to contain the function pointers to the rest of the auth subsystem's components. (Who needs non-static functions anyway?) In working all this mess out, I fixed a number of memory leaks and moved the entire auth subsystem over to talloc(). Note that the TALLOC_CTX attached to the auth_context can be rather long-lived, it is provided for things that are intended to live as long. (The global_negprot_auth_context lasts the whole life of the smbd). I've also adjusted a few things in auth_domain.c, mainly passing the domain as a paramater to a few functions instead of looking up lp_workgroup(). I'm hopign to make this entire thing a bit more trusted domains (as PDC) freindly in the near future. Other than that, I moved a bit of the code around, hence the rather messy diff. Andrew Bartlett (This used to be commit 12f5515f556cf39fea98134fe3e2ac4540501048) --- source3/smbd/negprot.c | 51 +++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index d3afa19d00..52ba5e9789 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -27,7 +27,28 @@ extern fstring global_myworkgroup; extern fstring remote_machine; BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; -auth_authsupplied_info *negprot_global_auth_info = NULL; +struct auth_context *negprot_global_auth_context = NULL; + +static void get_challange(char buff[8]) +{ + NTSTATUS nt_status; + const uint8 *cryptkey; + + /* We might be called more than once, muliple negprots are premitted */ + if (negprot_global_auth_context) { + DEBUG(3, ("get challange: is this a secondary negprot? negprot_global_auth_context is non-NULL!\n")); + negprot_global_auth_context->free(&negprot_global_auth_context); + } + + DEBUG(10, ("get challange: creating negprot_global_auth_context\n")); + if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&negprot_global_auth_context))) { + DEBUG(0, ("make_auth_context_subsystem returned %s", get_nt_error_msg(nt_status))); + smb_panic("cannot make_negprot_global_auth_context!\n"); + } + DEBUG(10, ("get challange: getting challange\n")); + cryptkey = negprot_global_auth_context->get_ntlm_challenge(negprot_global_auth_context); + memcpy(buff, cryptkey, 8); +} /**************************************************************************** reply for the core protocol @@ -69,7 +90,6 @@ static int reply_lanman1(char *inbuf, char *outbuf) int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; time_t t = time(NULL); - DATA_BLOB cryptkey; global_encrypted_passwords_negotiated = lp_encrypted_passwords(); @@ -80,12 +100,7 @@ static int reply_lanman1(char *inbuf, char *outbuf) SSVAL(outbuf,smb_vwv1,secword); /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - if (!make_auth_info_subsystem(&negprot_global_auth_info)) { - smb_panic("cannot make_negprot_global_auth_info!\n"); - } - cryptkey = auth_get_challenge(negprot_global_auth_info); - memcpy(smb_buf(outbuf), cryptkey.data, 8); - data_blob_free(&cryptkey); + get_challange(smb_buf(outbuf)); } Protocol = PROTOCOL_LANMAN1; @@ -114,7 +129,6 @@ static int reply_lanman2(char *inbuf, char *outbuf) int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; time_t t = time(NULL); - DATA_BLOB cryptkey; global_encrypted_passwords_negotiated = lp_encrypted_passwords(); @@ -125,13 +139,9 @@ static int reply_lanman2(char *inbuf, char *outbuf) SSVAL(outbuf,smb_vwv1,secword); SIVAL(outbuf,smb_vwv6,sys_getpid()); + /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - if (!make_auth_info_subsystem(&negprot_global_auth_info)) { - smb_panic("cannot make_negprot_global_auth_info!\n"); - } - cryptkey = auth_get_challenge(negprot_global_auth_info); - memcpy(smb_buf(outbuf), cryptkey.data, 8); - data_blob_free(&cryptkey); + get_challange(smb_buf(outbuf)); } Protocol = PROTOCOL_LANMAN2; @@ -216,7 +226,6 @@ static int reply_nt1(char *inbuf, char *outbuf) int secword=0; time_t t = time(NULL); - DATA_BLOB cryptkey; char *p, *q; BOOL negotiate_spnego = False; @@ -275,13 +284,9 @@ static int reply_nt1(char *inbuf, char *outbuf) p = q = smb_buf(outbuf); if (!negotiate_spnego) { - if (global_encrypted_passwords_negotiated) { - if (!make_auth_info_subsystem(&negprot_global_auth_info)) { - smb_panic("cannot make_negprot_global_auth_info!\n"); - } - cryptkey = auth_get_challenge(negprot_global_auth_info); - memcpy(p, cryptkey.data, 8); - data_blob_free(&cryptkey); + /* Create a token value and add it to the outgoing packet. */ + if (global_encrypted_passwords_negotiated) { + get_challange(p); } SSVALS(outbuf,smb_vwv16+1,8); p += 8; -- cgit From f5bc0e92a66b418b2bd8f3669a9642b4d46bc8d1 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 9 Jan 2002 07:52:51 +0000 Subject: Better explanation message for dmalloc. Also more insertion of parenthesis to handle struct members called 'free'. You can now get useful dmalloc output, as long as it is compatible with your C library. On RH7.1 it looks like you have to rebuild dmalloc to allow free(0) by default, because something in libcrypt does that. (sigh) (This used to be commit 391cbb690196537c8b6292b42c2e27408cc7e249) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 52ba5e9789..af2f91936e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -37,7 +37,7 @@ static void get_challange(char buff[8]) /* We might be called more than once, muliple negprots are premitted */ if (negprot_global_auth_context) { DEBUG(3, ("get challange: is this a secondary negprot? negprot_global_auth_context is non-NULL!\n")); - negprot_global_auth_context->free(&negprot_global_auth_context); + (negprot_global_auth_context->free)(&negprot_global_auth_context); } DEBUG(10, ("get challange: creating negprot_global_auth_context\n")); -- cgit From a36c10bd1e801228a002b2cdbecfe1fb6c3181a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Jan 2002 02:41:15 +0000 Subject: First part of UNIX extensions (#ifdefed out) more to follow. Jeremy. (This used to be commit 02b18f2cca6d6d046d2d8fd7375b207d44031ddc) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index af2f91936e..81f035f3b6 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -242,7 +242,7 @@ static int reply_nt1(char *inbuf, char *outbuf) capabilities |= CAP_EXTENDED_SECURITY; } - capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; + capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNIX; if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) { capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS; -- cgit From d6823366b881612234ab0655adb11c594f864c4a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Jan 2002 19:10:25 +0000 Subject: Same fix as went into 2.2 (I'm waiting for jerry to finish some code). Jeremy. (This used to be commit 01ff6ce4963e1daff019f2b936cef218e1c93f67) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 81f035f3b6..5899f0af52 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -269,7 +269,7 @@ static int reply_nt1(char *inbuf, char *outbuf) set_message(outbuf,17,0,True); - CVAL(outbuf,smb_vwv1) = secword; + SCVAL(outbuf,smb_vwv1,secword); Protocol = PROTOCOL_NT1; -- cgit From 1f670cfb275ee34e66f504cd35b1c790840999bf Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 20 Jan 2002 22:50:23 +0000 Subject: Spelling fixes. (This used to be commit e67c7c5852624bcdd5c565ea5f00b143aaf7fee4) --- source3/smbd/negprot.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 5899f0af52..04e6eb445b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -29,23 +29,23 @@ BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; struct auth_context *negprot_global_auth_context = NULL; -static void get_challange(char buff[8]) +static void get_challenge(char buff[8]) { NTSTATUS nt_status; const uint8 *cryptkey; /* We might be called more than once, muliple negprots are premitted */ if (negprot_global_auth_context) { - DEBUG(3, ("get challange: is this a secondary negprot? negprot_global_auth_context is non-NULL!\n")); + DEBUG(3, ("get challenge: is this a secondary negprot? negprot_global_auth_context is non-NULL!\n")); (negprot_global_auth_context->free)(&negprot_global_auth_context); } - DEBUG(10, ("get challange: creating negprot_global_auth_context\n")); + DEBUG(10, ("get challenge: creating negprot_global_auth_context\n")); if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&negprot_global_auth_context))) { DEBUG(0, ("make_auth_context_subsystem returned %s", get_nt_error_msg(nt_status))); smb_panic("cannot make_negprot_global_auth_context!\n"); } - DEBUG(10, ("get challange: getting challange\n")); + DEBUG(10, ("get challenge: getting challenge\n")); cryptkey = negprot_global_auth_context->get_ntlm_challenge(negprot_global_auth_context); memcpy(buff, cryptkey, 8); } @@ -100,7 +100,7 @@ static int reply_lanman1(char *inbuf, char *outbuf) SSVAL(outbuf,smb_vwv1,secword); /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - get_challange(smb_buf(outbuf)); + get_challenge(smb_buf(outbuf)); } Protocol = PROTOCOL_LANMAN1; @@ -141,7 +141,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - get_challange(smb_buf(outbuf)); + get_challenge(smb_buf(outbuf)); } Protocol = PROTOCOL_LANMAN2; @@ -286,7 +286,7 @@ static int reply_nt1(char *inbuf, char *outbuf) if (!negotiate_spnego) { /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - get_challange(p); + get_challenge(p); } SSVALS(outbuf,smb_vwv16+1,8); p += 8; -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/smbd/negprot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 04e6eb445b..073edd70db 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. + Unix SMB/CIFS implementation. negprot reply code Copyright (C) Andrew Tridgell 1992-1998 -- cgit From 566fafdb251de4b88d2f6f71bd210d464b1d2a0a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Feb 2002 03:14:58 +0000 Subject: don't do an ADS init when not in ADS mode (This used to be commit 68693ba4e80257bf895b1c8db18c138d5d9919bb) --- source3/smbd/negprot.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 073edd70db..934d594853 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -193,16 +193,15 @@ static int negprot_spnego(char *p) return 16; } #endif - { + if (lp_security() != SEC_ADS) { + blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); + } else { ADS_STRUCT *ads; ads = ads_init(NULL, NULL, NULL, NULL); - /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ asprintf(&principal, "HOST/%s@%s", guid, ads->realm); - blob = spnego_gen_negTokenInit(guid, - lp_security()==SEC_ADS ? OIDs_krb5 : OIDs_plain, - principal); + blob = spnego_gen_negTokenInit(guid, OIDs_krb5, principal); free(principal); ads_destroy(&ads); } -- cgit From 2da4d64cfcf289d18d622c67d3250c51e6b88466 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Feb 2002 21:46:53 +0000 Subject: Added "nt status support" parameter. Fix offline synchronisation. Jeremy. (This used to be commit 9243a9778e52999d5c62cba484640637b24994d8) --- source3/smbd/negprot.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 934d594853..f4ed360845 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -220,7 +220,7 @@ static int reply_nt1(char *inbuf, char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| - CAP_LEVEL_II_OPLOCKS|CAP_STATUS32; + CAP_LEVEL_II_OPLOCKS; int secword=0; time_t t = time(NULL); @@ -242,28 +242,29 @@ static int reply_nt1(char *inbuf, char *outbuf) capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNIX; - if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) { + if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS; - } - if (SMB_OFF_T_BITS == 64) { + if (SMB_OFF_T_BITS == 64) capabilities |= CAP_LARGE_FILES; - } - - if (lp_readraw() && lp_writeraw()) { + + if (lp_readraw() && lp_writeraw()) capabilities |= CAP_RAW_MODE; - } /* allow for disabling unicode */ - if (lp_unicode()) { + if (lp_unicode()) capabilities |= CAP_UNICODE; - } + + if (lp_nt_status_support()) + capabilities |= CAP_STATUS32; if (lp_host_msdfs()) capabilities |= CAP_DFS; - if (lp_security() >= SEC_USER) secword |= 1; - if (global_encrypted_passwords_negotiated) secword |= 2; + if (lp_security() >= SEC_USER) + secword |= 1; + if (global_encrypted_passwords_negotiated) + secword |= 2; set_message(outbuf,17,0,True); -- cgit From ab13654dc9ac23872e4d1384e1c54e336f113009 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Mar 2002 04:36:35 +0000 Subject: Renamed get_nt_error_msg() to nt_errstr(). (This used to be commit 1f007d3ed41c1b71a89fa6be7d173e67e927c302) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index f4ed360845..18682e6c9f 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -41,7 +41,7 @@ static void get_challenge(char buff[8]) DEBUG(10, ("get challenge: creating negprot_global_auth_context\n")); if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&negprot_global_auth_context))) { - DEBUG(0, ("make_auth_context_subsystem returned %s", get_nt_error_msg(nt_status))); + DEBUG(0, ("make_auth_context_subsystem returned %s", nt_errstr(nt_status))); smb_panic("cannot make_negprot_global_auth_context!\n"); } DEBUG(10, ("get challenge: getting challenge\n")); -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/smbd/negprot.c | 380 ++++++++++++++++++++++++------------------------- 1 file changed, 189 insertions(+), 191 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 18682e6c9f..81c2427a00 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -50,8 +50,9 @@ static void get_challenge(char buff[8]) } /**************************************************************************** -reply for the core protocol + Reply for the core protocol. ****************************************************************************/ + static int reply_corep(char *inbuf, char *outbuf) { int outsize = set_message(outbuf,1,0,True); @@ -61,107 +62,110 @@ static int reply_corep(char *inbuf, char *outbuf) return outsize; } - /**************************************************************************** -reply for the coreplus protocol + Reply for the coreplus protocol. ****************************************************************************/ + static int reply_coreplus(char *inbuf, char *outbuf) { - int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); - int outsize = set_message(outbuf,13,0,True); - SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support - readbraw and writebraw (possibly) */ - /* Reply, SMBlockread, SMBwritelock supported. */ - SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); - SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */ + int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); + int outsize = set_message(outbuf,13,0,True); + SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support + readbraw and writebraw (possibly) */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); + SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */ - Protocol = PROTOCOL_COREPLUS; + Protocol = PROTOCOL_COREPLUS; - return outsize; + return outsize; } - /**************************************************************************** -reply for the lanman 1.0 protocol + Reply for the lanman 1.0 protocol. ****************************************************************************/ + static int reply_lanman1(char *inbuf, char *outbuf) { - int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); - int secword=0; - time_t t = time(NULL); + int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); + int secword=0; + time_t t = time(NULL); - global_encrypted_passwords_negotiated = lp_encrypted_passwords(); + global_encrypted_passwords_negotiated = lp_encrypted_passwords(); - if (lp_security()>=SEC_USER) secword |= 1; - if (global_encrypted_passwords_negotiated) secword |= 2; + if (lp_security()>=SEC_USER) + secword |= NEGOTIATE_SECURITY_USER_LEVEL; + if (global_encrypted_passwords_negotiated) + secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); - SSVAL(outbuf,smb_vwv1,secword); - /* Create a token value and add it to the outgoing packet. */ - if (global_encrypted_passwords_negotiated) { - get_challenge(smb_buf(outbuf)); - } + set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); + SSVAL(outbuf,smb_vwv1,secword); + /* Create a token value and add it to the outgoing packet. */ + if (global_encrypted_passwords_negotiated) { + get_challenge(smb_buf(outbuf)); + } - Protocol = PROTOCOL_LANMAN1; + Protocol = PROTOCOL_LANMAN1; - /* Reply, SMBlockread, SMBwritelock supported. */ - SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); - SSVAL(outbuf,smb_vwv2,max_recv); - SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ - SSVAL(outbuf,smb_vwv4,1); - SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support - readbraw writebraw (possibly) */ - SIVAL(outbuf,smb_vwv6,sys_getpid()); - SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); + SSVAL(outbuf,smb_vwv2,max_recv); + SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ + SSVAL(outbuf,smb_vwv4,1); + SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support + readbraw writebraw (possibly) */ + SIVAL(outbuf,smb_vwv6,sys_getpid()); + SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); - put_dos_date(outbuf,smb_vwv8,t); + put_dos_date(outbuf,smb_vwv8,t); - return (smb_len(outbuf)+4); + return (smb_len(outbuf)+4); } - /**************************************************************************** -reply for the lanman 2.0 protocol + Reply for the lanman 2.0 protocol. ****************************************************************************/ + static int reply_lanman2(char *inbuf, char *outbuf) { - int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); - int secword=0; - time_t t = time(NULL); + int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); + int secword=0; + time_t t = time(NULL); - global_encrypted_passwords_negotiated = lp_encrypted_passwords(); + global_encrypted_passwords_negotiated = lp_encrypted_passwords(); - if (lp_security()>=SEC_USER) secword |= 1; - if (global_encrypted_passwords_negotiated) secword |= 2; - - set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); - SSVAL(outbuf,smb_vwv1,secword); - SIVAL(outbuf,smb_vwv6,sys_getpid()); - - /* Create a token value and add it to the outgoing packet. */ - if (global_encrypted_passwords_negotiated) { - get_challenge(smb_buf(outbuf)); - } - - Protocol = PROTOCOL_LANMAN2; - - /* Reply, SMBlockread, SMBwritelock supported. */ - SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); - SSVAL(outbuf,smb_vwv2,max_recv); - SSVAL(outbuf,smb_vwv3,lp_maxmux()); - SSVAL(outbuf,smb_vwv4,1); - SSVAL(outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ - SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); - put_dos_date(outbuf,smb_vwv8,t); - - return (smb_len(outbuf)+4); -} + if (lp_security()>=SEC_USER) + secword |= NEGOTIATE_SECURITY_USER_LEVEL; + if (global_encrypted_passwords_negotiated) + secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; + set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); + SSVAL(outbuf,smb_vwv1,secword); + SIVAL(outbuf,smb_vwv6,sys_getpid()); + /* Create a token value and add it to the outgoing packet. */ + if (global_encrypted_passwords_negotiated) { + get_challenge(smb_buf(outbuf)); + } + + Protocol = PROTOCOL_LANMAN2; + + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); + SSVAL(outbuf,smb_vwv2,max_recv); + SSVAL(outbuf,smb_vwv3,lp_maxmux()); + SSVAL(outbuf,smb_vwv4,1); + SSVAL(outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ + SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); + put_dos_date(outbuf,smb_vwv8,t); + + return (smb_len(outbuf)+4); +} + +/**************************************************************************** + Generate the spnego negprot reply blob. Return the number of bytes used. +****************************************************************************/ -/* - generate the spnego negprot reply blob. Return the number of bytes used -*/ static int negprot_spnego(char *p) { DATA_BLOB blob; @@ -197,7 +201,7 @@ static int negprot_spnego(char *p) blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); } else { ADS_STRUCT *ads; - ads = ads_init(NULL, NULL, NULL, NULL); + ads = ads_init_simple(); /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ asprintf(&principal, "HOST/%s@%s", guid, ads->realm); @@ -211,11 +215,10 @@ static int negprot_spnego(char *p) return len; } - - /**************************************************************************** -reply for the nt protocol + Reply for the nt protocol. ****************************************************************************/ + static int reply_nt1(char *inbuf, char *outbuf) { /* dual names + lock_and_read + nt SMBs + remote API calls */ @@ -262,9 +265,9 @@ static int reply_nt1(char *inbuf, char *outbuf) capabilities |= CAP_DFS; if (lp_security() >= SEC_USER) - secword |= 1; + secword |= NEGOTIATE_SECURITY_USER_LEVEL; if (global_encrypted_passwords_negotiated) - secword |= 2; + secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; set_message(outbuf,17,0,True); @@ -377,133 +380,128 @@ protocol [LANMAN2.1] /* List of supported protocols, most desired first */ static struct { - char *proto_name; - char *short_name; - int (*proto_reply_fn)(char *, char *); - int protocol_level; + char *proto_name; + 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}, - {"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}, + {"NT LANMAN 1.0", "NT1", reply_nt1, PROTOCOL_NT1}, + {"NT LM 0.12", "NT1", reply_nt1, PROTOCOL_NT1}, + {"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 + 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; - START_PROFILE(SMBnegprot); - - 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 ); - 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; - } + 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; + START_PROFILE(SMBnegprot); + + 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 ); + 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; + } - p += strlen(p) + 2; - } + p += strlen(p) + 2; + } - switch ( arch ) { - 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; - } + switch ( arch ) { + 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); + /* possibly reload - change of architecture */ + reload_services(True); - /* 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; - } + /* 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) { - extern fstring remote_proto; - 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); + SSVAL(outbuf,smb_vwv0,choice); + if(choice != -1) { + extern fstring remote_proto; + 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 ) ); + DEBUG( 5, ( "negprot index=%d\n", choice ) ); - END_PROFILE(SMBnegprot); - return(outsize); + END_PROFILE(SMBnegprot); + return(outsize); } - -- cgit From 127e77e6e334fdc33086bffcbe00d340c0ba0097 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 15:27:10 +0000 Subject: Sync 3.0 branch with head (This used to be commit 42615b945e2e48e53a21ea47f2e45407913a6a1e) --- source3/smbd/negprot.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 81c2427a00..2be04fd686 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -23,7 +23,6 @@ extern int Protocol; extern int max_recv; extern fstring global_myworkgroup; -extern fstring remote_machine; BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; struct auth_context *negprot_global_auth_context = NULL; @@ -200,14 +199,11 @@ static int negprot_spnego(char *p) if (lp_security() != SEC_ADS) { blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); } else { - ADS_STRUCT *ads; - ads = ads_init_simple(); /* win2000 uses host$@REALM, which we will probably use eventually, but for now this works */ - asprintf(&principal, "HOST/%s@%s", guid, ads->realm); + asprintf(&principal, "HOST/%s@%s", guid, lp_realm()); blob = spnego_gen_negTokenInit(guid, OIDs_krb5, principal); free(principal); - ads_destroy(&ads); } memcpy(p, blob.data, blob.length); len = blob.length; @@ -288,10 +284,12 @@ static int reply_nt1(char *inbuf, char *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); + SSVALS(outbuf,smb_vwv16+1,8); + p += 8; } - SSVALS(outbuf,smb_vwv16+1,8); - p += 8; p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN); DEBUG(3,("not using SPNEGO\n")); @@ -412,8 +410,17 @@ int reply_negprot(connection_struct *conn, 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++; -- cgit From a834a73e341059be154426390304a42e4a011f72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 15:19:00 +0000 Subject: sync'ing up for 3.0alpha20 release (This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139) --- source3/smbd/negprot.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 2be04fd686..16427b00d7 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -170,9 +170,9 @@ static int negprot_spnego(char *p) DATA_BLOB blob; extern pstring global_myname; uint8 guid[16]; - const char *OIDs_krb5[] = {OID_NTLMSSP, - OID_KERBEROS5, + const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, + OID_NTLMSSP, NULL}; const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; char *principal; @@ -199,9 +199,7 @@ static int negprot_spnego(char *p) if (lp_security() != SEC_ADS) { blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); } else { - /* win2000 uses host$@REALM, which we will probably use eventually, - but for now this works */ - asprintf(&principal, "HOST/%s@%s", guid, lp_realm()); + asprintf(&principal, "%s$@%s", guid, lp_realm()); blob = spnego_gen_negTokenInit(guid, OIDs_krb5, principal); free(principal); } @@ -239,7 +237,11 @@ static int reply_nt1(char *inbuf, char *outbuf) capabilities |= CAP_EXTENDED_SECURITY; } - capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNIX; + capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; + + if (lp_unix_extensions()) { + capabilities |= CAP_UNIX; + } if (lp_large_readwrite() && (SMB_OFF_T_BITS == 64)) capabilities |= CAP_LARGE_READX|CAP_LARGE_WRITEX|CAP_W2K_SMBS; -- cgit From 3d8274df34a9f7d2a1f221534f7c32bfb4450f87 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 15 Oct 2002 21:35:46 +0000 Subject: Change default of max_xmit to match W2K. Ensure NT negprot uses it. Jeremy. (This used to be commit 0bf7187e3ba57ee2422a0f6f736266a55502123c) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 16427b00d7..06a55cb33e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -275,7 +275,7 @@ static int reply_nt1(char *inbuf, char *outbuf) SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */ SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */ - SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */ + 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 */ -- cgit From 2f194322d419350f35a48dff750066894d68eccf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Nov 2002 23:20:50 +0000 Subject: Removed global_myworkgroup, global_myname, global_myscope. Added liberal dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit f755711df8f74f9b8e8c1a2b0d07d02a931eeb89) --- source3/smbd/negprot.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 06a55cb33e..b91c0c0866 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -22,7 +22,6 @@ extern int Protocol; extern int max_recv; -extern fstring global_myworkgroup; BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; struct auth_context *negprot_global_auth_context = NULL; @@ -168,7 +167,6 @@ static int reply_lanman2(char *inbuf, char *outbuf) static int negprot_spnego(char *p) { DATA_BLOB blob; - extern pstring global_myname; uint8 guid[16]; const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, @@ -181,7 +179,7 @@ static int negprot_spnego(char *p) global_spnego_negotiated = True; memset(guid, 0, 16); - safe_strcpy((char *)guid, global_myname, 16); + safe_strcpy((char *)guid, global_myname(), 16); strlower((char *)guid); #if 0 @@ -292,7 +290,7 @@ static int reply_nt1(char *inbuf, char *outbuf) SSVALS(outbuf,smb_vwv16+1,8); p += 8; } - p += srvstr_push(outbuf, p, global_myworkgroup, -1, + p += srvstr_push(outbuf, p, lp_workgroup(), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN); DEBUG(3,("not using SPNEGO\n")); } else { -- cgit From 634c54310c92c48dd4eceec602e230a021bdcfc5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Jan 2003 08:28:12 +0000 Subject: Merge from HEAD - make Samba compile with -Wwrite-strings without additional warnings. (Adds a lot of const). Andrew Bartlett (This used to be commit 3a7458f9472432ef12c43008414925fd1ce8ea0c) --- source3/smbd/negprot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b91c0c0866..c8f023514e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -377,9 +377,9 @@ protocol [LANMAN2.1] #define ARCH_ALL 0x3F /* List of supported protocols, most desired first */ -static struct { - char *proto_name; - char *short_name; +static const struct { + const char *proto_name; + const char *short_name; int (*proto_reply_fn)(char *, char *); int protocol_level; } supported_protocols[] = { -- cgit From d5ee9b2f480ddbda0b8f69409698d27c99384f9c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 18 Mar 2003 11:22:52 +0000 Subject: Jeremy merged across my string parinoia fixes, but forgot to enable them! :-) This patch catches up on the rest of the work - as much string checking as is possible is done at compile time, and the rest at runtime. Lots of code converted to pstrcpy() etc, and other code reworked to correctly call sizeof(). Andrew Bartlett (This used to be commit c5b604e2ee67d74241ae2fa07ae904647d35a2be) --- source3/smbd/negprot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index c8f023514e..db0694a840 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -167,7 +167,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) static int negprot_spnego(char *p) { DATA_BLOB blob; - uint8 guid[16]; + uint8 guid[17]; const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, OID_NTLMSSP, @@ -178,8 +178,8 @@ static int negprot_spnego(char *p) global_spnego_negotiated = True; - memset(guid, 0, 16); - safe_strcpy((char *)guid, global_myname(), 16); + ZERO_STRUCT(guid); + safe_strcpy((char *)guid, global_myname(), sizeof(guid)-1); strlower((char *)guid); #if 0 -- cgit From c9d0ee977c929f6a46905ff74cc221aaa028af74 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 May 2003 05:20:54 +0000 Subject: merge LANMAN1/LANMAN2.1 fixes from head (This used to be commit 73c686ab771b6c3e9a9335032f851083d44701c7) --- source3/smbd/negprot.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index db0694a840..bd1b9b0d57 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -101,6 +101,7 @@ static int reply_lanman1(char *inbuf, char *outbuf) /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { get_challenge(smb_buf(outbuf)); + SSVAL(outbuf,smb_vwv11, 8); } Protocol = PROTOCOL_LANMAN1; @@ -144,6 +145,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { get_challenge(smb_buf(outbuf)); + SSVAL(outbuf,smb_vwv11, 8); } Protocol = PROTOCOL_LANMAN2; -- cgit From 1fdbe30685501362fc90bdd968453f726e18c6eb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 31 May 2003 01:48:59 +0000 Subject: Fixes to stop valgrind complaining about uninitialised memory when it's copying clobbered buffer areas and doing hashes on them and sending them onto the wire. Jeremy. (This used to be commit 7dfcf714ae2e81fece489640e2341f132c9f567d) --- source3/smbd/negprot.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index bd1b9b0d57..648801e955 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -182,6 +182,15 @@ static int negprot_spnego(char *p) ZERO_STRUCT(guid); safe_strcpy((char *)guid, global_myname(), sizeof(guid)-1); + +#ifdef DEVELOPER + { + size_t sl = strlen(guid); + if (sizeof(guid)-sl) + memset(&guid[sl], '\0', sizeof(guid)-sl); + } +#endif + strlower((char *)guid); #if 0 -- cgit From 0899066fd6afc0fa8617d9e8c6dc5f6a7ece1dc5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 31 May 2003 02:03:58 +0000 Subject: Got us happy running under valgrind again :-). Jeremy. (This used to be commit b6ab9d73610861d225d72845d4df7cf970155e39) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 648801e955..2a2ca25532 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -184,6 +184,7 @@ static int negprot_spnego(char *p) safe_strcpy((char *)guid, global_myname(), sizeof(guid)-1); #ifdef DEVELOPER + /* valgrind fixer... */ { size_t sl = strlen(guid); if (sizeof(guid)-sl) -- cgit From ce72beb2b558d86fb49063c6b1fa00e07952ce56 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 3 Jul 2003 19:11:31 +0000 Subject: Removed strupper/strlower macros that automatically map to strupper_m/strlower_m. I really want people to think about when they're using multibyte strings. Jeremy. (This used to be commit ff222716a08af65d26ad842ce4c2841cc6540959) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 2a2ca25532..f452dd845b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -192,7 +192,7 @@ static int negprot_spnego(char *p) } #endif - strlower((char *)guid); + strlower_m((char *)guid); #if 0 /* strangely enough, NT does not sent the single OID NTLMSSP when -- cgit From f1b6cd794dd5de853c4b068361a326160a3d0384 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Jul 2003 00:48:21 +0000 Subject: Putting the framework for server signing in place. Ensure we don't use sendfile when signing (I need to add this for readbraw/writebraw too...). Jeremy. (This used to be commit f2e84f1ba67b13ff29e24a38099b559d9033a680) --- source3/smbd/negprot.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index f452dd845b..0b58eb3eb2 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -277,6 +277,14 @@ static int reply_nt1(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; + if (lp_server_signing()) { + 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; + } + set_message(outbuf,17,0,True); SCVAL(outbuf,smb_vwv1,secword); @@ -521,6 +529,10 @@ int reply_negprot(connection_struct *conn, 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); } -- cgit From 814e987c6241601fb03335b2ba9a633d65cc5e23 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 18 Jul 2003 00:53:34 +0000 Subject: Signing so far... the client code fails on a SMBtrans2 secondary transaction I think (my changes haven't affected this I believe). Initial support on the server side for smbclient. Still doesn't work for w2k clients I think... Work in progress..... (don't change). Jeremy. (This used to be commit e5714edc233424c2f74edb6d658f32f8e0ec9275) --- source3/smbd/negprot.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 0b58eb3eb2..28e3cf97d1 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -278,11 +278,19 @@ static int reply_nt1(char *inbuf, char *outbuf) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; if (lp_server_signing()) { - 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; + 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); -- cgit From 6b9dbbcd249360fb9acd61d6900baccf621c9cce Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 13 Mar 2004 02:16:21 +0000 Subject: Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com (MORIYAMA Masayuki). Don't use nstrings to hold workgroup and netbios names. The problem with them is that MB netbios and workgroup names in unix charset (particularly utf8) may be up to 3x bigger than the name when represented in dos charset (ie. cp932). So go back to using fstrings for these but translate into nstrings (ie. 16 byte length values) for transport on the wire. Jeremy. (This used to be commit b4ea493599ab414f7828b83f40a5a8b43479ff64) --- source3/smbd/negprot.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 28e3cf97d1..96961368fb 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -169,6 +169,8 @@ static int reply_lanman2(char *inbuf, char *outbuf) static int negprot_spnego(char *p) { DATA_BLOB blob; + nstring dos_name; + fstring unix_name; uint8 guid[17]; const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, @@ -181,7 +183,11 @@ static int negprot_spnego(char *p) global_spnego_negotiated = True; ZERO_STRUCT(guid); - safe_strcpy((char *)guid, global_myname(), sizeof(guid)-1); + + safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1); + strlower_m(unix_name); + push_ascii_nstring(dos_name, unix_name); + safe_strcpy((char *)guid, dos_name, sizeof(guid)-1); #ifdef DEVELOPER /* valgrind fixer... */ @@ -192,8 +198,6 @@ static int negprot_spnego(char *p) } #endif - strlower_m((char *)guid); - #if 0 /* strangely enough, NT does not sent the single OID NTLMSSP when not a ADS member, it sends no OIDs at all -- cgit From deee8fae47be8722f737d4a2583e93f85658c126 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 27 Mar 2004 05:38:20 +0000 Subject: As I raised (without objection) on the mailing list a while back, this patch removes the 'unicode' smb.conf option. Clients are as always free not to negotiate unicode, but Samba will always accept unicode in smbd. Setting 'unicode = no' caused me more client BSODs than any other option I have seen, and I really want to protect some of our more silly users, who will, no matter what, select and change every option... Andrew Bartlett (This used to be commit 3f9177bd5df68809294335a36919994893ff8ead) --- source3/smbd/negprot.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 96961368fb..1843c174bb 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -251,7 +251,7 @@ static int reply_nt1(char *inbuf, char *outbuf) capabilities |= CAP_EXTENDED_SECURITY; } - capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS; + capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNICODE; if (lp_unix_extensions()) { capabilities |= CAP_UNIX; @@ -266,10 +266,6 @@ static int reply_nt1(char *inbuf, char *outbuf) if (lp_readraw() && lp_writeraw()) capabilities |= CAP_RAW_MODE; - /* allow for disabling unicode */ - if (lp_unicode()) - capabilities |= CAP_UNICODE; - if (lp_nt_status_support()) capabilities |= CAP_STATUS32; -- cgit From 2acd0848663f28afedff9b11b738e048f5ead2cc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 15 Jun 2004 18:36:45 +0000 Subject: r1154: Change default setting for case sensitivity to "auto". If set to auto then is the client supports it (current clients supported are Samba and CIFSVFS - detected by the negprot strings "Samba", "POSIX 2" and a bare "NT LM 0.12" string) then the setting of the per packet flag smb_flag FLAG_CASELESS_PATHNAMES is taken into account per packet. This allows the linux CIFS client to use Samba in a case sensitive manner. Additional command in smbclient "case_sensitive", toggles the flag in subsequent packets. Docs to follow. Jeremy. (This used to be commit cf84c0fe1a061acc0313f7db124b8f947cdf623d) --- source3/smbd/negprot.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 1843c174bb..5ff53f6300 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -401,8 +401,9 @@ protocol [LANMAN2.1] #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 0x3F +#define ARCH_ALL 0x7F /* List of supported protocols, most desired first */ static const struct { @@ -413,6 +414,7 @@ static const struct { } 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}, {"LM1.2X002", "LANMAN2", reply_lanman2, PROTOCOL_LANMAN2}, {"Samba", "LANMAN2", reply_lanman2, PROTOCOL_LANMAN2}, {"DOS LM1.2X002", "LANMAN2", reply_lanman2, PROTOCOL_LANMAN2}, @@ -460,7 +462,7 @@ int reply_negprot(connection_struct *conn, 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 &= ( 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")) @@ -472,12 +474,23 @@ int reply_negprot(connection_struct *conn, 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; -- cgit From 6219c997cbe49952213460f1e100004d32469132 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Aug 2004 20:03:41 +0000 Subject: r1936: Fix bug noticed by Steve - ensure extended security bit is on only if we negotiated extended security. Do not merge for 3.0.6. Works with W2K but needs further testing. Jeremy. (This used to be commit 284689aa18d2711a9041598cdf490359466f7f77) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 5ff53f6300..5ee8abbe6b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -249,6 +249,7 @@ static int reply_nt1(char *inbuf, char *outbuf) (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { negotiate_spnego = True; capabilities |= CAP_EXTENDED_SECURITY; + add_to_common_flags2(FLAGS2_EXTENDED_SECURITY); } capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNICODE; -- cgit From b4470656298303f477798929d44556f3926bb2aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Aug 2004 22:47:05 +0000 Subject: r1939: Ensure with my new change we set extended security in flags2 in the negprot reply. Jeremy. (This used to be commit 8b80b46b8b76ead72c17dc65f2de4c0cc0b263c7) --- source3/smbd/negprot.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 5ee8abbe6b..447073acd8 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -250,6 +250,9 @@ static int reply_nt1(char *inbuf, char *outbuf) negotiate_spnego = True; capabilities |= CAP_EXTENDED_SECURITY; add_to_common_flags2(FLAGS2_EXTENDED_SECURITY); + /* Ensure FLAGS2_EXTENDED_SECURITY gets set in this reply (already + partially constructed. */ + SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2) | FLAGS2_EXTENDED_SECURITY); } capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNICODE; -- cgit From 482f14871d568a24006fec5af68d722b5fa70a0d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 25 Nov 2004 00:07:01 +0000 Subject: r3946: Fix for bugid #2085 reported by Jason Mader . Use consistent enum type for Protocol extern. Jeremy. (This used to be commit 65dfae7ea45d4c9452b2a08efa09b01d870142f3) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 447073acd8..7da9d1281e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -20,7 +20,7 @@ #include "includes.h" -extern int Protocol; +extern enum protocol_types Protocol; extern int max_recv; BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; -- cgit From 2fffc40b1ddcd8a89160db877bd868f6e7fa8b72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 30 Nov 2004 15:52:46 +0000 Subject: r4018: * move claim_connection from the netbios session request reply code to the negprot reply code to cope with client connections on port 445. Fixes the spurious "register_message_flags: tdb fetch failed" errors. * don't run the backgroup LPQ daemon when we are running in interactive mode. (This used to be commit 88747a7da351261185222e78e9c8d470ff53a246) --- source3/smbd/negprot.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 7da9d1281e..9aaa818c62 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -523,6 +523,12 @@ int reply_negprot(connection_struct *conn, /* 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++) { -- cgit From 404fa5636ddae8caa0a46bb68b796d23ec3f5a0e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 26 Mar 2005 00:44:46 +0000 Subject: r6069: Fix for bug #2541. Ensure we recognise LANMAN2.1 as OS/2 and select LANMAN2 protocol, ensure the EA size is always correctly set on a query for a file with no EA's. Jeremy. (This used to be commit d6ad1f8df05e16152d9c95df56e612fde288d3b4) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 9aaa818c62..bdb15cb3f7 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -419,6 +419,7 @@ static const struct { {"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}, -- cgit From 978ca8486031e43754a3c23757f361bf3a85f335 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 6 Apr 2005 16:28:04 +0000 Subject: r6225: get rid of warnings from my compiler about nested externs (This used to be commit efea76ac71412f8622cd233912309e91b9ea52da) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index bdb15cb3f7..054afac683 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -20,6 +20,7 @@ #include "includes.h" +extern fstring remote_proto; extern enum protocol_types Protocol; extern int max_recv; BOOL global_encrypted_passwords_negotiated = False; @@ -549,7 +550,6 @@ int reply_negprot(connection_struct *conn, SSVAL(outbuf,smb_vwv0,choice); if(choice != -1) { - extern fstring remote_proto; fstrcpy(remote_proto,supported_protocols[protocol].short_name); reload_services(True); outsize = supported_protocols[protocol].proto_reply_fn(inbuf, outbuf); -- cgit From dacdfbc98ccb533626058745f4aacef0b0b36286 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 8 Jun 2005 14:57:37 +0000 Subject: r7398: commiting abartlet's patch for kerberos authentication when using a keytab and security != ads (This used to be commit 3faaa5c3eb3b2057984586e069a47cb210c99140) --- source3/smbd/negprot.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 054afac683..d4f0167a5f 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -178,7 +178,6 @@ static int negprot_spnego(char *p) OID_NTLMSSP, NULL}; const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; - char *principal; int len; global_spnego_negotiated = True; @@ -211,12 +210,16 @@ static int negprot_spnego(char *p) return 16; } #endif - if (lp_security() != SEC_ADS) { + if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); } else { - asprintf(&principal, "%s$@%s", guid, lp_realm()); - blob = spnego_gen_negTokenInit(guid, OIDs_krb5, principal); - free(principal); + fstring myname; + char *host_princ_s = NULL; + name_to_fqdn(myname, global_myname()); + strlower_m(myname); + asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm()); + blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s); + SAFE_FREE(host_princ_s); } memcpy(p, blob.data, blob.length); len = blob.length; -- cgit From 4a190ec27bf69f849f22daf3060841f9a1c92b4f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Oct 2005 23:08:49 +0000 Subject: r10947: Fix bugs #3133 and #1828 - SPNEGO not working with PocketPC 2003. Our sessionsetup code now handles raw NTLMSSP connects, so we can go back to doing what W2K3 does here which is to send no OID's in the negprot reply when not in a security=ads mode. Jeremy. (This used to be commit 38a70185b7ca20677026103d40f61608e7ad0c90) --- source3/smbd/negprot.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index d4f0167a5f..1f4cb30003 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -177,7 +177,6 @@ static int negprot_spnego(char *p) OID_KERBEROS5_OLD, OID_NTLMSSP, NULL}; - const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; int len; global_spnego_negotiated = True; @@ -198,20 +197,22 @@ static int negprot_spnego(char *p) } #endif -#if 0 /* strangely enough, NT does not sent the single OID NTLMSSP when not a ADS member, it sends no OIDs at all - we can't do this until we teach our sesssion setup parser to know - about raw NTLMSSP (clients send no ASN.1 wrapping if we do this) + OLD COMMENT : "we can't do this until we teach our sesssion setup parser to know + about raw NTLMSSP (clients send no ASN.1 wrapping if we do this)" + + Our sessionsetup code now handles raw NTLMSSP connects, so we can go + back to doing what W2K3 does here. This is needed to make PocketPC 2003 + CIFS connections work with SPNEGO. See bugzilla bugs #1828 and #3133 + for details. JRA. + */ - if (lp_security() != SEC_ADS) { + + if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { memcpy(p, guid, 16); return 16; - } -#endif - if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { - blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); } else { fstring myname; char *host_princ_s = NULL; -- cgit From 97a321e557e494e98fa745ec530202120a69403e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Oct 2005 19:45:24 +0000 Subject: r10974: Get closer to trying to fix #1825 (PcoketPC spnego bug). Ensure we set keylen to zero if no spnego. Jeremy. (This used to be commit 57ed94e6e4a095422496d92a0095dc48cfecdd68) --- source3/smbd/negprot.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 1f4cb30003..91942bf028 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -167,7 +167,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) Generate the spnego negprot reply blob. Return the number of bytes used. ****************************************************************************/ -static int negprot_spnego(char *p) +static int negprot_spnego(char *p, uint8 *pkeylen) { DATA_BLOB blob; nstring dos_name; @@ -212,6 +212,7 @@ static int negprot_spnego(char *p) if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { memcpy(p, guid, 16); + *pkeylen = 0; return 16; } else { fstring myname; @@ -224,6 +225,11 @@ static int negprot_spnego(char *p) } memcpy(p, blob.data, blob.length); len = blob.length; + if (len > 256) { + DEBUG(0,("negprot_spnego: blob length too long (%d)\n", len)); + len = 255; + } + *pkeylen = len; data_blob_free(&blob); return len; } @@ -324,16 +330,17 @@ static int reply_nt1(char *inbuf, char *outbuf) /* note that we do not send a challenge at all if we are using plaintext */ get_challenge(p); - SSVALS(outbuf,smb_vwv16+1,8); + 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 { - int len = negprot_spnego(p); + uint8 keylen; + int len = negprot_spnego(p, &keylen); - SSVALS(outbuf,smb_vwv16+1,len); + SCVAL(outbuf,smb_vwv16+1,keylen); p += len; DEBUG(3,("using SPNEGO\n")); } -- cgit From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/smbd/negprot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 91942bf028..65c31449bb 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -172,7 +172,7 @@ static int negprot_spnego(char *p, uint8 *pkeylen) DATA_BLOB blob; nstring dos_name; fstring unix_name; - uint8 guid[17]; + char guid[17]; const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, OID_NTLMSSP, @@ -186,7 +186,7 @@ static int negprot_spnego(char *p, uint8 *pkeylen) safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1); strlower_m(unix_name); push_ascii_nstring(dos_name, unix_name); - safe_strcpy((char *)guid, dos_name, sizeof(guid)-1); + safe_strcpy(guid, dos_name, sizeof(guid)-1); #ifdef DEVELOPER /* valgrind fixer... */ -- cgit From 6d5757395a0e54245543794d0d6d6d6a32cd857a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 5 Nov 2005 04:21:55 +0000 Subject: r11511: A classic "friday night check-in" :-). This moves much of the Samba4 timezone handling code back into Samba3. Gets rid of "kludge-gmt" and removes the effectiveness of the parameter "time offset" (I can add this back in very easily if needed) - it's no longer being looked at. I'm hoping this will fix the problems people have been having with DST transitions. I'll start comprehensive testing tomorrow, but for now all modifications are done. Splits time get/set functions into srv_XXX and cli_XXX as they need to look at different timezone offsets. Get rid of much of the "efficiency" cruft that was added to Samba back in the day when the C library timezone handling functions were slow. Jeremy. (This used to be commit 414303bc0272f207046b471a0364fa296b67c1f8) --- source3/smbd/negprot.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 65c31449bb..db061cb1b8 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -23,6 +23,7 @@ extern fstring remote_proto; extern enum protocol_types Protocol; extern int max_recv; + BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; struct auth_context *negprot_global_auth_context = NULL; @@ -115,9 +116,9 @@ static int reply_lanman1(char *inbuf, char *outbuf) SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support readbraw writebraw (possibly) */ SIVAL(outbuf,smb_vwv6,sys_getpid()); - SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); + SSVAL(outbuf,smb_vwv10, set_server_zone_offset(t)/60); - put_dos_date(outbuf,smb_vwv8,t); + srv_put_dos_date(outbuf,smb_vwv8,t); return (smb_len(outbuf)+4); } @@ -157,8 +158,8 @@ static int reply_lanman2(char *inbuf, char *outbuf) SSVAL(outbuf,smb_vwv3,lp_maxmux()); SSVAL(outbuf,smb_vwv4,1); SSVAL(outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ - SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60); - put_dos_date(outbuf,smb_vwv8,t); + SSVAL(outbuf,smb_vwv10, set_server_zone_offset(t)/60); + srv_put_dos_date(outbuf,smb_vwv8,t); return (smb_len(outbuf)+4); } @@ -245,9 +246,9 @@ static int reply_nt1(char *inbuf, char *outbuf) CAP_LEVEL_II_OPLOCKS; int secword=0; - time_t t = time(NULL); char *p, *q; BOOL negotiate_spnego = False; + time_t t = time(NULL); global_encrypted_passwords_negotiated = lp_encrypted_passwords(); @@ -321,7 +322,7 @@ static int reply_nt1(char *inbuf, char *outbuf) 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,TimeDiff(t)/60); + SSVALS(outbuf,smb_vwv15+1,set_server_zone_offset(t)/60); p = q = smb_buf(outbuf); if (!negotiate_spnego) { -- cgit From 0229b657552dad428343b9e06ead6c66dbc347c3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 23 Feb 2006 01:53:26 +0000 Subject: r13647: Fix for standalone Samba servers and XP clients. Reverts part of the PocketPC bugfix. I'm trying to get someone who has a pocketpc to test this. Jeremy. (This used to be commit ce25e6b002f39ba084c3430ca832ad4990cf1994) --- source3/smbd/negprot.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index db061cb1b8..5d2ed6a10d 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -178,6 +178,7 @@ static int negprot_spnego(char *p, uint8 *pkeylen) OID_KERBEROS5_OLD, OID_NTLMSSP, NULL}; + const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; int len; global_spnego_negotiated = True; @@ -212,9 +213,13 @@ static int negprot_spnego(char *p, uint8 *pkeylen) */ if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { - memcpy(p, guid, 16); - *pkeylen = 0; - return 16; +#if 0 + /* Code for PocketPC client */ + blob = data_blob(guid, 16); +#else + /* Code for standalone WXP client */ + blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE"); +#endif } else { fstring myname; char *host_princ_s = NULL; @@ -224,14 +229,20 @@ static int negprot_spnego(char *p, uint8 *pkeylen) blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s); SAFE_FREE(host_princ_s); } + memcpy(p, blob.data, blob.length); len = blob.length; if (len > 256) { DEBUG(0,("negprot_spnego: blob length too long (%d)\n", len)); len = 255; } - *pkeylen = len; data_blob_free(&blob); + + if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { + *pkeylen = 0; + } else { + *pkeylen = len; + } return len; } -- cgit From ce61fb21d948bd8e3c7733d542f8ecae1390cbfc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Jun 2006 02:38:28 +0000 Subject: r16397: Fix Klocwork #11767 and drasticly simplify the logic in smbd/process.c. All interested (Volker, Jerry, James etc). PLEASE REVIEW THIS CHANGE. The logic should be identical but *much* easier to follow and change (and shouldn't confuse Klockwork :-). Jeremy. (This used to be commit d357f8b33594472ffa78d0a112accccc2a8b1fe7) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 5d2ed6a10d..3347008cdf 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -456,6 +456,7 @@ static const struct { /**************************************************************************** Reply to a negprot. + conn POINTER CAN BE NULL HERE ! ****************************************************************************/ int reply_negprot(connection_struct *conn, -- cgit From 45ca718d1903cfd400c9e12665c59f3089fe2318 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Sep 2006 00:30:47 +0000 Subject: r18760: Fix typos, remove unneeded code (This used to be commit 56ccfe98b299e1569d59ef447ac486209aa84ca0) --- source3/smbd/negprot.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 3347008cdf..4362bb5467 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -33,7 +33,8 @@ static void get_challenge(char buff[8]) NTSTATUS nt_status; const uint8 *cryptkey; - /* We might be called more than once, muliple negprots are premitted */ + /* We might be called more than once, multiple negprots are + * permitted */ if (negprot_global_auth_context) { DEBUG(3, ("get challenge: is this a secondary negprot? negprot_global_auth_context is non-NULL!\n")); (negprot_global_auth_context->free)(&negprot_global_auth_context); @@ -190,15 +191,6 @@ static int negprot_spnego(char *p, uint8 *pkeylen) push_ascii_nstring(dos_name, unix_name); safe_strcpy(guid, dos_name, sizeof(guid)-1); -#ifdef DEVELOPER - /* valgrind fixer... */ - { - size_t sl = strlen(guid); - if (sizeof(guid)-sl) - memset(&guid[sl], '\0', sizeof(guid)-sl); - } -#endif - /* strangely enough, NT does not sent the single OID NTLMSSP when not a ADS member, it sends no OIDs at all -- cgit From 8f7643bd8345de0be03b59db2e9490ee5e0ca85f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Sep 2006 01:49:18 +0000 Subject: r18761: Even if only offering NTLMSSP Windows (tested with Vista & XP) sends 0 as the key length in the case of extended security. It does make sense because with SPNEGO our beloved ASN1 structure gives us the length. Next test I did to verify this: I modified the server to put in random garbage, and W2kwks, XP, Vista and W2k3srv still talked to us. Volker (This used to be commit f19bd479cee57f064f63659c533ae108885d54a2) --- source3/smbd/negprot.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 4362bb5467..b984558fb4 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -230,11 +230,8 @@ static int negprot_spnego(char *p, uint8 *pkeylen) } data_blob_free(&blob); - if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { - *pkeylen = 0; - } else { - *pkeylen = len; - } + *pkeylen = 0; + return len; } -- cgit From a4a2d795b1dc218705cf8bd148a4e59845155f7c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Sep 2006 05:07:47 +0000 Subject: r18771: Sequel to r18761: If we always set the keylen to 0 there's no point in passing a pointer down to negprot_spnego(). Volker (This used to be commit 18f47130b1ccf09873ca684ee0ea986e28f47d78) --- source3/smbd/negprot.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b984558fb4..2df7f45aba 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -169,7 +169,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) Generate the spnego negprot reply blob. Return the number of bytes used. ****************************************************************************/ -static int negprot_spnego(char *p, uint8 *pkeylen) +static int negprot_spnego(char *p) { DATA_BLOB blob; nstring dos_name; @@ -230,8 +230,6 @@ static int negprot_spnego(char *p, uint8 *pkeylen) } data_blob_free(&blob); - *pkeylen = 0; - return len; } @@ -338,10 +336,9 @@ static int reply_nt1(char *inbuf, char *outbuf) STR_UNICODE|STR_TERMINATE|STR_NOALIGN); DEBUG(3,("not using SPNEGO\n")); } else { - uint8 keylen; - int len = negprot_spnego(p, &keylen); + int len = negprot_spnego(p); - SCVAL(outbuf,smb_vwv16+1,keylen); + SCVAL(outbuf,smb_vwv16+1, 0); p += len; DEBUG(3,("using SPNEGO\n")); } -- cgit From 3bddf16b1f61930f58b49070f1ca8a1c7df50886 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Sep 2006 05:19:22 +0000 Subject: r18772: Now that we don't have a one-byte keylength in the extended security case anymore, we don't have to truncate the length to 255 anymore. The test I did for this: I sent 50 times the NTLMSSP oid. With truncating Vista said Access Denied, without truncating it liked the response. Volker (This used to be commit f1512cb43c69338d4f2cb806486c4f5db51cf695) --- source3/smbd/negprot.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 2df7f45aba..b583623a4b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -224,10 +224,6 @@ static int negprot_spnego(char *p) memcpy(p, blob.data, blob.length); len = blob.length; - if (len > 256) { - DEBUG(0,("negprot_spnego: blob length too long (%d)\n", len)); - len = 255; - } data_blob_free(&blob); return len; -- cgit From c209219d062830aa95e39cd97ac988244f1fc49b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Sep 2006 05:29:07 +0000 Subject: r18773: Change negprot_spnego to return a blob (This used to be commit 28fa772721640a6d3a0f6a30fb56fde18b5f5616) --- source3/smbd/negprot.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index b583623a4b..bbd1013050 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -169,7 +169,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) Generate the spnego negprot reply blob. Return the number of bytes used. ****************************************************************************/ -static int negprot_spnego(char *p) +static DATA_BLOB negprot_spnego(void) { DATA_BLOB blob; nstring dos_name; @@ -180,7 +180,6 @@ static int negprot_spnego(char *p) OID_NTLMSSP, NULL}; const char *OIDs_plain[] = {OID_NTLMSSP, NULL}; - int len; global_spnego_negotiated = True; @@ -222,11 +221,7 @@ static int negprot_spnego(char *p) SAFE_FREE(host_princ_s); } - memcpy(p, blob.data, blob.length); - len = blob.length; - data_blob_free(&blob); - - return len; + return blob; } /**************************************************************************** @@ -332,10 +327,17 @@ static int reply_nt1(char *inbuf, char *outbuf) STR_UNICODE|STR_TERMINATE|STR_NOALIGN); DEBUG(3,("not using SPNEGO\n")); } else { - int len = negprot_spnego(p); - + DATA_BLOB spnego_blob = negprot_spnego(); + + if (spnego_blob.data == NULL) { + return ERROR_NT(NT_STATUS_NO_MEMORY); + } + + memcpy(p, spnego_blob.data, spnego_blob.length); + p += spnego_blob.length; + data_blob_free(&spnego_blob); + SCVAL(outbuf,smb_vwv16+1, 0); - p += len; DEBUG(3,("using SPNEGO\n")); } -- cgit From 5bb49b08f3d79ef9ee17dbbd64ce90dc438d96df Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 18 Dec 2006 04:25:21 +0000 Subject: r20237: Replace exit_server with exit_server_cleanly where appropriate. All send_smb failures should be clean exits. All times when we exit as a matter of policy should also be clean exits. (This used to be commit d6382092e72120a3c89ffe81975e8898d454bf06) --- source3/smbd/negprot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index bbd1013050..8e9dcf22e2 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -293,7 +293,7 @@ static int reply_nt1(char *inbuf, char *outbuf) } 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."); + exit_server_cleanly("reply_nt1: smb signing required and share level security selected."); } } } @@ -461,7 +461,7 @@ int reply_negprot(connection_struct *conn, if (done_negprot) { END_PROFILE(SMBnegprot); - exit_server("multiple negprot's are not permitted"); + exit_server_cleanly("multiple negprot's are not permitted"); } done_negprot = True; @@ -570,7 +570,8 @@ int reply_negprot(connection_struct *conn, 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"); + exit_server_cleanly("SMB signing is required and " + "client negotiated a downlevel protocol"); } END_PROFILE(SMBnegprot); -- cgit From 2703b3ac480b1c29684b13297f5e78481c889223 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Dec 2006 23:52:47 +0000 Subject: r20368: Fix valgrind report of uninitialized memory being returned (false positive). Up debug level on "open_directory" message. Jeremy. (This used to be commit 71a8b8863f8bdcce082c5971d6489a2da3ff4b2c) --- source3/smbd/negprot.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 8e9dcf22e2..fec5971045 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -174,6 +174,9 @@ static DATA_BLOB negprot_spnego(void) DATA_BLOB blob; nstring dos_name; fstring unix_name; +#ifdef DEVELOPER + size_t slen; +#endif char guid[17]; const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, @@ -183,13 +186,21 @@ static DATA_BLOB negprot_spnego(void) global_spnego_negotiated = True; - ZERO_STRUCT(guid); + memset(guid, '\0', sizeof(guid)); safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1); strlower_m(unix_name); push_ascii_nstring(dos_name, unix_name); safe_strcpy(guid, dos_name, sizeof(guid)-1); +#ifdef DEVELOPER + /* Fix valgrind 'uninitialized bytes' issue. */ + slen = strlen(dos_name); + if (slen < sizeof(guid)) { + memset(guid+slen, '\0', sizeof(guid) - slen); + } +#endif + /* strangely enough, NT does not sent the single OID NTLMSSP when not a ADS member, it sends no OIDs at all -- cgit From 7db1c6873c15e7950bf7dcc10ce3cdc7bc10248c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 8 Feb 2007 21:48:09 +0000 Subject: r21250: Partial fix for BUG 4093: Make %a expand to "Vista" based on the flags2 values in the negprot request. This also includes some code for testing the dialect strings for "SMB 2.001" but this is unreliable as Vista only sends that in the 1st negprot and caches the fact that we don't support it. Restartnig the WOrkstation service on the client clears the cache. (This used to be commit d781eeb0e4362b7af1497634d26315498a5257d4) --- source3/smbd/negprot.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index fec5971045..fb5610b20b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -252,6 +252,16 @@ static int reply_nt1(char *inbuf, char *outbuf) global_encrypted_passwords_negotiated = lp_encrypted_passwords(); + /* Check the flags field to see if this is Vista. + WinXP sets it and Vista does not. But we have to + distinguish from NT which doesn't set it either. */ + + if ( (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY) && + ((SVAL(inbuf, smb_flg2) & FLAGS2_UNKNOWN_BIT4) == 0) ) + { + set_remote_arch( RA_VISTA ); + } + /* do spnego in user level security if the client supports it and we can do encrypted passwords */ @@ -388,6 +398,15 @@ protocol [LM1.2X002] protocol [LANMAN2.1] protocol [NT LM 0.12] +Vista: +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] +protocol [SMB 2.001] + OS/2: protocol [PC NETWORK PROGRAM 1.0] protocol [XENIX CORE] @@ -401,18 +420,19 @@ protocol [LANMAN2.1] * * 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 + Protocol WfWg Win95 WinNT Win2K OS/2 Vista + PC NETWORK PROGRAM 1.0 1 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 + LANMAN1.0 4 2 3 2 + Windows for Workgroups 3.1a 5 5 5 3 3 + LM1.2X002 6 4 4 4 + LANMAN2.1 7 5 5 5 + NT LM 0.12 6 8 6 6 + SMB 2.001 7 * * tim@fsg.com 09/29/95 * Win2K added by matty 17/7/99 @@ -425,6 +445,7 @@ protocol [LANMAN2.1] #define ARCH_OS2 0x14 /* Again OS/2 is like NT */ #define ARCH_SAMBA 0x20 #define ARCH_CIFSFS 0x40 +#define ARCH_VISTA 0x8C /* Vista is like XP/2K */ #define ARCH_ALL 0x7F @@ -488,6 +509,8 @@ int reply_negprot(connection_struct *conn, 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,"SMB 2.001")) + arch = ARCH_VISTA; else if (strcsequal(p,"LANMAN2.1")) arch &= ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 ); else if (strcsequal(p,"LM1.2X002")) @@ -532,7 +555,13 @@ int reply_negprot(connection_struct *conn, set_remote_arch(RA_WINNT); break; case ARCH_WIN2K: - set_remote_arch(RA_WIN2K); + /* Vista may have been set in the negprot so don't + override it here */ + if ( get_remote_arch() != RA_VISTA ) + set_remote_arch(RA_WIN2K); + break; + case ARCH_VISTA: + set_remote_arch(RA_VISTA); break; case ARCH_OS2: set_remote_arch(RA_OS2); -- cgit From 8d5f85e0046c8fd2c0f8832788719e319751d358 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 Mar 2007 16:20:47 +0000 Subject: r21857: Stop pretending to be Vista in the %a macro towards Samba clients. Guenther (This used to be commit f55e1a312e75dc72ea040a35a9c20ccf539c4ae4) --- source3/smbd/negprot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index fb5610b20b..04b06a9bce 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -259,7 +259,9 @@ static int reply_nt1(char *inbuf, char *outbuf) if ( (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY) && ((SVAL(inbuf, smb_flg2) & FLAGS2_UNKNOWN_BIT4) == 0) ) { - set_remote_arch( RA_VISTA ); + if (get_remote_arch() != RA_SAMBA) {; + set_remote_arch( RA_VISTA ); + } } /* do spnego in user level security if the client -- cgit From ab9a46a35c05869f1aa4bb3c57a987def459791e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 Mar 2007 16:21:38 +0000 Subject: r21858: Fix typo. Guenther (This used to be commit 663514e511982437c09d45334b8d435448347ed6) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 04b06a9bce..bc7c75aab4 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -259,7 +259,7 @@ static int reply_nt1(char *inbuf, char *outbuf) if ( (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY) && ((SVAL(inbuf, smb_flg2) & FLAGS2_UNKNOWN_BIT4) == 0) ) { - if (get_remote_arch() != RA_SAMBA) {; + if (get_remote_arch() != RA_SAMBA) { set_remote_arch( RA_VISTA ); } } -- cgit From 8b63654c2e63448cc21505d7996e1a4805e391df Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Mar 2007 00:50:53 +0000 Subject: r21969: Start working on the gss-side of the server negotiation. Jeremy. (This used to be commit fbc569b530104679e47fe743963eb0c4384de6ae) --- source3/smbd/negprot.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index bc7c75aab4..e1df08579d 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -228,6 +228,10 @@ static DATA_BLOB negprot_spnego(void) name_to_fqdn(myname, global_myname()); strlower_m(myname); asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm()); + if (host_princ_s == NULL) { + blob = data_blob(NULL, 0); + return blob; + } blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s); SAFE_FREE(host_princ_s); } -- cgit From 0829e1ad1c3646efecf50729f493b9ee72ef0517 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Apr 2007 22:40:32 +0000 Subject: r22391: Looks bigger than it is. Make "inbuf" available to all callers of smb_setlen (via set_message() calls). This will allow the server to reflect back the correct encryption context. Jeremy. (This used to be commit 2d80a96120a5fe2fe726f00746d36d85044c4bdb) --- source3/smbd/negprot.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e1df08579d..1722c81d2a 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -56,7 +56,7 @@ static void get_challenge(char buff[8]) static int reply_corep(char *inbuf, char *outbuf) { - int outsize = set_message(outbuf,1,0,True); + int outsize = set_message(inbuf,outbuf,1,0,True); Protocol = PROTOCOL_CORE; @@ -70,7 +70,7 @@ static int reply_corep(char *inbuf, char *outbuf) static int reply_coreplus(char *inbuf, char *outbuf) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); - int outsize = set_message(outbuf,13,0,True); + int outsize = set_message(inbuf,outbuf,13,0,True); SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support readbraw and writebraw (possibly) */ /* Reply, SMBlockread, SMBwritelock supported. */ @@ -99,7 +99,7 @@ static int reply_lanman1(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); + set_message(inbuf,outbuf,13,global_encrypted_passwords_negotiated?8:0,True); SSVAL(outbuf,smb_vwv1,secword); /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { @@ -141,7 +141,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - set_message(outbuf,13,global_encrypted_passwords_negotiated?8:0,True); + set_message(inbuf,outbuf,13,global_encrypted_passwords_negotiated?8:0,True); SSVAL(outbuf,smb_vwv1,secword); SIVAL(outbuf,smb_vwv6,sys_getpid()); @@ -325,7 +325,7 @@ static int reply_nt1(char *inbuf, char *outbuf) } } - set_message(outbuf,17,0,True); + set_message(inbuf,outbuf,17,0,True); SCVAL(outbuf,smb_vwv1,secword); @@ -369,7 +369,7 @@ static int reply_nt1(char *inbuf, char *outbuf) } SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ - set_message_end(outbuf, p); + set_message_end(inbuf,outbuf, p); return (smb_len(outbuf)+4); } @@ -485,7 +485,7 @@ 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 outsize = set_message(inbuf,outbuf,1,0,True); int Index=0; int choice= -1; int protocol; -- cgit From b4a7b7a8889737e2891fc1176feabd4ce47f2737 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 May 2007 12:16:20 +0000 Subject: r22844: Introduce const DATA_BLOB data_blob_null = { NULL, 0, NULL }; and replace all data_blob(NULL, 0) calls. (This used to be commit 3d3d61687ef00181f4f04e001d42181d93ac931e) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 1722c81d2a..12b1e84600 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -229,7 +229,7 @@ static DATA_BLOB negprot_spnego(void) strlower_m(myname); asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm()); if (host_princ_s == NULL) { - blob = data_blob(NULL, 0); + blob = data_blob_null; return blob; } blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s); -- cgit From f3c477c631e7318ccaa6f277731b721a462112b8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 May 2007 16:22:12 +0000 Subject: r23167: Remove an unused parameter (This used to be commit 3452a870d58cdddf03ddf6ee698bca8416e05cbf) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 12b1e84600..7aa9725062 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -584,7 +584,7 @@ int reply_negprot(connection_struct *conn, 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); + claim_connection(NULL,"",0,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++) { -- cgit From 14e25f10d6a3da34fb8b29c4331571efa11ee3b8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 May 2007 16:34:49 +0000 Subject: r23168: Move the lp_max_connections() into service.c. (This used to be commit 4afe37d431b6eb475769a2057025da9aa8d1bb14) --- source3/smbd/negprot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 7aa9725062..92c392b366 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -584,7 +584,8 @@ int reply_negprot(connection_struct *conn, 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,FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL); + claim_connection( + NULL,"",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++) { -- cgit From b1ce226af8b61ad7e3c37860a59c6715012e738b Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 15 Jun 2007 21:58:49 +0000 Subject: r23510: Tidy calls to smb_panic by removing trailing newlines. Print the failed expression in SMB_ASSERT. (This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 92c392b366..3fdae1e06b 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -43,7 +43,7 @@ static void get_challenge(char buff[8]) DEBUG(10, ("get challenge: creating negprot_global_auth_context\n")); if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&negprot_global_auth_context))) { DEBUG(0, ("make_auth_context_subsystem returned %s", nt_errstr(nt_status))); - smb_panic("cannot make_negprot_global_auth_context!\n"); + smb_panic("cannot make_negprot_global_auth_context!"); } DEBUG(10, ("get challenge: getting challenge\n")); cryptkey = negprot_global_auth_context->get_ntlm_challenge(negprot_global_auth_context); -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 3fdae1e06b..7256e2da6d 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/smbd/negprot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 7256e2da6d..4a9492a766 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From de1c9f1f6d36282fc6d1a7f25a7d79b74a081160 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jul 2007 11:08:43 +0000 Subject: r24001: Separate out the parsing of the client's requested protocols This way the range checking only needs to be done once (This used to be commit befaa9713adec90088eedcf264f1e396ab150d25) --- source3/smbd/negprot.c | 95 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 29 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 4a9492a766..4e3d8f1b3e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -481,16 +481,17 @@ static const struct { ****************************************************************************/ int reply_negprot(connection_struct *conn, - char *inbuf,char *outbuf, int dum_size, + char *inbuf,char *outbuf, int size, int dum_buffsize) { int outsize = set_message(inbuf,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; + int num_cliprotos; + char **cliprotos; + int i; static BOOL done_negprot = False; @@ -502,41 +503,78 @@ int reply_negprot(connection_struct *conn, } done_negprot = True; + if (inbuf[size-1] != '\0') { + DEBUG(0, ("negprot protocols not 0-terminated\n")); + END_PROFILE(SMBnegprot); + return ERROR_NT(NT_STATUS_INVALID_PARAMETER); + } + 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")) + + num_cliprotos = 0; + cliprotos = NULL; + + while (smb_bufrem(inbuf, p) > 0) { + char **tmp; + + tmp = TALLOC_REALLOC_ARRAY(tmp_talloc_ctx(), cliprotos, char *, + num_cliprotos+1); + if (tmp == NULL) { + DEBUG(0, ("talloc failed\n")); + TALLOC_FREE(cliprotos); + END_PROFILE(SMBnegprot); + return ERROR_NT(NT_STATUS_NO_MEMORY); + } + + cliprotos = tmp; + + if (pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p) + == (size_t)-1) { + DEBUG(0, ("pull_ascii_talloc failed\n")); + TALLOC_FREE(cliprotos); + END_PROFILE(SMBnegprot); + return ERROR_NT(NT_STATUS_NO_MEMORY); + } + + DEBUG(3, ("Requested protocol [%s]\n", + cliprotos[num_cliprotos])); + + num_cliprotos += 1; + p += strlen(p) + 2; + } + + for (i=0; i= lp_minprotocol())) - while (p < (smb_buf(inbuf) + bcc)) { - if (strequal(p,supported_protocols[protocol].proto_name)) - choice = Index; - Index++; - p += strlen(p) + 2; + while (i < num_cliprotos) { + if (strequal(cliprotos[i],supported_protocols[protocol].proto_name)) + choice = i; + i++; } if(choice != -1) break; @@ -620,6 +656,7 @@ int reply_negprot(connection_struct *conn, "client negotiated a downlevel protocol"); } + TALLOC_FREE(cliprotos); END_PROFILE(SMBnegprot); return(outsize); } -- cgit From 3d12c53eb3bf5506b0661fbcaa0d36f90f847c65 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jul 2007 11:18:20 +0000 Subject: r24002: Convert reply_negprot to the new API (This used to be commit bd981f53282573058bf4c2939e0e836499cf38be) --- source3/smbd/negprot.c | 204 +++++++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 90 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 4e3d8f1b3e..61be2e8f9a 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -27,7 +27,7 @@ BOOL global_encrypted_passwords_negotiated = False; BOOL global_spnego_negotiated = False; struct auth_context *negprot_global_auth_context = NULL; -static void get_challenge(char buff[8]) +static void get_challenge(uint8 buff[8]) { NTSTATUS nt_status; const uint8 *cryptkey; @@ -53,39 +53,39 @@ static void get_challenge(char buff[8]) Reply for the core protocol. ****************************************************************************/ -static int reply_corep(char *inbuf, char *outbuf) +static void reply_corep(struct smb_request *req, uint16 choice) { - int outsize = set_message(inbuf,outbuf,1,0,True); + reply_outbuf(req, 1, 0); + SSVAL(req->outbuf, smb_vwv0, choice); Protocol = PROTOCOL_CORE; - - return outsize; } /**************************************************************************** Reply for the coreplus protocol. ****************************************************************************/ -static int reply_coreplus(char *inbuf, char *outbuf) +static void reply_coreplus(struct smb_request *req, uint16 choice) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); - int outsize = set_message(inbuf,outbuf,13,0,True); - SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support + + reply_outbuf(req, 13, 0); + + SSVAL(req->outbuf,smb_vwv0,choice); + SSVAL(req->outbuf,smb_vwv5,raw); /* tell redirector we support readbraw and writebraw (possibly) */ /* Reply, SMBlockread, SMBwritelock supported. */ - SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); - SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */ - + SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); + SSVAL(req->outbuf,smb_vwv1,0x1); /* user level security, don't + * encrypt */ Protocol = PROTOCOL_COREPLUS; - - return outsize; } /**************************************************************************** Reply for the lanman 1.0 protocol. ****************************************************************************/ -static int reply_lanman1(char *inbuf, char *outbuf) +static void reply_lanman1(struct smb_request *req, uint16 choice) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; @@ -98,36 +98,38 @@ static int reply_lanman1(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - set_message(inbuf,outbuf,13,global_encrypted_passwords_negotiated?8:0,True); - SSVAL(outbuf,smb_vwv1,secword); + reply_outbuf(req, 13, global_encrypted_passwords_negotiated?8:0); + + SSVAL(req->outbuf,smb_vwv0,choice); + SSVAL(req->outbuf,smb_vwv1,secword); /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - get_challenge(smb_buf(outbuf)); - SSVAL(outbuf,smb_vwv11, 8); + get_challenge((uint8 *)smb_buf(req->outbuf)); + SSVAL(req->outbuf,smb_vwv11, 8); } Protocol = PROTOCOL_LANMAN1; /* Reply, SMBlockread, SMBwritelock supported. */ - SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); - SSVAL(outbuf,smb_vwv2,max_recv); - SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ - SSVAL(outbuf,smb_vwv4,1); - SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support + SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); + SSVAL(req->outbuf,smb_vwv2,max_recv); + SSVAL(req->outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ + SSVAL(req->outbuf,smb_vwv4,1); + SSVAL(req->outbuf,smb_vwv5,raw); /* tell redirector we support readbraw writebraw (possibly) */ - SIVAL(outbuf,smb_vwv6,sys_getpid()); - SSVAL(outbuf,smb_vwv10, set_server_zone_offset(t)/60); + SIVAL(req->outbuf,smb_vwv6,sys_getpid()); + SSVAL(req->outbuf,smb_vwv10, set_server_zone_offset(t)/60); - srv_put_dos_date(outbuf,smb_vwv8,t); + srv_put_dos_date((char *)req->outbuf,smb_vwv8,t); - return (smb_len(outbuf)+4); + return; } /**************************************************************************** Reply for the lanman 2.0 protocol. ****************************************************************************/ -static int reply_lanman2(char *inbuf, char *outbuf) +static void reply_lanman2(struct smb_request *req, uint16 choice) { int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0); int secword=0; @@ -140,28 +142,28 @@ static int reply_lanman2(char *inbuf, char *outbuf) if (global_encrypted_passwords_negotiated) secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE; - set_message(inbuf,outbuf,13,global_encrypted_passwords_negotiated?8:0,True); - SSVAL(outbuf,smb_vwv1,secword); - SIVAL(outbuf,smb_vwv6,sys_getpid()); + reply_outbuf(req, 13, global_encrypted_passwords_negotiated?8:0); + + SSVAL(req->outbuf,smb_vwv0,choice); + SSVAL(req->outbuf,smb_vwv1,secword); + SIVAL(req->outbuf,smb_vwv6,sys_getpid()); /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { - get_challenge(smb_buf(outbuf)); - SSVAL(outbuf,smb_vwv11, 8); + get_challenge((uint8 *)smb_buf(req->outbuf)); + SSVAL(req->outbuf,smb_vwv11, 8); } Protocol = PROTOCOL_LANMAN2; /* Reply, SMBlockread, SMBwritelock supported. */ - SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); - SSVAL(outbuf,smb_vwv2,max_recv); - SSVAL(outbuf,smb_vwv3,lp_maxmux()); - SSVAL(outbuf,smb_vwv4,1); - SSVAL(outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ - SSVAL(outbuf,smb_vwv10, set_server_zone_offset(t)/60); - srv_put_dos_date(outbuf,smb_vwv8,t); - - return (smb_len(outbuf)+4); + SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); + SSVAL(req->outbuf,smb_vwv2,max_recv); + SSVAL(req->outbuf,smb_vwv3,lp_maxmux()); + SSVAL(req->outbuf,smb_vwv4,1); + SSVAL(req->outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */ + SSVAL(req->outbuf,smb_vwv10, set_server_zone_offset(t)/60); + srv_put_dos_date((char *)req->outbuf,smb_vwv8,t); } /**************************************************************************** @@ -242,7 +244,7 @@ static DATA_BLOB negprot_spnego(void) Reply for the nt protocol. ****************************************************************************/ -static int reply_nt1(char *inbuf, char *outbuf) +static void reply_nt1(struct smb_request *req, uint16 choice) { /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| @@ -252,6 +254,7 @@ static int reply_nt1(char *inbuf, char *outbuf) char *p, *q; BOOL negotiate_spnego = False; time_t t = time(NULL); + ssize_t ret; global_encrypted_passwords_negotiated = lp_encrypted_passwords(); @@ -259,27 +262,30 @@ static int reply_nt1(char *inbuf, char *outbuf) WinXP sets it and Vista does not. But we have to distinguish from NT which doesn't set it either. */ - if ( (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY) && - ((SVAL(inbuf, smb_flg2) & FLAGS2_UNKNOWN_BIT4) == 0) ) + if ( (req->flags2 & FLAGS2_EXTENDED_SECURITY) && + ((req->flags2 & FLAGS2_UNKNOWN_BIT4) == 0) ) { if (get_remote_arch() != RA_SAMBA) { set_remote_arch( RA_VISTA ); } } + reply_outbuf(req,17,0); + /* do spnego in user level security if the client supports it and we can do encrypted passwords */ if (global_encrypted_passwords_negotiated && (lp_security() != SEC_SHARE) && lp_use_spnego() && - (SVAL(inbuf, smb_flg2) & FLAGS2_EXTENDED_SECURITY)) { + (req->flags2 & FLAGS2_EXTENDED_SECURITY)) { negotiate_spnego = True; capabilities |= CAP_EXTENDED_SECURITY; add_to_common_flags2(FLAGS2_EXTENDED_SECURITY); - /* Ensure FLAGS2_EXTENDED_SECURITY gets set in this reply (already - partially constructed. */ - SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2) | FLAGS2_EXTENDED_SECURITY); + /* Ensure FLAGS2_EXTENDED_SECURITY gets set in this reply + (already partially constructed. */ + SSVAL(req->outbuf, smb_flg2, + req->flags2 | FLAGS2_EXTENDED_SECURITY); } capabilities |= CAP_NT_SMBS|CAP_RPC_REMOTE_APIS|CAP_UNICODE; @@ -324,53 +330,72 @@ static int reply_nt1(char *inbuf, char *outbuf) } } - set_message(inbuf,outbuf,17,0,True); - - SCVAL(outbuf,smb_vwv1,secword); + SSVAL(req->outbuf,smb_vwv0,choice); + SCVAL(req->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); + SSVAL(req->outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */ + SSVAL(req->outbuf,smb_vwv2+1,1); /* num vcs */ + SIVAL(req->outbuf,smb_vwv3+1,max_recv); /* max buffer. LOTS! */ + SIVAL(req->outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */ + SIVAL(req->outbuf,smb_vwv7+1,sys_getpid()); /* session key */ + SIVAL(req->outbuf,smb_vwv9+1,capabilities); /* capabilities */ + put_long_date((char *)req->outbuf+smb_vwv11+1,t); + SSVALS(req->outbuf,smb_vwv15+1,set_server_zone_offset(t)/60); - p = q = smb_buf(outbuf); + p = q = smb_buf(req->outbuf); if (!negotiate_spnego) { /* Create a token value and add it to the outgoing packet. */ if (global_encrypted_passwords_negotiated) { + uint8 chal[8]; /* 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; + get_challenge(chal); + ret = message_push_blob( + &req->outbuf, data_blob_const(chal, sizeof(chal))); + if (ret == -1) { + DEBUG(0, ("Could not push challenge\n")); + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + SCVAL(req->outbuf, smb_vwv16+1, ret); + p += ret; + } + ret = message_push_string(&req->outbuf, lp_workgroup(), + STR_UNICODE|STR_TERMINATE + |STR_NOALIGN); + if (ret == -1) { + DEBUG(0, ("Could not push challenge\n")); + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; } - p += srvstr_push(outbuf, p, lp_workgroup(), -1, - STR_UNICODE|STR_TERMINATE|STR_NOALIGN); DEBUG(3,("not using SPNEGO\n")); } else { DATA_BLOB spnego_blob = negprot_spnego(); if (spnego_blob.data == NULL) { - return ERROR_NT(NT_STATUS_NO_MEMORY); + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; } - memcpy(p, spnego_blob.data, spnego_blob.length); - p += spnego_blob.length; + ret = message_push_blob(&req->outbuf, spnego_blob); + if (ret == -1) { + DEBUG(0, ("Could not push spnego blob\n")); + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + p += ret; data_blob_free(&spnego_blob); - SCVAL(outbuf,smb_vwv16+1, 0); + SCVAL(req->outbuf,smb_vwv16+1, 0); DEBUG(3,("using SPNEGO\n")); } - SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ - set_message_end(inbuf,outbuf, p); - - return (smb_len(outbuf)+4); + SSVAL(req->outbuf,smb_vwv17, p - q); /* length of challenge+domain + * strings */ + + return; } /* these are the protocol lists used for auto architecture detection: @@ -458,7 +483,7 @@ protocol [LANMAN2.1] static const struct { const char *proto_name; const char *short_name; - int (*proto_reply_fn)(char *, char *); + void (*proto_reply_fn)(struct smb_request *req, uint16 choice); int protocol_level; } supported_protocols[] = { {"NT LANMAN 1.0", "NT1", reply_nt1, PROTOCOL_NT1}, @@ -480,11 +505,9 @@ static const struct { conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_negprot(connection_struct *conn, - char *inbuf,char *outbuf, int size, - int dum_buffsize) +void reply_negprot(connection_struct *conn, struct smb_request *req) { - int outsize = set_message(inbuf,outbuf,1,0,True); + size_t size = smb_len(req->inbuf) + 4; int choice= -1; int protocol; char *p; @@ -503,18 +526,19 @@ int reply_negprot(connection_struct *conn, } done_negprot = True; - if (inbuf[size-1] != '\0') { + if (req->inbuf[size-1] != '\0') { DEBUG(0, ("negprot protocols not 0-terminated\n")); + reply_nterror(req, NT_STATUS_INVALID_PARAMETER); END_PROFILE(SMBnegprot); - return ERROR_NT(NT_STATUS_INVALID_PARAMETER); + return; } - p = smb_buf(inbuf)+1; + p = smb_buf(req->inbuf)+1; num_cliprotos = 0; cliprotos = NULL; - while (smb_bufrem(inbuf, p) > 0) { + while (smb_bufrem(req->inbuf, p) > 0) { char **tmp; tmp = TALLOC_REALLOC_ARRAY(tmp_talloc_ctx(), cliprotos, char *, @@ -522,8 +546,9 @@ int reply_negprot(connection_struct *conn, if (tmp == NULL) { DEBUG(0, ("talloc failed\n")); TALLOC_FREE(cliprotos); + reply_nterror(req, NT_STATUS_NO_MEMORY); END_PROFILE(SMBnegprot); - return ERROR_NT(NT_STATUS_NO_MEMORY); + return; } cliprotos = tmp; @@ -532,8 +557,9 @@ int reply_negprot(connection_struct *conn, == (size_t)-1) { DEBUG(0, ("pull_ascii_talloc failed\n")); TALLOC_FREE(cliprotos); + reply_nterror(req, NT_STATUS_NO_MEMORY); END_PROFILE(SMBnegprot); - return ERROR_NT(NT_STATUS_NO_MEMORY); + return; } DEBUG(3, ("Requested protocol [%s]\n", @@ -592,7 +618,7 @@ int reply_negprot(connection_struct *conn, set_remote_arch(RA_WIN95); break; case ARCH_WINNT: - if(SVAL(inbuf,smb_flg2)==FLAGS2_WIN2K_SIGNATURE) + if(req->flags2 == FLAGS2_WIN2K_SIGNATURE) set_remote_arch(RA_WIN2K); else set_remote_arch(RA_WINNT); @@ -638,16 +664,14 @@ int reply_negprot(connection_struct *conn, 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); + supported_protocols[protocol].proto_reply_fn(req, choice); 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 ) ); @@ -658,5 +682,5 @@ int reply_negprot(connection_struct *conn, TALLOC_FREE(cliprotos); END_PROFILE(SMBnegprot); - return(outsize); + return; } -- cgit From 3a836c3ee44e9abc5b5028bf6286628981bf0f99 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jul 2007 14:36:54 +0000 Subject: r24006: Some more paranoia in reply_negprot Some hosts see the smb_bufrem(req->inbuf, p) as an unsigned int. And as the p += strlen(p) + 2 went one beyond the buffer, this was a very large positive. Also take the chance to add one more consistency check. (This used to be commit 3673707f9f1a3ba29966ac7cf744e2b6462c8dde) --- source3/smbd/negprot.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 61be2e8f9a..7602490c2d 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -533,7 +533,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) return; } - p = smb_buf(req->inbuf)+1; + p = smb_buf(req->inbuf); num_cliprotos = 0; cliprotos = NULL; @@ -541,6 +541,16 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) while (smb_bufrem(req->inbuf, p) > 0) { char **tmp; + if (p[0] != 0x02) { + DEBUG(3, ("Invalid string specifier %x, expected " + "0x02\n", (int)p[0])); + reply_nterror(req, NT_STATUS_INVALID_PARAMETER); + END_PROFILE(SMBnegprot); + return; + } + + p += 1; /* Skip the "0x02" */ + tmp = TALLOC_REALLOC_ARRAY(tmp_talloc_ctx(), cliprotos, char *, num_cliprotos+1); if (tmp == NULL) { @@ -566,7 +576,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) cliprotos[num_cliprotos])); num_cliprotos += 1; - p += strlen(p) + 2; + p += strlen(p) + 1; } for (i=0; i Date: Mon, 23 Jul 2007 19:46:48 +0000 Subject: r24009: Revert to the 3.0.25 logic for parsing the client's protocols. hpisgr8 with gcc still gives timeouts which worry me. Volker (This used to be commit c30835b4f0416b2b2b7d77d31b0fca0606f2387a) --- source3/smbd/negprot.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 7602490c2d..a8578d56b5 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -511,6 +511,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) int choice= -1; int protocol; char *p; + int bcc = SVAL(smb_buf(req->inbuf),-2); int arch = ARCH_ALL; int num_cliprotos; char **cliprotos; @@ -533,23 +534,14 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) return; } - p = smb_buf(req->inbuf); + p = smb_buf(req->inbuf) + 1; num_cliprotos = 0; cliprotos = NULL; - while (smb_bufrem(req->inbuf, p) > 0) { - char **tmp; - - if (p[0] != 0x02) { - DEBUG(3, ("Invalid string specifier %x, expected " - "0x02\n", (int)p[0])); - reply_nterror(req, NT_STATUS_INVALID_PARAMETER); - END_PROFILE(SMBnegprot); - return; - } + while (p < (smb_buf(req->inbuf) + bcc)) { - p += 1; /* Skip the "0x02" */ + char **tmp; tmp = TALLOC_REALLOC_ARRAY(tmp_talloc_ctx(), cliprotos, char *, num_cliprotos+1); @@ -576,7 +568,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) cliprotos[num_cliprotos])); num_cliprotos += 1; - p += strlen(p) + 1; + p += strlen(p) + 2; } for (i=0; i Date: Thu, 2 Aug 2007 18:28:41 +0000 Subject: r24135: Convert call_trans2open to the new API This itself won't help much, because send_trans2_replies_new still allocates the big buffers, but stay tuned :-) Also add/update my copyright on stuff I recently touched. Volker (This used to be commit 248f15ff143474db2493cef89ba446892342a361) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index a8578d56b5..06b17a9a24 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. negprot reply code Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Volker Lendecke 2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit From f210f7c4320bb253944193f2a96d4f6c0169214f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Aug 2007 09:56:13 +0000 Subject: r24307: fill in choise with value -1 on error as we've done before revision 24002 metze (This used to be commit 2961a35e90aae44c8560b1f4b56bfa6343c837d7) --- source3/smbd/negprot.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 06b17a9a24..a28b2f3d4c 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -674,6 +674,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) 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 ) ); -- cgit From aece6db7148cad4876c90bb9da8653c780285abb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Aug 2007 09:57:30 +0000 Subject: r24308: this needs a better fix that compiles... metze (This used to be commit 1a177eb08d4022c1ef7b5400ffdf426bcb9b97ff) --- source3/smbd/negprot.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index a28b2f3d4c..06b17a9a24 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -674,7 +674,6 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) 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 ) ); -- cgit From 66294f9db508038a333b6c73fa5181fec5773530 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Aug 2007 10:11:40 +0000 Subject: r24309: if no protocol matches, just return choise 0xffff as we've done before revision 24002 metze (This used to be commit 6014ecbbfd50bc8f4f351dec1f9dd35c3fe62456) --- source3/smbd/negprot.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 06b17a9a24..935d25fab3 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -674,6 +674,8 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name)); } else { DEBUG(0,("No protocol supported !\n")); + reply_outbuf(req, 1, 0); + SSVAL(req->outbuf, smb_vwv0, choice); } DEBUG( 5, ( "negprot index=%d\n", choice ) ); -- cgit From 5993ddf240a945ae770754454a201c3f7a0ad7d8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 25 Aug 2007 19:47:57 +0000 Subject: r24659: Some formatting changes helping to minimize the 3_2_0 diff (This used to be commit c5caea43af154671448df82881efe09a5c982386) --- source3/smbd/negprot.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 935d25fab3..4437f0bd3f 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -229,10 +229,9 @@ static DATA_BLOB negprot_spnego(void) char *host_princ_s = NULL; name_to_fqdn(myname, global_myname()); strlower_m(myname); - asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm()); - if (host_princ_s == NULL) { - blob = data_blob_null; - return blob; + if (asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm()) + == -1) { + return data_blob_null; } blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s); SAFE_FREE(host_princ_s); @@ -540,7 +539,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) num_cliprotos = 0; cliprotos = NULL; - while (p < (smb_buf(req->inbuf) + bcc)) { + while (p < (smb_buf(req->inbuf) + bcc)) { char **tmp; -- cgit From 929e1d99209e20a9c2c95c8bdfc8eaa37b2c2291 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 30 Aug 2007 19:48:31 +0000 Subject: r24809: Consolidate the use of temporary talloc contexts. This adds the two functions talloc_stackframe() and talloc_tos(). * When a new talloc stackframe is allocated with talloc_stackframe(), then * the TALLOC_CTX returned with talloc_tos() is reset to that new * frame. Whenever that stack frame is TALLOC_FREE()'ed, then the reverse * happens: The previous talloc_tos() is restored. * * This API is designed to be robust in the sense that if someone forgets to * TALLOC_FREE() a stackframe, then the next outer one correctly cleans up and * resets the talloc_tos(). The original motivation for this patch was to get rid of the sid_string_static & friends buffers. Explicitly passing talloc context everywhere clutters code too much for my taste, so an implicit talloc_tos() is introduced here. Many of these static buffers are replaced by a single static pointer. The intended use would thus be that low-level functions can rather freely push stuff to talloc_tos, the upper layers clean up by freeing the stackframe. The more of these stackframes are used and correctly freed the more exact the memory cleanup happens. This patch removes the main_loop_talloc_ctx, tmp_talloc_ctx and lp_talloc_ctx (did I forget any?) So, never do a tmp_ctx = talloc_init("foo"); anymore, instead, use tmp_ctx = talloc_stackframe() :-) Volker (This used to be commit 6585ea2cb7f417e14540495b9c7380fe9c8c717b) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 4437f0bd3f..98109a2149 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -543,7 +543,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) char **tmp; - tmp = TALLOC_REALLOC_ARRAY(tmp_talloc_ctx(), cliprotos, char *, + tmp = TALLOC_REALLOC_ARRAY(talloc_tos(), cliprotos, char *, num_cliprotos+1); if (tmp == NULL) { DEBUG(0, ("talloc failed\n")); -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/smbd/negprot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 98109a2149..02f752fd67 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -24,8 +24,8 @@ extern fstring remote_proto; extern enum protocol_types Protocol; extern int max_recv; -BOOL global_encrypted_passwords_negotiated = False; -BOOL global_spnego_negotiated = False; +bool global_encrypted_passwords_negotiated = False; +bool global_spnego_negotiated = False; struct auth_context *negprot_global_auth_context = NULL; static void get_challenge(uint8 buff[8]) @@ -252,7 +252,7 @@ static void reply_nt1(struct smb_request *req, uint16 choice) int secword=0; char *p, *q; - BOOL negotiate_spnego = False; + bool negotiate_spnego = False; time_t t = time(NULL); ssize_t ret; @@ -517,7 +517,7 @@ void reply_negprot(connection_struct *conn, struct smb_request *req) char **cliprotos; int i; - static BOOL done_negprot = False; + static bool done_negprot = False; START_PROFILE(SMBnegprot); -- cgit From 29562987c393ef7e908aa02ee7ba00a83f3db520 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Jan 2008 15:37:24 -0800 Subject: Now conn is part of smb_request, we don't need it as an extra parameter. This cleans up quite a few places we were passing it around without needing it. Jeremy. (This used to be commit 8f36def18e9f980e8db522e1de41e80cfd5f466e) --- source3/smbd/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 02f752fd67..9f56949eeb 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -505,7 +505,7 @@ static const struct { conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -void reply_negprot(connection_struct *conn, struct smb_request *req) +void reply_negprot(struct smb_request *req) { size_t size = smb_len(req->inbuf) + 4; int choice= -1; -- cgit From fb37f156009611af0dd454a0fb0829a09cd638ac Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 29 Apr 2008 14:36:24 -0700 Subject: Cleanup size_t return values in callers of convert_string_allocate This patch is the second iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 6b189dabc562d86dcaa685419d0cb6ea276f100d) --- source3/smbd/negprot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/smbd/negprot.c') diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 9f56949eeb..84f111fb02 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -516,6 +516,7 @@ void reply_negprot(struct smb_request *req) int num_cliprotos; char **cliprotos; int i; + size_t converted_size; static bool done_negprot = False; @@ -555,8 +556,8 @@ void reply_negprot(struct smb_request *req) cliprotos = tmp; - if (pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p) - == (size_t)-1) { + if (!pull_ascii_talloc(cliprotos, &cliprotos[num_cliprotos], p, + &converted_size)) { DEBUG(0, ("pull_ascii_talloc failed\n")); TALLOC_FREE(cliprotos); reply_nterror(req, NT_STATUS_NO_MEMORY); -- cgit