]> Pileus Git - ~andy/fetchmail/commitdiff
Added the --invisible option.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 8 Oct 1997 20:23:21 +0000 (20:23 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 8 Oct 1997 20:23:21 +0000 (20:23 -0000)
svn path=/trunk/; revision=1492

NEWS
driver.c
fetchmail.c
fetchmail.h
fetchmail.man
options.c
rcfile_l.l
rcfile_y.y
sample.rcfile

diff --git a/NEWS b/NEWS
index b2690f5f70abc5b9014f093f138ac68b5a11f7b1..b68d3f744f799ef509ad59d436890d5c02295f0c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ fetchmail-4.3.1 ()
 * Minor portation fixes for early AIX version and NextSTEP.
 * Fixed a bad interaction between --limit and the repoll feature.
 * = is now optional in global options.
+* Added --invisible option.
 
 There are 276 people on fetchmail-friends and 20 on fetchmail-announce.
 
index 70b500fb53882e552aa2f9facf41a41fcee1f85c..1111035442a8138b8f08597dc530fb1736c45676 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -394,9 +394,10 @@ static int smtp_open(struct query *ctl)
     {
        /* 
         * RFC 1123 requires that the domain name in HELO address is a
-        * "valid principal domain name" for the client host.  We
-        * violate this with malice aforethought in order to make the
-        * Received headers and logging look right.
+        * "valid principal domain name" for the client host. If we're
+        * running in invisible mode, violate this with malice
+        * aforethought in order to make the Received headers and
+        * logging look right.
         *
         * In fact this code relies on the RFC1123 requirement that the
         * SMTP listener must accept messages even if verification of the
@@ -410,6 +411,7 @@ static int smtp_open(struct query *ctl)
         * What it will affect is the listener's logging.
         */
        struct idlist   *idp;
+       char *id_me = use_invisible ? ctl->server.truename : fetchmailhost;
 
        errno = 0;
 
@@ -422,8 +424,7 @@ static int smtp_open(struct query *ctl)
                continue;
 
            if (SMTP_ok(ctl->smtp_socket) == SM_OK &&
-                   SMTP_ehlo(ctl->smtp_socket, 
-                         ctl->server.truename,
+                   SMTP_ehlo(ctl->smtp_socket, id_me,
                          &ctl->server.esmtp_options) == SM_OK)
               break;  /* success */
 
@@ -439,7 +440,7 @@ static int smtp_open(struct query *ctl)
                continue;
 
            if (SMTP_ok(ctl->smtp_socket) == SM_OK && 
-                   SMTP_helo(ctl->smtp_socket, ctl->server.truename) == SM_OK)
+                   SMTP_helo(ctl->smtp_socket, id_me) == SM_OK)
                break;  /* success */
 
            close(ctl->smtp_socket);
@@ -1138,7 +1139,7 @@ int num;          /* index of message */
        n = stuffline(ctl, headers);
        *rcv = 'R';
     }
-    if (n != -1)
+    if (!use_invisible && n != -1)
     {
        /* utter any per-message Received information we need here */
        sprintf(buf, "Received: from %s\n", ctl->server.truename);
@@ -1177,12 +1178,13 @@ int num;                /* index of message */
                time(&now);
                strcat(buf, ctime(&now));
                n = stuffline(ctl, buf);
-               if (n != -1)
-                   n = stuffline(ctl, rcv);    /* ship out rest of headers */
            }
        }
     }
 
+    if (n != -1)
+       n = stuffline(ctl, rcv);        /* ship out rest of headers */
+
     if (n == -1)
     {
        error(0, errno, "writing RFC822 headers");
index 73a1cb3f657577a4d7db952ec4b1ca8941af0e95..4e346a77b6604f0043ce8b85548509b0a2c1de9d 100644 (file)
@@ -170,6 +170,8 @@ int main (int argc, char **argv)
        if (use_syslog)
            printf("Progress messages will be logged via syslog\n");
 #endif
+       if (use_invisible)
+           printf("Fetchmail will masquerade and will not generate Received\n");
        for (ctl = querylist; ctl; ctl = ctl->next) {
            if (ctl->active && !(implicitmode && ctl->server.skip))
                dump_params(ctl);
index 89891d5477ee69caab5517e1a8ccfc16cb633285..4d35dded23ef86cfb08484cf44e7288b372d7d4f 100644 (file)
@@ -203,7 +203,8 @@ extern int yydebug;         /* enable parse debugging */
 extern int poll_interval;      /* poll interval in seconds */
 extern flag nodetach;          /* if TRUE, don't detach daemon process */
 extern char *logfile;          /* log file for daemon mode */
-extern flag use_syslog;                /* if --syslog was set */
+extern flag use_syslog;                /* if syslog was set */
+extern flag use_invisible;     /* if invisible was set */
 extern flag quitmode;          /* if --quit was set */
 extern flag check_only;                /* if --check was set */
 extern char *cmd_logfile;      /* if --logfile was set */
index 638f7f024aaf372a14d9d9aa5e49a5b6949e89dd..f044017c1ffa467f5b0dc5dbd69568945dc459c8 100644 (file)
@@ -572,6 +572,16 @@ or
 option was used.
 .PP
 The 
+.B --invisible
+option 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
index 2a719bdadb0a9445777cacd743649d59b7099384..eaf5606c323c22ad927ff0a786c5f7326201d96c 100644 (file)
--- a/options.c
+++ b/options.c
 #define LA_NODETACH    7
 #define LA_QUIT                8
 #define LA_LOGFILE     9
-#define LA_SYSLOG      10
-#define LA_RCFILE      11
-#define LA_IDFILE      12
-#define LA_PROTOCOL    13
-#define LA_UIDL                14
-#define LA_PORT                15
-#define LA_AUTHENTICATE        16
-#define LA_TIMEOUT     17
-#define LA_ENVELOPE    18
-#define LA_USERNAME    19
-#define LA_ALL          20
-#define LA_NOKEEP      21
-#define        LA_KEEP         22
-#define LA_FLUSH        23
-#define LA_NOREWRITE   24
-#define LA_LIMIT       25
-#define LA_FOLDER      26
-#define LA_SMTPHOST    27
-#define LA_BATCHLIMIT  28
-#define LA_FETCHLIMIT  29
-#define LA_EXPUNGE     30
-#define LA_MDA         31
-#define LA_INTERFACE    32
-#define LA_MONITOR      33
-#define LA_YYDEBUG     34
-#define LA_QVIRTUAL     35
+#define LA_INVISIBLE   10
+#define LA_SYSLOG      11
+#define LA_RCFILE      12
+#define LA_IDFILE      13
+#define LA_PROTOCOL    14
+#define LA_UIDL                15
+#define LA_PORT                16
+#define LA_AUTHENTICATE        17
+#define LA_TIMEOUT     18
+#define LA_ENVELOPE    19
+#define LA_USERNAME    20
+#define LA_ALL          21
+#define LA_NOKEEP      22
+#define        LA_KEEP         23
+#define LA_FLUSH        24
+#define LA_NOREWRITE   25
+#define LA_LIMIT       26
+#define LA_FOLDER      27
+#define LA_SMTPHOST    28
+#define LA_BATCHLIMIT  29
+#define LA_FETCHLIMIT  30
+#define LA_EXPUNGE     31
+#define LA_MDA         32
+#define LA_INTERFACE    33
+#define LA_MONITOR      34
+#define LA_YYDEBUG     35
+#define LA_QVIRTUAL     36
 
 /* options still left: CDgGhHjJoORTUwWxXYzZ */
 static const char *shortoptions = 
@@ -67,6 +68,7 @@ static const struct option longoptions[] = {
   {"nodetach", no_argument,       (int *) 0, LA_NODETACH    },
   {"quit",     no_argument,       (int *) 0, LA_QUIT        },
   {"logfile",  required_argument, (int *) 0, LA_LOGFILE     },
+  {"invisible",        no_argument,       (int *) 0, LA_INVISIBLE   },
   {"syslog",   no_argument,       (int *) 0, LA_SYSLOG      },
   {"fetchmailrc",required_argument,(int *) 0, LA_RCFILE      },
   {"idfile",   required_argument, (int *) 0, LA_IDFILE      },
@@ -169,6 +171,9 @@ struct query *ctl;  /* option record to be initialized */
        case LA_LOGFILE:
            cmd_logfile = optarg;
            break;
+       case LA_INVISIBLE:
+           use_invisible = TRUE;
+           break;
        case 'f':
        case LA_RCFILE:
            rcfile = (char *) xmalloc(strlen(optarg)+1);
@@ -360,6 +365,7 @@ struct query *ctl;  /* option record to be initialized */
        fputs("  -q, --quit        kill daemon process\n", stderr);
        fputs("  -L, --logfile     specify logfile name\n", stderr);
        fputs("      --syslog      use syslog(3) for most messages when running as a daemon\n", stderr);
+       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);
 #ifdef linux
index b6fc9b628f7807cdb4a69f23948d5d8d94f0a0a5..4a612f8781b46ad47358dc4559abe1c86bde5ecd 100644 (file)
@@ -24,6 +24,7 @@ set           { return SET; }
 logfile                { return LOGFILE; }
 daemon         { return DAEMON; }
 syslog         { return SYSLOG; }
+invisible      { return INVISIBLE; }
 
 defaults       { return DEFAULTS; }
 server                 { return POLL; }
index c3e5f51f07f77a83918367f161fd1ea98a83b3b4..3184a24cf8c4edc7ce314a3582e087c79b273580 100644 (file)
@@ -30,6 +30,7 @@ struct query cmd_opts;                /* where to put command-line info */
 int poll_interval;             /* poll interval in seconds */
 char *logfile;                 /* log file for daemon mode */
 flag use_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 */
@@ -60,7 +61,7 @@ extern char * yytext;
 %token PRECONNECT POSTCONNECT LIMIT
 %token IS HERE THERE TO MAP WILDCARD
 %token BATCHLIMIT FETCHLIMIT EXPUNGE
-%token SET LOGFILE DAEMON SYSLOG INTERFACE MONITOR
+%token SET LOGFILE DAEMON SYSLOG INVISIBLE INTERFACE MONITOR
 %token <proto> PROTO
 %token <sval>  STRING
 %token <number> NUMBER
@@ -83,6 +84,7 @@ optmap                : MAP | /* EMPTY */;
 statement      : SET LOGFILE optmap STRING     {logfile = xstrdup($4);}
                | SET DAEMON optmap NUMBER      {poll_interval = $4;}
                | SET SYSLOG                    {use_syslog = TRUE;}
+               | SET INVISIBLE                 {use_invisible = TRUE;}
 
 /* 
  * The way the next two productions are written depends on the fact that
index 191a944620b07f9e9d4d062bfdd92d33fd51274e..2250b4d6612a66ec1d0101c32a141ab2b9e2bf68 100644 (file)
@@ -88,6 +88,7 @@
 #   set logfile =              -- must be followed by a string
 #   set daemon                 -- must be followed by a number   
 #   set syslog
+#   set invisible
 #
 # The noise keywords `and', `with', `has', `wants', and `options' are ignored
 # anywhere in an entry; they can be used to make it resemble English.  The