[news.admin] how do i get mail

sullivan@vsi.UUCP (Michael T Sullivan) (09/08/88)

Note that this was originally posted to comp.unix.questions, but I thought
the followup should be cross-posted to news.admin.

In article <459@jonlab.UUCP>, jon@jonlab.UUCP (Jon H. LaBadie) writes:
> Any suggestions on how to automatically save outgoing mail
> sent from within vnews?

I modified our news to use mailx a few weeks ago.  I've been meaning to
post this, but I guess I'm just lazy.

A little background.  mailx(1) has the facility to save your outgoing
mail messages.  Problem is even if you have your news mailer be mailx,
your messages won't be saved in your obox because inews runs setuid and
setgid of the news administrator.  At first I just put a setuid(getuid())
after news forked off but before it exec'd the mailer.  This saved the
messages in the obox but it messed up the subject line (it didn't show
up).  Being lazy, I let this go on for a few months.  Then I got inspired
and did this.

Sorry this isn't in diff format, if that is what you expected.  I didn't
keep the original around since everything I added is #ifdef'd.  Below
I have the area of code you need to modify.  The idea is that if you
want to use mailx as your mailer just insert the "#ifdef MAILX" stuff,
put -DMAILX in CFLAGS in your Makefile, and recompile.  If you have any
problems (you shouldn't, this is pretty straightforward) just drop me a
line.  Since I made these changes here there have been no problems.

==================================================

readr.c about line #784:

		if ((tfp = fopen(tf, "w")) == NULL) {
			perror(tf);
			creatm = 0L;
		} else {
			fprintf(tfp, "To: %s\n", pathptr);
> #ifdef MAILX
> 			fprintf(tfp, "~s %s\n", subj);
> #else
> 			fprintf(tfp, "Subject: %s\n", subj);
> #endif
#ifdef INTERNET
			fprintf(tfp, "News-Path: %s\n", hptr->path);
#endif /* INTERNET */
			fprintf(tfp, "References: %s\n\n", folbuf);
			fstat(fileno(tfp), &statb);
			creatm = statb.st_mtime;
			(void) fclose(tfp);
		}
		(void) umask(oumask);

==================================================

recmail.c about line #61:

	while (fgets(linebuf, sizeof linebuf, stdin) != NULL) {
	   	 if ((strncmp(linebuf, "Bcc: ", 5) == 0 ||
		    strncmp(linebuf, "bcc: ", 5) == 0 ||
		    strncmp(linebuf, "BCC: ", 5) == 0)) {
		    if (linebuf[5] != '\n')
			addrecips(linebuf+5);
		    }
> #ifdef MAILX
> 		/*
> 		*	mailx will add the To: line for us.
> 		*/
> 		else if (strncmp(linebuf, "To: ", 4) == 0 ||
> 		    strncmp(linebuf, "to: ", 4) == 0 ||
> 		    strncmp(linebuf, "TO: ", 4) == 0)
> 			;
> #endif
		else if (fputs(linebuf, fd) == EOF)
			goto werror;
		if (linebuf[0] == '\n')
			break;
		if ((strncmp(linebuf, "To: ", 4) == 0 ||
		    strncmp(linebuf, "to: ", 4) == 0 ||
		    strncmp(linebuf, "TO: ", 4) == 0 ||
		    strncmp(linebuf, "Cc: ", 4) == 0 ||
		    strncmp(linebuf, "cc: ", 4) == 0 ||
		    strncmp(linebuf, "CC: ", 4) == 0) &&
		     linebuf[4] != '\n')
			addrecips(linebuf+4);
	}

==================================================

recmail.c about line 210:

	if (pid == 0) {
		(void) close(0);
		(void) open(tmpf, 0);
		if (errfd != NULL) {
			(void) close(1);
			(void) dup(fileno(errfd));
			(void) fclose(errfd);
			(void) close(2);
			(void) dup(1);
		}
> #ifdef MAILX
> 		/*
> 		*	This program is running suid usenet.  To read .mailrc
> 		*	we need to use the real id.
> 		*/
> 		setuid(getuid());
> #endif
		execlp(mailer, mailer, recip, (char *)0);
		perror(mailer);
		exit(1);
	}

==================================================

visual.c about line #1018:

	p = replyname(h);
	fprintf(rfp, "To: %s\n", p);
> #ifdef MAILX
> 	fprintf(rfp, "~s %s\n", subj);
> #else
>	fprintf(rfp, "Subject: %s\n", subj);
> #endif
	fprintf(rfp, "In-reply-to: your article %s\n", h->ident);
#ifdef INTERNET
	fprintf(rfp, "News-Path: %s\n", h->path);
#endif /* INTERNET */
	(void) sprintf(rcbuf, "%s -t < %s; rm -f %s", MAILPARSER, tf, tf);
	putc('\n', rfp);
-- 
Michael Sullivan				{uunet|attmail}!vsi!sullivan
V-Systems, Inc. Santa Ana, CA			sullivan@vsi.com
whump, whump, whump, whump, whump, whump, whump, whump, whump, whump, whump