| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vacation.c,v 1.37 2019/05/05 23:08:37 pgoyette Exp $ */ | | 1 | /* $NetBSD: vacation.c,v 1.38 2023/04/11 10:34:52 hauke Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1983, 1987, 1993 | | 4 | * Copyright (c) 1983, 1987, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -30,27 +30,27 @@ | | | @@ -30,27 +30,27 @@ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | | | 33 | |
34 | #ifndef lint | | 34 | #ifndef lint |
35 | __COPYRIGHT("@(#) Copyright (c) 1983, 1987, 1993\ | | 35 | __COPYRIGHT("@(#) Copyright (c) 1983, 1987, 1993\ |
36 | The Regents of the University of California. All rights reserved."); | | 36 | The Regents of the University of California. All rights reserved."); |
37 | #endif /* not lint */ | | 37 | #endif /* not lint */ |
38 | | | 38 | |
39 | #ifndef lint | | 39 | #ifndef lint |
40 | #if 0 | | 40 | #if 0 |
41 | static char sccsid[] = "@(#)vacation.c 8.2 (Berkeley) 1/26/94"; | | 41 | static char sccsid[] = "@(#)vacation.c 8.2 (Berkeley) 1/26/94"; |
42 | #endif | | 42 | #endif |
43 | __RCSID("$NetBSD: vacation.c,v 1.37 2019/05/05 23:08:37 pgoyette Exp $"); | | 43 | __RCSID("$NetBSD: vacation.c,v 1.38 2023/04/11 10:34:52 hauke Exp $"); |
44 | #endif /* not lint */ | | 44 | #endif /* not lint */ |
45 | | | 45 | |
46 | /* | | 46 | /* |
47 | ** Vacation | | 47 | ** Vacation |
48 | ** Copyright (c) 1983 Eric P. Allman | | 48 | ** Copyright (c) 1983 Eric P. Allman |
49 | ** Berkeley, California | | 49 | ** Berkeley, California |
50 | */ | | 50 | */ |
51 | | | 51 | |
52 | #include <sys/param.h> | | 52 | #include <sys/param.h> |
53 | #include <sys/stat.h> | | 53 | #include <sys/stat.h> |
54 | | | 54 | |
55 | #include <ctype.h> | | 55 | #include <ctype.h> |
56 | #include <db.h> | | 56 | #include <db.h> |
| @@ -315,59 +315,73 @@ readheaders(void) | | | @@ -315,59 +315,73 @@ readheaders(void) |
315 | cont = tome = 0; | | 315 | cont = tome = 0; |
316 | #define COMPARE(a, b) strncmp(a, b, sizeof(b) - 1) | | 316 | #define COMPARE(a, b) strncmp(a, b, sizeof(b) - 1) |
317 | #define CASECOMPARE(a, b) strncasecmp(a, b, sizeof(b) - 1) | | 317 | #define CASECOMPARE(a, b) strncasecmp(a, b, sizeof(b) - 1) |
318 | while (fgets(buf, sizeof(buf), stdin) && *buf != '\n') | | 318 | while (fgets(buf, sizeof(buf), stdin) && *buf != '\n') |
319 | switch(*buf) { | | 319 | switch(*buf) { |
320 | case 'F': /* "From " or "From:" */ | | 320 | case 'F': /* "From " or "From:" */ |
321 | cont = 0; | | 321 | cont = 0; |
322 | if (COMPARE(buf, "From ") == 0) | | 322 | if (COMPARE(buf, "From ") == 0) |
323 | getfrom(buf + sizeof("From ") - 1); | | 323 | getfrom(buf + sizeof("From ") - 1); |
324 | if ((fflag & FROM_FROM) != 0 && | | 324 | if ((fflag & FROM_FROM) != 0 && |
325 | COMPARE(buf, "From:") == 0) | | 325 | COMPARE(buf, "From:") == 0) |
326 | getfrom(buf + sizeof("From:") - 1); | | 326 | getfrom(buf + sizeof("From:") - 1); |
327 | break; | | 327 | break; |
328 | case 'P': /* "Precedence:" */ | | 328 | case 'P': /* "Precedence:" rfc 2076 ch 3.9 */ |
329 | cont = 0; | | 329 | cont = 0; |
330 | if (CASECOMPARE(buf, "Precedence") != 0 || | | 330 | if (CASECOMPARE(buf, "Precedence") != 0 || |
331 | (buf[10] != ':' && buf[10] != ' ' && | | 331 | (buf[10] != ':' && buf[10] != ' ' && |
332 | buf[10] != '\t')) | | 332 | buf[10] != '\t')) |
333 | break; | | 333 | break; |
334 | if ((p = strchr(buf, ':')) == NULL) | | 334 | if ((p = strchr(buf, ':')) == NULL) |
335 | break; | | 335 | break; |
336 | while (*++p && isspace((unsigned char)*p)) | | 336 | while (*++p && isspace((unsigned char)*p)) |
337 | continue; | | 337 | continue; |
338 | if (!*p) | | 338 | if (!*p) |
339 | break; | | 339 | break; |
340 | if (CASECOMPARE(p, "junk") == 0 || | | 340 | if (CASECOMPARE(p, "junk") == 0 || |
341 | CASECOMPARE(p, "bulk") == 0|| | | 341 | CASECOMPARE(p, "bulk") == 0|| |
342 | CASECOMPARE(p, "list") == 0) | | 342 | CASECOMPARE(p, "list") == 0) |
343 | exit(0); | | 343 | exit(0); |
344 | break; | | 344 | break; |
345 | case 'C': /* "Cc:" */ | | 345 | case 'C': /* "Cc:" */ |
346 | if (COMPARE(buf, "Cc:")) | | 346 | if (COMPARE(buf, "Cc:")) |
347 | break; | | 347 | break; |
348 | cont = 1; | | 348 | cont = 1; |
349 | goto findme; | | 349 | goto findme; |
350 | case 'T': /* "To:" */ | | 350 | case 'T': /* "To:" */ |
351 | if (COMPARE(buf, "To:")) | | 351 | if (COMPARE(buf, "To:")) |
352 | break; | | 352 | break; |
353 | cont = 1; | | 353 | cont = 1; |
354 | goto findme; | | 354 | goto findme; |
355 | case 'A': /* "Apparently-To:" */ | | 355 | case 'A': |
356 | if ((tflag & APPARENTLY_TO) == 0 || | | 356 | /* "Apparently-To:" */ |
357 | COMPARE(buf, "Apparently-To:") != 0) | | 357 | if ((tflag & APPARENTLY_TO) != 0 && |
| | | 358 | COMPARE(buf, "Apparently-To:") == 0) { |
| | | 359 | cont = 1; |
| | | 360 | goto findme; |
| | | 361 | } |
| | | 362 | /* "Auto-Submitted:" rfc 3834 ch 5 */ |
| | | 363 | cont = 0; |
| | | 364 | if (CASECOMPARE(buf, "Auto-Submitted") != 0 || |
| | | 365 | (buf[14] != ':' && buf[14] != ' ' && |
| | | 366 | buf[14] != '\t')) |
358 | break; | | 367 | break; |
359 | cont = 1; | | 368 | if ((p = strchr(buf, ':')) == NULL) |
360 | goto findme; | | 369 | break; |
| | | 370 | while (*++p && isspace((unsigned char)*p)) |
| | | 371 | continue; |
| | | 372 | if (CASECOMPARE(p, "no") != 0 ) |
| | | 373 | exit(0); |
| | | 374 | break; |
361 | case 'D': /* "Delivered-To:" */ | | 375 | case 'D': /* "Delivered-To:" */ |
362 | if ((tflag & DELIVERED_TO) == 0 || | | 376 | if ((tflag & DELIVERED_TO) == 0 || |
363 | COMPARE(buf, "Delivered-To:") != 0) | | 377 | COMPARE(buf, "Delivered-To:") != 0) |
364 | break; | | 378 | break; |
365 | cont = 1; | | 379 | cont = 1; |
366 | goto findme; | | 380 | goto findme; |
367 | case 'R': /* "Return-Path:" */ | | 381 | case 'R': /* "Return-Path:" */ |
368 | cont = 0; | | 382 | cont = 0; |
369 | if ((fflag & RETURN_PATH_FROM) != 0 && | | 383 | if ((fflag & RETURN_PATH_FROM) != 0 && |
370 | COMPARE(buf, "Return-Path:") == 0) | | 384 | COMPARE(buf, "Return-Path:") == 0) |
371 | getfrom(buf + sizeof("Return-Path:") - 1); | | 385 | getfrom(buf + sizeof("Return-Path:") - 1); |
372 | break; | | 386 | break; |
373 | case 'S': /* "Sender:" */ | | 387 | case 'S': /* "Sender:" */ |
| @@ -618,26 +632,27 @@ sendmessage(const char *myname) | | | @@ -618,26 +632,27 @@ sendmessage(const char *myname) |
618 | getprogname(), _PATH_SENDMAIL); | | 632 | getprogname(), _PATH_SENDMAIL); |
619 | _exit(1); | | 633 | _exit(1); |
620 | } | | 634 | } |
621 | (void)close(pvect[0]); | | 635 | (void)close(pvect[0]); |
622 | sfp = fdopen(pvect[1], "w"); | | 636 | sfp = fdopen(pvect[1], "w"); |
623 | if (sfp == NULL) { | | 637 | if (sfp == NULL) { |
624 | syslog(LOG_ERR, "%s: can't fdopen %d: %m", | | 638 | syslog(LOG_ERR, "%s: can't fdopen %d: %m", |
625 | getprogname(), pvect[1]); | | 639 | getprogname(), pvect[1]); |
626 | _exit(1); | | 640 | _exit(1); |
627 | } | | 641 | } |
628 | } | | 642 | } |
629 | (void)fprintf(sfp, "To: %s\n", from); | | 643 | (void)fprintf(sfp, "To: %s\n", from); |
630 | (void)fputs("Auto-Submitted: auto-replied\n", sfp); | | 644 | (void)fputs("Auto-Submitted: auto-replied\n", sfp); |
| | | 645 | (void)fputs("Precedence: bulk\n", sfp); |
631 | while (fgets(buf, sizeof buf, mfp) != NULL) { | | 646 | while (fgets(buf, sizeof buf, mfp) != NULL) { |
632 | char *p; | | 647 | char *p; |
633 | if ((p = strstr(buf, "$SUBJECT")) != NULL) { | | 648 | if ((p = strstr(buf, "$SUBJECT")) != NULL) { |
634 | *p = '\0'; | | 649 | *p = '\0'; |
635 | (void)fputs(buf, sfp); | | 650 | (void)fputs(buf, sfp); |
636 | (void)fputs(subject, sfp); | | 651 | (void)fputs(subject, sfp); |
637 | p += sizeof("$SUBJECT") - 1; | | 652 | p += sizeof("$SUBJECT") - 1; |
638 | (void)fputs(p, sfp); | | 653 | (void)fputs(p, sfp); |
639 | } else | | 654 | } else |
640 | (void)fputs(buf, sfp); | | 655 | (void)fputs(buf, sfp); |
641 | } | | 656 | } |
642 | (void)fclose(mfp); | | 657 | (void)fclose(mfp); |
643 | if (sfp != stdout) | | 658 | if (sfp != stdout) |