IDA-sendmail patch to enable BIT8 use for POP-clients (corrected REPOST)

IDA-sendmail patch to enable BIT8 use for POP-clients (corrected REPOST)

Post by Martin Wend » Wed, 15 Jan 1992 17:13:59



It seems I posted a bug-loaded patchfile (thanks to Paul Pomes who informed me
of this). If you choose to try it out, please inform me if errors are encountered.
 Here's the corrected version (I include all of the article just in case):

MULTIPLE LOCAL MAILER SUPPORT IN IDA SENDMAIL

Summary

This is a patch (unofficial) to sendmail-5.65c+IDA-1.4.4. Applying this patch
will enable the use of a local mailer table with user local-mailer pairs.
In conjunction with the BIT8 flag it will enable the use of character set
conversion for POP or IMAP clients.

Background

The BIT8 flag in sendmail-5.65c+IDA-1.4.4 enables the use of character set
conversion. This is good for converting character sets when exchanging mail
between SMTP hosts with different character sets. Often it is usual to
use a host running sendmail as a POP server (or IMAP). The clients are
also often of different types, Mac's, PC's etc. Because sendmail-5.65c only
has got one local mailer, this mailer will deliver mail with one character
set for both Mac's and PC's. It's fairly simple to define two or more local
mailers identical to the Mlocal except for the C and X arguments used by
the character set conversion kit. Then you define another table in
sendmail.cf:

OKT/usr/local/lib/mail/localtable

and change in

ruleset s0 3:d rule RHS:
change $#LOCAL$@$w$:$>25<$1>$2 to $#$(T$2$:LOCAL$)$@$w$:$>25<$1>$2
ruleset s0 4:th rule RHS:
change $#LOCAL$@$w$:$1$2 to $#$(T$1$:LOCAL$)$@$w$:$1$2
and ruleset s26 7:th rule RHS:
change $#LOCAL $2$w $:$1 to $#$(T$1$:LOCAL$)$@$w$:$1

Then you create the file /usr/local/lib/mail/localtable and write mailer
user pairs in it:

local-a         martin
local-b         peter
etc.

Then you can start sending and receiving mail from your POP client and get
the character conversion that is right for you. But to make this work you
have to be sure that the usernames in localtable aren't aliases, otherwise
sendmail will complain when remaking the aliases table. At our site we use
aliases like this (xaliases):

Martin.Wendel:          <> martin
Peter.Anderson:         <> peter
etc.

It is quite certain that our POP users will define their alias as from
address when sending mail (Murphy's law:-). Therefore the localtable will
have no effect.

The only way to solve this is to insert the alias names also on the
localtable, like this:

local-a         martin
local-a         Martin.Wendel
local-b         peter
local-b         Peter.Anderson

Sendmail will complain about this when redoing the aliases database
because the only mailer that is acceptable for aliases is the local
mailer LocalMailer. Here's where my patch comes in. Instead of
just accepting the local mailer for aliasing I want to use any
mailer whose name starts with "local". Then I can use character set
conversion for local mail to mailboxes read by POP or IMAP clients.

Here's the corrected patchfile:
--- cut here ----
*** ./alias.c.orig      Tue Jan 14 08:17:34 1992
--- ./alias.c   Tue Jan 14 07:55:40 1992
***************
*** 546,550 ****
                        LineNumber++;
                }
!               if (al.q_mailer != LocalMailer)
                {
                        syserr("cannot alias non-local names");
--- 546,554 ----
                        LineNumber++;
                }
! #ifdef MULTILOCAL
!               if(strncasecmp((al.q_mailer)->m_name, "local", 5))
! #else
!               if(al.q_mailer != LocalMailer)
! #endif /* MULTILOCAL */
                {
                        syserr("cannot alias non-local names");
***************
*** 690,696 ****
        if (tTd(27, 1))
                printf("forward(%s)\n", user->q_paddr);
!
!       if (user->q_mailer != LocalMailer || bitset(QBADADDR, user->q_flags))
!               return;
        if (user->q_home == NULL)
                syserr("forward: no home");
--- 694,705 ----
        if (tTd(27, 1))
                printf("forward(%s)\n", user->q_paddr);
!       if (bitset(QBADADDR, user->q_flags) ||
! #ifdef MULTILOCAL
!       strncasecmp((user->q_mailer)->m_name, "local", 5)
! #else
!       user->q_mailer != LocalMailer
! #endif
!           )
!         return;
        if (user->q_home == NULL)
                syserr("forward: no home");
*** ./conf.h.orig       Tue Jan 14 08:18:05 1992
--- ./conf.h    Thu Dec  5 13:45:17 1991
***************
*** 114,117 ****
--- 114,126 ----

  /*
+  * Support multiple local mailers in conjunction with a local-mailer table,
+  * containing optional user mailer pairs. A local mailer is defined by
+  * having the string "local" first in the mailername. Useful when BIT8 is
+  * defined and you plan to have mailboxes used by clients (POP, IMAP etc),
+  * who use different character sets.
+  */
+ # define MULTILOCAL 1    /* */
+
+ /*
  ** Change this to the location where sendmail should read its configuration
  ** file.  Older systems used /usr/lib/sendmail.cf, some newer systems move
*** ./deliver.c.orig    Tue Jan 14 08:18:16 1992
--- ./deliver.c Tue Jan 14 07:56:35 1992
***************
*** 395,400 ****
                **      with the others, so we fudge on the To person.
                */
!
                if (m == LocalMailer)
                {
                        if (user[0] == '/')
--- 395,403 ----
                **      with the others, so we fudge on the To person.
                */
! #ifdef MULTILOCAL
!               if (!strncasecmp(m->m_name, "local", 5))
! #else
                if (m == LocalMailer)
+ #endif /* MULTILOCAL */
                {
                        if (user[0] == '/')
***************
*** 1092,1096 ****
                syserr("Cannot exec %s", m->m_mailer);
                errno = i;
!                 if (m == LocalMailer || errno == EIO || errno == EAGAIN ||
  #if defined(EPROCLIM)
                                                        errno == EPROCLIM ||
--- 1095,1104 ----
                syserr("Cannot exec %s", m->m_mailer);
                errno = i;
!                 if (errno == EIO || errno == EAGAIN ||
! #ifdef MULTILOCAL
!                   strncasecmp(m->m_name, "local", 5) == 0 ||
! #else
!                   m == LocalMailer ||
! #endif /* MULTILOCAL */
  #if defined(EPROCLIM)
                                                        errno == EPROCLIM ||
*** ./envelope.c.orig   Tue Jan 14 08:18:30 1992
--- ./envelope.c        Tue Jan 14 07:57:13 1992
***************
*** 499,504 ****
        SuprErrs = FALSE;

!       if (CurEnv->e_from.q_mailer == LocalMailer &&
!           (pw = getpwnam(CurEnv->e_from.q_user)) != NULL)
        {
                /*
--- 499,510 ----
        SuprErrs = FALSE;

!       if ((pw = getpwnam(CurEnv->e_from.q_user)) != NULL &&
! #ifdef MULTILOCAL
!         !strncasecmp((CurEnv->e_from.q_mailer)->m_name, "local", 5)
! #else
!           CurEnv->e_from.q_mailer == LocalMailer
! #endif
!             )
!
        {
                /*
***************
*** 597,598 ****
--- 603,606 ----
        return (FALSE);
  }
+
+
*** ./headers.c.orig    Tue Jan 14 08:18:47 1992
--- ./headers.c Tue Jan 14 07:57:48 1992
***************
*** 131,135 ****
                if (CurEnv->e_from.q_paddr != NULL &&
                    strcmp(fvalue, CurEnv->e_from.q_paddr) == 0 &&
!                   CurEnv->e_from.q_mailer == LocalMailer)
                        return (hi->hi_flags);
        }
--- 131,140 ----
                if (CurEnv->e_from.q_paddr != NULL &&
                    strcmp(fvalue, CurEnv->e_from.q_paddr) == 0 &&
! #ifdef MULTILOCAL
!                   !strncasecmp((CurEnv->e_from.q_mailer)->m_name, "local", 5)
! #else
!                   CurEnv->e_from.q_mailer == LocalMailer
! #endif /* MULTILOCAL */
!                   )
                        return (hi->hi_flags);
        }
*** ./recipient.c.orig  Tue Jan 14 08:19:01 1992
--- ./recipient.c       Tue Jan 14 07:58:52 1992
***************
*** 215,219 ****

        /* do sickly crude mapping for program mailing, etc. */
!       if (m == LocalMailer && buf[0] == '|')
        {
                a->q_mailer = m = ProgMailer;
--- 215,225 ----

        /* do sickly crude mapping for program mailing, etc. */
!       if (buf[0] == '|' &&
! #ifdef MULTILOCAL
!           !strncasecmp(m->m_name, "local", 5)
! #else
!           m == LocalMailer
! #endif /* MULTILOCAL */
!           )
        {
                a->q_mailer = m = ProgMailer;
***************
*** 260,265 ****
        **  Alias the name and handle :include: specs.
        */
!
!       if (m == LocalMailer && !bitset(QDONTSEND, a->q_flags))
        {
                if (strncmp(a->q_user, ":include:", 9) == 0)
--- 266,276 ----
        **  Alias the name and handle :include: specs.
        */
!       if (!bitset(QDONTSEND, a->q_flags) &&
! #ifdef MULTILOCAL
!       !strncasecmp(m->m_name, "local", 5)
! #else
!       m == LocalMailer
! #endif /* MULTILOCAL */
!           )
        {
                if (strncmp(a->q_user, ":include:", 9) == 0)
***************
*** 289,293 ****
        */

!       if (!bitset(QDONTSEND, a->q_flags) && m == LocalMailer)
        {
                struct stat stb;
--- 300,310 ----
        */

!       if (!bitset(QDONTSEND, a->q_flags) &&
! #ifdef MULTILOCAL
!           !strncasecmp(m->m_name, "local", 5)
! #else
!           m == LocalMailer
! #endif /* MULTILOCAL */
!           )
        {
                struct stat stb;
*** ./savemail.c.orig   Tue Jan 14 08:19:13 1992
--- ./savemail.c        Tue Jan 14 07:59:41 1992
***************
*** 161,165 ****
--- 161,169 ----
                {
                  case ESM_QUIET:
+ #ifdef MULTILOCAL
+                       if (!strncasecmp((e->e_from.q_mailer)->m_name,"local", 5))
+ #else
                        if (e->e_from.q_mailer == LocalMailer)
+ #endif /* MULTILOCAL */
                                state = ESM_DEADLETTER;
                        else
***************
*** 267,271 ****
--- 271,279 ----

                        p = NULL;
+ #ifdef MULTILOCAL
+                       if (!strncasecmp((e->e_from.q_mailer)->m_name, "local", 5))
+ #else
                        if (e->e_from.q_mailer == LocalMailer)
+ #endif /* MULTILOCAL */
                        {
                                if (e->e_from.q_home != NULL)
*** ./usersmtp.c.orig   Tue Jan 14 08:19:30 1992
--- ./usersmtp.c        Tue Jan 14 08:00:12 1992
***************
*** 247,252 ****

        expand("\001g", buf, &buf[sizeof buf - 1], CurEnv);
!       if (CurEnv->e_from.q_mailer == LocalMailer ||
!           !bitnset(M_FROMPATH, m->m_flags))
        {
                smtpmessage("MAIL From:<%s>", m, buf);
--- 247,257 ----

        expand("\001g", buf, &buf[sizeof buf - 1], CurEnv);
!       if ( !bitnset(M_FROMPATH, m->m_flags) ||
! #ifdef MULTILOCAL
!       !strncasecmp((CurEnv->e_from.q_mailer)->m_name, "local", 5)
! #else
!       CurEnv->e_from.q_mailer == LocalMailer
! #endif
!           )
        {
                smtpmessage("MAIL From:<%s>", m, buf);
--- cut here ---

--
______________________________________________________________
E-Mail:Martin.Wen...@UDAC.UU.SE ; Snail-Mail: UDAC
       Domainmas...@UU.SE                     Martin Wendel
       Postmas...@UU.SE                       Box 174
Tel:  018 - 18 77 80                          S-751 04 Uppsala
Int: +46 18 18 77 80                          SWEDEN
Fax: +46 18 51 66 00
______________________________________________________________