procmail
[Top] [All Lists]

Re: procmail recipe spawning shell, appending message

1998-06-30 21:15:31
Sweth Chandramouli asked,

|       i have the following procmail recipe, taken from someone
| on this list, i think, to add a Content-Type header to incoming
| PGP-encrypted mail.  any mail that actually matches it, however,
| ends up spawning a shell; my .zshenv prints a greeting message,
| which then becomes the first line of the message, and the From_
| line gets escaped by a >.  the end result is that any PGP-signed
| message gets appended to the last message in its appropriate mailbox,
| rather than being filed as a message of its own; checking the
| procmail logs shows an error message produced by .zshenv, in addition
| to the normal delivery.
|       any idea what's going wrong here?

Yes.  First, the commands in your action lines contain a character from
$SHELLMETAS -- specifically, a semicolon -- so procmail is duly invoking a
shell to run them.  The semicolons are there just as plain text and not as
shell metacharacters, but procmail isn't taking the risk of doing that
analysis.  Second, your .zshenv is printing a greeting message even for non-
interactive shells and shells where stdout is not a terminal; either alone
should be reason enough not to print the greeting, and both apply here.

Although it is the combination of both problems that is messing up your mail,
and fixing either will relieve this symptom, you really ought to correct
both.  There will be other occasions -- for example, commands for which
procmail really does need the help of a shell invocation -- when you will
want zsh to start up quietly, and even when it does you don't want the over-
head of a shell when it isn't really needed.

I don't know how to make .zshenv print a greeting only if the shell is
interactive and has stdout connected to a terminal (for ksh I could tell you
how), but I do know how to prevent procmail from invoking a shell when it
doesn't really need to:

  savemetas=$SHELLMETAS  # We may need it again later.
  SHELLMETAS # This unsets it; now procmail will never invoke a shell
             # unless the executable in the action line is a shell.

# Sweth's recipes, unchanged:
  # Add a "Content-Type: application/pgp" header so Mutt will know the
  # mail is encrypted.
  :0 fBw
  * ^-----BEGIN PGP MESSAGE-----
  | formail -a "Content-Type: application/pgp; format=text; 
x-action=encryptsign"
 
  # Add a "Content-Type: application/pgp" header so Mutt will know the
  # mail is signed.
  :0 fBw
  * ^-----BEGIN PGP SIGNED MESSAGE-----
  | formail -a "Content-Type: application/pgp; format=text; x-action=sign"

# And now, put things back as they were:
  SHELLMETAS=$savemetas # Re-enable shell invocation for later recipes.

You should also put `h' (lower case!) flags on those two recipes; only the
head needs to be filtered through those particular formail commands.

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