[comp.mail.elm] Filter

piziali@convex.com (Andy Piziali) (10/16/90)

I discovered today that the elm filter program does not notify inetd(8) of mail
it delivers to /usr/spool/mail.  Inetd(8) tells comsat(8) about the new mail
and, if the user has set biff set to "y" (/dev/tty* owner execute bit set),
comsat(8) writes the bell and mail header to the tty.

In order to use the elm filter program, all incoming mail must be forwarded to
it using the ~/.forward file.  Filter(1) writes all mail messages, not
otherwise processed, to /usr/spool/mail but doesn't notify inetd(8) it has done
so.  Therefore, comsat(8) doesn't know the mail arrived and the bell and
message header are not written to the tty.

Are there any work-arounds for this filter(1) side effect?  Syd, is there an
easy fix to filter(1) we could install?

I am running elm on a Berkeley 4.2 derived operating system, ConvexOS, on a
CONVEX C-240.

syd@DSI.COM (Syd Weinstein) (10/16/90)

piziali@convex.com (Andy Piziali) writes:
:I discovered today that the elm filter program does not notify inetd(8) of mail
:it delivers to /usr/spool/mail.  Inetd(8) tells comsat(8) about the new mail
:and, if the user has set biff set to "y" (/dev/tty* owner execute bit set),
:comsat(8) writes the bell and mail header to the tty.
Gee, I didn't know any MTA notified comsat, I thought it watched
/usr/spool/mail for timestamp changes.

:Syd, is there an
:easy fix to filter(1) we could install?
Nope.  Nor would there be.
-- 
=====================================================================
Sydney S. Weinstein, CDP, CCP                   Elm Coordinator
Datacomp Systems, Inc.                          Voice: (215) 947-9900
syd@DSI.COM or dsinc!syd                        FAX:   (215) 938-0235

gorell@hp-ptp.HP.COM (Beth_Gorell) (10/17/90)

/ hp-ptp:comp.mail.elm / vook@narnia.rtp.dg.com (Eric R Vook) / 10:50 am  Oct 15, 1990 /
> I'd like to have elm ring a bell when I get new mail.  Is there an
> easy way to have this happen?

Yes -- I would like this too!  Could someone pleas e-mail to me, or
post it here?  Thx.

Beth
gorell@hpdstma.ptp.hp.com

woof@hpfcmgw.HP.COM (Steve Wolf) (10/17/90)

>                            The emulator I have in mind, when iconified
> can flips its icon [reverse video] when it receives a bell [^G].  The
> problem I have is generating a ^G from elm when I get new mail.

I have a program running that periodically compares the mailbox's access
time to its modification time (with stat(2)).  If mtime > atime, there
is new mail and the icon colors are reversed.  Clicking on the icon
fires up elm as a child process.

I can't give out the source (it's part of HP Vue), but the concept is
simple enough.
--
Steve Wolf
Hewlett-Packard				UUCP: {ihnp4|hplabs}!hpfcla!woof
Fort Collins, CO			ARPA: woof@hpfcsdw.fc.hp.com

wls@uwm.edu (Bill Stapleton) (10/18/90)

In article <1990Oct16.160303.19442@DSI.COM>, syd@DSI.COM (Syd Weinstein) writes:
> piziali@convex.com (Andy Piziali) writes:
> :I discovered today that the elm filter program does not notify inetd(8) of mail
> :it delivers to /usr/spool/mail.  Inetd(8) tells comsat(8) about the new mail
> :and, if the user has set biff set to "y" (/dev/tty* owner execute bit set),
> :comsat(8) writes the bell and mail header to the tty.
> Gee, I didn't know any MTA notified comsat, I thought it watched
> /usr/spool/mail for timestamp changes.

There's a simple little protocol:  You open a connection to comsat (inetd; udp,
biff) and send it the username and file address of the new message, and
it does the rest.  On our system (BSD 4.3), /bin/mail is normally used to
deliver messages, and it notifies comsat.  I've added this comsat notification
to the filter program here.
 
> :Syd, is there an
> :easy fix to filter(1) we could install?
> Nope.  Nor would there be.

It's a simple addition, and I've had no problems with it.  My code isn't very
polished, it's BSD-specific with no #ifdefs or anything, but I'll mail it to
anybody who's interested.

--
Bill Stapleton
     wls@csd4.csd.uwm.edu
     uwmcsd4!wls

chris@vision.UUCP (Chris Davies) (10/22/90)

In article <1990Oct16.160303.19442@DSI.COM> piziali@convex.com (Andy Piziali)
writes:
> Syd, is there an easy fix to filter(1) we could install?

And Syd replies:
> Nope.  Nor would there be.


We use Chip's "deliver" program with a system-wide script which notifies users
of new mail (provided the x bit is set on the tty - as per biff).  While I'm
not going to post the sources to deliver (available at many archive servers,
I presume), I will post our deliver.sys script...

