🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #9500

Fix for SunOS 4.1.1 Sendmail

#9500
From: Martin Boyer
Date: Thu, 04 Jul 1991 17:18
140 lines
4925 bytes
A while ago, I complained (in gnu.emacs.bugs) about mail errors when
sending messages to global NIS aliases from VM, on a Sun client
machine running SunOS 4.1.1.

Well, I narrowed it down to a bug in SunOS 4.1.1 sendmail (it works
under SunOS 4.0.3). When VM passes a message to sendmail, it tells
sendmail to look in the message to parse the destination addresses.
This is done when sendmail is invoked with the '-t' flag, but it
doesn't work with system-wide aliases (it should).  If the same
destination address is put on the command line instead, it works.  I
have written a perl filter that scans the message for destination
addresses (what the '-t' flag does) and calls sendmail with those
addresses on the command line.  I've been using it for a month without
a glitch.

If you're using VM (a GNU emacs mail interface) on a mail client
running SunOS 4.1.1, you need this patch (and you need perl to run
it).  Simply install this script somewhere, make sure it is
executable, and tell emacs where it is by adapting this line and
putting it in your .emacs:

(setq sendmail-program "..../sendmail-fix")

For those not using VM, this hack is useful only if you're not using
the standard mail(1) or mailtool(1) interface (mail doesn't use the
'-t' flag).


Martin

PS. Mark Neale <mjn@uucp.jet.uk>, I did get your message about this,
    but the mailers around here couldn't grok your address.


-----------------------------------Cut Here-----------------------------------
#! /local/bin/perl
# ---Le laboratoire de robotique de l'Institut de recherche d'Hydro-Quebec-----
# 
# Nom     : sendmail-fix [sendmail options]
# Fonction: Wrapper to fix the SunOS 4.1.1 defective sendmail.
# Fichiers: sendmail-fix.pl
# Notes   : In emacs, use (setq sendmail-program "..../sendmail-fix")
# 
# Cree    :  3 juin 91 ---------- Martin Boyer <mboyer@ireq-robot.hydro.qc.ca>
# Modifie :  3 juin 91 --------1- Martin Boyer <mboyer@ireq-robot.hydro.qc.ca>
#           Copyright (c) 1991 Hydro-Quebec
# 
# Historique: 
# -----------------------------------------------------------------------------

# This simply recognizes the -t option and parses the mail message to
# dig out the recipients.  The recipients are then passed as command line
# arguments to sendmail.  This is a hack, but I'll be glad to get the bugs out
# if you document and send them to my attention.


#The sendmail progam itself

$sendmail = '/usr/lib/sendmail';

while ($_ = $ARGV[0]) {
    shift;
    if (/^-t/) {
	$parse++;
    } else {
	@nargv = (@nargv, $_);
    }    
}

# printf("ARGS: %s\n", join(" ", @nargv));

sub cleanup {
    unlink $tmpname;
    exit(1);
}

if ($parse) {

    # Look for comma-separated destination addresses in the message

    $tmpname = "/tmp/sm-fix$$";

    $SIG{'INT'} = 'cleanup';
    $SIG{'QUIT'} = 'cleanup';
    $SIG{'TERM'} = 'cleanup';

    open(TMP, ">$tmpname");

    while ( $line = <> ) {
	print TMP $line;
	chop ($line);
	
	# The end of header is marked by the first empty line.
	last if $line eq "";

	# Skip uninteresting lines
	next unless $line =~ /^(To|Bcc|Cc|Fcc):\s+(.*)/io;

	# Remove (user) fields
	$line = $2;
	$line =~ s/\([^()]*\)//go;
	# Split into individual recipients
	split(/,+/, $line);
	# If an <address> field is present, use that
	foreach (@_) { s/.*\<([^<>]*)\>.*/$1/o; };
	@dest = (@dest, @_);
    }

    # Output the rest of the message.
    while (<>) {
	print TMP $_;
    }
    close TMP;

    # printf("Dest: %s\n", join(" ", @dest));
    $cmd = sprintf("$sendmail %s %s < $tmpname",
		   join(" ", @nargv), join(" ", @dest));
    # print $cmd, "\n";
    system $cmd;
    unlink $tmpname;

} else {

    # If the -t option isn't used, do nothing
    open(CMD, sprintf("| $sendmail %s", join(" ", @nargv)));
    while (<>) {
	print CMD $_;
    }
    close CMD;

}

exit 0;
---------------------------------------------------------------------------

--
Martin Boyer                            mboyer@ireq-robot.hydro.qc.ca
Institut de recherche d'Hydro-Quebec    mboyer@ireq-robot.uucp
Varennes, QC, Canada   J3X 1S1
+1 514 652-8412
Technical Details
Message-ID: <GAMIN.91Jul4131814@pellan.ireq-robot.hydro.qc.ca>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bonnie.concordia.ca!s3!s3.ireq.hydro.qc.ca!gamin

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6829,f736ae48553f2811,start
X-Google-Attributes: gidf6829,public
X-Google-Thread: f88e1,f736ae48553f2811,start
X-Google-Attributes: gidf88e1,public
X-Google-ArrivalTime: 1991-07-04 11:15:18 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bonnie.concordia.ca!s3!s3.ireq.hydro.qc.ca!gamin
From: gamin@ireq-robot.hydro.qc.ca (Martin Boyer)
Newsgroups: gnu.emacs.vm.bug,alt.sys.sun
Subject: Fix for SunOS 4.1.1 Sendmail
Message-ID: <GAMIN.91Jul4131814@pellan.ireq-robot.hydro.qc.ca>
Date: 4 Jul 91 17:18:14 GMT
Sender: usenet@s3.ireq.hydro.qc.ca
Distribution: gnu
Organization: Le laboratoire de robotique de l'Institut de recherche
 d'Hydro-Quebec
Lines: 140