procmail
[Top] [All Lists]

safely passing email to the shell

1999-03-26 12:47:21
Howdy procmail gurus-

This is a problem I asked about several weeks ago, but now I have
a better idea about what's happening.

I have the following recipe in my .procmailrc, after all other 
processing is done:

----------------- v v cut here v v -------------------------------
:0 ci
* $ !^$list_header
| /home/mshaw/bin/mailnotify -number 5981529 -after 7 -before 18 -days MTWRF
----------------- ^ ^ cut here ^ ^ -------------------------------

The 'mailnotify' call is actually a perl script I wrote to forward
email to my pager, and list_header is a tag I throw in when I get
mailing-list email.  The important thing (I think) is that special
characters in email that's piped to mailnotify with this recipe
are causing problems.  Here's the output of mailstat:

----------------- v v cut here v v -------------------------------
% mailstat .maillog

  Total  Number Folder
  -----  ------ ------
      0       1  ## sh:   -- Fizz File           this is allowed:           
ALTERNATE_POWER_PORTS = ( VDDSHV ),           FROM PAD 150 TO 74;           
This wraps around the die.          JMA>  This is correct F2G/F2MW acknowledge 
the possibility of a bus wrapping       around the die as in your example 
above.  : cannot create
      0       1  ## sh: main: ray.c:113: warning: passing arg 1 of : not found
      0       1  ## sh: seidel from incompatible pointer type ray.c:113: 
warning: passing arg 3 of : not found
      0       1  ## sh: seidel from incompatible pointer type": not found
1744918     301 /var/mail/mshaw
 179347       2 spam
%
----------------- ^ ^ cut here ^ ^ -------------------------------

Take a look at the 2nd, 3rd and 4th errors, having to do with ray.c
and 'seidel'.  Here's the first portion of the email message associated
with those errors (sorry, this is a bit long, but I wanted to include
everything up to the portion of the message that's apparently causing
the errors):

----------------- v v cut here v v -------------------------------
From steved(_at_)unimem(_dot_)com  Fri Mar 26 11:16:56 1999
Received: from alfred.itg.ti.com (alfred.itg.ti.com [157.170.188.38])
        by spanky.dal.asp.ti.com (8.8.8+Sun/8.8.8/FL-ASP-1.9) with ESMTP id 
LAA209
09
        for <mshaw(_at_)dal(_dot_)asp(_dot_)ti(_dot_)com>; Fri, 26 Mar 1999 
11:16:55 -0600 (CST)
Received: from gatekeep.ti.com (ti.com [192.94.93.61])
        by alfred.itg.ti.com (8.8.8/8.8.8) with ESMTP id LAA01659
        for <mshaw(_at_)ti(_dot_)com>; Fri, 26 Mar 1999 11:16:55 -0600 (CST)
Received: from kintyre (umi.unimem.com [165.212.187.3]) by gatekeep.ti.com 
(8.8.8)
 with SMTP id LAA18147 for <mshaw(_at_)ti(_dot_)com>; Fri, 26 Mar 1999 11:16:48 
-0600 (CST)
Received: (from steved(_at_)localhost) by kintyre (8.6.12/8.6.9) id KAA16242; 
Fri, 26 M
ar 1999 10:16:04 -0700
Date: Fri, 26 Mar 1999 10:16:04 -0700
Message-Id: <199903261716(_dot_)KAA16242(_at_)kintyre>
From: Steve Dillinger <steved(_at_)unimem(_dot_)com>
To: mshaw(_at_)ti(_dot_)com
Subject: ray.c - greatly cleaned up
Content-Length: 10514
X-Lines: 333
Status: RO

Here are the only compile errors I get now:

ray.c: In function `main':
ray.c:113: warning: passing arg 1 of `seidel' from incompatible pointer type
ray.c:113: warning: passing arg 2 of `seidel' from incompatible pointer type
ray.c:113: warning: passing arg 3 of `seidel' from incompatible pointer type
ray.c:113: warning: passing arg 6 of `seidel' from incompatible pointer type
ray.c: In function `seidel':
ray.c:230: called object is not a function
ray.c:266: invalid operands to binary *

[et cetera]
----------------- ^ ^ cut here ^ ^ -------------------------------

An examination of the output of mailstat suggests that the shell is 
barfing on the backticks in the compiler-error section of that email,
no?  The string reported in error #2 of the mailstat log begins right
after the first ` and ends right before the second one (the single-
quote pairs in that listing are backtick/forward-tick).  Errors #3 and 
#4 seem to do much the same thing.

So my hypothesis is that I need to find a safe way of passing text that
may include special characters to the shell.  I realize that this is 
really a lot more of a unix-shell-for-dummies question than a procmail 
question, but I bet someone out there knows the answer....

Oh, two things:  

  - I don't do any other piping in my .procmailrc, except for these 
    recipes that create and manage a FIFO backup of incoming mail in 
    case things go wrong (they're the first two recipes in my .proc-
    mailrc):

:0 c
backup

:0 ic
| cd backup && rm -f dummy `ls -t msg.* | sed -e 1,32d`

  - The email message I quote above, that caused the errors, did not
    get filed to my mailbox.  It did, however, get filed in the backup
    directory.

Thanks in advance for any answers!

Mark Shaw <mshaw(_at_)ti(_dot_)com>






 

<Prev in Thread] Current Thread [Next in Thread>