A Challenge to Rick: a really weird .forward file.
Rick Stevens
rstevens at vitalstream.com
Tue Mar 8 02:41:47 UTC 2005
Waldher, Travis R wrote:
> Here's the deal... I have a .forward file as follows:
>
> "|IFS=' '&&p=/usr/bin/procmail&&test -f $p&&exec $p -Yf-||exit 75
> #username"
>
> The catch is, this causes sendmail 8.12 to not work (bounces email back
> as undeliverable), but is required by postfix on other systems to let
> procmail do it's job.
>
> Meaning, I have to have that line (or some form of it) but on the other
> hand, I can't either. Bad catch 22.
>
> My biggest problem, I have NO idea what that line is doing and neither
> does anyone I work with.
>
> Also, can I add an algorithm so that when it's called, can it do nothing
> if it's a sendmail based system, and execute that line if it's postfix?
>
> Thanks in advance
What do I get if I figure it out? Do I get a pony? Do I? Do I? :-)
Just break it down, Travis. The "&&" is a standard shell convention for
"if this is true, do A, AND if A is true, do B, AND if B is true...".
In other words, the next part of the pipe (reading left to right) is
executed ONLY if the previous part returned a "true" (return value of
0). Conversely, "||" means "OR": "if A fails, do B"
So, the first bit sets the input field separator (IFS) to a space (see
"Shell Variables" in "man bash").
If that was successful (and it will be), it sets "p" to the value
"/usr/bin/procmail". This is simply so the script doesn't have
"/usr/bin/procmail" all over the place.
If that was successful (again, it should be), then it checks to see if
"/usr/bin/procmail" is a regular file. I think that's bad. It should
be "test -x $p", or "if /usr/bin/procmail is executable".
If it is a regular file (or executable with my change), then execute it
and pass it the arguments "-Yf-" (methinks that should be "-Yf -").
"-Y" to procmail says "assume traditional mailbox format", the "-f -"
(note the space between "f" and the second dash) means "update the
timestamp of the "From " line, if any.
The || means "if any of the preceeding stuff fails, exit with a value of
75" (which is "EX_TEMPFAIL" from /usr/include/sysexits.h). Sendmail
expects any delivery agent (e.g. procmail) to return a value from
/usr/include/sysexits.h.
The "#username" bit I'm a bit confused on, but I think it's supposed to
be "$username" (the username the message is meant for).
In pseudo-code:
If setting the input field separator to a space is OK, AND
If setting "p" to /usr/bin/procmail is OK, AND
If "/usr/bin/procmail" is a file (executable), THEN
execute "/usr/bin/procmail -Yf - $username"
return whatever procmail generates for a result code
Else
exit with EX_TEMPFAIL (75)
Fi
Else
exit with EX_TEMPFAIL (75)
Fi
Else
exit with EX_TEMPFAIL (75)
Fi
Does that make sense to you? Do I get the pony?
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer rstevens at vitalstream.com -
- VitalStream, Inc. http://www.vitalstream.com -
- -
- The problem with being poor is that it takes up all of your time -
----------------------------------------------------------------------
More information about the Redhat-install-list
mailing list