diff options
Diffstat (limited to 'source/smbd/message.c')
-rw-r--r-- | source/smbd/message.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/source/smbd/message.c b/source/smbd/message.c index 6a96b4c7a9c..001fc652b29 100644 --- a/source/smbd/message.c +++ b/source/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-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 @@ -25,7 +25,6 @@ #include "includes.h" -#include "loadparm.h" /* look in server.c for some explanation of these variables */ extern int DEBUGLEVEL; @@ -43,8 +42,8 @@ static void msg_deliver(void) { pstring s; fstring name; - FILE *f; int i; + int fd; if (! (*lp_msg_command())) { @@ -54,35 +53,33 @@ static void msg_deliver(void) } /* 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; + 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); + if (fd == -1) { + DEBUG(1,("can't open message file %s\n",name)); + return; + } + + for (i=0;i<msgpos;) { + if (msgbuf[i]=='\r' && i<(msgpos-1) && msgbuf[i+1]=='\n') { + i++; continue; } - - for (i=0;i<msgpos;) - { - if (msgbuf[i]=='\r' && i<(msgpos-1) && msgbuf[i+1]=='\n') - i++; - fputc(msgbuf[i++],f); - } - - fclose(f); + write(fd,&msgbuf[i++],1); + } + close(fd); /* 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); - standard_sub(-1,s); - smbrun(s,NULL); + standard_sub_basic(s); + smbrun(s,NULL,False); } msgpos = 0; @@ -93,7 +90,8 @@ static void msg_deliver(void) /**************************************************************************** reply to a sends ****************************************************************************/ -int reply_sends(char *inbuf,char *outbuf) +int reply_sends(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; char *orig,*dest,*msg; @@ -111,8 +109,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); @@ -120,7 +118,7 @@ int reply_sends(char *inbuf,char *outbuf) 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(); @@ -131,7 +129,8 @@ int reply_sends(char *inbuf,char *outbuf) /**************************************************************************** reply to a sendstrt ****************************************************************************/ -int reply_sendstrt(char *inbuf,char *outbuf) +int reply_sendstrt(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { char *orig,*dest; int outsize = 0; @@ -146,10 +145,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, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); return(outsize); } @@ -158,7 +157,8 @@ int reply_sendstrt(char *inbuf,char *outbuf) /**************************************************************************** reply to a sendtxt ****************************************************************************/ -int reply_sendtxt(char *inbuf,char *outbuf) +int reply_sendtxt(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int len; int outsize = 0; @@ -177,7 +177,7 @@ int reply_sendtxt(char *inbuf,char *outbuf) memcpy(&msgbuf[msgpos],msg+2,len); msgpos += len; - DEBUG(3,("%s SMBsendtxt\n",timestring())); + DEBUG( 3, ( "SMBsendtxt\n" ) ); return(outsize); } @@ -186,7 +186,8 @@ int reply_sendtxt(char *inbuf,char *outbuf) /**************************************************************************** reply to a sendend ****************************************************************************/ -int reply_sendend(char *inbuf,char *outbuf) +int reply_sendend(connection_struct *conn, + char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int outsize = 0; @@ -195,7 +196,7 @@ int reply_sendend(char *inbuf,char *outbuf) outsize = set_message(outbuf,0,0,True); - DEBUG(3,("%s SMBsendend\n",timestring())); + DEBUG(3,("SMBsendend\n")); msg_deliver(); |