From 0e8fd3398771da2f016d72830179507f3edda51b Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sat, 4 May 1996 07:50:46 +0000 Subject: Initial version imported to CVS (This used to be commit 291551d80711daab7b7581720bcd9a08d6096517) --- source3/smbd/message.c | 204 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 source3/smbd/message.c (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c new file mode 100644 index 0000000000..6a96b4c7a9 --- /dev/null +++ b/source3/smbd/message.c @@ -0,0 +1,204 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + SMB messaging + Copyright (C) Andrew Tridgell 1992-1995 + + 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. +*/ +/* + This file handles the messaging system calls for winpopup style + messages +*/ + + +#include "includes.h" +#include "loadparm.h" + +/* look in server.c for some explanation of these variables */ +extern int DEBUGLEVEL; + + +static char msgbuf[1600]; +static int msgpos=0; +static fstring msgfrom=""; +static fstring msgto=""; + +/**************************************************************************** +deliver the message +****************************************************************************/ +static void msg_deliver(void) +{ + pstring s; + fstring name; + FILE *f; + int i; + + if (! (*lp_msg_command())) + { + DEBUG(1,("no messaging command specified\n")); + msgpos = 0; + return; + } + + /* put it in a temporary file */ + sprintf(s,"/tmp/msg.XXXXXX"); + strcpy(name,(char *)mktemp(s)); + + f = fopen(name,"w"); + if (!f) + { + DEBUG(1,("can't open message file %s\n",name)); + return; + } + + for (i=0;i Date: Mon, 10 Jun 1996 04:38:24 +0000 Subject: got rid of a lot of redundent header files as we now globally generate prototypes automatically using "make proto". This is much less prone to error than the old method of manually adding prototypes (This used to be commit b551dc98f7cc194a5fc2e67a4ebae7fd67a01bbc) --- source3/smbd/message.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 6a96b4c7a9..b26a6605ed 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -25,7 +25,6 @@ #include "includes.h" -#include "loadparm.h" /* look in server.c for some explanation of these variables */ extern int DEBUGLEVEL; -- cgit From e23f2b9cef8428bda51b413642d9720ba5c590d5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 4 Oct 1996 09:31:07 +0000 Subject: - changed the umask handling. We now set the umask to 0 and explicitly set the mode on all created files. I think this is a better policy. - change the debug levels on some items - fix a charset handling bug which affected foreign and extended charset users - no longer switch back to the original directory when idle, instead switch to / as the original directory may not be readable by ordinary users. - fix some bugs where the create mode of files was not being explicitly set (it was relying on the umask and using fopen). Not a big bug as it only affected obscure commands like the messaging ops. - got rid of the lock code in the lpq cache as its no longer needed - rewrote smbrun to be faster and to remove the security hole. We now don't actually need a external smbrun binary, its all done by smbd. - add a more explicit warning about uids and gids of -1 or 65535 (This used to be commit 5aa735c940ccdb6acae5f28449d484181c912e49) --- source3/smbd/message.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index b26a6605ed..22523aad3b 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -42,8 +42,8 @@ static void msg_deliver(void) { pstring s; fstring name; - FILE *f; int i; + int fd; if (! (*lp_msg_command())) { @@ -56,21 +56,19 @@ static void msg_deliver(void) sprintf(s,"/tmp/msg.XXXXXX"); strcpy(name,(char *)mktemp(s)); - f = fopen(name,"w"); - if (!f) - { - DEBUG(1,("can't open message file %s\n",name)); - return; - } + fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); + if (fd == -1) { + DEBUG(1,("can't open message file %s\n",name)); + return; + } - for (i=0;i Date: Thu, 24 Oct 1996 00:09:08 +0000 Subject: - added support for TMPDIR env variable - fixed fault.c for linux 2.1 - put back in the FIND_SELF failing code - cleaned up casts in encryption (This used to be commit 3af04f1580b2569c0a4f2549bf6352c7a25afa0d) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 22523aad3b..2ef5b246c4 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -53,7 +53,7 @@ static void msg_deliver(void) } /* put it in a temporary file */ - sprintf(s,"/tmp/msg.XXXXXX"); + sprintf(s,"%s/msg.XXXXXX",tmpdir()); strcpy(name,(char *)mktemp(s)); fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); -- cgit From 0f1f0ceb9519368188f695e18e2341ccfd1b2d15 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Thu, 8 May 1997 01:14:17 +0000 Subject: 'The mother of all checkins' :-). Jeremy Allison (jallison@whistle.com) Wed May 7 1997: Update for 1.9.17alpha1 release - 'browsefix release' designed to make browsing across subnets work. byteorder.h: Updated copyright to 1997. charcnv.c: Updated copyright to 1997. charset.c Updated copyright to 1997. charset.h Updated copyright to 1997. client.c Updated copyright to 1997. clientutil.c Updated copyright to 1997. dir.c Updated copyright to 1997. fault.c Updated copyright to 1997. includes.h Updated copyright to 1997. interface.c Updated copyright to 1997. ipc.c Updated copyright to 1997. kanji.c Updated copyright to 1997. kanji.h Updated copyright to 1997. loadparm.c Updated copyright to 1997. locking.c Updated copyright to 1997. mangle.c Updated copyright to 1997. message.c Updated copyright to 1997. nameannounce.c Made use of WINS subnet explicit. Added reset_announce_timer() so announcement can be made immediately when we become a master. Expanded code to do sync with dmb. namebrowse.c Removed redundent checks for AM_MASTER in sync code. Made use of WINS subnet explicit. namedbname.c Made use of WINS subnet explicit. namedbresp.c Made use of WINS subnet explicit. namedbserver.c Made use of WINS subnet explicit. namedbsubnet.c Explicitly add workgroup to WINS subnet when we become a dmb. Made use of WINS subnet explicit. namedbwork.c Made use of WINS subnet explicit. Removed redundent check_work_servertype() function. nameelect.c Explicitly add workgroup to WINS subnet when we become a master browser. Made use of WINS subnet explicit. namelogon.c Updated copyright to 1997. namepacket.c Updated copyright to 1997. namequery.c Updated copyright to 1997. nameresp.c Made use of WINS subnet explicit. Made nmbd fail if configured as master browser and one exists already. nameserv.c Made use of WINS subnet explicit. Remove redundent logon server and domain master code. nameserv.h Add emumerate subnet macros. nameservreply.c Made use of WINS subnet explicit. nameservresp.c Updated copyright to 1997. namework.c Made use of WINS subnet explicit. Updated code to add sync browser entries to add subnet parameter. nmbd.c Added sanity check for misconfigured nmbd. nmblib.c Updated copyright to 1997. nmblookup.c Updated copyright to 1997. nmbsync.c Removed redundent AM_ANY_MASTER check. params.c Updated copyright to 1997. password.c Updated copyright to 1997. pipes.c Updated copyright to 1997. predict.c Updated copyright to 1997. printing.c Updated copyright to 1997. proto.h Changed protos for new nmbd code. quotas.c Updated copyright to 1997. replace.c Updated copyright to 1997. reply.c Updated copyright to 1997. server.c Updated copyright to 1997. shmem.c Updated copyright to 1997. smb.h Updated copyright to 1997. smbencrypt.c Updated copyright to 1997. smbpasswd.c Updated copyright to 1997. smbrun.c Updated copyright to 1997. status.c Updated copyright to 1997. system.c Updated copyright to 1997. testparm.c Updated copyright to 1997. testprns.c Updated copyright to 1997. time.c Updated copyright to 1997. trans2.c Updated copyright to 1997. trans2.h Updated copyright to 1997. uid.c Updated copyright to 1997. username.c Updated copyright to 1997. util.c Updated copyright to 1997. version.h Changed to 1.9.17alpha1. (This used to be commit cf23a155a1315f50d488794a2caf88402bf3e3e6) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 2ef5b246c4..93a2d9d850 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. SMB messaging - Copyright (C) Andrew Tridgell 1992-1995 + Copyright (C) Andrew Tridgell 1992-1997 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 cef59090bb2fd3f8a9efd1a453cb90264b891d58 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 26 Sep 1997 18:55:29 +0000 Subject: Adding Andrews buffer overflow fixes into the main branch. Jeremy (jallison@whistle.com) (This used to be commit e7eb1f044d3101679dc7a118820ea5efe0cd837c) --- source3/smbd/message.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 93a2d9d850..64253932ab 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -54,7 +54,7 @@ static void msg_deliver(void) /* put it in a temporary file */ sprintf(s,"%s/msg.XXXXXX",tmpdir()); - strcpy(name,(char *)mktemp(s)); + fstrcpy(name,(char *)mktemp(s)); fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); if (fd == -1) { @@ -74,7 +74,7 @@ static void msg_deliver(void) /* run the command */ if (*lp_msg_command()) { - strcpy(s,lp_msg_command()); + pstrcpy(s,lp_msg_command()); string_sub(s,"%s",name); string_sub(s,"%f",msgfrom); string_sub(s,"%t",msgto); @@ -108,8 +108,8 @@ int reply_sends(char *inbuf,char *outbuf) dest = skip_string(orig,1)+1; msg = skip_string(dest,1)+1; - strcpy(msgfrom,orig); - strcpy(msgto,dest); + fstrcpy(msgfrom,orig); + fstrcpy(msgto,dest); len = SVAL(msg,0); len = MIN(len,1600-msgpos); @@ -143,10 +143,10 @@ int reply_sendstrt(char *inbuf,char *outbuf) orig = smb_buf(inbuf)+1; dest = skip_string(orig,1)+1; - strcpy(msgfrom,orig); - strcpy(msgto,dest); + fstrcpy(msgfrom,orig); + fstrcpy(msgto,dest); - DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),orig,dest)); + DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),msgfrom,msgto)); return(outsize); } -- cgit From 55f400bd84f26027f5ec9b7fa06b22895de7557c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jan 1998 13:27:43 +0000 Subject: This is *not* a big change (although it looks like one). This is merely updating the Copyright statements from 1997 to 1998. It's a once a year thing :-). NO OTHER CHANGES WERE MADE. Jeremy. (This used to be commit b9c16977231efb274e08856f7f3f4408dad6d96c) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 64253932ab..8c3f6f6630 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. SMB messaging - Copyright (C) Andrew Tridgell 1992-1997 + 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 -- cgit From cac6a060af598bf94e6414b06e7365ec51ca360e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Apr 1998 19:24:06 +0000 Subject: Changes to allow Samba to be compiled with -Wstrict-prototypes with gcc. (Not a big change although it looks like it :-). Jeremy. (This used to be commit cd2613c57261456485fe4eeecfda209ada70de8e) --- source3/smbd/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 8c3f6f6630..24477f31ff 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -90,7 +90,7 @@ static void msg_deliver(void) /**************************************************************************** reply to a sends ****************************************************************************/ -int reply_sends(char *inbuf,char *outbuf) +int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; char *orig,*dest,*msg; @@ -128,7 +128,7 @@ int reply_sends(char *inbuf,char *outbuf) /**************************************************************************** reply to a sendstrt ****************************************************************************/ -int reply_sendstrt(char *inbuf,char *outbuf) +int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { char *orig,*dest; int outsize = 0; @@ -155,7 +155,7 @@ int reply_sendstrt(char *inbuf,char *outbuf) /**************************************************************************** reply to a sendtxt ****************************************************************************/ -int reply_sendtxt(char *inbuf,char *outbuf) +int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; int outsize = 0; @@ -183,7 +183,7 @@ int reply_sendtxt(char *inbuf,char *outbuf) /**************************************************************************** reply to a sendend ****************************************************************************/ -int reply_sendend(char *inbuf,char *outbuf) +int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int outsize = 0; -- cgit From a2bddb20ed078c3e1b9cb60a7420b3d107898f52 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 May 1998 01:34:51 +0000 Subject: Fixes for the %U and %G problems people have reported. Essentially, multiple session_setup_and_X's may be done to an smbd. As there is only one global variable containing the requested connection name (sessionsetup_user), then any subsequent sessionsetups overwrite this name (causing %U and %G to get the wrong name). This is particularly common when an NT client does a null session setup to get a browse list after the user has connected, but before a share has been mounted. These changes store the requested_name in the vuid structure (so this only really works for user level and above security) and copies this name back into the global variable before the standard_sub call. Jeremy. (This used to be commit b5187ad6a3b3af9fbbeee8bced0ab16b41e9825b) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 24477f31ff..9fb506edd0 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -78,7 +78,7 @@ static void msg_deliver(void) string_sub(s,"%s",name); string_sub(s,"%f",msgfrom); string_sub(s,"%t",msgto); - standard_sub(-1,s); + standard_sub(-1,s,UID_FIELD_INVALID); smbrun(s,NULL,False); } -- cgit From 01df1ed95f880a671ead7bc92b3bcff01a2e2dc0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 May 1998 19:04:14 +0000 Subject: This should (hopefully :-) be the final fix for the %U %G substitution problem.... smbpass.c: Removed Luke's dire warning - as some of the functions in here *need* to be called externally :-). Jeremy. (This used to be commit 1fd8d12ca414066acec71b33eb8a13e16c2acd3a) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 9fb506edd0..24477f31ff 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -78,7 +78,7 @@ static void msg_deliver(void) string_sub(s,"%s",name); string_sub(s,"%f",msgfrom); string_sub(s,"%t",msgto); - standard_sub(-1,s,UID_FIELD_INVALID); + standard_sub(-1,s); smbrun(s,NULL,False); } -- cgit From 3dfc0c847240ac7e12c39f4ed9c31a888949ade1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 May 1998 06:38:36 +0000 Subject: changed to use slprintf() instead of sprintf() just about everywhere. I've implemented slprintf() as a bounds checked sprintf() using mprotect() and a non-writeable page. This should prevent any sprintf based security holes. (This used to be commit ee09e9dadb69aaba5a751dd20ccc6d587d841bd6) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 24477f31ff..b368c4d031 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -53,7 +53,7 @@ static void msg_deliver(void) } /* put it in a temporary file */ - sprintf(s,"%s/msg.XXXXXX",tmpdir()); + slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir()); fstrcpy(name,(char *)mktemp(s)); fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); -- cgit From 28900ea26ff1c8d41328bba30206db7fe91e2184 Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Fri, 31 Jul 1998 22:39:15 +0000 Subject: As per a Andrew's message, I went through and removed the timestring() timestamps from several DEBUG messages. The timestamps are redundant now that DEBUG() provides them automatically. There are still a few more files to do, but I've got to get home for dinner. Chris -)----- (This used to be commit 60286ccecaa6028d687e6406755016455e3b3a26) --- source3/smbd/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index b368c4d031..44ae272bdd 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -117,7 +117,7 @@ int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) memcpy(&msgbuf[msgpos],msg+2,len); msgpos += len; - DEBUG(3,("%s SMBsends (from %s to %s)\n",timestring(),orig,dest)); + DEBUG( 3, ( "SMBsends (from %s to %s)\n", orig, dest ) ); msg_deliver(); @@ -146,7 +146,7 @@ int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) fstrcpy(msgfrom,orig); fstrcpy(msgto,dest); - DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),msgfrom,msgto)); + DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); return(outsize); } @@ -174,7 +174,7 @@ int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) memcpy(&msgbuf[msgpos],msg+2,len); msgpos += len; - DEBUG(3,("%s SMBsendtxt\n",timestring())); + DEBUG( 3, ( "SMBsendtxt\n" ) ); return(outsize); } @@ -192,7 +192,7 @@ int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) outsize = set_message(outbuf,0,0,True); - DEBUG(3,("%s SMBsendend\n",timestring())); + DEBUG( 3, ( "%s SMBsendend\n" ) ); msg_deliver(); -- cgit From b9623ab59e813131b1ed3f51616a46e719d59c21 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 14 Aug 1998 17:38:29 +0000 Subject: this is the bug change to using connection_struct* instead of cnum. Connections[] is now a local array in server.c I might have broken something with this change. In particular the oplock code is suspect and some .dll files aren't being oplocked when I expected them to be. I'll look at it after I've got some sleep. (This used to be commit c7ee025ead4a85b6fa44a832047b878451845fb6) --- source3/smbd/message.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 44ae272bdd..001fc652b2 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -78,7 +78,7 @@ static void msg_deliver(void) string_sub(s,"%s",name); string_sub(s,"%f",msgfrom); string_sub(s,"%t",msgto); - standard_sub(-1,s); + standard_sub_basic(s); smbrun(s,NULL,False); } @@ -90,7 +90,8 @@ static void msg_deliver(void) /**************************************************************************** reply to a sends ****************************************************************************/ -int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +int reply_sends(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; char *orig,*dest,*msg; @@ -128,7 +129,8 @@ int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) /**************************************************************************** reply to a sendstrt ****************************************************************************/ -int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +int reply_sendstrt(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { char *orig,*dest; int outsize = 0; @@ -155,7 +157,8 @@ int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) /**************************************************************************** reply to a sendtxt ****************************************************************************/ -int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +int reply_sendtxt(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; int outsize = 0; @@ -183,7 +186,8 @@ int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) /**************************************************************************** reply to a sendend ****************************************************************************/ -int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +int reply_sendend(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int outsize = 0; @@ -192,7 +196,7 @@ int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize) outsize = set_message(outbuf,0,0,True); - DEBUG( 3, ( "%s SMBsendend\n" ) ); + DEBUG(3,("SMBsendend\n")); msg_deliver(); -- cgit From 768761820e8d7481c586c4e0ab4ac7cb36d18c4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Nov 1998 20:50:07 +0000 Subject: Added the same open()/fopen()/creat()/mmap() -> sys_XXX calls. Tidied up some of the mess (no other word for it). Still doesn't compile cleanly. There are calls with incorrect parameters that don't seem to be doing the right thing. This code still needs surgery :-(. Jeremy. (This used to be commit 18ff93a9abbf68ee8c59c0af3e57c63e4a015dac) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 001fc652b2..d13dfda1e0 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -56,7 +56,7 @@ static void msg_deliver(void) slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir()); fstrcpy(name,(char *)mktemp(s)); - fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); + fd = sys_open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); if (fd == -1) { DEBUG(1,("can't open message file %s\n",name)); return; -- 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/message.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index d13dfda1e0..2f94bdf111 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -54,7 +54,7 @@ static void msg_deliver(void) /* put it in a temporary file */ slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir()); - fstrcpy(name,(char *)mktemp(s)); + fstrcpy(name,(char *)smbd_mktemp(s)); fd = sys_open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); if (fd == -1) { @@ -74,10 +74,13 @@ static void msg_deliver(void) /* run the command */ if (*lp_msg_command()) { + fstring alpha_msgfrom; + fstring alpha_msgto; + pstrcpy(s,lp_msg_command()); - string_sub(s,"%s",name); - string_sub(s,"%f",msgfrom); - string_sub(s,"%t",msgto); + pstring_sub(s,"%s",name); + pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,sizeof(alpha_msgfrom))); + pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto))); standard_sub_basic(s); smbrun(s,NULL,False); } @@ -99,7 +102,6 @@ int reply_sends(connection_struct *conn, msgpos = 0; - if (! (*lp_msg_command())) return(ERROR(ERRSRV,ERRmsgoff)); @@ -113,7 +115,9 @@ int reply_sends(connection_struct *conn, fstrcpy(msgto,dest); len = SVAL(msg,0); - len = MIN(len,1600-msgpos); + len = MIN(len,sizeof(msgbuf)-msgpos); + + memset(msgbuf,'\0',sizeof(msgbuf)); memcpy(&msgbuf[msgpos],msg+2,len); msgpos += len; @@ -140,6 +144,7 @@ int reply_sendstrt(connection_struct *conn, outsize = set_message(outbuf,1,0,True); + memset(msgbuf,'\0',sizeof(msgbuf)); msgpos = 0; orig = smb_buf(inbuf)+1; @@ -172,7 +177,7 @@ int reply_sendtxt(connection_struct *conn, msg = smb_buf(inbuf) + 1; len = SVAL(msg,0); - len = MIN(len,1600-msgpos); + len = MIN(len,sizeof(msgbuf)-msgpos); memcpy(&msgbuf[msgpos],msg+2,len); msgpos += len; @@ -202,4 +207,3 @@ int reply_sendend(connection_struct *conn, return(outsize); } - -- cgit From 451dcb3351461f52fee619e0d8a1b04d31725181 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 27 Jan 2000 01:09:21 +0000 Subject: Fixed code page conversions of messages outgoing/incoming. Jeremy. (This used to be commit 84b045cbc8b337f1e23f200af433ac9d265a22d4) --- source3/smbd/message.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 2f94bdf111..cc329d61a6 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -62,6 +62,16 @@ static void msg_deliver(void) return; } + /* + * Incoming message is in DOS codepage format. Convert to UNIX in + * place. + */ + + if(msgpos > 0) { + msgbuf[msgpos] = '\0'; /* Ensure null terminated. */ + dos_to_unix(msgbuf,True); + } + for (i=0;i 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/message.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index cc329d61a6..a65539affa 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -1,3 +1,5 @@ +#define OLD_NTDOMAIN 1 + /* Unix SMB/Netbios implementation. Version 1.9. @@ -217,3 +219,5 @@ int reply_sendend(connection_struct *conn, return(outsize); } + +#undef OLD_NTDOMAIN -- 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/message.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index a65539affa..ab3c841d9c 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -111,11 +111,14 @@ int reply_sends(connection_struct *conn, int len; char *orig,*dest,*msg; int outsize = 0; + START_PROFILE(SMBsends); msgpos = 0; - if (! (*lp_msg_command())) + if (! (*lp_msg_command())) { + END_PROFILE(SMBsends); return(ERROR(ERRSRV,ERRmsgoff)); + } outsize = set_message(outbuf,0,0,True); @@ -138,6 +141,7 @@ int reply_sends(connection_struct *conn, msg_deliver(); + END_PROFILE(SMBsends); return(outsize); } @@ -150,9 +154,12 @@ int reply_sendstrt(connection_struct *conn, { char *orig,*dest; int outsize = 0; + START_PROFILE(SMBsendstrt); - if (! (*lp_msg_command())) + if (! (*lp_msg_command())) { + END_PROFILE(SMBsendstrt); return(ERROR(ERRSRV,ERRmsgoff)); + } outsize = set_message(outbuf,1,0,True); @@ -167,6 +174,7 @@ int reply_sendstrt(connection_struct *conn, DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); + END_PROFILE(SMBsendstrt); return(outsize); } @@ -180,9 +188,12 @@ int reply_sendtxt(connection_struct *conn, int len; int outsize = 0; char *msg; + START_PROFILE(SMBsendtxt); - if (! (*lp_msg_command())) + if (! (*lp_msg_command())) { + END_PROFILE(SMBsendtxt); return(ERROR(ERRSRV,ERRmsgoff)); + } outsize = set_message(outbuf,0,0,True); @@ -196,6 +207,7 @@ int reply_sendtxt(connection_struct *conn, DEBUG( 3, ( "SMBsendtxt\n" ) ); + END_PROFILE(SMBsendtxt); return(outsize); } @@ -207,9 +219,12 @@ int reply_sendend(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int outsize = 0; + START_PROFILE(SMBsendend); - if (! (*lp_msg_command())) + if (! (*lp_msg_command())) { + END_PROFILE(SMBsendend); return(ERROR(ERRSRV,ERRmsgoff)); + } outsize = set_message(outbuf,0,0,True); @@ -217,6 +232,7 @@ int reply_sendend(connection_struct *conn, msg_deliver(); + END_PROFILE(SMBsendend); return(outsize); } -- 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/message.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index ab3c841d9c..3afe7218e0 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -1,5 +1,3 @@ -#define OLD_NTDOMAIN 1 - /* Unix SMB/Netbios implementation. Version 1.9. @@ -235,5 +233,3 @@ int reply_sendend(connection_struct *conn, END_PROFILE(SMBsendend); return(outsize); } - -#undef OLD_NTDOMAIN -- cgit From 376a44c81d360026eb0c2886e9a05dd2bfefd2cc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 14 Mar 2001 11:55:08 +0000 Subject: converted the smb messaging code to unicode (This used to be commit 54bde1b3aec829ba55b8a6c946424fdaf38803a9) --- source3/smbd/message.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 3afe7218e0..21750f9cd4 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -31,9 +31,9 @@ extern int DEBUGLEVEL; static char msgbuf[1600]; -static int msgpos=0; -static fstring msgfrom=""; -static fstring msgto=""; +static int msgpos; +static fstring msgfrom; +static fstring msgto; /**************************************************************************** deliver the message @@ -107,8 +107,10 @@ int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; - char *orig,*dest,*msg; + char *msg; int outsize = 0; + char *p; + START_PROFILE(SMBsends); msgpos = 0; @@ -120,12 +122,11 @@ int reply_sends(connection_struct *conn, outsize = set_message(outbuf,0,0,True); - orig = smb_buf(inbuf)+1; - dest = skip_string(orig,1)+1; - msg = skip_string(dest,1)+1; + p = smb_buf(inbuf)+1; + p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE|STR_CONVERT) + 1; + p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE|STR_CONVERT) + 1; - fstrcpy(msgfrom,orig); - fstrcpy(msgto,dest); + msg = p; len = SVAL(msg,0); len = MIN(len,sizeof(msgbuf)-msgpos); @@ -135,8 +136,6 @@ int reply_sends(connection_struct *conn, memcpy(&msgbuf[msgpos],msg+2,len); msgpos += len; - DEBUG( 3, ( "SMBsends (from %s to %s)\n", orig, dest ) ); - msg_deliver(); END_PROFILE(SMBsends); @@ -150,8 +149,9 @@ int reply_sends(connection_struct *conn, int reply_sendstrt(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - char *orig,*dest; int outsize = 0; + char *p; + START_PROFILE(SMBsendstrt); if (! (*lp_msg_command())) { @@ -164,11 +164,9 @@ int reply_sendstrt(connection_struct *conn, memset(msgbuf,'\0',sizeof(msgbuf)); msgpos = 0; - orig = smb_buf(inbuf)+1; - dest = skip_string(orig,1)+1; - - fstrcpy(msgfrom,orig); - fstrcpy(msgto,dest); + p = smb_buf(inbuf)+1; + p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE|STR_CONVERT) + 1; + p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE|STR_CONVERT) + 1; DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); -- cgit From 6578fd874283ee97c2896bcf7257db7f3e37c2ec Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Apr 2001 23:19:08 +0000 Subject: To stop people complaining about the mktemp call, move it into lib/util.c. Thanks to Andrew for all this code. Fixed extra line in lib/sysacls.c that broke XFS ACL code. Jeremy. (This used to be commit 9b32b8a8cfc8ddb93c14d5581f433d2e93f89ed2) --- source3/smbd/message.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 21750f9cd4..9206442b94 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -40,8 +40,7 @@ deliver the message ****************************************************************************/ static void msg_deliver(void) { - pstring s; - fstring name; + pstring name; int i; int fd; @@ -53,10 +52,9 @@ static void msg_deliver(void) } /* put it in a temporary file */ - slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir()); - fstrcpy(name,(char *)smbd_mktemp(s)); + slprintf(name,sizeof(name)-1, "%s/msg.XXXXXX",tmpdir()); + fd = smb_mkstemp(name); - fd = sys_open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600); if (fd == -1) { DEBUG(1,("can't open message file %s\n",name)); return; @@ -86,12 +84,13 @@ static void msg_deliver(void) { fstring alpha_msgfrom; fstring alpha_msgto; + pstring s; pstrcpy(s,lp_msg_command()); - pstring_sub(s,"%s",name); pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,sizeof(alpha_msgfrom))); pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto))); standard_sub_basic(s); + pstring_sub(s,"%s",name); smbrun(s,NULL,False); } -- cgit From 50e78a9ac8cf0949c2471fafde844c674f97d73d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Apr 2001 00:37:00 +0000 Subject: As Andrew suggested, make smbrun return a fd for a deleted file which can then be read. Jeremy. (This used to be commit e7d59d6de89a5fdd201e4b5c6072dab08b1519db) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 9206442b94..01b5f51acc 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -91,7 +91,7 @@ static void msg_deliver(void) pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto))); standard_sub_basic(s); pstring_sub(s,"%s",name); - smbrun(s,NULL,False); + smbrun(s,NULL,NULL); } msgpos = 0; -- cgit From 2ef68c7e92d4661664f0410509f7cb551e74a198 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Apr 2001 19:12:06 +0000 Subject: Merge of Andrew's changes in 2.2. Jeremy. (This used to be commit fc76681812b1469208ad6c8847afdfc68bc6db49) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 01b5f51acc..98eb336c0a 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -91,7 +91,7 @@ static void msg_deliver(void) pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto))); standard_sub_basic(s); pstring_sub(s,"%s",name); - smbrun(s,NULL,NULL); + smbrun(s,NULL); } msgpos = 0; -- cgit From fda0f83d751a1ea6c731fd6a82484a724a1c6e32 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 21 Jun 2001 01:01:15 +0000 Subject: Following info from TAKAHASHI Motonobu , Samba Users Group Japan, ensure that we don't use dos_to_unix(xx,True), but always use dos_to_unix(xx,False) to prevent overwriting. Jeremy. (This used to be commit 244aec8ea623fec828add3ab09c5003bf32bd5c7) --- source3/smbd/message.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 98eb336c0a..a023650c74 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -61,13 +61,12 @@ static void msg_deliver(void) } /* - * Incoming message is in DOS codepage format. Convert to UNIX in - * place. + * Incoming message is in DOS codepage format. Convert to UNIX. */ if(msgpos > 0) { msgbuf[msgpos] = '\0'; /* Ensure null terminated. */ - dos_to_unix(msgbuf,True); + pstrcpy(msgbuf,dos_to_unix(msgbuf,False)); } for (i=0;i Date: Sat, 23 Jun 2001 07:22:16 +0000 Subject: Added other_safe_chars to alpha_strcpy(). Needs testing but is a better fix for the problem. Jeremy. (This used to be commit e059fffd03a1382fb2b7059b6de369d9fc765a17) --- source3/smbd/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index a023650c74..bae9f6c906 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -86,8 +86,8 @@ static void msg_deliver(void) pstring s; pstrcpy(s,lp_msg_command()); - pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,sizeof(alpha_msgfrom))); - pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto))); + pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); + pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); standard_sub_basic(s); pstring_sub(s,"%s",name); smbrun(s,NULL); -- 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/message.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index bae9f6c906..a5726d44f8 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -66,7 +66,6 @@ static void msg_deliver(void) if(msgpos > 0) { msgbuf[msgpos] = '\0'; /* Ensure null terminated. */ - pstrcpy(msgbuf,dos_to_unix(msgbuf,False)); } for (i=0;i 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/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index a5726d44f8..f2e88352ee 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -114,7 +114,7 @@ int reply_sends(connection_struct *conn, if (! (*lp_msg_command())) { END_PROFILE(SMBsends); - return(ERROR(ERRSRV,ERRmsgoff)); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); } outsize = set_message(outbuf,0,0,True); @@ -153,7 +153,7 @@ int reply_sendstrt(connection_struct *conn, if (! (*lp_msg_command())) { END_PROFILE(SMBsendstrt); - return(ERROR(ERRSRV,ERRmsgoff)); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); } outsize = set_message(outbuf,1,0,True); @@ -185,7 +185,7 @@ int reply_sendtxt(connection_struct *conn, if (! (*lp_msg_command())) { END_PROFILE(SMBsendtxt); - return(ERROR(ERRSRV,ERRmsgoff)); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); } outsize = set_message(outbuf,0,0,True); @@ -216,7 +216,7 @@ int reply_sendend(connection_struct *conn, if (! (*lp_msg_command())) { END_PROFILE(SMBsendend); - return(ERROR(ERRSRV,ERRmsgoff)); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); } outsize = set_message(outbuf,0,0,True); -- 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/message.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index f2e88352ee..7cc53e082c 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -27,9 +27,6 @@ #include "includes.h" /* look in server.c for some explanation of these variables */ -extern int DEBUGLEVEL; - - static char msgbuf[1600]; static int msgpos; static fstring msgfrom; -- cgit From e0066d2dd4d9a657d1fbcb474e66a304a64e2a31 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 6 Dec 2001 13:09:15 +0000 Subject: again an intrusive patch: - removed the ugly as hell sam_logon_in_ssb variable, I changed a bit the definition of standard_sub_basic() to cope with that. - removed the smb.conf: 'domain admin group' and 'domain guest group' parameters ! We're not playing anymore with the user's group RIDs ! - in get_domain_user_groups(), if the user's gid is a group, put it first in the group RID list. I just have to write an HOWTO now ;-) J.F. (This used to be commit fef52c4b96c987115fb1818c00c2352c67790e50) --- source3/smbd/message.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 7cc53e082c..a3625e3716 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -26,6 +26,8 @@ #include "includes.h" +extern userdom_struct current_user_info; + /* look in server.c for some explanation of these variables */ static char msgbuf[1600]; static int msgpos; @@ -84,7 +86,7 @@ static void msg_deliver(void) pstrcpy(s,lp_msg_command()); pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); - standard_sub_basic(s); + standard_sub_basic(current_user_info.smb_name, s); pstring_sub(s,"%s",name); smbrun(s,NULL); } -- 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/message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index a3625e3716..971834c012 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. + Unix SMB/CIFS implementation. SMB messaging Copyright (C) Andrew Tridgell 1992-1998 -- 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/message.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 971834c012..ba646f12aa 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -85,7 +85,7 @@ static void msg_deliver(void) pstrcpy(s,lp_msg_command()); pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); - standard_sub_basic(current_user_info.smb_name, s); + standard_sub_basic(current_user_info.smb_name, s, sizeof(s)); pstring_sub(s,"%s",name); smbrun(s,NULL); } @@ -118,8 +118,8 @@ int reply_sends(connection_struct *conn, outsize = set_message(outbuf,0,0,True); p = smb_buf(inbuf)+1; - p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE) + 1; - p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_TERMINATE) + 1; msg = p; @@ -160,8 +160,8 @@ int reply_sendstrt(connection_struct *conn, msgpos = 0; p = smb_buf(inbuf)+1; - p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE) + 1; - p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_TERMINATE) + 1; DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); -- cgit From 0b72dd8325bc5c78de56039942acc175d28042a7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 16:44:14 +0000 Subject: Patch from Samuel Thibault to convert messages from dos to unix charset when sending(and vice versa when receiving). (This used to be commit 5310447ec6e0df1c000e3ee14572f5b7fee31f28) --- source3/smbd/message.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index ba646f12aa..233848d2d6 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -41,6 +41,8 @@ static void msg_deliver(void) pstring name; int i; int fd; + char *msg; + int len; if (! (*lp_msg_command())) { @@ -61,16 +63,23 @@ static void msg_deliver(void) /* * Incoming message is in DOS codepage format. Convert to UNIX. */ - - if(msgpos > 0) { - msgbuf[msgpos] = '\0'; /* Ensure null terminated. */ - } - - for (i=0;i Date: Wed, 20 Aug 2003 22:06:19 +0000 Subject: Attempt to fix the charcnv issues causing nmbd to crash. If we get a failed conversion simply copy as is. Also fixed the horrid malloc-twice-copy code in the convert alloc path. Jeremy. (This used to be commit cfde7477fd12caef943a9422b52174438092a135) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 233848d2d6..88f833e468 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -64,7 +64,7 @@ static void msg_deliver(void) * Incoming message is in DOS codepage format. Convert to UNIX. */ - if ((len = convert_string_allocate(CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg)) < 0 || !msg) { + if ((len = convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg)) < 0 || !msg) { DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); for (i = 0; i < msgpos;) { if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { -- cgit From e3f5b542707e2328030b9d5eff0836a904eccde5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Mar 2004 22:48:24 +0000 Subject: Restore the contract on all convert_stringXX() interfaces. Add a "allow_bad_conv" boolean parameter that allows broken iconv conversions to work. Gets rid of the nasty errno checks in mangle_hash2 and check_path_syntax and allows correct return code checking. Jeremy. (This used to be commit 7b96765c23637613f079d37566d95d5edd511f05) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 88f833e468..f853a91475 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -64,7 +64,7 @@ static void msg_deliver(void) * Incoming message is in DOS codepage format. Convert to UNIX. */ - if ((len = convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg)) < 0 || !msg) { + if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg, True)) < 0 || !msg) { DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); for (i = 0; i < msgpos;) { if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { -- cgit From 94b88f8f26342b6ca4afecec459235c523355f6c Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 12 Jan 2005 09:54:50 +0000 Subject: r4704: Fix encoding while receiving of a message which was actually sent using STR_ASCII. Patch from Grigory Batalov (This used to be commit dddd5726462c13374788713ad5ddcbdf9ee7b439) --- source3/smbd/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index f853a91475..5af7d3e451 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -127,8 +127,8 @@ int reply_sends(connection_struct *conn, outsize = set_message(outbuf,0,0,True); p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; msg = p; @@ -169,8 +169,8 @@ int reply_sendstrt(connection_struct *conn, msgpos = 0; p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/smbd/message.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 5af7d3e451..e975da3e15 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -43,6 +43,7 @@ static void msg_deliver(void) int fd; char *msg; int len; + ssize_t sz; if (! (*lp_msg_command())) { @@ -70,14 +71,20 @@ static void msg_deliver(void) if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { i++; continue; } - write(fd, &msgbuf[i++], 1); + sz = write(fd, &msgbuf[i++], 1); + if ( sz != 1 ) { + DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); + } } } else { for (i = 0; i < len;) { if (msg[i] == '\r' && i < (len-1) && msg[i+1] == '\n') { i++; continue; } - write(fd, &msg[i++],1); + sz = write(fd, &msg[i++],1); + if ( sz != 1 ) { + DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); + } } SAFE_FREE(msg); } -- cgit From d1f91f7c723733113b4e9792042101c80dfc064c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Dec 2005 06:46:46 +0000 Subject: r12043: It's amazing the warnings you find when compiling on a 64-bit box with gcc4 and -O6... Fix a bunch of C99 dereferencing type-punned pointer will break strict-aliasing rules errors. Also added prs_int32 (not uint32...) as it's needed in one place. Find places where prs_uint32 was being used to marshall/unmarshall a time_t (a big no no on 64-bits). More warning fixes to come. Thanks to Volker for nudging me to compile like this. Jeremy. (This used to be commit c65b752604f8f58abc4e7ae8514dc2c7f086271c) --- source3/smbd/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index e975da3e15..fd28df0d80 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -65,7 +65,7 @@ static void msg_deliver(void) * Incoming message is in DOS codepage format. Convert to UNIX. */ - if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg, True)) < 0 || !msg) { + if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **)(void *)&msg, True)) < 0 || !msg) { DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); for (i = 0; i < msgpos;) { if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { -- 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/message.c | 305 ++++++++++++++++++++++++------------------------- 1 file changed, 152 insertions(+), 153 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index fd28df0d80..31dab45844 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -34,211 +34,210 @@ static fstring msgfrom; static fstring msgto; /**************************************************************************** -deliver the message + Deliver the message. ****************************************************************************/ + static void msg_deliver(void) { - pstring name; - int i; - int fd; - char *msg; - int len; - ssize_t sz; - - if (! (*lp_msg_command())) - { - DEBUG(1,("no messaging command specified\n")); - msgpos = 0; - return; - } - - /* put it in a temporary file */ - slprintf(name,sizeof(name)-1, "%s/msg.XXXXXX",tmpdir()); - fd = smb_mkstemp(name); - - if (fd == -1) { - DEBUG(1,("can't open message file %s\n",name)); - return; - } - - /* - * Incoming message is in DOS codepage format. Convert to UNIX. - */ + pstring name; + int i; + int fd; + char *msg; + int len; + ssize_t sz; + + if (! (*lp_msg_command())) { + DEBUG(1,("no messaging command specified\n")); + msgpos = 0; + return; + } + + /* put it in a temporary file */ + slprintf(name,sizeof(name)-1, "%s/msg.XXXXXX",tmpdir()); + fd = smb_mkstemp(name); + + if (fd == -1) { + DEBUG(1,("can't open message file %s\n",name)); + return; + } + + /* + * Incoming message is in DOS codepage format. Convert to UNIX. + */ - if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **)(void *)&msg, True)) < 0 || !msg) { - DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); - for (i = 0; i < msgpos;) { - if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { - i++; continue; - } - sz = write(fd, &msgbuf[i++], 1); - if ( sz != 1 ) { - DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); - } - } - } else { - for (i = 0; i < len;) { - if (msg[i] == '\r' && i < (len-1) && msg[i+1] == '\n') { - i++; continue; - } - sz = write(fd, &msg[i++],1); - if ( sz != 1 ) { - DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); - } - } - SAFE_FREE(msg); - } - close(fd); - - - /* run the command */ - if (*lp_msg_command()) - { - fstring alpha_msgfrom; - fstring alpha_msgto; - pstring s; - - pstrcpy(s,lp_msg_command()); - pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); - pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); - standard_sub_basic(current_user_info.smb_name, s, sizeof(s)); - pstring_sub(s,"%s",name); - smbrun(s,NULL); - } - - msgpos = 0; + if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **)(void *)&msg, True)) < 0 || !msg) { + DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); + for (i = 0; i < msgpos;) { + if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { + i++; + continue; + } + sz = write(fd, &msgbuf[i++], 1); + if ( sz != 1 ) { + DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); + } + } + } else { + for (i = 0; i < len;) { + if (msg[i] == '\r' && i < (len-1) && msg[i+1] == '\n') { + i++; + continue; + } + sz = write(fd, &msg[i++],1); + if ( sz != 1 ) { + DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); + } + } + SAFE_FREE(msg); + } + close(fd); + + /* run the command */ + if (*lp_msg_command()) { + fstring alpha_msgfrom; + fstring alpha_msgto; + pstring s; + + pstrcpy(s,lp_msg_command()); + pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); + pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); + standard_sub_basic(current_user_info.smb_name, s, sizeof(s)); + pstring_sub(s,"%s",name); + smbrun(s,NULL); + } + + msgpos = 0; } - - /**************************************************************************** - reply to a sends + Reply to a sends. + conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sends(connection_struct *conn, - char *inbuf,char *outbuf, int dum_size, int dum_buffsize) + +int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - int len; - char *msg; - int outsize = 0; - char *p; + int len; + char *msg; + int outsize = 0; + char *p; - START_PROFILE(SMBsends); + START_PROFILE(SMBsends); - msgpos = 0; + msgpos = 0; - if (! (*lp_msg_command())) { - END_PROFILE(SMBsends); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); - } + if (! (*lp_msg_command())) { + END_PROFILE(SMBsends); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); + } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,True); - p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; + p = smb_buf(inbuf)+1; + p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; - msg = p; + msg = p; - len = SVAL(msg,0); - len = MIN(len,sizeof(msgbuf)-msgpos); + len = SVAL(msg,0); + len = MIN(len,sizeof(msgbuf)-msgpos); - memset(msgbuf,'\0',sizeof(msgbuf)); + memset(msgbuf,'\0',sizeof(msgbuf)); - memcpy(&msgbuf[msgpos],msg+2,len); - msgpos += len; + memcpy(&msgbuf[msgpos],msg+2,len); + msgpos += len; - msg_deliver(); + msg_deliver(); - END_PROFILE(SMBsends); - return(outsize); + END_PROFILE(SMBsends); + return(outsize); } - /**************************************************************************** - reply to a sendstrt + Reply to a sendstrt. + conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sendstrt(connection_struct *conn, - char *inbuf,char *outbuf, int dum_size, int dum_buffsize) + +int reply_sendstrt(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - int outsize = 0; - char *p; + int outsize = 0; + char *p; - START_PROFILE(SMBsendstrt); + START_PROFILE(SMBsendstrt); - if (! (*lp_msg_command())) { - END_PROFILE(SMBsendstrt); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); - } + if (! (*lp_msg_command())) { + END_PROFILE(SMBsendstrt); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); + } - outsize = set_message(outbuf,1,0,True); + outsize = set_message(outbuf,1,0,True); - memset(msgbuf,'\0',sizeof(msgbuf)); - msgpos = 0; + memset(msgbuf,'\0',sizeof(msgbuf)); + msgpos = 0; - p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; + p = smb_buf(inbuf)+1; + p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; - DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); + DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); - END_PROFILE(SMBsendstrt); - return(outsize); + END_PROFILE(SMBsendstrt); + return(outsize); } - /**************************************************************************** - reply to a sendtxt + Reply to a sendtxt. + conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sendtxt(connection_struct *conn, - char *inbuf,char *outbuf, int dum_size, int dum_buffsize) + +int reply_sendtxt(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - int len; - int outsize = 0; - char *msg; - START_PROFILE(SMBsendtxt); + int len; + int outsize = 0; + char *msg; + START_PROFILE(SMBsendtxt); - if (! (*lp_msg_command())) { - END_PROFILE(SMBsendtxt); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); - } + if (! (*lp_msg_command())) { + END_PROFILE(SMBsendtxt); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); + } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,True); - msg = smb_buf(inbuf) + 1; + msg = smb_buf(inbuf) + 1; - len = SVAL(msg,0); - len = MIN(len,sizeof(msgbuf)-msgpos); + len = SVAL(msg,0); + len = MIN(len,sizeof(msgbuf)-msgpos); - memcpy(&msgbuf[msgpos],msg+2,len); - msgpos += len; + memcpy(&msgbuf[msgpos],msg+2,len); + msgpos += len; - DEBUG( 3, ( "SMBsendtxt\n" ) ); + DEBUG( 3, ( "SMBsendtxt\n" ) ); - END_PROFILE(SMBsendtxt); - return(outsize); + END_PROFILE(SMBsendtxt); + return(outsize); } - /**************************************************************************** - reply to a sendend + Reply to a sendend. + conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sendend(connection_struct *conn, - char *inbuf,char *outbuf, int dum_size, int dum_buffsize) + +int reply_sendend(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - int outsize = 0; - START_PROFILE(SMBsendend); + int outsize = 0; + START_PROFILE(SMBsendend); - if (! (*lp_msg_command())) { - END_PROFILE(SMBsendend); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); - } + if (! (*lp_msg_command())) { + END_PROFILE(SMBsendend); + return(ERROR_DOS(ERRSRV,ERRmsgoff)); + } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(outbuf,0,0,True); - DEBUG(3,("SMBsendend\n")); + DEBUG(3,("SMBsendend\n")); - msg_deliver(); + msg_deliver(); - END_PROFILE(SMBsendend); - return(outsize); + END_PROFILE(SMBsendend); + return(outsize); } -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/smbd/message.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 31dab45844..fd53e60c14 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -101,7 +101,8 @@ static void msg_deliver(void) pstrcpy(s,lp_msg_command()); pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); - standard_sub_basic(current_user_info.smb_name, s, sizeof(s)); + standard_sub_basic(current_user_info.smb_name, + current_user_info.domain, s, sizeof(s)); pstring_sub(s,"%s",name); smbrun(s,NULL); } -- 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/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index fd53e60c14..e6a5015276 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -131,7 +131,7 @@ int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, return(ERROR_DOS(ERRSRV,ERRmsgoff)); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(inbuf,outbuf,0,0,True); p = smb_buf(inbuf)+1; p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; @@ -170,7 +170,7 @@ int reply_sendstrt(connection_struct *conn, char *inbuf,char *outbuf, int dum_si return(ERROR_DOS(ERRSRV,ERRmsgoff)); } - outsize = set_message(outbuf,1,0,True); + outsize = set_message(inbuf,outbuf,1,0,True); memset(msgbuf,'\0',sizeof(msgbuf)); msgpos = 0; @@ -202,7 +202,7 @@ int reply_sendtxt(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz return(ERROR_DOS(ERRSRV,ERRmsgoff)); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(inbuf,outbuf,0,0,True); msg = smb_buf(inbuf) + 1; @@ -233,7 +233,7 @@ int reply_sendend(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz return(ERROR_DOS(ERRSRV,ERRmsgoff)); } - outsize = set_message(outbuf,0,0,True); + outsize = set_message(inbuf,outbuf,0,0,True); DEBUG(3,("SMBsendend\n")); -- cgit From fcda5b589633b96415890c569bf23e3e284e0916 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 5 Jul 2007 16:33:37 +0000 Subject: r23726: Explicitly pass down the FLAGS2 field to srvstr_pull_buf. The next checkin will pull this up to srvstr_get_path. At that point we can get more independent of the inbuf, the base_ptr in pull_string will only be used to satisfy UCS2 alignment constraints. (This used to be commit 836782b07bf133e9b2598c4a089f1c810e4c7754) --- source3/smbd/message.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index e6a5015276..f390e539b0 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -134,8 +134,10 @@ int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, outsize = set_message(inbuf,outbuf,0,0,True); p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgfrom, p, + sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgto, p, + sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; msg = p; @@ -176,8 +178,10 @@ int reply_sendstrt(connection_struct *conn, char *inbuf,char *outbuf, int dum_si msgpos = 0; p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgfrom, p, + sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgto, p, + sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); -- 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/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index f390e539b0..22fb593b11 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.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/message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 22fb593b11..fa4c9e69ef 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.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 . */ /* This file handles the messaging system calls for winpopup style -- cgit From c5572072e5c50883a643ebd55295c7fb4d10fe3e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 14 Aug 2007 21:07:44 +0000 Subject: r24440: Convert the reply_sendXX functions to the new API (This used to be commit a64bc31098de8694b79eeafd3a226cf519700707) --- source3/smbd/message.c | 62 +++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index fa4c9e69ef..b044b6f92d 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -114,11 +114,10 @@ static void msg_deliver(void) conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +void reply_sends(connection_struct *conn, struct smb_request *req) { int len; char *msg; - int outsize = 0; char *p; START_PROFILE(SMBsends); @@ -126,16 +125,15 @@ int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, msgpos = 0; if (! (*lp_msg_command())) { + reply_doserror(req, ERRSRV, ERRmsgoff); END_PROFILE(SMBsends); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); + return; } - outsize = set_message(inbuf,outbuf,0,0,True); - - p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgfrom, p, + p = smb_buf(req->inbuf)+1; + p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgto, p, + p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; msg = p; @@ -150,8 +148,10 @@ int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, msg_deliver(); + reply_outbuf(req, 0, 0); + END_PROFILE(SMBsends); - return(outsize); + return; } /**************************************************************************** @@ -159,33 +159,33 @@ int reply_sends(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sendstrt(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +void reply_sendstrt(connection_struct *conn, struct smb_request *req) { - int outsize = 0; char *p; START_PROFILE(SMBsendstrt); if (! (*lp_msg_command())) { + reply_doserror(req, ERRSRV, ERRmsgoff); END_PROFILE(SMBsendstrt); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); + return; } - outsize = set_message(inbuf,outbuf,1,0,True); - memset(msgbuf,'\0',sizeof(msgbuf)); msgpos = 0; - p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgfrom, p, + p = smb_buf(req->inbuf)+1; + p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgfrom, p, sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf(inbuf, SVAL(inbuf, smb_flg2), msgto, p, + p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgto, p, sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); + reply_outbuf(req, 0, 0); + END_PROFILE(SMBsendstrt); - return(outsize); + return; } /**************************************************************************** @@ -193,21 +193,19 @@ int reply_sendstrt(connection_struct *conn, char *inbuf,char *outbuf, int dum_si conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sendtxt(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +void reply_sendtxt(connection_struct *conn, struct smb_request *req) { int len; - int outsize = 0; char *msg; START_PROFILE(SMBsendtxt); if (! (*lp_msg_command())) { + reply_doserror(req, ERRSRV, ERRmsgoff); END_PROFILE(SMBsendtxt); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); + return; } - outsize = set_message(inbuf,outbuf,0,0,True); - - msg = smb_buf(inbuf) + 1; + msg = smb_buf(req->inbuf) + 1; len = SVAL(msg,0); len = MIN(len,sizeof(msgbuf)-msgpos); @@ -217,8 +215,10 @@ int reply_sendtxt(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz DEBUG( 3, ( "SMBsendtxt\n" ) ); + reply_outbuf(req, 0, 0); + END_PROFILE(SMBsendtxt); - return(outsize); + return; } /**************************************************************************** @@ -226,22 +226,22 @@ int reply_sendtxt(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_sendend(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +void reply_sendend(connection_struct *conn, struct smb_request *req) { - int outsize = 0; START_PROFILE(SMBsendend); if (! (*lp_msg_command())) { + reply_doserror(req, ERRSRV, ERRmsgoff); END_PROFILE(SMBsendend); - return(ERROR_DOS(ERRSRV,ERRmsgoff)); + return; } - outsize = set_message(inbuf,outbuf,0,0,True); - DEBUG(3,("SMBsendend\n")); msg_deliver(); + reply_outbuf(req, 0, 0); + END_PROFILE(SMBsendend); - return(outsize); + return; } -- cgit From 052efa9a33d7a9a3b9ae9b038f6b3943c85c4bfc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Nov 2007 12:51:31 -0800 Subject: Remove last pstring from smbd/*.c Jeremy. (This used to be commit f1680bada913af4eaf5c0d686983018d6c8b3e5f) --- source3/smbd/message.c | 51 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index b044b6f92d..12a4bc0d54 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -38,7 +38,8 @@ static fstring msgto; static void msg_deliver(void) { - pstring name; + TALLOC_CTX *ctx = talloc_tos(); + char *name = NULL; int i; int fd; char *msg; @@ -52,7 +53,10 @@ static void msg_deliver(void) } /* put it in a temporary file */ - slprintf(name,sizeof(name)-1, "%s/msg.XXXXXX",tmpdir()); + name = talloc_asprintf(ctx, "%s/msg.XXXXXX",tmpdir()); + if (!name) { + return; + } fd = smb_mkstemp(name); if (fd == -1) { @@ -63,7 +67,7 @@ static void msg_deliver(void) /* * Incoming message is in DOS codepage format. Convert to UNIX. */ - + if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **)(void *)&msg, True)) < 0 || !msg) { DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); for (i = 0; i < msgpos;) { @@ -95,14 +99,39 @@ static void msg_deliver(void) if (*lp_msg_command()) { fstring alpha_msgfrom; fstring alpha_msgto; - pstring s; - - pstrcpy(s,lp_msg_command()); - pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,NULL,sizeof(alpha_msgfrom))); - pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,NULL,sizeof(alpha_msgto))); - standard_sub_basic(current_user_info.smb_name, - current_user_info.domain, s, sizeof(s)); - pstring_sub(s,"%s",name); + char *s = talloc_strdup(ctx, + lp_msg_command()); + + if (!s) { + return; + } + s = talloc_string_sub(ctx, s, "%f", + alpha_strcpy(alpha_msgfrom, + msgfrom, + NULL, + sizeof(alpha_msgfrom))); + if (!s) { + return; + } + s = talloc_string_sub(ctx, s, "%t", + alpha_strcpy(alpha_msgto, + msgto, + NULL, + sizeof(alpha_msgto))); + if (!s) { + return; + } + s = talloc_sub_basic(ctx, + current_user_info.smb_name, + current_user_info.domain, + s); + if (!s) { + return; + } + s = talloc_string_sub(ctx, s, "%s",name); + if (!s) { + return; + } smbrun(s,NULL); } -- cgit From 22e329d37fe7ce2cbb8545c83560a4698bca4a4b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 9 Dec 2007 13:45:10 +0100 Subject: Get rid of the msgbuf[1600] (This used to be commit af228007915cc8bb65fa7968da25a1a36004bc22) --- source3/smbd/message.c | 230 ++++++++++++++++++++++++++++--------------------- 1 file changed, 132 insertions(+), 98 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 12a4bc0d54..d0b524da0e 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -26,116 +26,110 @@ extern userdom_struct current_user_info; -/* look in server.c for some explanation of these variables */ -static char msgbuf[1600]; -static int msgpos; -static fstring msgfrom; -static fstring msgto; +struct msg_state { + char *from; + char *to; + char *msg; +}; + +static struct msg_state *smbd_msg_state; /**************************************************************************** Deliver the message. ****************************************************************************/ -static void msg_deliver(void) +static void msg_deliver(struct msg_state *state) { - TALLOC_CTX *ctx = talloc_tos(); + TALLOC_CTX *frame = talloc_stackframe(); char *name = NULL; int i; int fd; char *msg; int len; ssize_t sz; + fstring alpha_buf; + char *s; if (! (*lp_msg_command())) { DEBUG(1,("no messaging command specified\n")); - msgpos = 0; - return; + goto done; } /* put it in a temporary file */ - name = talloc_asprintf(ctx, "%s/msg.XXXXXX",tmpdir()); + name = talloc_asprintf(talloc_tos(), "%s/msg.XXXXXX", tmpdir()); if (!name) { - return; + goto done; } fd = smb_mkstemp(name); if (fd == -1) { - DEBUG(1,("can't open message file %s\n",name)); - return; + DEBUG(1, ("can't open message file %s: %s\n", name, + strerror(errno))); + goto done; } /* * Incoming message is in DOS codepage format. Convert to UNIX. */ - if ((len = (int)convert_string_allocate(NULL,CH_DOS, CH_UNIX, msgbuf, msgpos, (void **)(void *)&msg, True)) < 0 || !msg) { - DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n")); - for (i = 0; i < msgpos;) { - if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') { - i++; - continue; - } - sz = write(fd, &msgbuf[i++], 1); - if ( sz != 1 ) { - DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); - } + len = convert_string_talloc( + talloc_tos(), CH_DOS, CH_UNIX, state->msg, + talloc_get_size(state->msg), (void *)&msg, true); + + if (len == -1) { + DEBUG(3, ("Conversion failed, delivering message in DOS " + "codepage format\n")); + msg = state->msg; + } + + for (i = 0; i < len; i++) { + if ((msg[i] == '\r') && (i < (len-1)) && (msg[i+1] == '\n')) { + continue; } - } else { - for (i = 0; i < len;) { - if (msg[i] == '\r' && i < (len-1) && msg[i+1] == '\n') { - i++; - continue; - } - sz = write(fd, &msg[i++],1); - if ( sz != 1 ) { - DEBUG(0,("Write error to fd %d: %ld(%d)\n",fd, (long)sz, errno )); - } + sz = write(fd, &msg[i], 1); + if ( sz != 1 ) { + DEBUG(0, ("Write error to fd %d: %ld(%s)\n", fd, + (long)sz, strerror(errno))); } - SAFE_FREE(msg); } + close(fd); /* run the command */ - if (*lp_msg_command()) { - fstring alpha_msgfrom; - fstring alpha_msgto; - char *s = talloc_strdup(ctx, - lp_msg_command()); - - if (!s) { - return; - } - s = talloc_string_sub(ctx, s, "%f", - alpha_strcpy(alpha_msgfrom, - msgfrom, - NULL, - sizeof(alpha_msgfrom))); - if (!s) { - return; - } - s = talloc_string_sub(ctx, s, "%t", - alpha_strcpy(alpha_msgto, - msgto, - NULL, - sizeof(alpha_msgto))); - if (!s) { - return; - } - s = talloc_sub_basic(ctx, - current_user_info.smb_name, - current_user_info.domain, - s); - if (!s) { - return; - } - s = talloc_string_sub(ctx, s, "%s",name); - if (!s) { - return; - } - smbrun(s,NULL); + s = talloc_strdup(talloc_tos(), lp_msg_command()); + if (s == NULL) { + goto done; + } + + alpha_strcpy(alpha_buf, state->from, NULL, sizeof(alpha_buf)); + + s = talloc_string_sub(talloc_tos(), s, "%f", alpha_buf); + if (s == NULL) { + goto done; + } + + alpha_strcpy(alpha_buf, state->to, NULL, sizeof(alpha_buf)); + + s = talloc_string_sub(talloc_tos(), s, "%t", alpha_buf); + if (s == NULL) { + goto done; } - msgpos = 0; + s = talloc_sub_basic(talloc_tos(), current_user_info.smb_name, + current_user_info.domain, s); + if (s == NULL) { + goto done; + } + + s = talloc_string_sub(talloc_tos(), s, "%s", name); + if (s == NULL) { + goto done; + } + smbrun(s,NULL); + + done: + TALLOC_FREE(frame); + return; } /**************************************************************************** @@ -145,37 +139,45 @@ static void msg_deliver(void) void reply_sends(connection_struct *conn, struct smb_request *req) { + struct msg_state *state; int len; char *msg; char *p; START_PROFILE(SMBsends); - msgpos = 0; - - if (! (*lp_msg_command())) { + if (!(*lp_msg_command())) { reply_doserror(req, ERRSRV, ERRmsgoff); END_PROFILE(SMBsends); return; } + state = talloc(talloc_tos(), struct msg_state); + p = smb_buf(req->inbuf)+1; - p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgfrom, p, - sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgto, p, - sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf_talloc( + state, (char *)req->inbuf, req->flags2, &state->from, p, + STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf_talloc( + state, (char *)req->inbuf, req->flags2, &state->to, p, + STR_ASCII|STR_TERMINATE) + 1; msg = p; len = SVAL(msg,0); - len = MIN(len,sizeof(msgbuf)-msgpos); + len = MIN(len, smb_bufrem(req->inbuf, msg+2)); - memset(msgbuf,'\0',sizeof(msgbuf)); + state->msg = talloc_array(state, char, len); - memcpy(&msgbuf[msgpos],msg+2,len); - msgpos += len; + if (state->msg == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + END_PROFILE(SMBsends); + return; + } + + memcpy(state->msg, msg+2, len); - msg_deliver(); + msg_deliver(state); reply_outbuf(req, 0, 0); @@ -194,22 +196,32 @@ void reply_sendstrt(connection_struct *conn, struct smb_request *req) START_PROFILE(SMBsendstrt); - if (! (*lp_msg_command())) { + if (!(*lp_msg_command())) { reply_doserror(req, ERRSRV, ERRmsgoff); END_PROFILE(SMBsendstrt); return; } - memset(msgbuf,'\0',sizeof(msgbuf)); - msgpos = 0; + TALLOC_FREE(smbd_msg_state); + + smbd_msg_state = TALLOC_ZERO_P(NULL, struct msg_state); + + if (smbd_msg_state == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + END_PROFILE(SMBsendstrt); + return; + } p = smb_buf(req->inbuf)+1; - p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgfrom, p, - sizeof(msgfrom), STR_ASCII|STR_TERMINATE) + 1; - p += srvstr_pull_buf((char *)req->inbuf, req->flags2, msgto, p, - sizeof(msgto), STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf_talloc( + smbd_msg_state, (char *)req->inbuf, req->flags2, + &smbd_msg_state->from, p, STR_ASCII|STR_TERMINATE) + 1; + p += srvstr_pull_buf_talloc( + smbd_msg_state, (char *)req->inbuf, req->flags2, + &smbd_msg_state->to, p, STR_ASCII|STR_TERMINATE) + 1; - DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); + DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", smbd_msg_state->from, + smbd_msg_state->to ) ); reply_outbuf(req, 0, 0); @@ -226,6 +238,9 @@ void reply_sendtxt(connection_struct *conn, struct smb_request *req) { int len; char *msg; + char *tmp; + size_t old_len; + START_PROFILE(SMBsendtxt); if (! (*lp_msg_command())) { @@ -234,13 +249,30 @@ void reply_sendtxt(connection_struct *conn, struct smb_request *req) return; } + if (smbd_msg_state == NULL) { + reply_nterror(req, NT_STATUS_INVALID_PARAMETER); + END_PROFILE(SMBsendtxt); + return; + } + msg = smb_buf(req->inbuf) + 1; - len = SVAL(msg,0); - len = MIN(len,sizeof(msgbuf)-msgpos); + old_len = talloc_get_size(smbd_msg_state->msg); + + len = MIN(SVAL(msg, 0), smb_bufrem(req->inbuf, msg+2)); - memcpy(&msgbuf[msgpos],msg+2,len); - msgpos += len; + tmp = TALLOC_REALLOC_ARRAY(smbd_msg_state, smbd_msg_state->msg, + char, old_len + len); + + if (tmp == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + END_PROFILE(SMBsendtxt); + return; + } + + smbd_msg_state->msg = tmp; + + memcpy(&smbd_msg_state->msg[old_len], msg+2, len); DEBUG( 3, ( "SMBsendtxt\n" ) ); @@ -267,7 +299,9 @@ void reply_sendend(connection_struct *conn, struct smb_request *req) DEBUG(3,("SMBsendend\n")); - msg_deliver(); + msg_deliver(smbd_msg_state); + + TALLOC_FREE(smbd_msg_state); reply_outbuf(req, 0, 0); -- 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/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index d0b524da0e..a870f03df9 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -137,7 +137,7 @@ static void msg_deliver(struct msg_state *state) conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -void reply_sends(connection_struct *conn, struct smb_request *req) +void reply_sends(struct smb_request *req) { struct msg_state *state; int len; @@ -190,7 +190,7 @@ void reply_sends(connection_struct *conn, struct smb_request *req) conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -void reply_sendstrt(connection_struct *conn, struct smb_request *req) +void reply_sendstrt(struct smb_request *req) { char *p; @@ -234,7 +234,7 @@ void reply_sendstrt(connection_struct *conn, struct smb_request *req) conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -void reply_sendtxt(connection_struct *conn, struct smb_request *req) +void reply_sendtxt(struct smb_request *req) { int len; char *msg; @@ -287,7 +287,7 @@ void reply_sendtxt(connection_struct *conn, struct smb_request *req) conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -void reply_sendend(connection_struct *conn, struct smb_request *req) +void reply_sendend(struct smb_request *req) { START_PROFILE(SMBsendend); -- 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/message.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source3/smbd/message.c') diff --git a/source3/smbd/message.c b/source3/smbd/message.c index a870f03df9..62df5c37eb 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -45,7 +45,7 @@ static void msg_deliver(struct msg_state *state) int i; int fd; char *msg; - int len; + size_t len; ssize_t sz; fstring alpha_buf; char *s; @@ -72,18 +72,17 @@ static void msg_deliver(struct msg_state *state) * Incoming message is in DOS codepage format. Convert to UNIX. */ - len = convert_string_talloc( - talloc_tos(), CH_DOS, CH_UNIX, state->msg, - talloc_get_size(state->msg), (void *)&msg, true); - - if (len == -1) { + if (!convert_string_talloc(talloc_tos(), CH_DOS, CH_UNIX, state->msg, + talloc_get_size(state->msg), (void *)&msg, + &len, true)) { DEBUG(3, ("Conversion failed, delivering message in DOS " "codepage format\n")); msg = state->msg; } for (i = 0; i < len; i++) { - if ((msg[i] == '\r') && (i < (len-1)) && (msg[i+1] == '\n')) { + if ((msg[i] == '\r') && + (i < (len-1)) && (msg[i+1] == '\n')) { continue; } sz = write(fd, &msg[i], 1); -- cgit