]> Pileus Git - ~andy/fetchmail/commitdiff
Added postmaster option.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 20 Jul 1998 06:19:22 +0000 (06:19 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 20 Jul 1998 06:19:22 +0000 (06:19 -0000)
svn path=/trunk/; revision=1986

NEWS
design-notes.html
driver.c
fetchmail.c
fetchmail.h
fetchmail.man
fetchmailconf
options.c
rcfile_l.l
rcfile_y.y
sample.rcfile

diff --git a/NEWS b/NEWS
index 37fc4f21a27636581ebcf2afbc386cb30dc26f85..ea00e3d2560d5864107955809c3a9876ab694610 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,14 +2,15 @@
 
 * Add an "ident" per-user option for debugging that produces an 
   "X-Fetchmail-ID" header in fetched messages for debugging.
-* -U/--userdefault option to specify postmaster overriding USER.
 * Can the initial gethostname() be eliminated?
 
                                Release Notes:
 
 ------------------------------------------------------------------------------
 fetchmail-4.5.3 ():
-* Minor fixes to the GSSAPI code.  Seems to work with stock UW IMAP now! 
+* Minor fixes to the GSSAPI code.  Seems to work with stock UW IMAP now!
+* Fetchmail running as root now sends misaddressed multidrop mail to
+  `postmaster', not root.  Added `postmaster' option to allow override.
 
 There are 267 people on fetchmail-friends and 249 on fetchmail-announce.
 
@@ -23,7 +24,7 @@ There are 270 people on fetchmail-friends and 245 on fetchmail-announce.
 
 fetchmail-4.5.1 (Wed Jul  1 19:27:56 EDT 1998):
 * Checkalias option from Enrico Musio <enrico.musio@spaziozerouno.it>.
-* Discard Unix From_ lines in headers (copes with Debian bug report #23808.
+* Discard Unix From_ lines in headers (copes with Debian bug report #23808).
 * Tell fetchmailconf not to care if the attempt to create an icon window fails.
 * All fetchmailconf windows now iconify with an image.
 * obituary@freshmeat's enhancements to hook fetchmail into the Red Hat 
index c856511cd625cc7b0279014660dc4e81b21a3176..d01833b11f772ef2017f93e68adf59439b8628c3 100644 (file)
@@ -10,7 +10,7 @@
 <table width="100%" cellpadding=0><tr>
 <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
 <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 1998/07/01 23:29:16 $
+<td width="30%" align=right>$Date: 1998/07/20 06:19:12 $
 </table>
 <HR>
 <H1 ALIGN=CENTER>Design Notes On Fetchmail</H1>
@@ -336,6 +336,8 @@ following minimum steps.
 <LI>Add the new token and a brief description to the header comment of
     sample.rcfile.
 
+<LI>Hack fetchmailconf to configure it.  Bump the fetchmailconf version.
+
 <LI>Add an entry to NEWS.
 </UL>
 
@@ -477,7 +479,7 @@ all shaped the design in one way or another.<P>
 <table width="100%" cellpadding=0><tr>
 <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
 <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 1998/07/01 23:29:16 $
+<td width="30%" align=right>$Date: 1998/07/20 06:19:12 $
 </table>
 
 <P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com">&lt;esr@snark.thyrsus.com&gt;</A></ADDRESS>
index c045393b7ebb51d6ff80ac6fbe5f8240251c8d4b..b4a66194192245480b8de27f595a366d2a48ef7e 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -976,11 +976,11 @@ int num;          /* index of message */
        if (!accept_count)
        {
            no_local_matches = TRUE;
-           save_str(&xmit_names, user, XMIT_ACCEPT);
+           save_str(&xmit_names, run.postmaster, XMIT_ACCEPT);
            if (outlevel == O_VERBOSE)
                error(0, 0, 
                      "no local matches, forwarding to %s",
-                     user);
+                     run.postmaster);
        }
     }
     else       /* it's a single-drop box, use first localname */
index b91e47650ed5d58c339e22266d868a831eeae1e2..41a345676865785a2fd12781117bd41514a5d677 100644 (file)
@@ -987,6 +987,16 @@ static int load_params(int argc, char **argv, int optind)
        initialize_saved_lists(querylist, run.idfile);
 #endif /* POP3_ENABLE */
 
+    /*
+     * If the user didn't set a last-resort user to get misaddressed
+     * multidrop mail, set an appropriate default here.
+     */
+    if (!run.postmaster)
+       if (getuid())                           /* ordinary user */
+           run.postmaster = user;
+       else                                    /* root */
+           run.postmaster = "postmaster";
+
     return(implicitmode);
 }
 
@@ -1146,6 +1156,9 @@ void dump_params (struct runctl *runp, struct query *querylist, flag implicit)
 #endif
     if (runp->invisible)
        printf("Fetchmail will masquerade and will not generate Received\n");
