IDA-sendmail patch to enable BIT8 use for POP-clients

IDA-sendmail patch to enable BIT8 use for POP-clients

Post by Martin Wend » Tue, 14 Jan 1992 22:23:50



Multiple Local Mailer Support in IDA Sendmail

Summary

This is a patch 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. Control the new feature with the MULTILOCAL flag.

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. You then 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 patchfile:
--- cut here ----
% diff -rc2 alias.c.orig alias.c
*** alias.c.orig        Fri Jun 21 14:17:13 1991
--- alias.c     Thu Dec  5 14:02:53 1991
***************
*** 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, "local", 5)
! #else
!       user->q_mailer != LocalMailer
! #endif
!           )
!         return;
        if (user->q_home == NULL)
                syserr("forward: no home");
% diff -rc2 conf.h.orig conf.h
*** conf.h.orig Thu Aug  8 13:15:51 1991
--- 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
% diff -rc2 src/deliver.c newsrc/deliver.c
*** deliver.c.orig      Fri Jun 21 14:45:58 1991
--- deliver.c   Thu Dec  5 12:40:38 1991
***************
*** 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, "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, "local", 5) == 0 ||
! #else
!                   m == LocalMailer ||
! #endif /* MULTILOCAL */
  #if defined(EPROCLIM)
                                                        errno == EPROCLIM ||
% diff -rc2 envelope.c.orig envelope.c
*** envelope.c.orig     Fri Jun 21 14:47:48 1991
--- envelope.c  Thu Dec  5 12:47:58 1991
***************
*** 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, "local", 5)
! #else
!           CurEnv->e_from.q_mailer == LocalMailer
! #endif
!             )
!
        {
                /*
***************
*** 597,598 ****
--- 603,606 ----
        return (FALSE);
  }
+
+
% diff -rc2 headers.c.orig headers.c
*** headers.c.orig      Wed Jun 26 23:43:44 1991
--- headers.c   Thu Dec  5 12:50:30 1991
***************
*** 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, "local", 5)
! #else
!                   CurEnv->e_from.q_mailer == LocalMailer
! #endif /* MULTILOCAL */
!                   )
                        return (hi->hi_flags);
        }
% diff -rc2 recipient.c.orig recipient.c
*** recipient.c.orig    Mon Jun 24 18:22:34 1991
--- recipient.c Thu Dec  5 12:57:30 1991
***************
*** 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, "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, "local", 5)
! #else
!           m == LocalMailer
! #endif /* MULTILOCAL */
!           )
        {
                struct stat stb;
% diff -rc2 savemail.c.orig savemail.c
*** savemail.c.orig     Mon Jun 24 18:23:02 1991
--- savemail.c  Thu Dec  5 13:04:59 1991
***************
*** 161,165 ****
--- 161,169 ----
                {
                  case ESM_QUIET:
+ #ifdef MULTILOCAL
+                       if (!strncasecmp(e->e_from.q_mailer,"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, "local", 5))
+ #else
                        if (e->e_from.q_mailer == LocalMailer)
+ #endif /* MULTILOCAL */
                        {
                                if (e->e_from.q_home != NULL)
% diff -rc2 usersmtp.c.orig usersmtp.c
*** usersmtp.c.orig     Mon Jun 24 22:31:35 1991
--- usersmtp.c  Thu Dec  5 13:02:10 1991
***************
*** 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, "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
______________________________________________________________