git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@856 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-10-17 19:46:17 +00:00
parent f1c349921c
commit 576d77483b

View File

@@ -29,17 +29,18 @@ pop_xmit (POP *p)
int id, pid; int id, pid;
/* Create a temporary file into which to copy the user's message */ /* Create a temporary file into which to copy the user's message */
(void)mktemp((char *)strcpy(temp_xmit,POP_TMPXMIT)); mktemp(strcpy(temp_xmit,POP_TMPXMIT));
#ifdef DEBUG #ifdef DEBUG
if(p->debug) if(p->debug)
pop_log(p,POP_DEBUG, pop_log(p, POP_DEBUG,
"Creating temporary file for sending a mail message \"%s\"\n", "Creating temporary file for sending a mail message \"%s\"\n",
temp_xmit); temp_xmit);
#endif /* DEBUG */ #endif /* DEBUG */
if ((tmp = fopen(temp_xmit,"w+")) == NULL) if ((tmp = fopen(temp_xmit, "w+")) == NULL)
return (pop_msg(p,POP_FAILURE, return (pop_msg(p, POP_FAILURE,
"Unable to create temporary message file \"%s\", errno = %d", "Unable to create temporary message file \"%s\": %s",
temp_xmit,errno)); temp_xmit,
strerror(errno)));
/* Tell the client to start sending the message */ /* Tell the client to start sending the message */
pop_msg(p,POP_SUCCESS,"Start sending the message."); pop_msg(p,POP_SUCCESS,"Start sending the message.");
@@ -53,13 +54,10 @@ pop_xmit (POP *p)
#ifdef DEBUG #ifdef DEBUG
if(p->debug)pop_log(p,POP_DEBUG,"Receiving: \"%s\"",buffer); if(p->debug)pop_log(p,POP_DEBUG,"Receiving: \"%s\"",buffer);
#endif /* DEBUG */ #endif /* DEBUG */
if (*buffer == '.') { if (strcmp(buffer,".\r\n") == 0) break;
/* Exit on end of message */ fputs (buffer,tmp);
if (strcmp(buffer,".\r\n") == 0) break;
}
(void)fputs (buffer,tmp);
} }
(void)fclose (tmp); fclose (tmp);
#ifdef DEBUG #ifdef DEBUG
if(p->debug)pop_log(p,POP_DEBUG,"Forking for \"%s\"",MAIL_COMMAND); if(p->debug)pop_log(p,POP_DEBUG,"Forking for \"%s\"",MAIL_COMMAND);
@@ -67,12 +65,13 @@ pop_xmit (POP *p)
/* Send the message */ /* Send the message */
switch (pid = fork()) { switch (pid = fork()) {
case 0: case 0:
(void)fclose (p->input); fclose (p->input);
(void)fclose (p->output); fclose (p->output);
(void)close(0); close(0);
if (open(temp_xmit,O_RDONLY,0) < 0) (void)_exit(1); if (open(temp_xmit,O_RDONLY,0) < 0)
(void)execl (MAIL_COMMAND,"send-mail","-t","-oem",NULLCP); _exit(1);
(void)_exit(1); execl (MAIL_COMMAND, "send-mail", "-t", "-oem", (char *)NULL);
_exit(1);
case -1: case -1:
#ifdef DEBUG #ifdef DEBUG
if (!p->debug) (void)unlink (temp_xmit); if (!p->debug) (void)unlink (temp_xmit);
@@ -80,11 +79,13 @@ pop_xmit (POP *p)
return (pop_msg(p,POP_FAILURE, return (pop_msg(p,POP_FAILURE,
"Unable to execute \"%s\"",MAIL_COMMAND)); "Unable to execute \"%s\"",MAIL_COMMAND));
default: default:
while((id = wait(&stat)) >=0 && id != pid); while((id = wait(&stat)) >=0 && id != pid)
if (!p->debug) (void)unlink (temp_xmit); ;
if (!p->debug)
unlink (temp_xmit);
if (WEXITSTATUS(stat) != 0) if (WEXITSTATUS(stat) != 0)
return (pop_msg(p,POP_FAILURE,"Unable to send message")); return pop_msg(p,POP_FAILURE,"Unable to send message");
return (pop_msg (p,POP_SUCCESS,"Message sent successfully")); return pop_msg (p,POP_SUCCESS,"Message sent successfully");
} }
} }