nmh-workers
[Top] [All Lists]

nmh-0.20: Add "-local" option to msgchk and inc

1998-02-05 11:01:49
The patch below adds the option "-local" option to msgchk and inc.
This option tells these programs to check local mail drops even if
"pophost" is set in mts.conf.  It is necessary in environments where
some users read mail by POP and others read mail from local mail
drops, and they all want to be able to use the same MH binaries.

Some of the changes below are actually nothing more than changes in
indentation because blocks have been wrapped inside a new "if"
statement, so to get a better idea of what has changed, you should
probably do a "diff -bu" on msgchk.c and inc.c after applying the
patches.

Jonathan Kamens
American Internet Corp.

Index: man/inc.man
===================================================================
RCS file: /home/aic_tools/src/cvsroot/nmh/nmh-0.20/man/inc.man,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 inc.man
--- inc.man     1998/01/05 16:44:17     1.1.1.1
+++ inc.man     1998/02/05 15:59:23
@@ -28,6 +28,7 @@
 \%[\-width\ columns]
 %nmhbeginpop%
 \%[\-host\ hostname]
+\%[\-local]
 .br
 \%[\-user\ username]
 \%[\-pack\ file]
@@ -117,7 +118,8 @@
 file \*(lqmts.conf\*(rq, or if the `\-host\ hostname' switch is given,
 then \fIinc\fR will query this POP service host for mail to incorporate.
 If the `\-user\ username' switch is not given, then the current username
-is used.
+is used.  The `\-local' switch tells \fIinc\fR to check local mail drops
+even if the \*(lqpophost:\*(rq option is set.
 
 If \fIinc\fR uses POP, then the `\-pack\ file' switch is considered.
 If given, then \fIinc\fR simply uses the POP to \fIpackf\fR\0(1) the
Index: man/msgchk.man
===================================================================
RCS file: /home/aic_tools/src/cvsroot/nmh/nmh-0.20/man/msgchk.man,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 msgchk.man
--- msgchk.man  1998/01/05 16:44:39     1.1.1.1
+++ msgchk.man  1998/02/05 15:56:14
@@ -20,6 +20,7 @@
 %nmhbeginpop%
 \%[\-host\ hostname]
 \%[\-user\ username]
+\%[\-local]
 .br
 %nmhendpop%
 \%[users\ ...]
@@ -53,7 +54,8 @@
 \*(lqmts.conf\*(rq, or if the `\-host\ hostname' switch is given,
 \fImsgchk\fR will query this POP service host as to the status of
 mail waiting.  If the `\-user\ username' switch is not given, then the
-current username is used.
+current username is used.  The `\-local' switch tells \fImsgchk\fR to
+check local mail drops even if the \*(lqpophost:\*(rq option is set.
 
 For debugging purposes, there is also a switch `\-snoop', which will
 allow you to watch the POP transaction take place between you and the
Index: uip/inc.c
===================================================================
RCS file: /home/aic_tools/src/cvsroot/nmh/nmh-0.20/uip/inc.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 inc.c
--- inc.c       1998/01/05 01:37:34     1.1.1.1
+++ inc.c       1998/02/05 15:52:58
@@ -106,6 +106,8 @@
     { "help", 4 },
 #define SNOOPSW                   22
     { "snoop", -5 },
+#define LOCALSW                          23
+    { "local", -5 },
     { NULL, 0 }
 };
 
@@ -118,7 +120,7 @@
 #define INC_POP   1
 
 static int inc_type;
-static int snoop = 0;
+static int snoop = 0, local = 0;
 
 #ifdef POP
 extern char response[];
@@ -192,32 +194,6 @@
     invo_name = r1bindex (argv[0], '/');
     mts_init (invo_name);
 
-#ifdef POP
-# ifdef HESIOD
-    /*
-     * Scheme is:
-     *        use MAILHOST environment variable if present,
-     *  else try Hesiod.
-     *  If that fails, use the default (if any)
-     *  provided by mts.conf in mts_init()
-     */
-    if ((tmphost = getenv("MAILHOST")) != NULL)
-       pophost = tmphost;
-    else if ((po = hes_getmailhost(getusr())) != NULL &&
-            strcmp(po->po_type, "POP") == 0)
-       pophost = po->po_host;
-# endif /* HESIOD */
-    /*
-     * If there is a valid "pophost" entry in mts.conf,
-     * then use it as the default host.
-     */
-    if (pophost && *pophost)
-       host = pophost;
-
-    if ((cp = getenv ("MHPOPDEBUG")) && *cp)
-       snoop++;
-#endif /* POP */
-
     if ((cp = context_find (invo_name))) {
        ap = brkstring (cp = getcpy (cp), " ", "\n");
        ap = copyip (ap, arguments);
@@ -339,6 +315,10 @@
            case SNOOPSW:
                snoop++;
                continue;
+
+           case LOCALSW:
+               local++;
+               continue;
            }
        }
        if (*cp == '+' || *cp == '@') {
@@ -357,7 +337,34 @@
 #endif /* MAILGROUP */
 
 #ifdef POP
-    if (host && !*host)
+    if (!local) {
+# ifdef HESIOD
+       /*
+        * Scheme is:
+        *        use MAILHOST environment variable if present,
+        *  else try Hesiod.
+        *  If that fails, use the default (if any)
+        *  provided by mts.conf in mts_init()
+        */
+       if ((tmphost = getenv("MAILHOST")) != NULL)
+           pophost = tmphost;
+       else if ((po = hes_getmailhost(getusr())) != NULL &&
+                strcmp(po->po_type, "POP") == 0)
+           pophost = po->po_host;
+# endif /* HESIOD */
+       /*
+        * If there is a valid "pophost" entry in mts.conf,
+        * then use it as the default host.
+        */
+       if (pophost && *pophost)
+           host = pophost;
+
+       if ((cp = getenv ("MHPOPDEBUG")) && *cp)
+           snoop++;
+       if (host && !*host)
+           host = NULL;
+    }
+    else
        host = NULL;
     if (from || !host || rpop <= 0)
        setuid (getuid ());
Index: uip/msgchk.c
===================================================================
RCS file: /home/aic_tools/src/cvsroot/nmh/nmh-0.20/uip/msgchk.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 msgchk.c
--- msgchk.c    1998/01/05 01:32:30     1.1.1.1
+++ msgchk.c    1998/02/05 15:52:44
@@ -63,6 +63,8 @@
     { "help", 4 },
 #define SNOOPSW                 12
     { "snoop", -5 },
+#define LOCALSW                        13
+    { "local", -5 },
     { NULL, 0 }
 };
 
@@ -96,7 +98,7 @@
 {
     int datesw = 1, notifysw = NT_ALL;
     int rpop = 0, status = 0;
-    int snoop = 0, vecp = 0;
+    int snoop = 0, vecp = 0, local = 0;
     uid_t uid;
     char *cp, *host = NULL, buf[80], **ap;
     char **argp, *arguments[MAXARGS], *vec[50];
@@ -193,6 +195,10 @@
                case SNOOPSW:
                    snoop++;
                    continue;
+
+               case LOCALSW:
+                   local++;
+                   continue;
            }
        vec[vecp++] = cp;
     }
@@ -201,29 +207,33 @@
     /*
      * If -host is not specified by user
      */
-    if (!host || !*host) {
+    if (! local) {
+       if (!host || !*host) {
 # ifdef HESIOD
-       /*
-        * Scheme is:
-        *        use MAILHOST environment variable if present,
-        *  else try Hesiod.
-        *  If that fails, use the default (if any)
-        *  provided by mts.conf in mts_init()
-        */
-       if ((tmphost = getenv("MAILHOST")) != NULL)
-           pophost = tmphost;
-       else if ((po = hes_getmailhost(vecp ? vec[0] : user)) != NULL &&
-               strcmp(po->po_type, "POP") == 0)
-           pophost = po->po_host;
+           /*
+            * Scheme is:
+            *        use MAILHOST environment variable if present,
+            *  else try Hesiod.
+            *  If that fails, use the default (if any)
+            *  provided by mts.conf in mts_init()
+            */
+           if ((tmphost = getenv("MAILHOST")) != NULL)
+               pophost = tmphost;
+           else if ((po = hes_getmailhost(vecp ? vec[0] : user)) != NULL &&
+                    strcmp(po->po_type, "POP") == 0)
+               pophost = po->po_host;
 # endif /* HESIOD */
-       /*
-        * If "pophost" is specified in mts.conf,
-        * use it as default value.
-        */
-       if (pophost && *pophost)
-           host = pophost;
+           /*
+            * If "pophost" is specified in mts.conf,
+            * use it as default value.
+            */
+           if (pophost && *pophost)
+               host = pophost;
+       }
+       if (host && !*host)
+           host = NULL;
     }
-    if (!host || !*host)
+    else
        host = NULL;
     if (!host || rpop <= 0)
        setuid (uid);


<Prev in Thread] Current Thread [Next in Thread>
  • nmh-0.20: Add "-local" option to msgchk and inc, Jonathan Kamens <=