+    if (runp->postmaster)
+       printf("Fetchmail will forward misaddressed multidrop messages to %s.",
+              runp->postmaster);
 
     for (ctl = querylist; ctl; ctl = ctl->next)
     {
index a1f27b54188ecd8ffd5e238a69da3e64a8161985..cfb729a718ab690e3696955b06f04e38d0a0a27a 100644 (file)
@@ -96,6 +96,7 @@ struct runctl
     int                poll_interval;
     flag       use_syslog;
     flag       invisible;
+    char       *postmaster;
 };
 
 struct idlist
index 1831b0405360f56b7cd018f22839b200cb2ceabc..ed24bdc915d403e627d55841cb98886385c92d60 100644 (file)
@@ -657,17 +657,6 @@ or
 option was used.
 .PP
 The 
-.B --invisible
-option (keyword: set invisible) tries to make fetchmail invisible.
-Normally, fetchmail behaves like any other MTA would -- it generates a
-Received header into each message describing its place in the chain of
-transmission, and tells the MTA it forwards to that the mail came from
-the machine fetchmail itself is running on.  If the invisible option
-is on, the Received header is suppressed and fetchmail tries to spoof
-the MTA it forwards to into thinking it came directly from the
-mailserver host.
-.PP
-The 
 .B \-N
 or --nodetach option suppresses backgrounding and detachment of the
 daemon process from its control terminal.  This is primarily useful