I don't see why you couldn't use this in cojunction with filter(1) to do the
required munging etc.

Just a quick note, there is a line with grep "^$USER[ 	]"; the whitespace is
one space and one tab.  Don't miss this!

Chris

--cut--here--
: '/bin/sh'
# Mail delivery shell script for local mail.
#
# This is executed as root at delivery-time (see deliver(8L) for details)

ARGS=$@

NULL=/dev/null
DATE=`date '+%d-%h-%y (%T)'`
WHOFIL=/tmp/delwho.$$
LOGFIL=/usr/local/lib/deliver/deliver.log

trap 'S=$?; rm -f $WHOFIL; exit $S' 1 2 15

for USER in $ARGS
do
    #
    # Notify the recipient (if they've got mailchecking enabled).
    #
    if who | grep "^$USER[ 	]" > $WHOFIL 2> $NULL
    then
	#
	# User is logged on
	#
	FROM=`grep '^From:' "$HEADER" | cut -c7-` 2> $NULL
	if [ -z "$FROM" ]
	then
	    FROM="someone"
	fi

	while read D1 TTY D2
	do
	    TTYDEV="/dev/$TTY"
# Can't use test(1) since we're root, and we've got all r/w/x permissions!
	    if [ "`/bin/ls -l $TTYDEV | cut -c3-4`" = "wx" ]
	    then
		echo "\r\nYou have new mail on $HOSTNAME from $FROM\07\r\n" > $TTYDEV 2> $NULL
	    fi
	done < $WHOFIL
    fi

    #
    # This ensures "deliver" actually delivers the mail.  If you remove
    # this line, no mail will be delivered!
    #
    echo "$USER"
done

rm -f $WHOFIL
exit 0
--and--here--
-- 
VISIONWARE LTD         | UK: chris@vision.uucp    JANET: chris%vision.uucp@ukc
57 Cardigan Lane       | US: chris@vware.mn.org   BANGNET: ...!ukc!vision!chris
LEEDS LS4 2LE, England | VOICE:  +44 532 788858   FAX:  +44 532 304676
-------------- "VisionWare:   The home of DOS/UNIX/X integration" --------------

elsn4000@mailgzrz.tu-berlin.de (Frank Elsner) (11/13/90)

I have the following set of filter-rules:
----------------------------------------- 

if ( to contains "mhs-admins" ) then savecopy $HOME/Mail/folder/mhs-adm
if ( to contains "prmd-admins" ) then savecopy $HOME/Mail/folder/mhs-adm
if ( to contains "win-ip" ) then savecopy $HOME/Mail/folder/win-ip
if ( from contains "386USERS" ) then savecopy $HOME/Mail/folder/386users
if ( from contains "9NOV89-L" ) then savecopy $HOME/Mail/folder/9nov89-l
if ( from contains "BIG-LAN" ) then savecopy $HOME/Mail/folder/big-lan
if ( from contains "BITNEWS" ) then savecopy $HOME/Mail/folder/bitnews 
if ( from contains "CCNEWS" ) then savecopy $HOME/Mail/folder/ccnews  
if ( from contains "CHINANET" ) then savecopy $HOME/Mail/folder/chinanet
if ( from contains "CONS-L" ) then savecopy $HOME/Mail/folder/cons-l
if ( from contains "CYBER-L" ) then savecopy $HOME/Mail/folder/cyber-l
if ( from contains "DATUS-L" ) then savecopy $HOME/Mail/folder/datus-l
if ( from contains "EARNEWS" ) then savecopy $HOME/Mail/folder/earnews
if ( from contains "EARNTECH" ) then savecopy $HOME/Mail/folder/earntech
if ( from contains "EARN-UG" ) then savecopy $HOME/Mail/folder/earn-ug
if ( from contains "FUTURE-L" ) then savecopy $HOME/Mail/folder/future-l
if ( from contains "OWNER-INFO-NETS" ) then savecopy $HOME/Mail/folder/info-nets
if ( from contains "LIAISON" ) then savecopy $HOME/Mail/folder/liaison
if ( from contains "LSTERN-L" ) then savecopy $HOME/Mail/folder/lstern-l
if ( from contains "LSTSRV-L" ) then savecopy $HOME/Mail/folder/lstsrv-l
if ( from contains "MAIL-L" ) then savecopy $HOME/Mail/folder/mail-l 
if ( from contains "MON-L" ) then savecopy $HOME/Mail/folder/mon-l  
if ( from contains "NETMONTH" ) then savecopy $HOME/Mail/folder/netmonth
if ( from contains "NEW-LIST" ) then savecopy $HOME/Mail/folder/new-list
if ( from contains "NODMGT-L" ) then savecopy $HOME/Mail/folder/nodmgt-l
if ( from contains "NUTWORKS" ) then savecopy $HOME/Mail/folder/nutworks
if ( from contains "TRAFIC-L" ) then savecopy $HOME/Mail/folder/trafic-l
if ( from contains "TECHNEWS" ) then savecopy $HOME/Mail/folder/technews
if ( from contains "UNIX-WIZ" and subject contains "Digest" ) then savecopy $HOME/Mail/folder/unix-wiz
if ( subject contains "VIRUS-L" ) then savecopy $HOME/Mail/folder/virus-l 
if ( from contains "WIN-L" ) then savecopy $HOME/Mail/folder/win-l
if ( from contains "XMAILER" ) then savecopy $HOME/Mail/folder/xmailer
 
