diff options
Diffstat (limited to 'source/smbd/message.c')
-rw-r--r-- | source/smbd/message.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/source/smbd/message.c b/source/smbd/message.c index 6a96b4c7a9c..64253932abb 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-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 @@ -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; + sprintf(s,"%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); + smbrun(s,NULL,False); } msgpos = 0; @@ -111,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); @@ -146,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); } |