[go: up one dir, main page]

Menu

[d77762]: / vacation.c  Maximize  Restore  History

Download this file

804 lines (756 with data), 18.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
/*
* Copyright (c) 1983, 1987 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1983, 1987 Regents of the University of California.\n\
All rights reserved.\n";
#endif /* not lint */
#ifndef lint
/*static char sccsid[] = "from: @(#)vacation.c 5.19 (Berkeley) 3/23/91";*/
static char rcsid[] __attribute__ ((unused)) =
"$Id$";
#endif /* not lint */
/*
** Vacation
** Copyright (c) 1983 Eric P. Allman
** Berkeley, California
*/
/* ported to Linux and
** Copyright (c) 1993-1998 Harald Milz (hm@seneca.muc.de)
*/
/* some tiny patches recognizing/generating headers
** Mark Seuffert (moak@pirate.de)
*/
/* Raaah! Someone has changed the behaviour of vfork() in the kernel >= 2.2.x
** We'll use fork instead, that works.
** Patrik Schindler (poc@pocnet.net)
*/
/* Aleksey Barabanov <alekseybb@mtu-net.ru>
** Sun Feb 4 00:37:29 2001
** 1.add option -h hostname for virtual domain processing
** 2.realname in /etc/passwd with blank internals
*/
#include <sys/param.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pwd.h>
#include <gdbm.h>
#include <time.h>
#include <syslog.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <paths.h>
#include "tzfile.h"
#include "vacation.h"
/*
* VACATION -- return a message to the sender when on vacation.
*
* This program is invoked as a message receiver. It returns a
* message specified by the user to whomever sent the mail, taking
* care not to return a message too often to prevent "I am on
* vacation" loops.
*/
int
main (int argc, char **argv)
{
extern int optind, opterr;
extern char *optarg;
struct passwd *pw;
ALIAS *cur;
time_t interval;
int ch, iflag, nflag;
char *vacation;
char *vdomain;
char *vusername;
openlog ("vacation", LOG_PID, LOG_MAIL);
opterr = iflag = nflag = rflag = 0;
interval = -1;
vdomain = NULL;
#ifdef _PATH_VACATION
vacation = _PATH_VACATION;
#else
vacation = argv[0];
#endif
if (argc == 1)
nflag = 1;
while ((ch = getopt (argc, argv, "a:h:Iit:jr")) != EOF)
switch ((char) ch)
{
case 'a': /* alias */
if (!(cur = (ALIAS *) malloc ((u_int) sizeof (ALIAS))))
{
perror ("malloc");
exit (-1);
}
cur->name = optarg;
cur->next = names;
names = cur;
break;
case 'h': /* hostname */
vdomain = optarg;
break;
case 'I': /* init the database */
case 'i': /* init the database */
iflag = 1;
break;
case 't':
if (isdigit (*optarg))
{
interval = atol (optarg) * SECSPERDAY; /* unit is `days' */
if (interval < 0)
usage ();
}
else
interval = LONG_MAX;
break;
case 'j': /* don't check To: and Cc: fields */
jflag = 1;
break;
case 'r': /* "Reply-To:" overrides "From:" */
rflag = 1;
break;
case '?':
default:
usage ();
break;
}
argc -= optind;
argv += optind;
if (argc != 1)
{
if (!iflag && !nflag)
usage ();
if (!(pw = getpwuid (getuid ())))
{
syslog (LOG_ERR, "vacation: no such user uid %u.\n", getuid ());
exit (1);
}
}
else if (!(pw = getpwnam (*argv)))
{
syslog (LOG_ERR, "vacation: no such user %s.\n", *argv);
exit (1);
}
if (chdir (pw->pw_dir))
{
syslog (LOG_NOTICE, "vacation: no such directory %s.\n", pw->pw_dir);
exit (1);
}
do
{
db = gdbm_open (VDB, 128, ((iflag || nflag) ? GDBM_NEWDB : GDBM_WRITER),
0644, NULL);
if (!db && errno == EAGAIN)
sleep ((rand () & 7) + 1);
}
while (!db && errno == EAGAIN);
if (!db)
{
syslog (LOG_NOTICE, "vacation: %s: %s\n", VDB, strerror (errno));
exit (1);
}
if (interval != -1)
setinterval (interval);
if (iflag)
{
(void) gdbm_close (db);
exit (0);
}
if (nflag)
{
(void) gdbm_close (db);
initialize (vacation, pw->pw_name);
exit (0);
}
if (!(cur = malloc ((u_int) sizeof (ALIAS))))
exit (1);
cur->name = pw->pw_name;
cur->next = names;
names = cur;
#ifdef DEBUG
printd ("next message");
#endif
readheaders ();
if (!recent ())
{
setreply ();
(void) gdbm_close (db);
if (vdomain)
{ /* add virtual domain to username */
if (!(vusername = (char *) malloc (MAXLINE)))
{
perror ("malloc");
exit (-1);
}
(void) strcpy (vusername, pw->pw_name);
strcat (vusername, "@");
strcat (vusername, vdomain);
sendmessage (vusername, pw->pw_gecos);
free (vusername);
}
else
{
sendmessage (pw->pw_name, pw->pw_gecos);
}
}
else
(void) gdbm_close (db);
exit (0);
/* NOTREACHED */
}
/*
* readheaders --
* read mail headers
*/
void
readheaders (void)
{
register ALIAS *cur;
register char *p;
int tome, cont;
char buf[MAXLINE];
char uucpfrom[MAXLINE];
// char sender[MAXLINE];
// char domain[MAXLINE];
cont = tome = 0;
while (fgets (buf, sizeof (buf), stdin) && *buf != '\n')
switch (toupper (*buf))
{
case 'F': /* "From: " or "From " */
cont = 0;
if (!strncasecmp (buf, "From:", 5))
{ /* "From:" */
if ((p = index (buf, '>')))
{ /* address in <> ? */
*p = '\0'; /* let string end here */
p = index (buf, '<') + 1; /* and start copy here */
}
else
{ /* address isolated */
for (p = buf + 6; *p && *p != ' '; ++p);
*p = '\0';
p = buf + 6; /* start copy here */
}
(void) strcpy (from, p); /* actual copy */
if ((p = index (from, '\n'))) /* was there a NL ? */
*p = '\0';
#ifdef DEBUG
sprintf (logline, "From: >%s<", from);
printd (logline);
#endif
}
else if (!strncasecmp (buf, "From ", 5))
{ /* "From " */
for (p = buf + 5; *p && *p != ' '; ++p);
*p = '\0';
(void) strcpy (uucpfrom, buf + 5); /* this contains a bang path */
if ((p = index (uucpfrom, '\n')))
*p = '\0';
#ifdef DEBUG
sprintf (logline, "From >%s<", uucpfrom);
printd (logline);
#endif
}
else
break; /* other "F" header */
if (index (from, '@') > rindex (from, '.'))
{ /* domain addr. complete? */
if ((p = rindex (uucpfrom, '!')))
{
strcpy (from, p + 1);
strcat (from, "@");
*p = '\0';
}
else
exit (1); /* this should not occur */
if ((p = rindex (uucpfrom, '!')))
strcat (from, p + 1);
else
strcat (from, uucpfrom);
}
#ifdef DEBUG
sprintf (logline, "From: now: >%s<", from);
printd (logline);
#endif
if (junkmail ())
exit (0);
break;
case 'R': /* "Reply-To: " */
cont = 0;
if (!strncasecmp (buf, "Reply-To:", 9))
{ /* much simpler than From: */
for (p = buf + 10; *p && *p != ' '; ++p);
*p = '\0';
(void) strcpy (replyto, buf + 10);
if ((p = index (replyto, '\n')))
*p = '\0';
#ifdef DEBUG
sprintf (logline, "Reply-To: >%s<", replyto);
printd (logline);
#endif
if (junkmail ())
exit (0);
}
break;
case 'S': /* "Subject" */
cont = 0;
if (!strncasecmp (buf, "Subject:", 8))
{
(void) strcpy (subject, buf + 9);
if ((p = index (subject, '\n')))
*p = '\0';
#ifdef DEBUG
sprintf (logline, "Subject found: >%s<", subject);
printd (logline);
#endif
if (junkmail ())
exit (0);
}
break;
case 'P': /* "Precedence:" */
cont = 0;
if (strncasecmp (buf, "Precedence", 10) ||
(buf[10] != ':' && buf[10] != ' ' && buf[10] != '\t'))
break;
if (!(p = index (buf, ':')))
break;
while (*++p && isspace (*p));
if (!*p)
break;
if (!strncasecmp (p, "junk", 4) ||
!strncasecmp (p, "list", 4) || !strncasecmp (p, "bulk", 4))
exit (0);
break;
case 'C': /* "Cc:" */
if (strncasecmp (buf, "Cc:", 3))
break;
cont = 1;
goto findme;
case 'T': /* "To:" */
if (strncasecmp (buf, "To:", 3))
break;
cont = 1;
goto findme;
default:
if (!isspace (*buf) || !cont || tome)
{
cont = 0;
break;
}
findme:
for (cur = names; !tome && cur; cur = cur->next)
tome += nsearch (cur->name, buf);
}
if (!jflag && !tome)
exit (0);
if (!*from)
{
syslog (LOG_NOTICE, "vacation: no \"From:\" line.\n");
exit (2);
}
if (rflag && (*replyto != 0x0))
strcpy (from, replyto);
#ifdef DEBUG
sprintf (logline, "From: %s Reply-To: %s\n", from, replyto);
printd (logline);
#endif
}
/*
* nsearch --
* do a nice, slow, search of a string for a substring.
*/
int
nsearch (register char *name, register char *str)
{
register int len;
register char c;
c = tolower (*name);
for (len = strlen (name); *str; ++str)
if (tolower (*str) == c && !strncasecmp (name, str, len))
return (1);
return (0);
}
/*
* junkmail --
* read the header and return if automagic/junk/bulk mail
*/
int
junkmail (void)
{
static struct ignore
{
char *name;
int len;
} ignore[] =
{
/* I am not sure whether this list is near to complete. Maybe a
separate file containing all the exceptions would be more
handy than hardwiring this into the code. hm */
{
"Lisp-Help", 9},
{
"List-Unsubscribe", 16},
{
"List-Subscribe", 14},
{
"List-Post", 9},
{
"List-Owner", 10},
{
"List-Archive", 12},
{
"-request", 8},
{
"postmaster", 10},
{
"uucp", 4},
{
"mailer-daemon", 13},
{
"mailer", 6},
{
"-relay", 6},
{
"-activists", 10},
{
"-programmers", 12},
{
NULL, 0},};
register struct ignore *cur;
register int len;
register char *p;
/*
* This is mildly amusing, and I'm not positive it's right; trying
* to find the "real" name of the sender, assuming that addresses
* will be some variant of:
*
* From site!site!SENDER%site.domain%site.domain@site.domain
*/
if (!(p = index (from, '%')))
if (!(p = index (from, '@')))
{
if ((p = rindex (from, '!')))
++p;
else
p = from;
for (; *p; ++p);
}
len = p - from;
for (cur = ignore; cur->name; ++cur)
if (len >= cur->len && !strncasecmp (cur->name, p - cur->len, cur->len))
return (1);
return (0);
}
#define VIT "__VACATION__INTERVAL__TIMER__"
/*
* recent --
* find out if user has gotten a vacation message recently.
* use bcopy for machines with alignment restrictions
*/
int
recent (void)
{
datum key, data;
time_t then, next;
/* get interval time */
key.dptr = VIT;
key.dsize = sizeof (VIT);
data = gdbm_fetch (db, key);
if (data.dptr == NULL)
next = SECSPERDAY * DAYSPERWEEK; /* default repeat time is one week */
else
{
bcopy (data.dptr, &next, sizeof (next));
/* Safely stashed in next, now we can release the GDBM pointer */
free (data.dptr);
}
/* get record for this address */
key.dptr = from;
key.dsize = strlen (from);
data = gdbm_fetch (db, key);
if (data.dptr != NULL)
{
bcopy (data.dptr, &then, sizeof (then));
/* Safely stashed in then, we can free the GDBM pointer now */
free (data.dptr);
if (next == LONG_MAX || then + next > time (NULL))
return (1); /* Return 1 to say we've had a recent message */
}
return (0); /* Drop through to return 0 to say no recent message */
}
/*
* setinterval --
* store the reply interval
*/
void
setinterval (time_t interval)
{
datum key, data;
key.dptr = VIT;
key.dsize = sizeof (VIT);
data.dptr = (char *) &interval;
data.dsize = sizeof (interval);
(void) gdbm_store (db, key, data, GDBM_REPLACE);
}
/*
* setreply --
* store that this user knows about the vacation.
*/
void
setreply (void)
{
datum key, data;
time_t now;
key.dptr = from;
key.dsize = strlen (from);
(void) time (&now);
data.dptr = (char *) &now;
data.dsize = sizeof (now);
(void) gdbm_store (db, key, data, GDBM_REPLACE);
}
/*
* sendmessage --
* exec sendmail to send the vacation file to sender
*/
void
sendmessage (char *myname, char *myrealname)
{
register char *p;
FILE *mfp, *sfp;
int i;
int pvect[2];
char buf[MAXLINE];
char line[MAXLINE];
if ((p = index (myrealname, ',')))
{ /* realname with , ? */
*p = '\0'; /* let string end here */
}
while ((p = index (myrealname, ' ')))
{
*p = '_'; /* replace all blanks to underlines */
}
if (index (myrealname, '(') || index (myrealname, ')'))
{
*buf = '\"'; /* put " around realnames with () */
(void) strcpy (buf + 1, myrealname);
strcat (buf, "\"");
}
else
{ /* this is a normal realname */
(void) strcpy (buf, myrealname);
}
#ifdef DEBUG
sprintf (logline, "sendmessage: using realname >%s<", buf);
printd (logline);
#endif
mfp = fopen (VMSG, "r");
if (mfp == NULL)
{
syslog (LOG_NOTICE, "vacation: no ~%s/%s file.\n", myname, VMSG);
exit (1);
}
if (pipe (pvect) < 0)
{
syslog (LOG_ERR, "vacation: pipe: %s", strerror (errno));
exit (1);
}
i = fork ();
if (i < 0)
{
syslog (LOG_ERR, "vacation: fork: %s", strerror (errno));
exit (1);
}
if (i == 0)
{
dup2 (pvect[0], 0);
close (pvect[0]);
close (pvect[1]);
fclose (mfp);
execl (_PATH_SENDMAIL, "sendmail", "-f", myname, "-F", buf, "--", from,
NULL);
syslog (LOG_ERR, "vacation: can't exec %s: %s", _PATH_SENDMAIL,
strerror (errno));
exit (1);
}
close (pvect[0]);
sfp = fdopen (pvect[1], "w");
fprintf (sfp,
"User-Agent: Vacation/1.2.6 http://vacation.sourceforge.net\n");
fprintf (sfp, "Precedence: bulk\n");
fprintf (sfp, "To: %s\n", from);
while (fgets (buf, sizeof buf, mfp))
{
char *sp, *fromp, *subjp, *nextp;
subjp = strstr (buf, "$SUBJECT");
#ifdef DEBUG
if (subjp)
{
sprintf (logline, "sendmessage: found $SUBJECT %s\n", subjp);
printd (logline);
}
#endif
fromp = strstr (buf, "$FROM");
for (sp = buf; subjp || fromp; sp = nextp)
{
if (subjp && !(fromp && fromp < subjp))
{
*subjp = '\0';
nextp = subjp + 8;
sprintf (line, "%s%s", sp, subject);
subjp = NULL;
}
else
{
*fromp = '\0';
nextp = fromp + 5;
sprintf (line, "%s%s", sp, from);
fromp = NULL;
}
fputs (line, sfp);
}
fputs (sp, sfp);
}
fclose (mfp);
fclose (sfp);
}
void
usage (void)
{
puts ("usage: vacation [ -Ii ]");
puts
("or: vacation [ -j ] [ -a alias ] [ -h hostname ] [ -tN ] [ -r ] login");
exit (1);
}
void
initialize (char *path, char *myname)
{
char *editor;
char ebuf[PATH_MAX];
char c;
FILE *message;
FILE *oldmessage;
FILE *forward;
FILE *oldforward;
if (((forward = fopen (FWD, "r")) == NULL))
{
if (((forward = fopen (FWD, "w")) == NULL))
{
fprintf (stderr, "vacation: cannot open %s for reading\n", FWD);
exit (1);
}
}
else
{
if (((oldforward = fopen (OLDFWD, "w")) == NULL))
{
fprintf (stderr, "vacation: cannot open %s for writing\n", OLDFWD);
exit (1);
}
while (((c = fgetc (forward)) != EOF))
{
fprintf (oldforward, "%c", c);
chmod (OLDFWD, 00600);
}
fclose (oldforward);
if (((forward = freopen (FWD, "w", forward)) == NULL))
{
fprintf (stderr, "vacation: cannot open %s for writing\n", FWD);
exit (1);
}
}
fprintf (forward, "\\%s, \"|%s %s\"\n", myname, path, myname);
fclose (forward);
chmod (FWD, 00600);
if (((editor = getenv ("VISUAL")) == NULL))
if (((editor = getenv ("EDITOR")) == NULL))
editor = _PATH_VI;
#ifdef DEBUG
sprintf (logline, "editor: %s\n", editor);
printd (logline);
#endif
if (((message = fopen (VMSG, "r")) == NULL))
{
if (((message = fopen (VMSG, "w")) == NULL))
{
fprintf (stderr, "vacation: cannot open %s\n", VMSG);
exit (1);
}
message = fopen (VMSG, "w");
fprintf (message, "Subject: away from my mail\n\n");
fprintf (message, "I will not be reading my mail for a while.\n");
fprintf (message, "Your mail concerning \"$SUBJECT\"\n");
fprintf (message, "will be read when I'm back.\n");
}
else
{
if (((oldmessage = fopen (OLDVMSG, "w")) == NULL))
{
fprintf (stderr, "vacation: cannot open %s\n", OLDVMSG);
exit (1);
}
while (((c = fgetc (message)) != EOF))
{
fprintf (oldmessage, "%c", c);
}
fclose (oldmessage);
}
fclose (message);
sprintf (ebuf, "%s %s", editor, VMSG);
#ifdef DEBUG
sprintf (logline, "calling editor with \"%s\"\n", ebuf);
printd (logline);
#endif
system (ebuf);
exit (0);
}
#ifdef DEBUG
void
printd (char *message)
{
FILE *file;
time_t now;
char *timestr;
char *p;
time (&now);
timestr = ctime (&now);
if ((p = index (timestr, '\n')))
*p = '\0';
file = fopen ("/tmp/vacation.log", "a");
fprintf (file, "%s %s\n", timestr, message);
fclose (file);
}
#endif