procmail
[Top] [All Lists]

Re: procmailrc problem

2002-02-25 00:28:08
Piotr Synowiec asked,

| I have got users without shell
| and in .procmailrc
| entries
| FROM=`formail -x Return-Path`
| SENDER=`formail -x Return-Path | sed 's/[<>]//g;s/^[ ]*//'`

It's much better to extract those within procmail.

| result is as follow
| procmail: Executing "formail,-x,Return-Path"
| procmail: Assigning "FROM= <root(_at_)mysiar(_dot_)net>"
| procmail: Executing "formail -x Return-Path | sed 's/[<>]//g;s/^[ ]*//'"
| procmail: Assigning "SENDER="

The command to set SENDER requires a shell; procmail cannot do piping,
redirection, conjunction, disjunction, backgrounding, nor filename globbing,
so when a command has a character that normally means one of those things,
procmail invokes a shell to run the command.  Those characters are stored in
a variable named SHELLMETAS, and you can change its value in the rcfile.
Now, [, <, and > are in it, but they have other meanings in that command, so
you could temporarily change the value of $SHELLMETAS to exclude them, but
it also includes |, and in that command the pipe symbol means shell piping,
which procmail cannot do on its own.  Therefore you cannot run that command
unless $SHELL is the path to a working shell.

| when I add shell for user
| I got
| procmail: Executing "formail,-x,Return-Path"
| procmail: Assigning "FROM= <mysiarld(_at_)mysiar(_dot_)net>"
| procmail: Executing "formail -x Return-Path | sed 's/[<>]//g;s/^[ ]*//'"
| procmail: Assigning "SENDER=mysiarld(_at_)mysiar(_dot_)net"

Yup.  When you have a shell, procmail can get one command piped to another.
Note that the words in the first command are logged with commas between
them, but that those in the second command keep their original spaces: that
is an indication that procmail parsed and ran the first command itself but
passed the second one to a shell as a whole, spaces intact, for the shell to
parse.

| and how I can achieve what I need without shell for a user?

You could set SHELL=/bin/sh at the top of the rcfile; that would not give
the user a shell in /etc/passwd, so the user still couldn't log in.

Far better, though, do this (if your procmail is too old to do extraction,
upgrade it).  You might still have reason to set SHELL=/bin/sh for other
commands in the rcfile, but when procmail can do something without help,
it's a waste to fork another program for it:

 :0 # why you want that leading space in there I cannot guess
 * ^Return-Path:\/.+
 { FROM=$MATCH }

But I'd recommend not keeping the leading space in $FROM:

 :0 # first brackets enclose space+tab, second set caret+space+tab
 * ^Return-Path:[     ]*\/[^     ].*
 { FROM=$MATCH }

Then, to set SENDER,

 :0 # first pair of brackets enclose space+tab
 * ^Return-Path:.*<\/[^>]+
 { SENDER=$MATCH }


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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