简体   繁体   English

procmail是chroot还是使用Linux命令受到限制?

[英]Is procmail chrooted or limited in using linux commands?

im using procmail to forward emails to different folders in my Maildir. 即时通讯使用procmail将电子邮件转发到我的Maildir中的其他文件夹。 I use these two lines to get the FROM and TO from the mail, which works pretty fine. 我使用这两行从邮件中获取FROM和TO,效果很好。

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

These two commands return the whole line without the From: and To: prefix. 这两个命令返回整行,而不包含From:和To:前缀。 So i get something like: 所以我得到类似的东西:

Firstname Lastname <firstname.lastname@mail-domain.com>

Now i want to extract the email between < and >. 现在,我想提取<和>之间的电子邮件。 For this i pipe the variable FROM and TO grepping it like this. 为此,我通过管道将变量FROM和TO像这样grepping。

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. 但是,当我使用LOG = FROM_PARSED将FROM_PARSED打印到procmail日志中时,我在FROM_PARSED和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 >). 我尝试了许多其他grepping方法,使用grep,egrep,sed甚至剪切(剪切<和>)。 All working on console, but i use it in procmail it just returns nothing. 所有工作在控制台上,但是我在procmail中使用它,它什么也没返回。

Is it possible that procmail is not allowed to use grep and sed commands? 是否有可能不允许procmail使用grep和sed命令? Something like a chroot? 像chroot一样?

I dont get any error logs in my procmail log. 我在procmail日志中没有收到任何错误日志。 I just want to extract the valid email address from the FROM and TO line. 我只想从FROM和TO行中提取有效的电子邮件地址。 Extracting with formail works, but parsing it with grep or sed fails, even if expression is correct. 使用formail进行提取是可行的,但是即使表达式正确,也无法使用grep或sed对其进行解析。

Could somebody help? 有人可以帮忙吗? Maybe i need to setup procmail somehow. 也许我需要以某种方式设置procmail。

Strange. 奇怪。

I added this to the users .procmailrc file 我将此添加到用户.procmailrc文件

SHELL=/bin/bash

The users shell was set to /bin/false, which is correct because its a mail user, no ssh access at all. users shell设置为/ bin / false,这是正确的,因为它是一个邮件用户,根本没有ssh访问权限。

You should properly quote "$FROM" and " $TO ". 您应该正确引用"$FROM"和“ $TO ”。

You will also need to prefix grep with LC_ALL=POSIX to ensure [:alnum:] will actually match the 26 well-known characters + 10 digits of the English alphabet. 您还需要为grep加上LC_ALL=POSIX前缀,以确保[:alnum:]实际上与26个知名字符和英语字母的10位数字匹配。

You already solved this, but to answer your actual question, it is possible to run procmail in a chroot, but this is certainly not done by Procmail itself. 您已经解决了这个问题,但是要回答您的实际问题,可以在chroot中运行procmail ,但这当然不是Procmail本身可以完成的。 Sendmail used to come with something called the Sendmail Restricted Shell (originally called rsh but renamed to remsh ) which allowed system administrators to chroot the delivery process. Sendmail以前带有一个称为Sendmail Restricted Shell的东西(最初称为rsh但重命名为remsh ),它使系统管理员可以更改传送过程。 But to summarize, this is a feature of the MTA, not of Procmail. 但总而言之,这是MTA的功能,而不是Procmail的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM