Search code examples
emailgrepextractprocmail

Is procmail chrooted or limited in using linux commands?


im using procmail to forward emails to different folders in my Maildir. I use these two lines to get the FROM and TO from the mail, which works pretty fine.

FROM=`formail -x"From:"`
TO=`formail -x"To:"`

These two commands return the whole line without the From: and To: prefix. So i get something like:

Firstname Lastname <[email protected]>

Now i want to extract the email between < and >. For this i pipe the variable FROM and TO grepping it like this.

FROM_PARSED=`echo $FROM | grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*'`
TO_PARSED=`echo $TO | grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*'`

But when i print FROM_PARSED into the procmail log by using LOG=FROM_PARSED, i get an empty string in FROM_PARSED and TO_PARSED.

But if i run these commands on my console, all works fine. I tried many other grepping methods, using grep, egrep, sed and even cut (cutting < and >). All working on console, but i use it in procmail it just returns nothing.

Is it possible that procmail is not allowed to use grep and sed commands? Something like a chroot?

I dont get any error logs in my procmail log. I just want to extract the valid email address from the FROM and TO line. Extracting with formail works, but parsing it with grep or sed fails, even if expression is correct.

Could somebody help? Maybe i need to setup procmail somehow.


Solution

  • Strange.

    I added this to the users .procmailrc file

    SHELL=/bin/bash
    

    The users shell was set to /bin/false, which is correct because its a mail user, no ssh access at all.