@@ -683,6 +672,27 @@ locally due to some transient error, it will be re-fetched during the
 next poll cycle.  (The IMAP logic doesn't delete messages until
 they're delivered, so this problem does not arise.)
 
+.SH ADMINISTRATIVE OPTIONS
+.PP
+The 
+.B --postmaster
+option (keyword: set postmaster) specifies the last-resort username to
+which multidrop mail is to be forwarded if no matching local recipient
+can be found.  Normally this is just the user who invoked fetchmail.
+If the invoking user is root, then the default of this option is
+the user `postmaster'.
+.PP
+The 
+.B --invisible
+option (keyword: set invisible) tries to make fetchmail invisible.
+Normally, fetchmail behaves like any other MTA would -- it generates a
+Received header into each message describing its place in the chain of
+transmission, and tells the MTA it forwards to that the mail came from
+the machine fetchmail itself is running on.  If the invisible option
+is on, the Received header is suppressed and fetchmail tries to spoof
+the MTA it forwards to into thinking it came directly from the
+mailserver host.
+
 .SH RETRIEVAL FAILURE MODES
 The protocols \fIfetchmail\fR uses to talk to mailservers are next to
 bulletproof.  In normal operation forwarding to port 25, no message is
@@ -1059,11 +1069,14 @@ headers of retrieved mail (this is `multidrop mode').  It looks for
 addresses with hostname parts that match your poll name or your `via',
 `aka' or `localdomains' options, and usually also for hostname parts
 which DNS tells it are aliases of the mailserver.  See the discussion
-of `dns', `checkalias', `localdomains', and `aka' for details on how matching
-addresses are handled.  If \fIfetchmail\fR cannot match any mailserver
-usernames or localdomain addresses, the default recipient is the
+of `dns', `checkalias', `localdomains', and `aka' for details on how
+matching addresses are handled.
+.PP
+If \fIfetchmail\fR cannot match any mailserver usernames or
+localdomain addresses, the default recipient is the value of the
+`postmaster' global option if that has been set; otherwise it's the
 calling user (as set by the USER or LOGNAME variable in the
-environment; you could use this to redirect to an alias like postmaster).
+environment).
 .PP
 The `dns' option (normally on) controls the way addresses from
 multidrop mailboxes are checked.  On, it enables logic to check each
@@ -1536,7 +1549,7 @@ run failed while trying to do an SMTP port open or transaction.
 .IP 11
 Fatal DNS error.  Fetchmail encountered an error while performing
 a DNS lookup at startup and could not proceed.
-.IP 11
+.IP 12
 Internal error.  You should see a message on standard error with
 details.
 .PP
index 6d23a4aa66eedd9e5b276545fc69cdfc8f1f45d0..50eddd4267baf83731ebad8e32e50de9885a25bb 100755 (executable)
@@ -7,7 +7,7 @@
 #
 # TO DO: Arrange for save and quit buttons to clean up all frames dependent
 # on the current ones.
-version = "1.0"
+version = "1.1"
 
 from Tkinter import *
 from Dialog import *
@@ -22,6 +22,7 @@ class Configuration:
        self.syslog = FALSE             # Use syslogd for logging?
        self.logfile = None             # No logfile, initially
        self.idfile = os.environ["HOME"] + "/.fetchids"         # Default idfile, initially
+        self.postmaster = None         # No last-resort address, initially
        self.invisible = FALSE          # Suppress Received line & spoof?
        self.servers = []               # List of included sites
        Configuration.typemap = (
@@ -29,6 +30,7 @@ class Configuration:
            ('syslog',          'Boolean'),
            ('logfile',         'String'),
            ('idfile',          'String'),
+           ('postmaster',      'String'),
            ('invisible',       'Boolean'))
 
     def __repr__(self):
@@ -39,6 +41,8 @@ class Configuration:
            str = str + ("set logfile \"%s\"\n" % (self.logfile,));
        if self.idfile != ConfigurationDefaults.idfile:
            str = str + ("set idfile \"%s\"\n" % (self.idfile,));
+       if self.postmaster != ConfigurationDefaults.postmaster:
+           str = str + ("set postmaster \"%s\"\n" % (self.postmaster,));
        if self.poll_interval > 0:
            str = str + "set daemon " + `self.poll_interval` + "\n"
        for site in self.servers:
@@ -544,7 +548,13 @@ Idfile
         If empty, store seen-message IDs in .fetchids under user's home
         directory.  If nonempty, use given file name.
 
-Invisible:
+Postmaster
+        Who to send multidrop mail to as a last resort if no address can
+        be matched.  Normally empty; in this case, fetchmail treats the
+        invoking user as the address of last resort unless that user is
+        root.  If that user is root, fetchmail sends to `postmaster'.
+
+Invisible
         If false (the default) fetchmail generates a Received line into
         each message and generates a HELO from the machine it is running on.
         If true, fetchmail generates no Received line and HELOs as if it were
@@ -618,6 +628,9 @@ class ConfigurationEdit(Frame, MyWidget):
             # Set the idfile
             log = LabeledEntry(gf, '     Idfile:', self.idfile, '14')
             log.pack(side=RIGHT, anchor=E)
+            # Set the postmaster
+            log = LabeledEntry(gf, '     Postmaster:', self.postmaster, '14')
+            log.pack(side=RIGHT, anchor=E)
 
        gf.pack(fill=X)
 
index 69ae2c566bf3ab17fc91656108cc51eef0afe398..892e0f3e30061c83b7bf020ee243bc86017a05d3 100644 (file)
--- a/options.c
+++ b/options.c
 #define LA_NOSYSLOG    12
 #define LA_RCFILE      13
 #define LA_IDFILE      14
-#define LA_PROTOCOL    15
-#define LA_UIDL                16
-#define LA_PORT                17
-#define LA_AUTHENTICATE        18
-#define LA_TIMEOUT     19
-#define LA_ENVELOPE    20
-#define LA_QVIRTUAL     21
-#define LA_USERNAME    22
-#define LA_ALL          23
-#define LA_NOKEEP      24
-#define        LA_KEEP         25
-#define LA_FLUSH        26
-#define LA_NOREWRITE   27
-#define LA_LIMIT       28
-#define LA_FOLDER      29
-#define LA_SMTPHOST    30
-#define LA_SMTPADDR     31
-#define LA_ANTISPAM    32
-#define LA_BATCHLIMIT  33
-#define LA_FETCHLIMIT  34
-#define LA_EXPUNGE     35
-#define LA_MDA         36
-#define LA_NETSEC      37
-#define LA_INTERFACE    38
-#define LA_MONITOR      39
-#define LA_CONFIGDUMP  40
-#define LA_YYDEBUG     41
-
-/* options still left: CgGhHjJoORUwWxXYz */
+#define LA_POSTMASTER  15
+#define LA_PROTOCOL    16
+#define LA_UIDL                17
+#define LA_PORT                18
+#define LA_AUTHENTICATE        19
+#define LA_TIMEOUT     20
+#define LA_ENVELOPE    21
+#define LA_QVIRTUAL     22
+#define LA_USERNAME    23
+#define LA_ALL          24
+#define LA_NOKEEP      25
+#define        LA_KEEP         26
+#define LA_FLUSH        27
+#define LA_NOREWRITE   28
+#define LA_LIMIT       29
+#define LA_FOLDER      30
+#define LA_SMTPHOST    31
+#define LA_SMTPADDR     32
+#define LA_ANTISPAM    33
+#define LA_BATCHLIMIT  34
+#define LA_FETCHLIMIT  35
+#define LA_EXPUNGE     36
+#define LA_MDA         37
+#define LA_NETSEC      38
+#define LA_INTERFACE    39
+#define LA_MONITOR      41
+#define LA_CONFIGDUMP  42
+#define LA_YYDEBUG     43
+
+/* options still left: CgGhHjJoORwWxXYz */
 static const char *shortoptions = 
        "?Vcsvd:NqL:f:i:p:UP:A:t:E:Q:u:akKFnl:r:S:Z:b:B:e:m:T:I:M:y";
 
@@ -82,6 +83,7 @@ static const struct option longoptions[] = {
   {"nosyslog", no_argument,       (int *) 0, LA_NOSYSLOG    },
   {"fetchmailrc",required_argument,(int *) 0, LA_RCFILE      },
   {"idfile",   required_argument, (int *) 0, LA_IDFILE      },
+  {"postmaster",required_argument, (int *) 0, LA_POSTMASTER  },
 
   {"protocol", required_argument, (int *) 0, LA_PROTOCOL    },
   {"proto",    required_argument, (int *) 0, LA_PROTOCOL    },
@@ -275,6 +277,9 @@ struct query *ctl;  /* option record to be initialized */
            rctl->idfile = (char *) xmalloc(strlen(optarg)+1);
            strcpy(rctl->idfile,optarg);
            break;
+       case LA_POSTMASTER:
+           rctl->postmaster = (char *) xmalloc(strlen(optarg)+1);
+           break;
        case 'p':
        case LA_PROTOCOL:
            /* XXX -- should probably use a table lookup here */
@@ -507,6 +512,7 @@ struct query *ctl;  /* option record to be initialized */
        fputs("      --invisible   suppress Received line & enable host spoofing\n", stderr);
        fputs("  -f, --fetchmailrc specify alternate run control file\n", stderr);
        fputs("  -i, --idfile      specify alternate UIDs file\n", stderr);
+       fputs("      --postmaster  specify recipient of last resort\n",stderr);
 #if defined(linux) && !INET6
        fputs("  -I, --interface   interface required specification\n",stderr);
        fputs("  -M, --monitor     monitor interface for activity\n",stderr);
index 6bdff96d196ddd194766abd19e232993b9414862..90fc2230d701fe29b08f6188c32f16ee53a04ddf 100644 (file)
@@ -27,6 +27,7 @@ idfile                { return IDFILE; }
 daemon         { return DAEMON; }
 syslog         { return SYSLOG; }
 invisible      { return INVISIBLE; }
+postmaster     { return POSTMASTER; }
 
 defaults       { return DEFAULTS; }
 server                 { return POLL; }
index f3af36f892032ec84ac63059e3c20818cd1043e8..d6930b2a2be9217e79a225b36cf5c8c601639709 100644 (file)
@@ -33,10 +33,6 @@ char *rcfile;                        /* path name of rc file */
 struct query cmd_opts;         /* where to put command-line info */
 
 /* parser sets these */
-int poll_interval;             /* poll interval in seconds */
-char *logfile;                 /* log file for daemon mode */
-flag errors_to_syslog;         /* if syslog was set */
-flag use_invisible;            /* if invisible was set */
 struct query *querylist;       /* head of server list (globally visible) */
 
 int yydebug;                   /* in case we didn't generate with -- debug */
@@ -65,9 +61,10 @@ extern char * yytext;
 %token AUTHENTICATE TIMEOUT KPOP KERBEROS4 KERBEROS5 KERBEROS
 %token ENVELOPE QVIRTUAL USERNAME PASSWORD FOLDER SMTPHOST MDA SMTPADDRESS
 %token SPAMRESPONSE PRECONNECT POSTCONNECT LIMIT
+%token NETSEC INTERFACE MONITOR
 %token IS HERE THERE TO MAP WILDCARD
 %token BATCHLIMIT FETCHLIMIT EXPUNGE
-%token SET LOGFILE DAEMON SYSLOG IDFILE INVISIBLE NETSEC INTERFACE MONITOR
+%token SET LOGFILE DAEMON SYSLOG IDFILE INVISIBLE POSTMASTER
 %token <proto> PROTO
 %token <sval>  STRING
 %token <number> NUMBER
@@ -90,6 +87,7 @@ optmap                : MAP | /* EMPTY */;
 statement      : SET LOGFILE optmap STRING     {run.logfile = xstrdup($4);}
                | SET IDFILE optmap STRING      {run.idfile = xstrdup($4);}
                | SET DAEMON optmap NUMBER      {run.poll_interval = $4;}
+               | SET POSTMASTER optmap STRING  {run.postmaster = xstrdup($4);}
                | SET SYSLOG                    {run.use_syslog = TRUE;}
                | SET INVISIBLE                 {run.invisible = TRUE;}
 
index 32627ce45c4df9414714976d2a8e3da17144349c..420a4852bbf837b09371d60f755c5d1ee1772a20 100644 (file)
@@ -94,6 +94,7 @@
 #
 #   set logfile                        -- must be followed by a string
 #   set idfile                 -- must be followed by a string
+#   set postmaster             -- must be followed by a string
 #   set daemon                 -- must be followed by a number   
 #   set syslog
 #   set invisible