Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2:Ports
vacation
vacation-1.2.7.1.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File vacation-1.2.7.1.diff of Package vacation
--- Makefile.orig 2012-01-29 21:44:38.112171303 -0500 +++ Makefile 2012-01-29 21:45:22.751613233 -0500 @@ -13,17 +13,8 @@ ifeq "$(ARCH)" "x86_64" # Uncomment below for backwards compatibility of gdbm files. # CFLAGS = $(CFLAGS) -m32 -else -ifeq "$(ARCH)" "ppc" - CFLAGS = $(CFLAGS) -fsigned-char -else -ifeq "$(ARCH)" "ppc64" - CFLAGS = $(CFLAGS) -fsigned-char -endif -endif endif -LFLAGS = -Xlinker -warn-common IFLAGS = LIBS = -lgdbm @@ -45,7 +36,7 @@ BINDIR = $(PREFIX)/bin VACATION = $(BINDIR)/vacation VACLOOK = $(BINDIR)/vaclook -MANDIR = $(PREFIX)/man/man +MANDIR = $(PREFIX)/share/man/man MANEXT1 = 1 VERSION = 1 --- vacation.c.orig 2012-01-29 21:44:45.532078540 -0500 +++ vacation.c 2012-01-30 20:18:31.399615458 -0500 @@ -76,6 +76,7 @@ #include <sys/param.h> #include <sys/stat.h> +#include <sys/vfs.h> #include <fcntl.h> #include <pwd.h> #include <gdbm.h> @@ -91,6 +92,13 @@ #include "tzfile.h" #include "vacation.h" +static void eatmsg (void); +#define EXITIT(excode) { eatmsg(); if (db) gdbm_close(db); exit(excode);} +#define EXITM(excode) { if (!iflag & !lflag) eatmsg(); if (db) gdbm_close(db); exit(excode); } +#ifndef NFS_SUPER_MAGIC +# define NFS_SUPER_MAGIC 0x6969 +#endif + /* Extern definitions for getopt(3) */ extern int optind, opterr; extern char *optarg; @@ -110,14 +118,15 @@ struct passwd *pw; ALIAS *cur; time_t interval; - int ch, iflag, nflag; + int ch, iflag, nflag, mfail, lflag, fflag, flags; char *vacation; char *vdomain; char *vusername; char tmpusername[ 1024 ]; openlog ("vacation", LOG_PID, LOG_MAIL); - opterr = iflag = nflag = rflag = 0; + db = (GDBM_FILE)0; + opterr = iflag = nflag = rflag = mfail = lflag = fflag = 0; interval = -1; vdomain = NULL; #ifdef _PATH_VACATION @@ -125,16 +134,16 @@ #else vacation = argv[0]; #endif - if (argc == 1) + if (argc == 1 || (argc == 2 && (strcmp(argv[1], "-F") == 0))) nflag = 1; - while ((ch = getopt (argc, argv, "a:h:Iit:jrv")) != EOF) + while ((ch = getopt (argc, argv, "a:h:Iit:jrlF")) != EOF) switch ((char) ch) { case 'a': /* alias */ if (!(cur = (ALIAS *) malloc ((u_int) sizeof (ALIAS)))) { - perror ("malloc"); - exit (-1); + mfail++; + break; } cur->name = optarg; cur->next = names; @@ -163,6 +172,12 @@ case 'r': /* "Reply-To:" overrides "From:" */ rflag = 1; break; + case 'l': /* List ~/vacation.db */ + lflag = 1; + break; + case 'F': /* Force creation of ~/vacation.db on NFS HOME */ + fflag = 1; + break; case 'v': /* Output vacation version number */ printf ("Linux Vacation %s\n", VACVERS); exit (0); @@ -175,32 +190,68 @@ argc -= optind; argv += optind; + if (mfail) { + syslog(LOG_NOTICE, "vacation: can't allocate memory for alias.\n"); + closelog(); + EXITM(-1); + } + if (argc != 1) { - if (!iflag && !nflag) + if (!iflag && !nflag && !lflag) usage (); if (!(pw = getpwuid (getuid ()))) { syslog (LOG_ERR, "vacation: no such user uid %u.\n", getuid ()); - exit (1); + closelog(); + EXITM(1); } } else if (!(pw = getpwnam (*argv))) { snprintf( tmpusername, 1023, "%s", *argv ); syslog (LOG_ERR, "vacation: no such user %s.\n", tmpusername); - exit (1); + closelog(); + EXITM(1); } if (chdir (pw->pw_dir)) { syslog (LOG_NOTICE, "vacation: no such directory %s.\n", pw->pw_dir); - exit (1); + closelog(); + EXITM(1); } + if (iflag || nflag) { + struct statfs fs; + flags = GDBM_NEWDB; + if (fflag == 0) { + if (statfs(pw->pw_dir, &fs) < 0) { + syslog(LOG_ERR, "vacation: can not stat %s %s.\n", pw->pw_dir, strerror(errno)); + closelog(); + EXITM(1); + } + if (fs.f_type == NFS_SUPER_MAGIC) { + fprintf(stderr, "vacation: Warning %s is mounted via NFS which may cause\n" + " a corrupted ~/.vacation.db database file!\n\n" + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n" + "Please run vacation on the mail delivering server, which is\n" + "normally the NFS server, or retry with the added option -F to\n" + "force the creation of ~/.vacation.db\n\n" + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n", + pw->pw_dir); + syslog(LOG_NOTICE, "vacation: no database on NFS file system created\n"); + closelog(); + EXITM(1); + } + } + } else if (lflag) + flags = GDBM_READER|GDBM_NOLOCK; + else + flags = GDBM_WRITER; + do { - db = gdbm_open ((char *) VDB, 128, ((iflag || nflag) ? GDBM_NEWDB : GDBM_WRITER), - 0644, NULL); + db = gdbm_open ((char *) VDB, 128, flags, 0644, NULL); if (!db && errno == ENOENT) { db = gdbm_open ((char *) VDB, 128, GDBM_NEWDB, 0644, NULL); @@ -210,12 +261,56 @@ } while (!db && errno == EAGAIN); - if (!db) - { - syslog (LOG_NOTICE, "vacation: %s: %s\n", VDB, strerror (errno)); - exit (1); + if (!db) { + char *errm; + if (errno == 0) + errm = gdbm_strerror(gdbm_errno); + else + errm = gdbm_strerror(errno); + if (lflag || iflag || nflag) { + fprintf(stderr, "vacation: %s: %s\n", (char *) VDB, errm); + close(0); + } + syslog(LOG_NOTICE, "vacation: %s: %s\n", (char *) VDB, errm); + closelog(); + EXITM(1); + } + + if (lflag) { + datum key, next = gdbm_firstkey (db); + + while(next.dptr) { + key = next; + next = gdbm_nextkey(db, key); + + if (key.dptr) { + datum data = gdbm_fetch(db, key); + + if (data.dptr) { + time_t was; + + if (data.dsize == (sizeof(was) >> 1)) { + /* We read on 64bit system 32bit time_t input */ + int32_t in; + + bzero(&was, sizeof(was)); + bcopy(data.dptr, &in, sizeof(in)); + was = (time_t)in; + } else + bcopy(data.dptr, &was, sizeof(was)); + + printf("%-36.*s %.36s", key.dsize, key.dptr, ctime(&was)); + free(data.dptr); + } + + free(key.dptr); + } } + (void) gdbm_close(db); + exit(0); + } + if (interval != -1) setinterval (interval); @@ -232,8 +327,11 @@ exit (0); } - if (!(cur = (ALIAS *) malloc ((u_int) sizeof (ALIAS)))) - exit (1); + if (!(cur = (ALIAS *) malloc ((u_int) sizeof (ALIAS)))) { + syslog(LOG_NOTICE, "vacation: can't allocate memory for username.\n"); + closelog(); + EXITM(-1); + } cur->name = pw->pw_name; cur->next = names; names = cur; @@ -250,8 +348,9 @@ { /* add virtual domain to username */ if (!(vusername = (char *) malloc (MAXLINE))) { - perror ("malloc"); - exit (-1); + syslog(LOG_NOTICE, "vacation: cant' allocation memory for virtual domain.\n"); + closelog(); + EXITM(-1); } (void) strlcpy (vusername, pw->pw_name, MAXLINE); strlcat (vusername, "@", MAXLINE); @@ -266,10 +365,17 @@ } else (void) gdbm_close (db); + closelog(); exit (0); /* NOTREACHED */ } +static void eatmsg() +{ + while(getc(stdin) != EOF) + continue; +} + /* * readheaders -- * read mail headers @@ -322,7 +428,7 @@ *p = '\0'; } else - exit (1); /* this should not occur */ + EXITIT (1); /* this should not occur */ if ((p = rindex (uucpfrom, '!'))) strlcat (from, p + 1, MAXLINE); else @@ -333,7 +439,7 @@ printd (logline); #endif if (junkmail ()) - exit (0); + EXITIT (0); break; case 'R': /* "Reply-To: " */ cont = 0; @@ -345,7 +451,7 @@ printd (logline); #endif if (junkmail ()) - exit (0); + EXITIT (0); } break; case 'S': /* "Subject" */ @@ -360,7 +466,7 @@ printd (logline); #endif if (junkmail ()) - exit (0); + EXITIT (0); } break; case 'P': /* "Precedence:" */ @@ -375,7 +481,7 @@ break; if (!strncasecmp (p, "junk", 4) || !strncasecmp (p, "list", 4) || !strncasecmp (p, "bulk", 4)) - exit (0); + EXITIT (0); break; case 'A': /* "Auto-Submitted:" */ cont = 0; @@ -388,8 +494,12 @@ if (!*p) break; if (strncasecmp (p, "no", 2)) - exit (0); + EXITIT (0); break; + case 'X': /* "To:" */ + cont = 0; + if (strncasecmp(buf, "X-Spam-Flag: YES", 16) == 0) + EXITIT (0); case 'C': /* "Cc:" */ if (strncasecmp (buf, "Cc:", 3)) break; @@ -400,10 +510,6 @@ break; cont = 1; goto findme; - case 'X': /* Don't reply to email marked as spam by SpamAssassin */ - if (!strncasecmp (buf, "X-Spam-Status: Yes", 18)) - exit (0); - break; default: if (!isspace (*buf) || !cont || tome) { @@ -413,13 +519,15 @@ findme: for (cur = names; !tome && cur; cur = cur->next) tome += nsearch (cur->name, buf); - } + } /* switch(toupper(*buf)) */ + if (!jflag && !tome) - exit (0); + EXITIT (0); if (!*from) { syslog (LOG_NOTICE, "vacation: no \"From:\" line.\n"); - exit (2); + closelog(); + EXITIT (2); } if (rflag && (*replyto != 0x0)) strlcpy (from, replyto, MAXLINE); @@ -503,7 +611,11 @@ { "-programmers", 12}, { - NULL, 0},}; + "bugzilla-daemon", 15}, + { + "noreply", 7}, + { + NULL, 0},}; register struct ignore *cur; register int len; register char *p; @@ -609,6 +721,7 @@ /* * sendmessage -- * exec sendmail to send the vacation file to sender + * A "Precedence: bulk" header is automatically added to the message. */ void sendmessage (char *myname, char *myrealname) @@ -628,17 +741,20 @@ if (mfp == NULL) { syslog (LOG_NOTICE, "vacation: no ~%s/%s file.\n", myname, VMSG); + closelog(); exit (1); } if (pipe (pvect) < 0) { syslog (LOG_ERR, "vacation: pipe: %s", strerror (errno)); + closelog(); exit (1); } i = fork (); if (i < 0) { syslog (LOG_ERR, "vacation: fork: %s", strerror (errno)); + closelog(); exit (1); } if (i == 0) @@ -651,6 +767,7 @@ NULL); syslog (LOG_ERR, "vacation: can't exec %s: %s", _PATH_SENDMAIL, strerror (errno)); + closelog(); exit (1); } close (pvect[0]); @@ -699,7 +816,7 @@ void usage (void) { - puts ("usage: vacation [ -I ]"); + puts ("usage: vacation [ -I | -i | -l ] [ -F ]"); puts ("or: vacation [ -j ] [ -a alias ] [ -h hostname ] [ -tN ] [ -r ] login"); exit (1); --- vacation-en.man.orig 2012-01-29 21:44:57.942923384 -0500 +++ vacation-en.man 2012-01-29 21:45:22.753613208 -0500 @@ -25,8 +25,9 @@ .SH SYNOPSIS .B vacation [ -.B \-I | \-i -] +.B \-I | \-i | \-l +] [ +.B \-F .br .B vacation [ @@ -48,6 +49,7 @@ .B \-? ] .I username +.br .SH DESCRIPTION .IX vacation "" "\fLvacation\fR \(em automatic mail replies" .LP @@ -162,9 +164,39 @@ .B \&.vacation.db file and start .BR vacation . +This should only be used on the command line, not +in the +.B \&.forward +file. +.TP +.B \-F +Force creation of +.B \&.vacation.db +even if the +.B $\s-1HOME +directory is identified as a NFS file system. +Please note that the used data base is not portable +between 32bit and 64bit architectures and also not +portable between little and big endianess architectures +even same bit-wide is used for. Therefore the +initial creation of the +.B \&/.vacation.db +should always happen on the server used for receiving +mails for the specific user. +.TP +.B \-l +List the content of the vacation database file +including the address and the associated time of +the last auto-response to that address. +This should only be used on the command line, not +in the +.B \&.forward +file. .LP If the -.B \-I +.BR \-I, \ \-i +or +.B \-l flag is not specified, and a .I user argument is given, --- vaclook.orig 2012-01-29 21:45:06.887811557 -0500 +++ vaclook 2012-01-29 21:45:22.754613195 -0500 @@ -1,14 +1,4 @@ -#!/usr/bin/perl +#!/bin/sh # -# $Id$ - -require 5; # This script requires Perl v5. -use GDBM_File; # Format that 'vacation' uses. - -# Associate the file with local hash. -tie (%vacdb, GDBM_File, "$ENV{'HOME'}/.vacation.db", 0, undef); - -# Dump the contents (with converted time-stamps). -map { - printf ("%-36s %.36s\n", "$_:", scalar (localtime (unpack ('i', $vacdb{$_})))) - } sort keys %vacdb; +# +exec /usr/bin/vacation -lF
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor