Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!jhunix!andy From: andy@jhunix.HCF.JHU.EDU (Andy S Poling) Newsgroups: comp.mail.sendmail Subject: Re: Intermittent .forward problem Summary: fix for queueing when .forwarding to a program Message-ID: <6200@jhunix.HCF.JHU.EDU> Date: 24 Aug 90 14:50:42 GMT References: <9012@ur-cc.UUCP> <9015@ur-cc.UUCP> <9023@ur-cc.UUCP> <1990Aug23.135914@uwm.edu> Reply-To: andy@jhunixhcf.jhu.edu (Andy Poling) Followup-To: comp.mail.sendmail Organization: The Johns Hopkins University - HCF Lines: 96 In article <1990Aug23.135914@uwm.edu> wls@uwm.edu (Bill Stapleton) writes: >In article <9023@ur-cc.UUCP>, msir@sulu.cc.rochester.edu (Mark Sirota) writes: >> In article <9012@ur-cc.UUCP> I write: >> > Sometimes, and I do mean sometimes, our sendmail seems to be ignoring >> > .forward files, and delivering locally instead. >> >> I really appreciate all the mail I'm getting regarding this problem. It's >> unfortunate that almost everyone is answering a question that I didn't ask. >> Let me try to rephrase it. > >I'm no sendmail guru, but since nobody's hit it yet, here's a blast from our >past that might apply: > >We had a problem with sendmail behaving differently depending on whether the >mail was sent immediately or queued (at busy times) and sent later. In >particular, it would pick up a program spec from a users' .forward (like >"|vacation") and if it wasn't queuing, it would execute the program as the >user who owned the .forward, ie the "to" user (right). But if the mail was >queued for later, it ended up executing the program as the user sending the >original message, ie the "from" user (wrong). This was fixed here, but I'm >not sure if the problem/fix was reported elsewhere. Ah, the old forwarding to a program with the wrong userid trick. The problem is even worse if the FROM address is not local - then sendmail seems to use the userid & groupid of the person to whom the *previous* message in the queue run was sent. Talk about an apparently random uid... Below is my simple patch for alias.c in 5.61 (I think this section of code is identical in 5.64). What the patch does is this: if this mail will be forwarded, don't read the .forward file yet - queue the mail instead. This way the original TO person's userid & groupid can be determined when forwarding the mail during a later queue run. This is pretty much a quick hack, and it will cause mail that will be forwarded to sit in the queue until your next queue run. We run the queue often enough that it's not a problem here. I consider it a reasonable trade-off. Someone should probably come up with a more sophisticated fix though... -Andy Andy Poling Internet: andy@gollum.hcf.jhu.edu Network Services Group Bitnet: ANDY@JHUNIX Homewood Academic Computing Voice: (301)338-8096 Johns Hopkins University UUCP: uunet!mimsy!aplcen!jhunix!andy *** alias.c~ Fri Aug 24 10:39:37 1990 --- alias.c Fri Aug 24 10:39:38 1990 *************** *** 578,590 if (user->q_home == NULL) syserr("forward: no home"); # endif /* DEBUG */ /* good address -- look for .forward file in home */ define('z', user->q_home, CurEnv); expand("\001z/.forward", buf, &buf[sizeof buf - 1], CurEnv); if (!safefile(buf, user->q_uid, S_IREAD)) return; /* we do have an address to forward to -- do it */ include(buf, "forwarding", user, sendq); } --- 578,608 ----- if (user->q_home == NULL) syserr("forward: no home"); # endif /* DEBUG */ /* good address -- look for .forward file in home */ define('z', user->q_home, CurEnv); expand("\001z/.forward", buf, &buf[sizeof buf - 1], CurEnv); if (!safefile(buf, user->q_uid, S_IREAD)) return; + #ifdef SAFE_FORWARD + /* + * if we will be forwarding, force queueing before we read the + * .forward file. This allows the original To address to live + * through queueing so that we can determine the recipient's uid + * when running the queue at later time. -- ASP + */ + if (!QueueRun) + if (bitset(QQUEUEUP, user->q_flags)) /* already set to queue it */ + return; + else + { + user->q_flags |= QQUEUEUP; /* queue it, don't send now */ + logdelivery("queued"); + return; + } + #endif /* SAFE_FORWARD */ + /* we do have an address to forward to -- do it */ include(buf, "forwarding", user, sendq); }