nmh-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated


From: Ken Hornstein
Subject: [Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated. 23af631076209b31fb28feb90a779ff8dcc153a2
Date: Wed, 15 Feb 2012 20:55:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The nmh Mail Handling System".

The branch, master has been updated
       via  23af631076209b31fb28feb90a779ff8dcc153a2 (commit)
       via  19bff15d9c875e211494e0cc24021888f67b1378 (commit)
       via  1bea35b19a2b952f4af4892c97541fa0715d91b9 (commit)
       via  4e0b71d26ea73fe5ae324cc9c5caa7f204760781 (commit)
       via  5aab34095ffbff27be09091e703e61ddf352ad87 (commit)
       via  681fb6f84e8094c2c857d4341d3e2fb97d377908 (commit)
      from  2793dbafc546ab90800df3591cb63f4747e3374d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=23af631076209b31fb28feb90a779ff8dcc153a2


commit 23af631076209b31fb28feb90a779ff8dcc153a2
Author: Ken Hornstein <address@hidden>
Date:   Wed Feb 15 15:54:47 2012 -0500

    Create test cases for the new format functions for local address writing.

diff --git a/.gitignore b/.gitignore
index b65e540..87e31cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,6 +96,7 @@ a.out.DSYM/
 /uip/whatnow
 /uip/whom
 /uip/*.exe
+/test/getfullname
 
 # Removed by mostlyclean:
 *.o
diff --git a/Makefile.am b/Makefile.am
index 84bf58f..5b473c3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,7 +42,10 @@ TESTS_ENVIRONMENT = MH_TEST_DIR=`pwd`/test/testdir \
 ## Important note: the "cleanup" test should always be last
 ##
 TESTS = test/bad-input/test-header test/folder/test-create \
-       test/folder/test-total test/inc/test-deb359167 test/inc/test-eom-align \
+       test/folder/test-total test/format/test-localmbox \
+       test/format/test-myname test/format/test-myhost \
+       test/format/test-mymbox \
+       test/inc/test-deb359167 test/inc/test-eom-align \
        test/manpages/test-manpages test/mhbuild/test-forw \
        test/mhshow/test-cte-binary test/mhshow/test-qp \
        test/mhshow/test-subpart test/new/test-basic test/pick/test-stderr \
@@ -51,6 +54,7 @@ TESTS = test/bad-input/test-header test/folder/test-create \
        test/whatnow/test-ls test/cleanup
 
 check_SCRIPTS = test/common.sh
+check_PROGRAMS = test/getfullname
 
 ##
 ## Stuff that should be cleaned via "make clean"
@@ -341,6 +345,9 @@ uip_spost_SOURCES = uip/spost.c uip/aliasbr.c
 uip_viamail_SOURCES = uip/viamail.c uip/mhmisc.c uip/mhoutsbr.c uip/sendsbr.c \
                      uip/annosbr.c uip/distsbr.c
 
+test_getfullname_SOURCES = test/getfullname.c
+test_getfullname_LDADD =
+
 ##
 ## Our rebuild rules for files that aren't built via the normal mechanisms
 ##
diff --git a/test/common.sh.in b/test/common.sh.in
index 34767f4..d5a9d7e 100644
--- a/test/common.sh.in
+++ b/test/common.sh.in
@@ -64,6 +64,7 @@ setup_test ()
   export MH_INST_DIR=${MH_TEST_DIR}/inst
   export MHMTSCONF=${MH_INST_DIR}${sysconfdir}/mts.conf
   export PATH=${MH_INST_DIR}${bindir}:${PATH}
+  export MH_LIB_DIR=${MH_INST_DIR}${auxexecdir}
 
   if [ -z "${srcdir}" ]; then
     echo "srcdir not set; aborting"
@@ -84,7 +85,7 @@ setup_test ()
   mkdir $MH_TEST_DIR/Mail || exit 1
   cat > $MH <<EOF || exit 1
 Path: ${MH_TEST_DIR}/Mail
-mhlproc: ${MH_INST_DIR}${auxexecdir}/mhl
+mhlproc: ${MH_LIB_DIR}/mhl
 EOF
 
   for f in MailAliases components digestcomps distcomps forwcomps mhl.body \
diff --git a/test/format/test-localmbox b/test/format/test-localmbox
new file mode 100755
index 0000000..196b03b
--- /dev/null
+++ b/test/format/test-localmbox
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Test that we can retrieve the local mailbox name from the profile via
+# component functions
+#
+
+if [ -z "${MH_TEST_COMMON}" ]; then
+       echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
+testname="Some User <address@hidden>"
+
+echo "Local-Mailbox: ${testname}" >> ${MH}
+
+# We can use "ap" to get the output of format commands
+
+testoutput=$(${MH_LIB_DIR}/ap -format "%(profile Local-Mailbox)" ignore)
+
+if [ x"${testname}" != x"${testoutput}" ]; then
+       echo "Expected ${testname}, got ${testoutput}"
+       exit 1
+fi
+
+exit 0
diff --git a/test/format/test-myhost b/test/format/test-myhost
new file mode 100755
index 0000000..d303a8f
--- /dev/null
+++ b/test/format/test-myhost
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# Test that the %(myhost) function returns the local hostname and
+# the localname entry out of the mts configuration file.
+#
+
+if [ -z "${MH_TEST_COMMON}" ]; then
+       echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
+runtest()
+{
+       testoutput=$(${MH_LIB_DIR}/ap -format "%(myhost)" ignore)
+
+       if [ x"$1" != x"${testoutput}" ]; then
+               echo "For $2, expected $1 but got ${testoutput}"
+               exit 1
+       fi
+}
+
+runtest "$(hostname)" "local hostname test"
+
+cp ${MHMTSCONF} ${MH_TEST_DIR}/Mail/mts.conf || exit 1
+export MHMTSCONF="${MH_TEST_DIR}/Mail/mts.conf"
+
+echo "localname: some.random.name" >> ${MHMTSCONF}
+
+runtest "some.random.name" "mts.conf localname test"
+
+exit 0
diff --git a/test/format/test-mymbox b/test/format/test-mymbox
new file mode 100755
index 0000000..82f0879
--- /dev/null
+++ b/test/format/test-mymbox
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# Test that the %(mymbox) function correctly determines whether or not
+# a particular email address is "mine" or not
+#
+
+if [ -z "${MH_TEST_COMMON}" ]; then
+       echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
+runtest()
+{
+       testoutput=$(${MH_LIB_DIR}/ap -format "%(mymbox{text})" "$1")
+
+       if [ -z "${testoutput}" ]; then
+               echo "Test program did not return anything for $3"
+               exit 1
+       fi
+
+       if [ "${testoutput}" -ne $2 ]; then
+               echo "Did not get expected output for $3"
+               exit 1
+       fi
+}
+
+user="$(id -un)"
+host="$(hostname)"
+
+runtest "${user}" 1 "Basic user test"
+runtest "address@hidden" 1 "Basic address@hidden test"
+runtest "address@hidden" 0 "Basic non-matching test"
+
+myname="Random User <address@hidden>"
+
+echo "Local-Mailbox: ${myname}" >> ${MH}
+
+runtest "${myname}" 1 "Local-Mailbox test"
+runtest "address@hidden" 0 "Local-mailbox overriding address@hidden test"
+
+exit 0
diff --git a/test/format/test-myname b/test/format/test-myname
new file mode 100755
index 0000000..4e1dfaa
--- /dev/null
+++ b/test/format/test-myname
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Test that we can retrieve the local username via the passwd file,
+# the Signature profile entry, and via SIGNATURE environment variable.
+#
+
+if [ -z "${MH_TEST_COMMON}" ]; then
+       echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
+unset SIGNATURE 
+
+runtest()
+{
+       testoutput=$(${MH_LIB_DIR}/ap -format "%(myname)" ignore)
+
+       if [ x"$1" != x"${testoutput}" ]; then
+               echo "For $2, expected $1 but got ${testoutput}"
+               exit 1
+       fi
+}
+
+runtest "$(${MH_OBJ_DIR}/test/getfullname)" "GECOS field test"
+
+echo "Signature: Some Random Name 1" >> ${MH}
+
+runtest "Some Random Name 1" "MH Profile Signature test"
+
+export SIGNATURE="Some Random Name 2"
+
+runtest "${SIGNATURE}" "SIGNATURE Environment test"
+
+exit 0
diff --git a/test/getfullname.c b/test/getfullname.c
new file mode 100644
index 0000000..3afa00f
--- /dev/null
+++ b/test/getfullname.c
@@ -0,0 +1,32 @@
+/*
+ * getfullname.c - Extract a user's name out of the GECOS field in
+ *                the password file.
+ *
+ * This code is Copyright (c) 2012, by the authors of nmh.  See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+int
+main(int argc, char *argv[])
+{
+       struct passwd *pwd;
+
+       pwd = getpwuid(getuid());
+
+       if (! pwd) {
+               fprintf(stderr, "Unable to retrieve user info for "
+                       "userid %d\n", getuid());
+               exit(1);
+       }
+
+       printf("%s\n", pwd->pw_gecos);
+
+       exit(0);
+}

http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=19bff15d9c875e211494e0cc24021888f67b1378


commit 19bff15d9c875e211494e0cc24021888f67b1378
Author: Ken Hornstein <address@hidden>
Date:   Wed Feb 15 15:53:26 2012 -0500

    Make it so we do NOT check our address against the "local" userid and
    hostname if Local-Mailbox is set.

diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c
index 70af81a..7bf4673 100644
--- a/sbr/addrsbr.c
+++ b/sbr/addrsbr.c
@@ -364,6 +364,7 @@ ismymbox (struct mailname *np)
     struct mailname *mp;
     static char *am = NULL;
     static struct mailname mq;
+    static int localmailbox = 0;
 
     /*
      * If this is the first call, initialize
@@ -374,7 +375,8 @@ ismymbox (struct mailname *np)
        mq.m_mbox = getusername ();
 
        if ((am = context_find ("local-mailbox"))) {
-           struct mailname *mptr;
+
+           localmailbox++;
 
            if ((cp = getname(am)) == NULL) {
                admonish (NULL, "Unable to find address in local-mailbox");
@@ -440,25 +442,30 @@ ismymbox (struct mailname *np)
     if (np == NULL) /* XXX */
        return 0;
     
-    switch (np->m_type) {
-       case NETHOST:
-           len = strlen (cp = LocalName (0));
-           if (!uprf (np->m_host, cp) || np->m_host[len] != '.')
-               break;
-           goto local_test;
+    /*
+     * Don't perform this "local" test if we have a Local-Mailbox set
+     */
 
-       case UUCPHOST:
-           if (mh_strcasecmp (np->m_host, SystemName()))
-               break;          /* fall */
-       case LOCALHOST:
+    if (! localmailbox)
+       switch (np->m_type) {
+           case NETHOST:
+               len = strlen (cp = LocalName (0));
+               if (!uprf (np->m_host, cp) || np->m_host[len] != '.')
+                   break;
+               goto local_test;
+
+           case UUCPHOST:
+               if (mh_strcasecmp (np->m_host, SystemName()))
+                   break;              /* fall */
+           case LOCALHOST:
 local_test: ;
-           if (!mh_strcasecmp (np->m_mbox, mq.m_mbox))
-               return 1;
-           break;
+               if (!mh_strcasecmp (np->m_mbox, mq.m_mbox))
+                   return 1;
+               break;
 
-       default:
-           break;
-    }
+           default:
+               break;
+       }
 
     /*
      * Now scan through list of alternate
@@ -467,8 +474,7 @@ local_test: ;
     for (mp = &mq; mp->m_next;) {
        mp = mp->m_next;
        if (!np->m_mbox)
-           continue;
-       if ((len = strlen (cp = np->m_mbox))
+           continue; if ((len = strlen (cp = np->m_mbox))
                < (i = strlen (pp = mp->m_mbox)))
            continue;
        switch (mp->m_type & W_MBOX) {

http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=1bea35b19a2b952f4af4892c97541fa0715d91b9


commit 1bea35b19a2b952f4af4892c97541fa0715d91b9
Author: Ken Hornstein <address@hidden>
Date:   Wed Feb 15 15:46:28 2012 -0500

    Sigh.  Turns out the first entry in the list isn't actually checked, so
    we need to make sure that our Local-Mailbox entry starts second.

diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c
index ffdac3f..70af81a 100644
--- a/sbr/addrsbr.c
+++ b/sbr/addrsbr.c
@@ -370,6 +370,9 @@ ismymbox (struct mailname *np)
      * list of alternate mailboxes.
      */
     if (am == NULL) {
+       mq.m_next = NULL;
+       mq.m_mbox = getusername ();
+
        if ((am = context_find ("local-mailbox"))) {
            struct mailname *mptr;
 
@@ -378,34 +381,20 @@ ismymbox (struct mailname *np)
                return 0;
            }
 
-           if ((mptr = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
+           if ((mq.m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
                admonish (NULL, "invalid entry in local-mailbox: %s", cp);
                return 0;
            }
 
            /*
-            * Yes, we're not freeing the whole entry, because all of those
-            * elements contain allocated pointers that we need; maybe
-            * later ...
-            */
-
-           mq = *mptr;
-
-           free(mptr);
-
-           /*
             * Sigh, it turns out that the address parser gets messed up
             * if you don't call getname() until it returns NULL.
             */
 
            while ((cp = getname(am)) != NULL)
                ;
-       } else {
-           mq.m_mbox = getusername ();
        }
 
-       mq.m_next = NULL;
-
        if ((am = context_find ("alternate-mailboxes")) == NULL)
            am = getusername();
        else {

http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=4e0b71d26ea73fe5ae324cc9c5caa7f204760781


commit 4e0b71d26ea73fe5ae324cc9c5caa7f204760781
Author: Ken Hornstein <address@hidden>
Date:   Wed Feb 15 14:55:25 2012 -0500

    Hm, it turns out we need to make sure we call getname() until we get
    a NULL, otherwise the next set of calls to it will be working from the
    "old" search string.

diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c
index 633f6ef..ffdac3f 100644
--- a/sbr/addrsbr.c
+++ b/sbr/addrsbr.c
@@ -373,8 +373,13 @@ ismymbox (struct mailname *np)
        if ((am = context_find ("local-mailbox"))) {
            struct mailname *mptr;
 
-           if ((mptr = getm (am, NULL, 0, AD_NAME, NULL)) == NULL) {
-               admonish (NULL, "invalid entry in local-mailbox: %s", am);
+           if ((cp = getname(am)) == NULL) {
+               admonish (NULL, "Unable to find address in local-mailbox");
+               return 0;
+           }
+
+           if ((mptr = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
+               admonish (NULL, "invalid entry in local-mailbox: %s", cp);
                return 0;
            }
 
@@ -387,6 +392,14 @@ ismymbox (struct mailname *np)
            mq = *mptr;
 
            free(mptr);
+
+           /*
+            * Sigh, it turns out that the address parser gets messed up
+            * if you don't call getname() until it returns NULL.
+            */
+
+           while ((cp = getname(am)) != NULL)
+               ;
        } else {
            mq.m_mbox = getusername ();
        }

http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=5aab34095ffbff27be09091e703e61ddf352ad87


commit 5aab34095ffbff27be09091e703e61ddf352ad87
Author: Ken Hornstein <address@hidden>
Date:   Wed Feb 15 11:36:36 2012 -0500

    Beginning of support for the Local-Mailbox profile entry.

diff --git a/man/mh-profile.man b/man/mh-profile.man
index ac10b26..9ba9f11 100644
--- a/man/mh-profile.man
+++ b/man/mh-profile.man
@@ -215,6 +215,22 @@ command.
 (context, no default)
 .RE
 .PP
+.BR Local\-Mailbox :
+Your Username <address@hidden>
+.RS 5
+Tells the various MH tools what your local mailbox is.  If set, will be used
+by the default component files by tools like
+.B comp
+and
+.B repl
+to construct your default \*(lqFrom\*(rq header.  The text used here will
+be copied exactly to your From: header, so it should already be RFC-822
+compliant.  If this is set, the
+.B Signature
+profile entry is NOT used, so it should include a signature as well.  (profile,
+default: address@hidden)
+.RE
+.PP
 .BR Alternate\-Mailboxes :
 address@hidden, bug-mh*
 .RS 5
diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c
index 8a468bb..633f6ef 100644
--- a/sbr/addrsbr.c
+++ b/sbr/addrsbr.c
@@ -370,8 +370,29 @@ ismymbox (struct mailname *np)
      * list of alternate mailboxes.
      */
     if (am == NULL) {
+       if ((am = context_find ("local-mailbox"))) {
+           struct mailname *mptr;
+
+           if ((mptr = getm (am, NULL, 0, AD_NAME, NULL)) == NULL) {
+               admonish (NULL, "invalid entry in local-mailbox: %s", am);
+               return 0;
+           }
+
+           /*
+            * Yes, we're not freeing the whole entry, because all of those
+            * elements contain allocated pointers that we need; maybe
+            * later ...
+            */
+
+           mq = *mptr;
+
+           free(mptr);
+       } else {
+           mq.m_mbox = getusername ();
+       }
+
        mq.m_next = NULL;
-       mq.m_mbox = getusername ();
+
        if ((am = context_find ("alternate-mailboxes")) == NULL)
            am = getusername();
        else {

http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=681fb6f84e8094c2c857d4341d3e2fb97d377908


commit 681fb6f84e8094c2c857d4341d3e2fb97d377908
Author: Ken Hornstein <address@hidden>
Date:   Wed Feb 15 10:48:52 2012 -0500

    Support getting the "fullname" out of the Signature profile setting.

diff --git a/sbr/mts.c b/sbr/mts.c
index 3ffdfea..868e603 100644
--- a/sbr/mts.c
+++ b/sbr/mts.c
@@ -412,9 +412,12 @@ getuserinfo (void)
        strncpy (username, pw->pw_name, sizeof(username));
 
     /* The $SIGNATURE environment variable overrides the GECOS field's idea of
-       your real name. */
+       your real name. If SIGNATURE isn't set, use the Signature profile
+       setting if it exists. */
     if ((cp = getenv ("SIGNATURE")) && *cp)
        strncpy (fullname, cp, sizeof(fullname));
+    else if ((cp = context_find("Signature")))
+       strncpy (fullname, cp, sizeof(fullname));
 
     if (strchr(fullname, '.')) {               /*  quote any .'s */
        char tmp[BUFSIZ];
@@ -424,6 +427,8 @@ getuserinfo (void)
        strncpy (fullname, tmp, sizeof(fullname));
     }
 
+    fullname[sizeof(fullname) - 1] = '\0';
+
     return;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                 |    1 +
 Makefile.am                |    9 +++++-
 man/mh-profile.man         |   16 +++++++++++
 sbr/addrsbr.c              |   65 +++++++++++++++++++++++++++++++------------
 sbr/mts.c                  |    7 ++++-
 test/common.sh.in          |    3 +-
 test/format/test-localmbox |   28 +++++++++++++++++++
 test/format/test-myhost    |   34 +++++++++++++++++++++++
 test/format/test-mymbox    |   44 +++++++++++++++++++++++++++++
 test/format/test-myname    |   37 +++++++++++++++++++++++++
 test/getfullname.c         |   32 +++++++++++++++++++++
 11 files changed, 255 insertions(+), 21 deletions(-)
 create mode 100755 test/format/test-localmbox
 create mode 100755 test/format/test-myhost
 create mode 100755 test/format/test-mymbox
 create mode 100755 test/format/test-myname
 create mode 100644 test/getfullname.c


hooks/post-receive
-- 
The nmh Mail Handling System



reply via email to

[Prev in Thread] Current Thread [Next in Thread]