[comp.mail.mh] questions about slocal

shore@adobe.com (Andrew Shore) (12/08/88)

I'm having difficulty getting slocal & .maildelivery working....
Here is my setup:

version: MH 6.5 #56[UCI] (duplex) of Fri Oct 16 17:09:44 PDT 1987
options: [ADOBE] [ATZ] [BERK] [BIND] [BSD42] [DPOP] [DUMB] [ISI] [MHE]
         [MHRC] [NETWORK] [RPOP] [SBACKUP='"#"'] [WHATNOW] [SENDMTS]
         [POP]

(You can safely ignore the [ADOBE]).

I'm running on a Sun3 with both SunOS 3.5 and 4.0
with Sendmail SMI-3.2 and SMI-4.0

.forward is:
\shore, "|/usr/local/lib/mh/slocal -user shore"

.maildelivery (for testing) is:
*	-	|	R	"/user/shore/bin/dropinfo $(sender) $(address) $(size) $(reply-to) $(info)"

But we never get that far....

My test message (indented) is:
    From shore Wed Dec  7 13:32:58 1988
    Return-Path: <shore>
    Received: by duplex.adobe.com (3.2/SMI-3.2)
	    id AA07548; Wed, 7 Dec 88 13:32:35 PST
    Date: Wed, 7 Dec 88 13:32:35 PST
    From: shore (Andrew Shore)
    Message-Id: <8812072132.AA07548@duplex.adobe.com>
    To: shore
    Subject: testing

    one two


When I run the message through slocal -debug by hand, I get:

temporary file "/tmp/slocala08112" selected
addr="shore" user="shore" info="" file="/tmp/slocala08112"
sender="(null)" mbox="/usr/spool/mail/shore" home="/user/shore" from=""
ddate="Delivery-Date: Wed, 07 Dec 88 15:03:21 PST
" now=15:03
vec[0]: "*"
vec[1]: "-"
vec[2]: "|"
vec[3]: "R"
vec[4]: "/user/shore/bin/dropinfo $(sender) $(address) $(size) $(reply-to) $(info)"
Segmentation fault (core dumped)


Note that "sender" is NULL. (Dereferencing a NULL pointer on a SUN
causes a segmentation fault and a core dump.)

Looking at the code, function copyinfo in uip/slocal.c is trying to
get the sender by using the "From " line.

But by that time, copyfile in uip/slocal.c has already changed "From "
into ">From ". So sender is never set!

This can be verified by looking at /tmp/slocala08112, the tmp file
above.  It's first line is now:
>From shore Wed Dec  7 13:32:58 1988


What is going on?  This code will never work!

Should copyfile be called with fold = 0, so that
it doesn't prepend the ">" to the "From " line,
OR should copyinfo match ">From " instead of "From "?

In either case, it looks like the I'll end up with what
MH thinks is a header line consisting of
	name=">From shore Wed Dec  7 13" value="32:58 1988
	"

with or without the ">".  This is wrong, but harmless perhaps.

A work-around would be to supply
	-sender <SOMETHING>
to slocal in my .forward file, but sendmail doesn't provide
that information to the .forward environment.  Is there some
trick to play with sendmail.cf?

Does anyone use slocal?
Anyone got the diffs to make it work at all?
Should I give up and get MH 6.6?

Thanks in advance,
--Andy Shore
  shore@adobe.com

dce@mips.COM (David Elliott) (12/09/88)

There is a bug in MH up to and including 6.6.  The routine
strindex (source in sbr/strindex.c) may be given a NULL
pointer and try to use it.  The following patch fixes the
problem (it's made slocal work for me for the past couple
of years):

*** strindex.c.orig	Thu Aug 25 07:47:36 1988
--- strindex.c	Wed Aug 24 15:48:14 1988
***************
*** 7,12 ****
--- 7,16 ----
  {
      register char  *p;
  
+     if (p1 == 0 || p2 == 0) {
+ 	return (-1);
+     }
+ 
      for (p = p2; *p; p++)
  	if (uprf (p, p1))
  	    return (p - p2);

-- 
David Elliott		dce@mips.com  or  {ames,prls,pyramid,decwrl}!mips!dce
"Did you see his eyes?  Did you see his crazy eyes?" -- Iggy (who else?)

edward@vangogh.sybase.com (Ed Hirgelt) (12/10/88)

I've been using slocal for several months with 6.5. I made one change to
sbr/getcpy.c to avoid dereferencing the null pointer. The code now looks
like:

/* getcpy.c - copy a string in managed memory */

#include "../h/mh.h"
#include <stdio.h>


char   *getcpy (str)
register char  *str;
{
    register char  *cp;

    if( str == NULL )
	str = "";

    if ((cp = malloc ((unsigned) (strlen (str) + 1))) == NULL)
	adios (NULLCP, "unable to allocate string storage");

    (void) strcpy (cp, str);
    return cp;
}


The new code is the test for str being null and setting it to the empty
string. It gets rid of the crash although it may ignore other problems.
I've had no problem slocal since.

Good luck...
Ed
--
---------------------------------------------------
Ed Hirgelt		sun!sybase!edward
Sybase, Inc.   
6475 Christie Ave
Emeryville, Ca. 94608