added %h expansion

This commit is contained in:
Todd C. Miller
1996-11-14 03:49:50 +00:00
parent 5e723efe75
commit 773ec24a37

View File

@@ -444,6 +444,7 @@ static void send_mail()
char *mailer = MAILER; char *mailer = MAILER;
char *subject = MAILSUBJECT; char *subject = MAILSUBJECT;
int fd[2]; int fd[2];
char *p;
#ifdef POSIX_SIGNALS #ifdef POSIX_SIGNALS
struct sigaction action; struct sigaction action;
@@ -498,8 +499,18 @@ static void send_mail()
/* feed the data to sendmail */ /* feed the data to sendmail */
/* XXX - do we need to fdopen this fd #1 to a new stream??? */ /* XXX - do we need to fdopen this fd #1 to a new stream??? */
(void) fprintf(stdout, "To: %s\nSubject: %s\n\n%s : %s\n\n", (void) fprintf(stdout, "To: %s\nSubject: ", ALERTMAIL);
ALERTMAIL, subject, host, logline); p = subject;
while (*p) {
/* expand %h -> hostname in subject */
if (*p == '%' && *(p+1) == 'h') {
(void) fputs(host, stdout);
p++;
} else
(void) fputc(*p, stdout);
p++;
}
(void) fprintf(stdout, "\n\n%s : %s\n\n", host, logline);
fclose(stdout); fclose(stdout);
exit(0); exit(0);