and they seen to work perfectly. But "filter -s" shows the following:
                                 ------------------------------------


			A Summary of Filter Activity
			----------------------------

A total of 34 messages were filtered:

The default rule of putting mail into your mailbox
	applied 15 times (44%)

Rule #1: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/mhs-adm")
	applied 2 times (6%)

Rule #3: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/win-ip")
	applied 7 times (21%)

Rule #5: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/9nov89-l")
	applied 2 times (6%)

Rule #9: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/chinanet")
	applied 2 times (6%)

Rule #20: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/lstsrv-l")
	applied 2 times (6%)

Rule #24: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/new-list")
	applied 1 time (3%)

Rule #25: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/nodmgt-l")
	applied 3 times (9%)

Rule #28: 
	applied 15 times (44%)

Rule #30: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/virus-l")
	applied 667949 times (1964556%)

Rule #31: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/win-l")
	applied 1697525552 times (-60180488%)

Rule #32: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/xmailer")
	applied 1714384236 times (-10596124%)

 
and the question raises "Where do the strange percentages for rules #30 ff.
came from ?" ...

Elm Version and Identification Information:

	Elm 2.3 PL8, of May 1, 1990
	(C) Copyright 1986, 1987 Dave Taylor
	(C) Copyright 1988, 1989, 1990 USENET Community Trust
	----------------------------------
	Configured Thu Oct 25 12:19:49 MEZ 1990
	----------------------------------
	From: and Reply-To: addresses are good: USE_EMBEDDED_ADDRESSES
	Return addresses will not be optimized: not OPTIMIZE_RETURN
	Prefers Internet address formats: INTERNET
	Debug options are available: DEBUG
	Crypt function enabled: CRYPT
	Mailbox editing included: ALLOW_MAILBOX_EDITING
	Calendar file feature enabled: ENABLE_CALENDAR
		(Default calendar file is calendar)


Any pointers are welcome ! 
 
Frank Elsner (TUBerlin/ZRZ Postmaster)

rusty@steelmill.cs.umd.edu (Rusty Haddock) (11/14/90)

In article <34@mailgzrz.tu-berlin.de> elsn4000@mailgzrz.tu-berlin.de (Frank Elsner) writes:
   >
   >I have the following set of filter-rules:
   >----------------------------------------- 
[nosave :-]
   >			A Summary of Filter Activity
   >			----------------------------
   >
   >A total of 34 messages were filtered:
   >
   >The default rule of putting mail into your mailbox
   >	applied 15 times (44%)
   >
   >Rule #1: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/mhs-adm")
   >	applied 2 times (6%)
   >
   >Rule #32: (left in mailbox and saved in "/usr/elsn4000/Mail/folder/xmailer")
   >	applied 1714384236 times (-10596124%)
   >
   >and the question raises "Where do the strange percentages for rules #30 ff.
   >came from ?" ...

According to hdrs/filter.h the filter program is limited to a maximum of
"only" 25 rules.  I suspect you overran an array but still within the
program's data area.   Around rule 29 or 30 you were actually getting
your sadistically data overwritten by the legitimate owners/variables of
that memory space.

		-Rusty-
--
Rusty Haddock / CompSci Dept		DOMAIN:	rusty@mimsy.cs.umd.edu
University of Maryland		PATH:	{uunet,rutgers}!mimsy!rusty
    If someone points a quad-vector, hyper-thermic cosmic blaster
    at you it's a safe bet that you're about to become toast.

elsn4000@mailgzrz.tu-berlin.de (Frank Elsner) (11/16/90)

In article <27638@mimsy.umd.edu> rusty@steelmill.cs.umd.edu (Rusty Haddock) writes:
>According to hdrs/filter.h the filter program is limited to a maximum of
>"only" 25 rules.  I suspect you overran an array but still within the
>program's data area.   Around rule 29 or 30 you were actually getting
>your sadistically data overwritten by the legitimate owners/variables of
>that memory space.
>
Many Thanks, I'll try to change the value in hdrs/filter.h. Let's see what
will happen.
 
Frank Elsner