17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate * 57c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T 67c478bd9Sstevel@tonic-gate * All Rights Reserved 77c478bd9Sstevel@tonic-gate */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Vacation 117c478bd9Sstevel@tonic-gate * Copyright (c) 1983 Eric P. Allman 127c478bd9Sstevel@tonic-gate * Berkeley, California 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * Copyright (c) 1983 Regents of the University of California. 157c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 167c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 177c478bd9Sstevel@tonic-gate */ 187c478bd9Sstevel@tonic-gate 197c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate #ifndef lint 227c478bd9Sstevel@tonic-gate static char SccsId[] = "%W% %E% SMI"; 237c478bd9Sstevel@tonic-gate #endif /* not lint */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #include <stdio.h> 267c478bd9Sstevel@tonic-gate #include <stdarg.h> 277c478bd9Sstevel@tonic-gate #include <stdlib.h> 287c478bd9Sstevel@tonic-gate #include <unistd.h> 297c478bd9Sstevel@tonic-gate #include <sysexits.h> 307c478bd9Sstevel@tonic-gate #include <pwd.h> 317c478bd9Sstevel@tonic-gate #include <ndbm.h> 327c478bd9Sstevel@tonic-gate #include <string.h> 337c478bd9Sstevel@tonic-gate #include <ctype.h> 347c478bd9Sstevel@tonic-gate #include <fcntl.h> 357c478bd9Sstevel@tonic-gate #include <strings.h> 367c478bd9Sstevel@tonic-gate #include <errno.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * VACATION -- return a message to the sender when on vacation. 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * This program could be invoked as a message receiver 427c478bd9Sstevel@tonic-gate * when someone is on vacation. It returns a message 437c478bd9Sstevel@tonic-gate * specified by the user to whoever sent the mail, taking 447c478bd9Sstevel@tonic-gate * care not to return a message too often to prevent 457c478bd9Sstevel@tonic-gate * "I am on vacation" loops. 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * For best operation, this program should run setuid to 487c478bd9Sstevel@tonic-gate * root or uucp or someone else that sendmail will believe 497c478bd9Sstevel@tonic-gate * a -f flag from. Otherwise, the user must be careful 507c478bd9Sstevel@tonic-gate * to include a header on his .vacation.msg file. 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * Positional Parameters: 537c478bd9Sstevel@tonic-gate * the user to collect the vacation message from. 547c478bd9Sstevel@tonic-gate * 557c478bd9Sstevel@tonic-gate * Flag Parameters: 567c478bd9Sstevel@tonic-gate * -I initialize the database. 577c478bd9Sstevel@tonic-gate * -d turn on debugging. 587c478bd9Sstevel@tonic-gate * -tT set the timeout to T. messages arriving more 597c478bd9Sstevel@tonic-gate * often than T will be ignored to avoid loops. 607c478bd9Sstevel@tonic-gate * 617c478bd9Sstevel@tonic-gate * Side Effects: 627c478bd9Sstevel@tonic-gate * A message is sent back to the sender. 637c478bd9Sstevel@tonic-gate * 647c478bd9Sstevel@tonic-gate * Author: 657c478bd9Sstevel@tonic-gate * Eric Allman 667c478bd9Sstevel@tonic-gate * UCB/INGRES 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate #define MAXLINE 256 /* max size of a line */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #define ONEWEEK (60L*60L*24L*7L) 727c478bd9Sstevel@tonic-gate #define MsgFile "/.vacation.msg" 737c478bd9Sstevel@tonic-gate #define FilterFile "/.vacation.filter" 747c478bd9Sstevel@tonic-gate #define DbFileBase "/.vacation" 757c478bd9Sstevel@tonic-gate #define _PATH_TMP "/tmp/vacation.XXXXXX" 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate typedef int bool; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #define FALSE 0 807c478bd9Sstevel@tonic-gate #define TRUE 1 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate static time_t Timeout = ONEWEEK; /* timeout between notices per user */ 837c478bd9Sstevel@tonic-gate static DBM *db; 847c478bd9Sstevel@tonic-gate static bool Debug = FALSE; 857c478bd9Sstevel@tonic-gate static bool AnswerAll = FALSE; /* default: answer if in To:/Cc: only */ 867c478bd9Sstevel@tonic-gate static char *Subject = NULL; /* subject in message header */ 877c478bd9Sstevel@tonic-gate static char *EncodedSubject = NULL; /* subject in message header */ 887c478bd9Sstevel@tonic-gate static char Charset[MAXLINE]; /* for use in reply message */ 897c478bd9Sstevel@tonic-gate static char *AliasList[MAXLINE]; /* list of aliases to allow */ 907c478bd9Sstevel@tonic-gate static int AliasCount = 0; 917c478bd9Sstevel@tonic-gate static char *myname; /* name of person "on vacation" */ 927c478bd9Sstevel@tonic-gate static char *homedir; /* home directory of said person */ 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate extern time_t convtime(char *, char); 957c478bd9Sstevel@tonic-gate extern bool decode_rfc2047(char *, char *, char *); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate static bool ask(char *); 987c478bd9Sstevel@tonic-gate static bool junkmail(char *); 997c478bd9Sstevel@tonic-gate static bool filter_ok(char *, char *); 1007c478bd9Sstevel@tonic-gate static bool knows(char *); 1017c478bd9Sstevel@tonic-gate static bool sameword(char *, char *); 1027c478bd9Sstevel@tonic-gate static char *getfrom(char **); 1037c478bd9Sstevel@tonic-gate static char *newstr(char *); 1047c478bd9Sstevel@tonic-gate static void AutoInstall(); 1057c478bd9Sstevel@tonic-gate static void initialize(char *); 1067c478bd9Sstevel@tonic-gate static void sendmessage(char *, char *, char *); 1077c478bd9Sstevel@tonic-gate static void setknows(char *); 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate void usrerr(const char *, ...); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate int 1127c478bd9Sstevel@tonic-gate main(argc, argv) 1137c478bd9Sstevel@tonic-gate int argc; 1147c478bd9Sstevel@tonic-gate char **argv; 1157c478bd9Sstevel@tonic-gate { 1167c478bd9Sstevel@tonic-gate char *from; 1177c478bd9Sstevel@tonic-gate char *p, *at, *c; 1187c478bd9Sstevel@tonic-gate struct passwd *pw; 1197c478bd9Sstevel@tonic-gate char *shortfrom; 1207c478bd9Sstevel@tonic-gate char buf[MAXLINE]; 1217c478bd9Sstevel@tonic-gate char *message_file = MsgFile; 1227c478bd9Sstevel@tonic-gate char *db_file_base = DbFileBase; 1237c478bd9Sstevel@tonic-gate char *filter_file = FilterFile; 1247c478bd9Sstevel@tonic-gate char *sender; 1257c478bd9Sstevel@tonic-gate bool sender_oob = FALSE; 1267c478bd9Sstevel@tonic-gate bool initialize_only = FALSE; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* process arguments */ 1297c478bd9Sstevel@tonic-gate while (--argc > 0 && (p = *++argv) != NULL && *p == '-') 1307c478bd9Sstevel@tonic-gate { 1317c478bd9Sstevel@tonic-gate switch (*++p) 1327c478bd9Sstevel@tonic-gate { 1337c478bd9Sstevel@tonic-gate case 'a': /* add this to list of acceptable aliases */ 1347c478bd9Sstevel@tonic-gate AliasList[AliasCount++] = argv[1]; 1357c478bd9Sstevel@tonic-gate if (argc > 0) { 1367c478bd9Sstevel@tonic-gate argc--; argv++; 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate break; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate case 'd': /* debug */ 1417c478bd9Sstevel@tonic-gate Debug = TRUE; 1427c478bd9Sstevel@tonic-gate break; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate case 'e': /* alternate filter file */ 1457c478bd9Sstevel@tonic-gate filter_file = argv[1]; 1467c478bd9Sstevel@tonic-gate if (argc > 0) { 1477c478bd9Sstevel@tonic-gate argc--; argv++; 1487c478bd9Sstevel@tonic-gate } 1497c478bd9Sstevel@tonic-gate break; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate case 'f': /* alternate database file name base */ 1527c478bd9Sstevel@tonic-gate db_file_base = argv[1]; 1537c478bd9Sstevel@tonic-gate if (argc > 0) { 1547c478bd9Sstevel@tonic-gate argc--; argv++; 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate break; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate case 'I': /* initialize */ 1597c478bd9Sstevel@tonic-gate initialize_only = TRUE; 1607c478bd9Sstevel@tonic-gate break; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate case 'j': /* answer all mail, even if not in To/Cc */ 1637c478bd9Sstevel@tonic-gate AnswerAll = TRUE; 1647c478bd9Sstevel@tonic-gate break; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate case 'm': /* alternate message file */ 1677c478bd9Sstevel@tonic-gate message_file = argv[1]; 1687c478bd9Sstevel@tonic-gate if (argc > 0) { 1697c478bd9Sstevel@tonic-gate argc--; argv++; 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate break; 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate case 's': /* sender: use this instead of getfrom() */ 1747c478bd9Sstevel@tonic-gate sender = argv[1]; 1757c478bd9Sstevel@tonic-gate sender_oob = TRUE; 1767c478bd9Sstevel@tonic-gate if (argc > 0) { 1777c478bd9Sstevel@tonic-gate argc--; argv++; 1787c478bd9Sstevel@tonic-gate } 1797c478bd9Sstevel@tonic-gate break; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate case 't': /* set timeout */ 1827c478bd9Sstevel@tonic-gate Timeout = convtime(++p, 'w'); 1837c478bd9Sstevel@tonic-gate break; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate default: 1867c478bd9Sstevel@tonic-gate usrerr("Unknown flag -%s", p); 1877c478bd9Sstevel@tonic-gate exit(EX_USAGE); 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate if (initialize_only) 1927c478bd9Sstevel@tonic-gate { 1937c478bd9Sstevel@tonic-gate initialize(db_file_base); 1947c478bd9Sstevel@tonic-gate exit(EX_OK); 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate /* verify recipient argument */ 1987c478bd9Sstevel@tonic-gate if (argc == 0) 1997c478bd9Sstevel@tonic-gate AutoInstall(); 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate if (argc != 1) 2027c478bd9Sstevel@tonic-gate { 2037c478bd9Sstevel@tonic-gate usrerr("Usage: vacation username (or) vacation -I"); 2047c478bd9Sstevel@tonic-gate exit(EX_USAGE); 2057c478bd9Sstevel@tonic-gate } 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate myname = p; 2087c478bd9Sstevel@tonic-gate Charset[0] = '\0'; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* find user's home directory */ 2117c478bd9Sstevel@tonic-gate pw = getpwnam(myname); 2127c478bd9Sstevel@tonic-gate if (pw == NULL) 2137c478bd9Sstevel@tonic-gate { 2147c478bd9Sstevel@tonic-gate usrerr("user %s look up failed, name services outage ?", 2157c478bd9Sstevel@tonic-gate myname); 2167c478bd9Sstevel@tonic-gate exit(EX_TEMPFAIL); 2177c478bd9Sstevel@tonic-gate } 2187c478bd9Sstevel@tonic-gate homedir = newstr(pw->pw_dir); 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf), "%s%s%s", homedir, 2217c478bd9Sstevel@tonic-gate (db_file_base[0] == '/') ? "" : "/", db_file_base); 2227c478bd9Sstevel@tonic-gate if (!(db = dbm_open(buf, O_RDWR, 0))) { 2237c478bd9Sstevel@tonic-gate usrerr("%s: %s\n", buf, strerror(errno)); 2247c478bd9Sstevel@tonic-gate exit(EX_DATAERR); 2257c478bd9Sstevel@tonic-gate } 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate if (sender_oob) 2287c478bd9Sstevel@tonic-gate { 2297c478bd9Sstevel@tonic-gate at = strchr(sender, '@'); 2307c478bd9Sstevel@tonic-gate if (at != NULL) 2317c478bd9Sstevel@tonic-gate for (c = at + 1; *c; c++) 2327c478bd9Sstevel@tonic-gate *c = (char)tolower((char)*c); 2337c478bd9Sstevel@tonic-gate from = sender; 2347c478bd9Sstevel@tonic-gate shortfrom = sender; 2357c478bd9Sstevel@tonic-gate } 2367c478bd9Sstevel@tonic-gate else 2377c478bd9Sstevel@tonic-gate /* read message from standard input (just from line) */ 2387c478bd9Sstevel@tonic-gate from = getfrom(&shortfrom); 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate /* check if junk mail or this person is already informed */ 2417c478bd9Sstevel@tonic-gate if (!junkmail(shortfrom) && filter_ok(shortfrom, filter_file) && 2427c478bd9Sstevel@tonic-gate !knows(shortfrom)) 2437c478bd9Sstevel@tonic-gate { 2447c478bd9Sstevel@tonic-gate /* mark this person as knowing */ 2457c478bd9Sstevel@tonic-gate setknows(shortfrom); 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* send the message back */ 2487c478bd9Sstevel@tonic-gate (void) strlcpy(buf, homedir, sizeof (buf)); 2497c478bd9Sstevel@tonic-gate if (message_file[0] != '/') 2507c478bd9Sstevel@tonic-gate (void) strlcat(buf, "/", sizeof (buf)); 2517c478bd9Sstevel@tonic-gate (void) strlcat(buf, message_file, sizeof (buf)); 2527c478bd9Sstevel@tonic-gate if (Debug) 2537c478bd9Sstevel@tonic-gate printf("Sending %s to %s\n", buf, from); 2547c478bd9Sstevel@tonic-gate else 2557c478bd9Sstevel@tonic-gate { 2567c478bd9Sstevel@tonic-gate sendmessage(buf, from, myname); 2577c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 2587c478bd9Sstevel@tonic-gate } 2597c478bd9Sstevel@tonic-gate } 2607c478bd9Sstevel@tonic-gate return (EX_OK); 2617c478bd9Sstevel@tonic-gate } 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate /* 2647c478bd9Sstevel@tonic-gate * GETFROM -- read message from standard input and return sender 2657c478bd9Sstevel@tonic-gate * 2667c478bd9Sstevel@tonic-gate * Parameters: 2677c478bd9Sstevel@tonic-gate * none. 2687c478bd9Sstevel@tonic-gate * 2697c478bd9Sstevel@tonic-gate * Returns: 2707c478bd9Sstevel@tonic-gate * pointer to the sender address. 2717c478bd9Sstevel@tonic-gate * 2727c478bd9Sstevel@tonic-gate * Side Effects: 2737c478bd9Sstevel@tonic-gate * Reads first line from standard input. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate static char * 2777c478bd9Sstevel@tonic-gate getfrom(shortp) 2787c478bd9Sstevel@tonic-gate char **shortp; 2797c478bd9Sstevel@tonic-gate { 2807c478bd9Sstevel@tonic-gate static char line[MAXLINE]; 2817c478bd9Sstevel@tonic-gate char *p, *start, *at, *bang, *c; 2827c478bd9Sstevel@tonic-gate char saveat; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* read the from line */ 2857c478bd9Sstevel@tonic-gate if (fgets(line, sizeof (line), stdin) == NULL || 2867c478bd9Sstevel@tonic-gate strncmp(line, "From ", 5) != NULL) 2877c478bd9Sstevel@tonic-gate { 2887c478bd9Sstevel@tonic-gate usrerr("No initial From line"); 2897c478bd9Sstevel@tonic-gate exit(EX_PROTOCOL); 2907c478bd9Sstevel@tonic-gate } 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* find the end of the sender address and terminate it */ 2937c478bd9Sstevel@tonic-gate start = &line[5]; 2947c478bd9Sstevel@tonic-gate p = strchr(start, ' '); 2957c478bd9Sstevel@tonic-gate if (p == NULL) 2967c478bd9Sstevel@tonic-gate { 2977c478bd9Sstevel@tonic-gate usrerr("Funny From line '%s'", line); 2987c478bd9Sstevel@tonic-gate exit(EX_PROTOCOL); 2997c478bd9Sstevel@tonic-gate } 3007c478bd9Sstevel@tonic-gate *p = '\0'; 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate /* 3037c478bd9Sstevel@tonic-gate * Strip all but the rightmost UUCP host 3047c478bd9Sstevel@tonic-gate * to prevent loops due to forwarding. 3057c478bd9Sstevel@tonic-gate * Start searching leftward from the leftmost '@'. 3067c478bd9Sstevel@tonic-gate * a!b!c!d yields a short name of c!d 3077c478bd9Sstevel@tonic-gate * a!b!c!d@e yields a short name of c!d@e 3087c478bd9Sstevel@tonic-gate * e@a!b!c yields the same short name 3097c478bd9Sstevel@tonic-gate */ 3107c478bd9Sstevel@tonic-gate #ifdef VDEBUG 3117c478bd9Sstevel@tonic-gate printf("start='%s'\n", start); 3127c478bd9Sstevel@tonic-gate #endif /* VDEBUG */ 3137c478bd9Sstevel@tonic-gate *shortp = start; /* assume whole addr */ 3147c478bd9Sstevel@tonic-gate if ((at = strchr(start, '@')) == NULL) /* leftmost '@' */ 3157c478bd9Sstevel@tonic-gate at = p; /* if none, use end of addr */ 3167c478bd9Sstevel@tonic-gate saveat = *at; 3177c478bd9Sstevel@tonic-gate *at = '\0'; 3187c478bd9Sstevel@tonic-gate if ((bang = strrchr(start, '!')) != NULL) { /* rightmost '!' */ 3197c478bd9Sstevel@tonic-gate char *bang2; 3207c478bd9Sstevel@tonic-gate *bang = '\0'; 3217c478bd9Sstevel@tonic-gate /* 2nd rightmost '!' */ 3227c478bd9Sstevel@tonic-gate if ((bang2 = strrchr(start, '!')) != NULL) 3237c478bd9Sstevel@tonic-gate *shortp = bang2 + 1; /* move past ! */ 3247c478bd9Sstevel@tonic-gate *bang = '!'; 3257c478bd9Sstevel@tonic-gate } 3267c478bd9Sstevel@tonic-gate *at = saveat; 3277c478bd9Sstevel@tonic-gate #ifdef VDEBUG 3287c478bd9Sstevel@tonic-gate printf("place='%s'\n", *shortp); 3297c478bd9Sstevel@tonic-gate #endif /* VDEBUG */ 3307c478bd9Sstevel@tonic-gate for (c = at + 1; *c; c++) 3317c478bd9Sstevel@tonic-gate *c = (char)tolower((char)*c); 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate /* return the sender address */ 3347c478bd9Sstevel@tonic-gate return (start); 3357c478bd9Sstevel@tonic-gate } 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate /* 3387c478bd9Sstevel@tonic-gate * JUNKMAIL -- read the header and tell us if this is junk/bulk mail. 3397c478bd9Sstevel@tonic-gate * 3407c478bd9Sstevel@tonic-gate * Parameters: 3417c478bd9Sstevel@tonic-gate * from -- the Return-Path of the sender. We assume that 3427c478bd9Sstevel@tonic-gate * anything from "*-REQUEST@*" is bulk mail. 3437c478bd9Sstevel@tonic-gate * 3447c478bd9Sstevel@tonic-gate * Returns: 3457c478bd9Sstevel@tonic-gate * TRUE -- if this is junk or bulk mail (that is, if the 3467c478bd9Sstevel@tonic-gate * sender shouldn't receive a response). 3477c478bd9Sstevel@tonic-gate * FALSE -- if the sender deserves a response. 3487c478bd9Sstevel@tonic-gate * 3497c478bd9Sstevel@tonic-gate * Side Effects: 3507c478bd9Sstevel@tonic-gate * May read the header from standard input. When this 3517c478bd9Sstevel@tonic-gate * returns the position on stdin is undefined. 3527c478bd9Sstevel@tonic-gate */ 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate static bool 3557c478bd9Sstevel@tonic-gate junkmail(from) 3567c478bd9Sstevel@tonic-gate char *from; 3577c478bd9Sstevel@tonic-gate { 3587c478bd9Sstevel@tonic-gate register char *p; 3597c478bd9Sstevel@tonic-gate char buf[MAXLINE+1]; 3607c478bd9Sstevel@tonic-gate bool inside, onlist; 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate /* test for inhuman sender */ 3637c478bd9Sstevel@tonic-gate p = strrchr(from, '@'); 3647c478bd9Sstevel@tonic-gate if (p != NULL) 3657c478bd9Sstevel@tonic-gate { 3667c478bd9Sstevel@tonic-gate *p = '\0'; 3677c478bd9Sstevel@tonic-gate if (sameword(&p[-8], "-REQUEST") || 3687c478bd9Sstevel@tonic-gate sameword(&p[-10], "Postmaster") || 3697c478bd9Sstevel@tonic-gate sameword(&p[-13], "MAILER-DAEMON")) 3707c478bd9Sstevel@tonic-gate { 3717c478bd9Sstevel@tonic-gate *p = '@'; 3727c478bd9Sstevel@tonic-gate return (TRUE); 3737c478bd9Sstevel@tonic-gate } 3747c478bd9Sstevel@tonic-gate *p = '@'; 3757c478bd9Sstevel@tonic-gate } 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate #define Delims " \n\t:,:;()<>@!" 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* read the header looking for "interesting" lines */ 3807c478bd9Sstevel@tonic-gate inside = FALSE; 3817c478bd9Sstevel@tonic-gate onlist = FALSE; 3827c478bd9Sstevel@tonic-gate while (fgets(buf, MAXLINE, stdin) != NULL && buf[0] != '\n') 3837c478bd9Sstevel@tonic-gate { 3847c478bd9Sstevel@tonic-gate if (buf[0] != ' ' && buf[0] != '\t' && strchr(buf, ':') == NULL) 3857c478bd9Sstevel@tonic-gate return (FALSE); /* no header found */ 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate p = strtok(buf, Delims); 3887c478bd9Sstevel@tonic-gate if (p == NULL) 3897c478bd9Sstevel@tonic-gate continue; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate if (sameword(p, "To") || sameword(p, "Cc")) 3927c478bd9Sstevel@tonic-gate { 3937c478bd9Sstevel@tonic-gate inside = TRUE; 3947c478bd9Sstevel@tonic-gate p = strtok((char *)NULL, Delims); 3957c478bd9Sstevel@tonic-gate if (p == NULL) 3967c478bd9Sstevel@tonic-gate continue; 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate } else /* continuation line? */ 3997c478bd9Sstevel@tonic-gate if (inside) 4007c478bd9Sstevel@tonic-gate inside = (buf[0] == ' ' || buf[0] == '\t'); 4017c478bd9Sstevel@tonic-gate 4027c478bd9Sstevel@tonic-gate if (inside) { 4037c478bd9Sstevel@tonic-gate int i; 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate do { 4067c478bd9Sstevel@tonic-gate if (sameword(p, myname)) 4077c478bd9Sstevel@tonic-gate onlist = TRUE; /* I am on the list */ 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate for (i = 0; i < AliasCount; i++) 4107c478bd9Sstevel@tonic-gate if (sameword(p, AliasList[i])) 4117c478bd9Sstevel@tonic-gate onlist = TRUE; /* alias on list */ 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate } while (p = strtok((char *)NULL, Delims)); 4147c478bd9Sstevel@tonic-gate continue; 4157c478bd9Sstevel@tonic-gate } 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate if (sameword(p, "Precedence")) 4187c478bd9Sstevel@tonic-gate { 4197c478bd9Sstevel@tonic-gate /* find the value of this field */ 4207c478bd9Sstevel@tonic-gate p = strtok((char *)NULL, Delims); 4217c478bd9Sstevel@tonic-gate if (p == NULL) 4227c478bd9Sstevel@tonic-gate continue; 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate /* see if it is "junk" or "bulk" */ 4257c478bd9Sstevel@tonic-gate p[4] = '\0'; 4267c478bd9Sstevel@tonic-gate if (sameword(p, "junk") || sameword(p, "bulk")) 4277c478bd9Sstevel@tonic-gate return (TRUE); 4287c478bd9Sstevel@tonic-gate } 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate if (sameword(p, "Subject")) 4317c478bd9Sstevel@tonic-gate { 4327c478bd9Sstevel@tonic-gate char *decoded_subject; 4337c478bd9Sstevel@tonic-gate 4347c478bd9Sstevel@tonic-gate Subject = newstr(buf+9); 4357c478bd9Sstevel@tonic-gate if (p = strrchr(Subject, '\n')) 4367c478bd9Sstevel@tonic-gate *p = '\0'; 4377c478bd9Sstevel@tonic-gate EncodedSubject = newstr(Subject); 4387c478bd9Sstevel@tonic-gate decoded_subject = newstr(Subject); 4397c478bd9Sstevel@tonic-gate if (decode_rfc2047(Subject, decoded_subject, Charset)) 4407c478bd9Sstevel@tonic-gate Subject = decoded_subject; 4417c478bd9Sstevel@tonic-gate else 4427c478bd9Sstevel@tonic-gate Charset[0] = '\0'; 4437c478bd9Sstevel@tonic-gate if (Debug) 4447c478bd9Sstevel@tonic-gate printf("Subject=%s\n", Subject); 4457c478bd9Sstevel@tonic-gate } 4467c478bd9Sstevel@tonic-gate } 4477c478bd9Sstevel@tonic-gate if (AnswerAll) 4487c478bd9Sstevel@tonic-gate return (FALSE); 4497c478bd9Sstevel@tonic-gate else 4507c478bd9Sstevel@tonic-gate return (!onlist); 4517c478bd9Sstevel@tonic-gate } 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate /* 4547c478bd9Sstevel@tonic-gate * FILTER_OK -- see if the Return-Path is in the filter file. 4557c478bd9Sstevel@tonic-gate * Note that a non-existent filter file means everything 4567c478bd9Sstevel@tonic-gate * is OK, but an empty file means nothing is OK. 4577c478bd9Sstevel@tonic-gate * 4587c478bd9Sstevel@tonic-gate * Parameters: 4597c478bd9Sstevel@tonic-gate * from -- the Return-Path of the sender. 4607c478bd9Sstevel@tonic-gate * 4617c478bd9Sstevel@tonic-gate * Returns: 4627c478bd9Sstevel@tonic-gate * TRUE -- if this is in the filter file 4637c478bd9Sstevel@tonic-gate * (sender should receive a response). 4647c478bd9Sstevel@tonic-gate * FALSE -- if the sender does not deserve a response. 4657c478bd9Sstevel@tonic-gate */ 4667c478bd9Sstevel@tonic-gate 4677c478bd9Sstevel@tonic-gate static bool 4687c478bd9Sstevel@tonic-gate filter_ok(from, filter_file) 4697c478bd9Sstevel@tonic-gate char *from; 4707c478bd9Sstevel@tonic-gate char *filter_file; 4717c478bd9Sstevel@tonic-gate { 4727c478bd9Sstevel@tonic-gate char file[MAXLINE]; 4737c478bd9Sstevel@tonic-gate char line[MAXLINE]; 474*d5e7c3fcSgww char *match_start; 4757c478bd9Sstevel@tonic-gate size_t line_len, from_len; 4767c478bd9Sstevel@tonic-gate bool result = FALSE; 477*d5e7c3fcSgww bool negated = FALSE; 4787c478bd9Sstevel@tonic-gate FILE *f; 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate from_len = strlen(from); 4817c478bd9Sstevel@tonic-gate (void) strlcpy(file, homedir, sizeof (file)); 4827c478bd9Sstevel@tonic-gate if (filter_file[0] != '/') 4837c478bd9Sstevel@tonic-gate (void) strlcat(file, "/", sizeof (file)); 4847c478bd9Sstevel@tonic-gate (void) strlcat(file, filter_file, sizeof (file)); 4857c478bd9Sstevel@tonic-gate f = fopen(file, "r"); 4867c478bd9Sstevel@tonic-gate if (f == NULL) { 4877c478bd9Sstevel@tonic-gate /* 4887c478bd9Sstevel@tonic-gate * If the file does not exist, then there is no filter to 4897c478bd9Sstevel@tonic-gate * apply, so we simply return TRUE. 4907c478bd9Sstevel@tonic-gate */ 4917c478bd9Sstevel@tonic-gate if (Debug) 4927c478bd9Sstevel@tonic-gate (void) printf("%s does not exist, filter ok.\n", 4937c478bd9Sstevel@tonic-gate file); 4947c478bd9Sstevel@tonic-gate return (TRUE); 4957c478bd9Sstevel@tonic-gate } 4967c478bd9Sstevel@tonic-gate while (fgets(line, MAXLINE, f)) { 4977c478bd9Sstevel@tonic-gate line_len = strlen(line); 4987c478bd9Sstevel@tonic-gate /* zero out trailing newline */ 4997c478bd9Sstevel@tonic-gate if (line[line_len - 1] == '\n') 5007c478bd9Sstevel@tonic-gate line[--line_len] = '\0'; 5017c478bd9Sstevel@tonic-gate /* skip blank lines */ 5027c478bd9Sstevel@tonic-gate if (line_len == 0) 5037c478bd9Sstevel@tonic-gate continue; 5047c478bd9Sstevel@tonic-gate /* skip comment lines */ 5057c478bd9Sstevel@tonic-gate if (line[0] == '#') 5067c478bd9Sstevel@tonic-gate continue; 507*d5e7c3fcSgww if (line[0] == '!') { 508*d5e7c3fcSgww negated = TRUE; 509*d5e7c3fcSgww match_start = &line[1]; 510*d5e7c3fcSgww line_len--; 511*d5e7c3fcSgww } else { 512*d5e7c3fcSgww negated = FALSE; 513*d5e7c3fcSgww match_start = &line[0]; 514*d5e7c3fcSgww } 5157c478bd9Sstevel@tonic-gate if (strchr(line, '@') != NULL) { 5167c478bd9Sstevel@tonic-gate /* @ => full address */ 517*d5e7c3fcSgww if (strcasecmp(match_start, from) == 0) { 5187c478bd9Sstevel@tonic-gate result = TRUE; 5197c478bd9Sstevel@tonic-gate if (Debug) 5207c478bd9Sstevel@tonic-gate (void) printf("filter match on %s\n", 5217c478bd9Sstevel@tonic-gate line); 5227c478bd9Sstevel@tonic-gate break; 5237c478bd9Sstevel@tonic-gate } 5247c478bd9Sstevel@tonic-gate } else { 5257c478bd9Sstevel@tonic-gate /* no @ => domain */ 5267c478bd9Sstevel@tonic-gate if (from_len <= line_len) 5277c478bd9Sstevel@tonic-gate continue; 5287c478bd9Sstevel@tonic-gate /* 5297c478bd9Sstevel@tonic-gate * Make sure the last part of from is the domain line 5307c478bd9Sstevel@tonic-gate * and that the character immediately preceding is an 5317c478bd9Sstevel@tonic-gate * '@' or a '.', otherwise we could get false positives 5327c478bd9Sstevel@tonic-gate * from e.g. twinsun.com for sun.com . 5337c478bd9Sstevel@tonic-gate */ 534*d5e7c3fcSgww if (strncasecmp(&from[from_len - line_len], 535*d5e7c3fcSgww match_start, line_len) == 0 && 5367c478bd9Sstevel@tonic-gate (from[from_len - line_len -1] == '@' || 5377c478bd9Sstevel@tonic-gate from[from_len - line_len -1] == '.')) { 5387c478bd9Sstevel@tonic-gate result = TRUE; 5397c478bd9Sstevel@tonic-gate if (Debug) 5407c478bd9Sstevel@tonic-gate (void) printf("filter match on %s\n", 5417c478bd9Sstevel@tonic-gate line); 5427c478bd9Sstevel@tonic-gate break; 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate } 5457c478bd9Sstevel@tonic-gate } 5467c478bd9Sstevel@tonic-gate (void) fclose(f); 5477c478bd9Sstevel@tonic-gate if (Debug && !result) 5487c478bd9Sstevel@tonic-gate (void) printf("no filter match\n"); 549*d5e7c3fcSgww return (!negated && result); 5507c478bd9Sstevel@tonic-gate } 5517c478bd9Sstevel@tonic-gate 5527c478bd9Sstevel@tonic-gate /* 5537c478bd9Sstevel@tonic-gate * KNOWS -- predicate telling if user has already been informed. 5547c478bd9Sstevel@tonic-gate * 5557c478bd9Sstevel@tonic-gate * Parameters: 5567c478bd9Sstevel@tonic-gate * user -- the user who sent this message. 5577c478bd9Sstevel@tonic-gate * 5587c478bd9Sstevel@tonic-gate * Returns: 5597c478bd9Sstevel@tonic-gate * TRUE if 'user' has already been informed that the 5607c478bd9Sstevel@tonic-gate * recipient is on vacation. 5617c478bd9Sstevel@tonic-gate * FALSE otherwise. 5627c478bd9Sstevel@tonic-gate * 5637c478bd9Sstevel@tonic-gate * Side Effects: 5647c478bd9Sstevel@tonic-gate * none. 5657c478bd9Sstevel@tonic-gate */ 5667c478bd9Sstevel@tonic-gate 5677c478bd9Sstevel@tonic-gate static bool 5687c478bd9Sstevel@tonic-gate knows(user) 5697c478bd9Sstevel@tonic-gate char *user; 5707c478bd9Sstevel@tonic-gate { 5717c478bd9Sstevel@tonic-gate datum key, data; 5727c478bd9Sstevel@tonic-gate time_t now, then; 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate (void) time(&now); 5757c478bd9Sstevel@tonic-gate key.dptr = user; 5767c478bd9Sstevel@tonic-gate key.dsize = strlen(user) + 1; 5777c478bd9Sstevel@tonic-gate data = dbm_fetch(db, key); 5787c478bd9Sstevel@tonic-gate if (data.dptr == NULL) 5797c478bd9Sstevel@tonic-gate return (FALSE); 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate bcopy(data.dptr, (char *)&then, sizeof (then)); 5827c478bd9Sstevel@tonic-gate if (then + Timeout < now) 5837c478bd9Sstevel@tonic-gate return (FALSE); 5847c478bd9Sstevel@tonic-gate if (Debug) 5857c478bd9Sstevel@tonic-gate printf("User %s already knows\n", user); 5867c478bd9Sstevel@tonic-gate return (TRUE); 5877c478bd9Sstevel@tonic-gate } 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate /* 5907c478bd9Sstevel@tonic-gate * SETKNOWS -- set that this user knows about the vacation. 5917c478bd9Sstevel@tonic-gate * 5927c478bd9Sstevel@tonic-gate * Parameters: 5937c478bd9Sstevel@tonic-gate * user -- the user who should be marked. 5947c478bd9Sstevel@tonic-gate * 5957c478bd9Sstevel@tonic-gate * Returns: 5967c478bd9Sstevel@tonic-gate * none. 5977c478bd9Sstevel@tonic-gate * 5987c478bd9Sstevel@tonic-gate * Side Effects: 5997c478bd9Sstevel@tonic-gate * The dbm file is updated as appropriate. 6007c478bd9Sstevel@tonic-gate */ 6017c478bd9Sstevel@tonic-gate 6027c478bd9Sstevel@tonic-gate static void 6037c478bd9Sstevel@tonic-gate setknows(user) 6047c478bd9Sstevel@tonic-gate char *user; 6057c478bd9Sstevel@tonic-gate { 6067c478bd9Sstevel@tonic-gate datum key, data; 6077c478bd9Sstevel@tonic-gate time_t now; 6087c478bd9Sstevel@tonic-gate 6097c478bd9Sstevel@tonic-gate key.dptr = user; 6107c478bd9Sstevel@tonic-gate key.dsize = strlen(user) + 1; 6117c478bd9Sstevel@tonic-gate (void) time(&now); 6127c478bd9Sstevel@tonic-gate data.dptr = (char *)&now; 6137c478bd9Sstevel@tonic-gate data.dsize = sizeof (now); 6147c478bd9Sstevel@tonic-gate dbm_store(db, key, data, DBM_REPLACE); 6157c478bd9Sstevel@tonic-gate } 6167c478bd9Sstevel@tonic-gate 6177c478bd9Sstevel@tonic-gate static bool 6187c478bd9Sstevel@tonic-gate any8bitchars(line) 6197c478bd9Sstevel@tonic-gate char *line; 6207c478bd9Sstevel@tonic-gate { 6217c478bd9Sstevel@tonic-gate char *c; 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate for (c = line; *c; c++) 6247c478bd9Sstevel@tonic-gate if (*c & 0x80) 6257c478bd9Sstevel@tonic-gate return (TRUE); 6267c478bd9Sstevel@tonic-gate return (FALSE); 6277c478bd9Sstevel@tonic-gate } 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate /* 6307c478bd9Sstevel@tonic-gate * SENDMESSAGE -- send a message to a particular user. 6317c478bd9Sstevel@tonic-gate * 6327c478bd9Sstevel@tonic-gate * Parameters: 6337c478bd9Sstevel@tonic-gate * msgf -- filename containing the message. 6347c478bd9Sstevel@tonic-gate * user -- user who should receive it. 6357c478bd9Sstevel@tonic-gate * 6367c478bd9Sstevel@tonic-gate * Returns: 6377c478bd9Sstevel@tonic-gate * none. 6387c478bd9Sstevel@tonic-gate * 6397c478bd9Sstevel@tonic-gate * Side Effects: 6407c478bd9Sstevel@tonic-gate * sends mail to 'user' using /usr/lib/sendmail. 6417c478bd9Sstevel@tonic-gate */ 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate static void 6447c478bd9Sstevel@tonic-gate sendmessage(msgf, user, myname) 6457c478bd9Sstevel@tonic-gate char *msgf; 6467c478bd9Sstevel@tonic-gate char *user; 6477c478bd9Sstevel@tonic-gate char *myname; 6487c478bd9Sstevel@tonic-gate { 6497c478bd9Sstevel@tonic-gate FILE *f, *fpipe, *tmpf; 6507c478bd9Sstevel@tonic-gate char line[MAXLINE]; 6517c478bd9Sstevel@tonic-gate char *p, *tmpf_name; 6527c478bd9Sstevel@tonic-gate int i, pipefd[2], tmpfd; 6537c478bd9Sstevel@tonic-gate bool seen8bitchars = FALSE; 6547c478bd9Sstevel@tonic-gate bool in_header = TRUE; 6557c478bd9Sstevel@tonic-gate 6567c478bd9Sstevel@tonic-gate /* find the message to send */ 6577c478bd9Sstevel@tonic-gate f = fopen(msgf, "r"); 6587c478bd9Sstevel@tonic-gate if (f == NULL) 6597c478bd9Sstevel@tonic-gate { 6607c478bd9Sstevel@tonic-gate f = fopen("/etc/mail/vacation.def", "r"); 6617c478bd9Sstevel@tonic-gate if (f == NULL) 6627c478bd9Sstevel@tonic-gate usrerr("No message to send"); 6637c478bd9Sstevel@tonic-gate exit(EX_OSFILE); 6647c478bd9Sstevel@tonic-gate } 6657c478bd9Sstevel@tonic-gate 6667c478bd9Sstevel@tonic-gate if (pipe(pipefd) < 0) { 6677c478bd9Sstevel@tonic-gate usrerr("pipe() failed"); 6687c478bd9Sstevel@tonic-gate exit(EX_OSERR); 6697c478bd9Sstevel@tonic-gate } 6707c478bd9Sstevel@tonic-gate i = fork(); 6717c478bd9Sstevel@tonic-gate if (i < 0) { 6727c478bd9Sstevel@tonic-gate usrerr("fork() failed"); 6737c478bd9Sstevel@tonic-gate exit(EX_OSERR); 6747c478bd9Sstevel@tonic-gate } 6757c478bd9Sstevel@tonic-gate if (i == 0) { 6767c478bd9Sstevel@tonic-gate dup2(pipefd[0], 0); 6777c478bd9Sstevel@tonic-gate close(pipefd[0]); 6787c478bd9Sstevel@tonic-gate close(pipefd[1]); 6797c478bd9Sstevel@tonic-gate fclose(f); 6807c478bd9Sstevel@tonic-gate execl("/usr/lib/sendmail", "sendmail", "-eq", "-f", myname, 6817c478bd9Sstevel@tonic-gate "--", user, NULL); 6827c478bd9Sstevel@tonic-gate usrerr("can't exec /usr/lib/sendmail"); 6837c478bd9Sstevel@tonic-gate exit(EX_OSERR); 6847c478bd9Sstevel@tonic-gate } 6857c478bd9Sstevel@tonic-gate close(pipefd[0]); 6867c478bd9Sstevel@tonic-gate fpipe = fdopen(pipefd[1], "w"); 6877c478bd9Sstevel@tonic-gate if (fpipe == NULL) { 6887c478bd9Sstevel@tonic-gate usrerr("fdopen() failed"); 6897c478bd9Sstevel@tonic-gate exit(EX_OSERR); 6907c478bd9Sstevel@tonic-gate } 6917c478bd9Sstevel@tonic-gate fprintf(fpipe, "To: %s\n", user); 6927c478bd9Sstevel@tonic-gate fputs("Auto-Submitted: auto-replied\n", fpipe); 6937c478bd9Sstevel@tonic-gate fputs("X-Mailer: vacation %I%\n", fpipe); 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate /* 6967c478bd9Sstevel@tonic-gate * We used to write directly to the pipe. But now we need to know 6977c478bd9Sstevel@tonic-gate * what character set to use, and we need to examine the entire 6987c478bd9Sstevel@tonic-gate * message to determine this. So write to a temp file first. 6997c478bd9Sstevel@tonic-gate */ 7007c478bd9Sstevel@tonic-gate tmpf_name = strdup(_PATH_TMP); 7017c478bd9Sstevel@tonic-gate if (tmpf_name == NULL) { 7027c478bd9Sstevel@tonic-gate usrerr("newstr: cannot alloc memory"); 7037c478bd9Sstevel@tonic-gate exit(EX_OSERR); 7047c478bd9Sstevel@tonic-gate } 7057c478bd9Sstevel@tonic-gate tmpfd = -1; 7067c478bd9Sstevel@tonic-gate tmpfd = mkstemp(tmpf_name); 7077c478bd9Sstevel@tonic-gate if (tmpfd == -1) { 7087c478bd9Sstevel@tonic-gate usrerr("can't open temp file %s", tmpf_name); 7097c478bd9Sstevel@tonic-gate exit(EX_OSERR); 7107c478bd9Sstevel@tonic-gate } 7117c478bd9Sstevel@tonic-gate tmpf = fdopen(tmpfd, "w"); 7127c478bd9Sstevel@tonic-gate if (tmpf == NULL) { 7137c478bd9Sstevel@tonic-gate usrerr("can't open temp file %s", tmpf_name); 7147c478bd9Sstevel@tonic-gate exit(EX_OSERR); 7157c478bd9Sstevel@tonic-gate } 7167c478bd9Sstevel@tonic-gate while (fgets(line, MAXLINE, f)) { 7177c478bd9Sstevel@tonic-gate /* 7187c478bd9Sstevel@tonic-gate * Check for a line with no ':' character. If it's just \n, 7197c478bd9Sstevel@tonic-gate * we're at the end of the headers and all is fine. Or if 7207c478bd9Sstevel@tonic-gate * it starts with white-space, then it's a continuation header. 7217c478bd9Sstevel@tonic-gate * Otherwise, it's the start of the body, which means the 7227c478bd9Sstevel@tonic-gate * header/body separator was skipped. So output it. 7237c478bd9Sstevel@tonic-gate */ 7247c478bd9Sstevel@tonic-gate if (in_header && line[0] != '\0' && strchr(line, ':') == NULL) { 7257c478bd9Sstevel@tonic-gate if (line[0] == '\n') 7267c478bd9Sstevel@tonic-gate in_header = FALSE; 7277c478bd9Sstevel@tonic-gate else if (!isspace(line[0])) { 7287c478bd9Sstevel@tonic-gate in_header = FALSE; 7297c478bd9Sstevel@tonic-gate fputs("\n", tmpf); 7307c478bd9Sstevel@tonic-gate } 7317c478bd9Sstevel@tonic-gate } 7327c478bd9Sstevel@tonic-gate p = strchr(line, '$'); 7337c478bd9Sstevel@tonic-gate if (p && strncmp(p, "$SUBJECT", 8) == 0) { 7347c478bd9Sstevel@tonic-gate *p = '\0'; 7357c478bd9Sstevel@tonic-gate seen8bitchars |= any8bitchars(line); 7367c478bd9Sstevel@tonic-gate fputs(line, tmpf); 7377c478bd9Sstevel@tonic-gate if (Subject) { 7387c478bd9Sstevel@tonic-gate if (in_header) 7397c478bd9Sstevel@tonic-gate fputs(EncodedSubject, tmpf); 7407c478bd9Sstevel@tonic-gate else { 7417c478bd9Sstevel@tonic-gate seen8bitchars |= any8bitchars(Subject); 7427c478bd9Sstevel@tonic-gate fputs(Subject, tmpf); 7437c478bd9Sstevel@tonic-gate } 7447c478bd9Sstevel@tonic-gate } 7457c478bd9Sstevel@tonic-gate seen8bitchars |= any8bitchars(p+8); 7467c478bd9Sstevel@tonic-gate fputs(p+8, tmpf); 7477c478bd9Sstevel@tonic-gate continue; 7487c478bd9Sstevel@tonic-gate } 7497c478bd9Sstevel@tonic-gate seen8bitchars |= any8bitchars(line); 7507c478bd9Sstevel@tonic-gate fputs(line, tmpf); 7517c478bd9Sstevel@tonic-gate } 7527c478bd9Sstevel@tonic-gate fclose(f); 7537c478bd9Sstevel@tonic-gate fclose(tmpf); 7547c478bd9Sstevel@tonic-gate 7557c478bd9Sstevel@tonic-gate /* 7567c478bd9Sstevel@tonic-gate * If we haven't seen a funky Subject with Charset, use the default. 7577c478bd9Sstevel@tonic-gate * If we have and it's us-ascii, 8-bit chars in the message file will 7587c478bd9Sstevel@tonic-gate * still result in iso-8859-1. 7597c478bd9Sstevel@tonic-gate */ 7607c478bd9Sstevel@tonic-gate if (Charset[0] == '\0') 7617c478bd9Sstevel@tonic-gate (void) strlcpy(Charset, (seen8bitchars) ? "iso-8859-1" : 7627c478bd9Sstevel@tonic-gate "us-ascii", sizeof (Charset)); 7637c478bd9Sstevel@tonic-gate else if ((strcasecmp(Charset, "us-ascii") == 0) && seen8bitchars) 7647c478bd9Sstevel@tonic-gate (void) strlcpy(Charset, "iso-8859-1", sizeof (Charset)); 7657c478bd9Sstevel@tonic-gate if (Debug) 7667c478bd9Sstevel@tonic-gate printf("Charset is %s\n", Charset); 7677c478bd9Sstevel@tonic-gate fprintf(fpipe, "Content-Type: text/plain; charset=%s\n", Charset); 7687c478bd9Sstevel@tonic-gate fputs("Mime-Version: 1.0\n", fpipe); 7697c478bd9Sstevel@tonic-gate 7707c478bd9Sstevel@tonic-gate /* 7717c478bd9Sstevel@tonic-gate * Now read back in from the temp file and write to the pipe. 7727c478bd9Sstevel@tonic-gate */ 7737c478bd9Sstevel@tonic-gate tmpf = fopen(tmpf_name, "r"); 7747c478bd9Sstevel@tonic-gate if (tmpf == NULL) { 7757c478bd9Sstevel@tonic-gate usrerr("can't open temp file %s", tmpf_name); 7767c478bd9Sstevel@tonic-gate exit(EX_OSERR); 7777c478bd9Sstevel@tonic-gate } 7787c478bd9Sstevel@tonic-gate while (fgets(line, MAXLINE, tmpf)) 7797c478bd9Sstevel@tonic-gate fputs(line, fpipe); 7807c478bd9Sstevel@tonic-gate fclose(fpipe); 7817c478bd9Sstevel@tonic-gate fclose(tmpf); 7827c478bd9Sstevel@tonic-gate (void) unlink(tmpf_name); 7837c478bd9Sstevel@tonic-gate free(tmpf_name); 7847c478bd9Sstevel@tonic-gate } 7857c478bd9Sstevel@tonic-gate 7867c478bd9Sstevel@tonic-gate /* 7877c478bd9Sstevel@tonic-gate * INITIALIZE -- initialize the database before leaving for vacation 7887c478bd9Sstevel@tonic-gate * 7897c478bd9Sstevel@tonic-gate * Parameters: 7907c478bd9Sstevel@tonic-gate * none. 7917c478bd9Sstevel@tonic-gate * 7927c478bd9Sstevel@tonic-gate * Returns: 7937c478bd9Sstevel@tonic-gate * none. 7947c478bd9Sstevel@tonic-gate * 7957c478bd9Sstevel@tonic-gate * Side Effects: 7967c478bd9Sstevel@tonic-gate * Initializes the files .vacation.{pag,dir} in the 7977c478bd9Sstevel@tonic-gate * caller's home directory. 7987c478bd9Sstevel@tonic-gate */ 7997c478bd9Sstevel@tonic-gate 8007c478bd9Sstevel@tonic-gate static void 8017c478bd9Sstevel@tonic-gate initialize(db_file_base) 8027c478bd9Sstevel@tonic-gate char *db_file_base; 8037c478bd9Sstevel@tonic-gate { 8047c478bd9Sstevel@tonic-gate char *homedir; 8057c478bd9Sstevel@tonic-gate char buf[MAXLINE]; 8067c478bd9Sstevel@tonic-gate DBM *db; 8077c478bd9Sstevel@tonic-gate 8087c478bd9Sstevel@tonic-gate setgid(getgid()); 8097c478bd9Sstevel@tonic-gate setuid(getuid()); 8107c478bd9Sstevel@tonic-gate homedir = getenv("HOME"); 8117c478bd9Sstevel@tonic-gate if (homedir == NULL) { 8127c478bd9Sstevel@tonic-gate usrerr("No home!"); 8137c478bd9Sstevel@tonic-gate exit(EX_NOUSER); 8147c478bd9Sstevel@tonic-gate } 8157c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf), "%s%s%s", homedir, 8167c478bd9Sstevel@tonic-gate (db_file_base[0] == '/') ? "" : "/", db_file_base); 8177c478bd9Sstevel@tonic-gate 8187c478bd9Sstevel@tonic-gate if (!(db = dbm_open(buf, O_WRONLY|O_CREAT|O_TRUNC, 0644))) { 8197c478bd9Sstevel@tonic-gate usrerr("%s: %s\n", buf, strerror(errno)); 8207c478bd9Sstevel@tonic-gate exit(EX_DATAERR); 8217c478bd9Sstevel@tonic-gate } 8227c478bd9Sstevel@tonic-gate dbm_close(db); 8237c478bd9Sstevel@tonic-gate } 8247c478bd9Sstevel@tonic-gate 8257c478bd9Sstevel@tonic-gate /* 8267c478bd9Sstevel@tonic-gate * USRERR -- print user error 8277c478bd9Sstevel@tonic-gate * 8287c478bd9Sstevel@tonic-gate * Parameters: 8297c478bd9Sstevel@tonic-gate * f -- format. 8307c478bd9Sstevel@tonic-gate * 8317c478bd9Sstevel@tonic-gate * Returns: 8327c478bd9Sstevel@tonic-gate * none. 8337c478bd9Sstevel@tonic-gate * 8347c478bd9Sstevel@tonic-gate * Side Effects: 8357c478bd9Sstevel@tonic-gate * none. 8367c478bd9Sstevel@tonic-gate */ 8377c478bd9Sstevel@tonic-gate 8387c478bd9Sstevel@tonic-gate /* PRINTFLIKE1 */ 8397c478bd9Sstevel@tonic-gate void 8407c478bd9Sstevel@tonic-gate usrerr(const char *f, ...) 8417c478bd9Sstevel@tonic-gate { 8427c478bd9Sstevel@tonic-gate va_list alist; 8437c478bd9Sstevel@tonic-gate 8447c478bd9Sstevel@tonic-gate va_start(alist, f); 8457c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "vacation: "); 8467c478bd9Sstevel@tonic-gate (void) vfprintf(stderr, f, alist); 8477c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "\n"); 8487c478bd9Sstevel@tonic-gate va_end(alist); 8497c478bd9Sstevel@tonic-gate } 8507c478bd9Sstevel@tonic-gate 8517c478bd9Sstevel@tonic-gate /* 8527c478bd9Sstevel@tonic-gate * NEWSTR -- copy a string 8537c478bd9Sstevel@tonic-gate * 8547c478bd9Sstevel@tonic-gate * Parameters: 8557c478bd9Sstevel@tonic-gate * s -- the string to copy. 8567c478bd9Sstevel@tonic-gate * 8577c478bd9Sstevel@tonic-gate * Returns: 8587c478bd9Sstevel@tonic-gate * A copy of the string. 8597c478bd9Sstevel@tonic-gate * 8607c478bd9Sstevel@tonic-gate * Side Effects: 8617c478bd9Sstevel@tonic-gate * none. 8627c478bd9Sstevel@tonic-gate */ 8637c478bd9Sstevel@tonic-gate 8647c478bd9Sstevel@tonic-gate static char * 8657c478bd9Sstevel@tonic-gate newstr(s) 8667c478bd9Sstevel@tonic-gate char *s; 8677c478bd9Sstevel@tonic-gate { 8687c478bd9Sstevel@tonic-gate char *p; 8697c478bd9Sstevel@tonic-gate size_t s_sz = strlen(s); 8707c478bd9Sstevel@tonic-gate 8717c478bd9Sstevel@tonic-gate p = malloc(s_sz + 1); 8727c478bd9Sstevel@tonic-gate if (p == NULL) 8737c478bd9Sstevel@tonic-gate { 8747c478bd9Sstevel@tonic-gate usrerr("newstr: cannot alloc memory"); 8757c478bd9Sstevel@tonic-gate exit(EX_OSERR); 8767c478bd9Sstevel@tonic-gate } 8777c478bd9Sstevel@tonic-gate (void) strlcpy(p, s, s_sz + 1); 8787c478bd9Sstevel@tonic-gate return (p); 8797c478bd9Sstevel@tonic-gate } 8807c478bd9Sstevel@tonic-gate 8817c478bd9Sstevel@tonic-gate /* 8827c478bd9Sstevel@tonic-gate * SAMEWORD -- return TRUE if the words are the same 8837c478bd9Sstevel@tonic-gate * 8847c478bd9Sstevel@tonic-gate * Ignores case. 8857c478bd9Sstevel@tonic-gate * 8867c478bd9Sstevel@tonic-gate * Parameters: 8877c478bd9Sstevel@tonic-gate * a, b -- the words to compare. 8887c478bd9Sstevel@tonic-gate * 8897c478bd9Sstevel@tonic-gate * Returns: 8907c478bd9Sstevel@tonic-gate * TRUE if a & b match exactly (modulo case) 8917c478bd9Sstevel@tonic-gate * FALSE otherwise. 8927c478bd9Sstevel@tonic-gate * 8937c478bd9Sstevel@tonic-gate * Side Effects: 8947c478bd9Sstevel@tonic-gate * none. 8957c478bd9Sstevel@tonic-gate */ 8967c478bd9Sstevel@tonic-gate 8977c478bd9Sstevel@tonic-gate static bool 8987c478bd9Sstevel@tonic-gate sameword(a, b) 8997c478bd9Sstevel@tonic-gate register char *a, *b; 9007c478bd9Sstevel@tonic-gate { 9017c478bd9Sstevel@tonic-gate char ca, cb; 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate do 9047c478bd9Sstevel@tonic-gate { 9057c478bd9Sstevel@tonic-gate ca = *a++; 9067c478bd9Sstevel@tonic-gate cb = *b++; 9077c478bd9Sstevel@tonic-gate if (isascii(ca) && isupper(ca)) 9087c478bd9Sstevel@tonic-gate ca = ca - 'A' + 'a'; 9097c478bd9Sstevel@tonic-gate if (isascii(cb) && isupper(cb)) 9107c478bd9Sstevel@tonic-gate cb = cb - 'A' + 'a'; 9117c478bd9Sstevel@tonic-gate } while (ca != '\0' && ca == cb); 9127c478bd9Sstevel@tonic-gate return (ca == cb); 9137c478bd9Sstevel@tonic-gate } 9147c478bd9Sstevel@tonic-gate 9157c478bd9Sstevel@tonic-gate /* 9167c478bd9Sstevel@tonic-gate * When invoked with no arguments, we fall into an automatic installation 9177c478bd9Sstevel@tonic-gate * mode, stepping the user through a default installation. 9187c478bd9Sstevel@tonic-gate */ 9197c478bd9Sstevel@tonic-gate 9207c478bd9Sstevel@tonic-gate static void 9217c478bd9Sstevel@tonic-gate AutoInstall() 9227c478bd9Sstevel@tonic-gate { 9237c478bd9Sstevel@tonic-gate char file[MAXLINE]; 9247c478bd9Sstevel@tonic-gate char forward[MAXLINE]; 9257c478bd9Sstevel@tonic-gate char cmd[MAXLINE]; 9267c478bd9Sstevel@tonic-gate char line[MAXLINE]; 9277c478bd9Sstevel@tonic-gate char *editor; 9287c478bd9Sstevel@tonic-gate FILE *f; 9297c478bd9Sstevel@tonic-gate struct passwd *pw; 9307c478bd9Sstevel@tonic-gate extern mode_t umask(mode_t cmask); 9317c478bd9Sstevel@tonic-gate 9327c478bd9Sstevel@tonic-gate umask(022); 9337c478bd9Sstevel@tonic-gate pw = getpwuid(getuid()); 9347c478bd9Sstevel@tonic-gate if (pw == NULL) { 9357c478bd9Sstevel@tonic-gate usrerr("User ID unknown"); 9367c478bd9Sstevel@tonic-gate exit(EX_NOUSER); 9377c478bd9Sstevel@tonic-gate } 9387c478bd9Sstevel@tonic-gate myname = strdup(pw->pw_name); 9397c478bd9Sstevel@tonic-gate if (myname == NULL) { 9407c478bd9Sstevel@tonic-gate usrerr("Out of memory"); 9417c478bd9Sstevel@tonic-gate exit(EX_OSERR); 9427c478bd9Sstevel@tonic-gate } 9437c478bd9Sstevel@tonic-gate homedir = getenv("HOME"); 9447c478bd9Sstevel@tonic-gate if (homedir == NULL) { 9457c478bd9Sstevel@tonic-gate usrerr("Home directory unknown"); 9467c478bd9Sstevel@tonic-gate exit(EX_NOUSER); 9477c478bd9Sstevel@tonic-gate } 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate printf("This program can be used to answer your mail automatically\n"); 9507c478bd9Sstevel@tonic-gate printf("when you go away on vacation.\n"); 9517c478bd9Sstevel@tonic-gate (void) strlcpy(file, homedir, sizeof (file)); 9527c478bd9Sstevel@tonic-gate (void) strlcat(file, MsgFile, sizeof (file)); 9537c478bd9Sstevel@tonic-gate do { 9547c478bd9Sstevel@tonic-gate f = fopen(file, "r"); 9557c478bd9Sstevel@tonic-gate if (f) { 9567c478bd9Sstevel@tonic-gate printf("You have a message file in %s.\n", file); 9577c478bd9Sstevel@tonic-gate if (ask("Would you like to see it")) { 9587c478bd9Sstevel@tonic-gate (void) snprintf(cmd, sizeof (cmd), 9597c478bd9Sstevel@tonic-gate "/usr/bin/more %s", file); 9607c478bd9Sstevel@tonic-gate system(cmd); 9617c478bd9Sstevel@tonic-gate } 9627c478bd9Sstevel@tonic-gate if (ask("Would you like to edit it")) 9637c478bd9Sstevel@tonic-gate f = NULL; 9647c478bd9Sstevel@tonic-gate } else { 9657c478bd9Sstevel@tonic-gate printf("You need to create a message file" 9667c478bd9Sstevel@tonic-gate " in %s first.\n", file); 9677c478bd9Sstevel@tonic-gate f = fopen(file, "w"); 9687c478bd9Sstevel@tonic-gate if (f == NULL) { 9697c478bd9Sstevel@tonic-gate usrerr("Cannot open %s", file); 9707c478bd9Sstevel@tonic-gate exit(EX_CANTCREAT); 9717c478bd9Sstevel@tonic-gate } 9727c478bd9Sstevel@tonic-gate fprintf(f, "Subject: away from my mail\n"); 9737c478bd9Sstevel@tonic-gate fprintf(f, "\nI will not be reading my mail" 9747c478bd9Sstevel@tonic-gate " for a while.\n"); 9757c478bd9Sstevel@tonic-gate fprintf(f, "Your mail regarding \"$SUBJECT\" will" 9767c478bd9Sstevel@tonic-gate " be read when I return.\n"); 9777c478bd9Sstevel@tonic-gate fclose(f); 9787c478bd9Sstevel@tonic-gate f = NULL; 9797c478bd9Sstevel@tonic-gate } 9807c478bd9Sstevel@tonic-gate if (f == NULL) { 9817c478bd9Sstevel@tonic-gate editor = getenv("VISUAL"); 9827c478bd9Sstevel@tonic-gate if (editor == NULL) 9837c478bd9Sstevel@tonic-gate editor = getenv("EDITOR"); 9847c478bd9Sstevel@tonic-gate if (editor == NULL) 9857c478bd9Sstevel@tonic-gate editor = "/usr/bin/vi"; 9867c478bd9Sstevel@tonic-gate (void) snprintf(cmd, sizeof (cmd), "%s %s", editor, 9877c478bd9Sstevel@tonic-gate file); 9887c478bd9Sstevel@tonic-gate printf("Please use your editor (%s)" 9897c478bd9Sstevel@tonic-gate " to edit this file.\n", editor); 9907c478bd9Sstevel@tonic-gate system(cmd); 9917c478bd9Sstevel@tonic-gate } 9927c478bd9Sstevel@tonic-gate } while (f == NULL); 9937c478bd9Sstevel@tonic-gate fclose(f); 9947c478bd9Sstevel@tonic-gate (void) strlcpy(forward, homedir, sizeof (forward)); 9957c478bd9Sstevel@tonic-gate (void) strlcat(forward, "/.forward", sizeof (forward)); 9967c478bd9Sstevel@tonic-gate f = fopen(forward, "r"); 9977c478bd9Sstevel@tonic-gate if (f) { 9987c478bd9Sstevel@tonic-gate printf("You have a .forward file" 9997c478bd9Sstevel@tonic-gate " in your home directory containing:\n"); 10007c478bd9Sstevel@tonic-gate while (fgets(line, MAXLINE, f)) 10017c478bd9Sstevel@tonic-gate printf(" %s", line); 10027c478bd9Sstevel@tonic-gate fclose(f); 10037c478bd9Sstevel@tonic-gate if (!ask("Would you like to remove it and" 10047c478bd9Sstevel@tonic-gate " disable the vacation feature")) 10057c478bd9Sstevel@tonic-gate exit(EX_OK); 10067c478bd9Sstevel@tonic-gate if (unlink(forward)) 10077c478bd9Sstevel@tonic-gate perror("Error removing .forward file:"); 10087c478bd9Sstevel@tonic-gate else 10097c478bd9Sstevel@tonic-gate printf("Back to normal reception of mail.\n"); 10107c478bd9Sstevel@tonic-gate exit(EX_OK); 10117c478bd9Sstevel@tonic-gate } 10127c478bd9Sstevel@tonic-gate 10137c478bd9Sstevel@tonic-gate printf("To enable the vacation feature" 10147c478bd9Sstevel@tonic-gate " a \".forward\" file is created.\n"); 10157c478bd9Sstevel@tonic-gate if (!ask("Would you like to enable the vacation feature")) { 10167c478bd9Sstevel@tonic-gate printf("OK, vacation feature NOT enabled.\n"); 10177c478bd9Sstevel@tonic-gate exit(EX_OK); 10187c478bd9Sstevel@tonic-gate } 10197c478bd9Sstevel@tonic-gate f = fopen(forward, "w"); 10207c478bd9Sstevel@tonic-gate if (f == NULL) { 10217c478bd9Sstevel@tonic-gate perror("Error opening .forward file"); 10227c478bd9Sstevel@tonic-gate exit(EX_CANTCREAT); 10237c478bd9Sstevel@tonic-gate } 10247c478bd9Sstevel@tonic-gate fprintf(f, "\\%s, \"|/usr/bin/vacation %s\"\n", myname, myname); 10257c478bd9Sstevel@tonic-gate fclose(f); 10267c478bd9Sstevel@tonic-gate printf("Vacation feature ENABLED." 10277c478bd9Sstevel@tonic-gate " Please remember to turn it off when\n"); 10287c478bd9Sstevel@tonic-gate printf("you get back from vacation. Bon voyage.\n"); 10297c478bd9Sstevel@tonic-gate 10307c478bd9Sstevel@tonic-gate initialize(DbFileBase); 10317c478bd9Sstevel@tonic-gate exit(EX_OK); 10327c478bd9Sstevel@tonic-gate } 10337c478bd9Sstevel@tonic-gate 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate /* 10367c478bd9Sstevel@tonic-gate * Ask the user a question until we get a reasonable answer 10377c478bd9Sstevel@tonic-gate */ 10387c478bd9Sstevel@tonic-gate 10397c478bd9Sstevel@tonic-gate static bool 10407c478bd9Sstevel@tonic-gate ask(prompt) 10417c478bd9Sstevel@tonic-gate char *prompt; 10427c478bd9Sstevel@tonic-gate { 10437c478bd9Sstevel@tonic-gate char line[MAXLINE]; 10447c478bd9Sstevel@tonic-gate char *res; 10457c478bd9Sstevel@tonic-gate 10467c478bd9Sstevel@tonic-gate for (;;) { 10477c478bd9Sstevel@tonic-gate printf("%s? ", prompt); 10487c478bd9Sstevel@tonic-gate fflush(stdout); 10497c478bd9Sstevel@tonic-gate res = fgets(line, sizeof (line), stdin); 10507c478bd9Sstevel@tonic-gate if (res == NULL) 10517c478bd9Sstevel@tonic-gate return (FALSE); 10527c478bd9Sstevel@tonic-gate if (res[0] == 'y' || res[0] == 'Y') 10537c478bd9Sstevel@tonic-gate return (TRUE); 10547c478bd9Sstevel@tonic-gate if (res[0] == 'n' || res[0] == 'N') 10557c478bd9Sstevel@tonic-gate return (FALSE); 10567c478bd9Sstevel@tonic-gate printf("Please reply \"yes\" or \"no\" (\'y\' or \'n\')\n"); 10577c478bd9Sstevel@tonic-gate } 10587c478bd9Sstevel@tonic-gate } 1059