File: filter_15.html

package info (click to toggle)
exim-html 3.20-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge, woody
  • size: 2,868 kB
  • ctags: 4,188
  • sloc: makefile: 40; sh: 19
file content (137 lines) | stat: -rw-r--r-- 5,376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52
     from filter on 25 November 2000 -->

<TITLE>Exim Filter Specification - The pipe command</TITLE>
</HEAD>
<body bgcolor="#FFFFFF" text="#00005A" link="#FF6600" alink="#FF9933" vlink="#990000">
Go to the <A HREF="filter_1.html">first</A>, <A HREF="filter_14.html">previous</A>, <A HREF="filter_16.html">next</A>, <A HREF="filter_34.html">last</A> section, <A HREF="filter_toc.html">table of contents</A>.
<P><HR><P>


<H2><A NAME="SEC15" HREF="filter_toc.html#TOC15">The pipe command</A></H2>


<PRE>
     pipe &#60;<EM>command</EM>&#62;
e.g. pipe "$home/bin/countmail $sender_address"
</PRE>

<P>
This command causes a separate process to be run, and a copy of the message is
passed on its standard input. The process runs as the user, under the user's
primary group. Any secondary groups to which the user may belong are not
normally taken into account, though the system administrator can configure Exim
to set them up.
More than one <EM>pipe</EM> command may appear; each one causes a copy of the message
to be written to its argument pipe, provided they are different (duplicate
<EM>pipe</EM> commands are ignored).

</P>
<P>
The command supplied to <EM>pipe</EM> is split up by Exim into a command name and a
number of arguments, delimited by white space except for arguments enclosed in
double quotes, in which case backslash is interpreted as an escape, or in
single quotes, in which case no escaping is recognized. Note that as the whole
command is normally supplied in double quotes, a second level of quoting is
required for internal double quotes. For example:

<PRE>
     pipe "$home/myscript \"size is $message_size\""
</PRE>

<P>
String expansion is performed on the separate components after the line has
been split up, and the command is then run directly by Exim; it is not run
under a shell. Therefore, substitution cannot change the number of arguments,
nor can quotes, backslashes or other shell metacharacters in variables cause
confusion.

</P>
<P>
Documentation for some programs that are normally run via this kind of pipe
often suggest the the command start with

<PRE>
IFS=" "
</PRE>

<P>
This is a shell command, and should <EM>not</EM> be present in Exim filter files,
since it does not normally run the command under a shell.

</P>
<P>
However, there is an option that the administrator can set to cause a shell to
be used. In this case, the entire command is expanded as a single string and
passed to the shell for interpretation. It is recommended that this be avoided
if at all possible, since it can lead to problems when inserted variables
contain shell metacharacters.

</P>

<P>
The default PATH set up for the command is determined by the system
administrator, usually containing at least <EM>/usr/bin</EM> so that common commands
are available without having to specify an absolute file name. However, it is
possible for the system administrator to restrict the pipe facility so that the
command name must not contain any / characters, and must be found in one of the
directories in the configured PATH. It is also possible for the system
administrator to lock out the use of the <EM>pipe</EM> command altogether.

</P>
<P>
When the command is run, the following environment variables are set up:

<PRE>
DOMAIN               the local domain of the address
HOME                 your home directory
LOCAL_PART           your login name
LOGNAME              your login name
MESSAGE_ID           the message's unique id
PATH                 the command search path
SENDER               the sender of the message
SHELL                /bin/sh
USER                 your login name
</PRE>

<P>
If you run a command that is a shell script, be very careful in your use of
data from the incoming message in the commands in your script. RFC 822 is very
generous in the characters that are legally permitted to appear in mail
addresses, and in particular, an address may begin with a vertical bar or a
slash. For this reason you should always use quotes round any arguments that
involve data from the message, like this:

<PRE>
/some/command "$SENDER"
</PRE>

<P>
so that inserted shell meta-characters do not cause unwanted effects.

</P>
<P>
The pipe command should return a zero completion code if all has gone well.
Most non-zero codes are treated by Exim as indicating a failure of the pipe.
This is treated as a delivery failure, causing the message to be returned to
its sender. However, there are some completion codes which are treated as
temporary errors. The message remains on Exim's spool disc, and the delivery is
tried again later, though it will ultimately time out if the delivery failures
go on too long. The completion codes to which this applies can be specified by
the system administrator; the default values are 73 and 75.

</P>
<P>
The pipe command should not normally write anything to its standard output or
standard error file descriptors. If it does, whatever is written is normally
returned to the sender of the message as a delivery error, though this action
can be varied by the system administrator.

</P>

<P><HR><P>
Go to the <A HREF="filter_1.html">first</A>, <A HREF="filter_14.html">previous</A>, <A HREF="filter_16.html">next</A>, <A HREF="filter_34.html">last</A> section, <A HREF="filter_toc.html">table of contents</A>.
</BODY>
</HTML>