Debian Codegraph @

doc/contrib/mod_wrap.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD module mod_wrap</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center>
11 <h2><b>ProFTPD module <code>mod_wrap</code></b></h2>
12 </center>
13 <hr><br>
14
15 <p>
16 This module is contained in the <code>contrib/mod_wrap.c</code> file for
17 ProFTPD 1.2.x, and is not compiled by default. It enables the daemon to
18 use the common tcpwrappers access control library while in
19 <code>standalone</code> mode, and in a very configurable manner.
20
21 <p>
22 If not installed on your system, the TCP wrappers library, required by this
23 module, can be found
24 <a href="ftp://ftp.porcupine.org/pub/security/tcp_wrappers_7.6.tar.gz">here</a>,
25 on Wietse Venema's site. Once installed, it <i>highly recommended</i>
26 that the <code>hosts_access(3)</code> and <code>hosts_access(5)</code> man
27 pages be read and understood. The <a href="#Installation">installation</a>
28 of <code>mod_wrap</code> is fairly straightforward, with some caveats for
29 Solaris and FreeBSD users.
30
31 <p>
32 Many programs will automatically add entries in the common allow/deny files,
33 and use of this module will allow a ProFTPD daemon running in
34 <code>standalone</code> mode to adapt as these entries are added. The
35 <code>portsentry</code> program does this, for example: when illegal access
36 is attempted, it will add hosts to the <code>/etc/hosts.deny</code> file.
37
38 <p>
39 The most current version of <code>mod_wrap</code> is distributed with the
40 ProFTPD source code.
41
42 <h2>Author</h2>
43 <p>
44 Please contact TJ Saunders &lt;tj <i>at</i> castaglia.org&gt; with any
45 questions, concerns, or suggestions regarding this module.
46
47 <h2>Thanks</h2>
48 <p>
49 <i>2000-05-29</i>: Thanks to David Douthitt &lt;ssrat <i>at</i> mailbag.com&gt;
50 for pointing out the usefulness of using <code>mod_wrap</code> in conjunction
51 with <code>portsentry</code>
52
53 <p>
54 <i>2001-03-01</i>: Updated the configuration directives, as per
55 lung <i>at</i> theuw.net's helpful suggestions.
56
57 <p>
58 <i>2001-09-24</i>: Thanks to Zenon Mousmoulas &lt;cajoline <i>at</i>
59 chaosengine.de &gt; for helping determine that adding <code>-lnsl</code> would
60 help in compiling <code>mod_wrap</code> with the stock RedHat
61 <code>libwrap.a</code>, so that recompiling tcpwrappers without NIS/YP support
62 should no longer be necessary.
63
64 <p>
65 <i>2001-09-27</i>: Thanks to Gabe Frost &lt;gfrost <i>at</i> gostnet.com&gt;
66 for helping track down several mergedown bugs.
67
68 <p>
69 <i>2001-12-19</i>: Thanks to Mark Castillo &lt;markc <i>at</i> webFreak.com&gt;
70 for pointing out the issue with passwords not being properly hidden
71
72 <h2>Directives</h2>
73 <ul>
74 <li><a href="#TCPAccessFiles">TCPAccessFiles</a>
75 <li><a href="#TCPAccessSyslogLevels">TCPAccessSyslogLevels</a>
76 <li><a href="#TCPGroupAccessFiles">TCPGroupAccessFiles</a>
77 <li><a href="#TCPServiceName">TCPServiceName</a>
78 <li><a href="#TCPUserAccessFiles">TCPUserAccessFiles</a>
79 </ul>
80
81 <hr>
82 <h3><a name="TCPAccessFiles">TCPAccessFiles</a></h3>
83 <strong>Syntax:</strong> TCPAccessFiles <em>allow-filename deny-filename</em><br>
84 <strong>Default:</strong> None<br>
85 <strong>Context:</strong> server config, <code>&lt;VirtualHost</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code><br>
86 <strong>Module:</strong> mod_wrap<br>
87 <strong>Compatibility:</strong> 1.2.1 and later
88
89 <p>
90 TCPAccessFiles specifies two files, an allow and a deny file, each of which
91 contain the IP addresses, networks or name-based masks to be allowed or denied
92 connections to the server. The files have the same format as the standard
93 tcpwrappers hosts.allow/deny files.
94
95 <p>
96 Both file names are required. Also, the paths to both files must be the full
97 path, with two exceptions: if the path starts with <code>~/</code>, the check
98 of that path will be delayed until a user requests a connection, at which time
99 the path will be resolved to that user's home directory; or if the path starts
100 with <code>~user/</code>, where user is some system user. In this latter case,
101 <code>mod_wrap</code> will attempt to resolve and verify the given user's home
102 directory on start-up.
103
104 <p>
105 The service name for which <code>mod_wrap</code> will look in the indicated
106 access files is <code>proftpd</code> by default; this can be configured via
107 the <code>TCPServiceName</code> directive.
108
109 <p>
110 There is a built-in precedence to the <code>TCPAccessFiles</code>,
111 <code>TCPGroupAccessFiles</code>, and <code>TCPUserAccessFiles</code>
112 directives, if all are used. <code>mod_wrap</code> will look for applicable
113 <code>TCPUserAccessFiles</code> for the connecting user first. If no applicable
114 <code>TCPUserAccessFiles</code> is found, <code>mod_wrap</code> will search for
115 <code>TCPGroupAccessFiles</code> which pertain to the connecting user. If not
116 found, <code>mod_wrap</code> will then look for the server-wide
117 <code>TCPAccessFiles</code> directive. This allows for access control to be
118 set on a per-server basis, and allow for per-user or per-group access control
119 to be handled without interfering with the server access rules.
120
121 <p>
122 Example:
123 <pre>
124 # server-wide access files
125 TCPAccessFiles /etc/ftpd.allow /etc/ftpd.deny
126
127 # per-user access files, which are to be found in the user's home directory
128 TCPAccessFiles ~/my.allow ~/my.deny
129 </pre>
130
131 <p>
132 See also:
133 <a href="#TCPGroupAccessFiles">TCPGroupAccessFiles</a>,
134 <a href="#TCPServiceName">TCPServiceName</a>,
135 <a href="#TCPUserAccessFiles">TCPUserAccessFiles</a>
136
137 <p>
138 <hr>
139 <h3><a name="TCPAccessSyslogLevels">TCPAccessSyslogLevels</a></h3>
140 <strong>Syntax:</strong> TCPAccessSyslogLevels <em>allow-level deny-level</em><br>
141 <strong>Default:</strong> <code>TCPAccessSyslogLevels info warn</code><br>
142 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code><br>
143 <strong>Module:</strong> mod_wrap<br>
144 <strong>Compatibility:</strong> 1.2.1 and later
145
146 <p>
147 ProFTPD can log when a connection is allowed, or denied, as the result of rules
148 in the files specified in <code>TCPAccessFiles</code>, to the Unix
149 <code>syslog</code> mechanism. A discussion on the <code>syslog</code> levels
150 which can be used is given in the <code>SyslogLevel</code> directive.
151
152 <p>
153 The <em>allow-level</em> parameter sets the syslog level at which allowed
154 connections are logged; the <em>deny-level</em> parameter sets the syslog
155 level for denied connections.
156
157 <p>
158 Example:
159 <pre>
160 TCPAccessSyslogLevels debug warn
161 </pre>
162
163 <p>
164 <hr>
165 <h3><a name="#TCPGroupAccessFiles">TCPGroupAccessFiles</a></h3>
166 <strong>Syntax:</strong> TCPGroupAccessFiles <em>group-expression allow-filename deny-filename</em><br>
167 <strong>Default:</strong> <em>None</em><br>
168 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
169 <strong>Module:</strong> mod_wrap<br>
170 <strong>Compatibility:</strong> 1.2.1 and later
171
172 <p>
173 <code>TCPGroupAccessFiles</code> allows for access control files, the same
174 types of files required by <code>TCPAccessFiles</code>, to be applied to
175 select groups. The given <em>group-expression</em> is a logical AND
176 expression, which means that the connecting user must be a member of all the
177 groups listed for this directive to apply. Group names may be negated with a
178 <code>!</code> prefix.
179
180 <p>
181 The rules for the filename paths are the same as for
182 <code>TCPAccessFiles</code> settings.
183
184 <p>
185 Example:
186 <pre>
187 # every member of group wheel must connect from restricted locations
188 TCPGroupAccessFiles wheel /etc/ftpd-strict.allow /etc/ftpd-strict.deny
189
190 # everyone else gets the standard access rules
191 TCPGroupAccessFiles !wheel /etc/hosts.allow /etc/hosts.deny
192 </pre>
193
194 <p>
195 See Also: <a href="#TCPAccessFiles">TCPAccessFiles</a>
196
197 <p>
198 <hr>
199 <h3><a name="TCPServiceName">TCPServiceName</a></h3>
200 <strong>Syntax:</strong> TCPServiceName <em>name</em><br>
201 <strong>Default:</strong> <code>TCPServiceName proftpd</code><br>
202 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
203 <strong>Module:</strong> mod_wrap<br>
204 <strong>Compatibility:</strong> 1.2.1 and later
205
206 <p>
207 <code>TCPServiceName</code> is used to configure the name of the service under
208 which <code>mod_wrap</code> will check the allow/deny files. By default, this
209 is the name of the program started, <em>i.e.</em> &quot;proftpd&quot;. However,
210 some administrators may want to use a different, more generic service name,
211 such as &quot;ftpd&quot;; use this directive for such needs.
212
213 <p>
214 <hr>
215 <h3><a name="TCPUserAccessFiles">TCPUserAccessFiles</a></h3>
216 <strong>Syntax:</strong> TCPUserAccessFiles <em>user-expression allow-filename deny-filename</em><br>
217 <strong>Default:</strong> <em>None</em><br>
218 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
219 <strong>Module:</strong> mod_wrap<br>
220 <strong>Compatibility:</strong> 1.2.1 and later
221
222 <p>
223 <code>TCPUserAccessFiles</code> allows for access control files, the same types
224 of files required by <code>TCPAccessFiles</code>, to be applied to select
225 users. The given <em>user-expression</em> is a logical AND expression.
226 Listing multiple users in a user-expression does not make much sense; however,
227 this type of AND evaluation allows for expressions such as &quot;everyone
228 <i>except</i> this user&quot; with the use of the <code>!</code> negation
229 prefix.
230
231 <p>
232 The rules for the filename paths are the same as for
233 <code>TCPAccessFiles</code> settings.
234
235 <p>
236 Example:
237 <pre>
238 # user admin might be allowed to connect from anywhere
239 TCPUserAccessFiles admin /etc/ftpd-anywhere.allow /etc/ftpd-anywhere.deny
240
241 # while every other user has to connect from LAN addresses
242 TCPUserAccessFiles !admin /etc/ftpd-lan.allow /etc/ftpd-lan.deny
243 </pre>
244
245 <p>
246 See also: <a href="#TCPAccessFiles">TCPAccessFiles</a>
247
248 <p>
249 <hr>
250 <h2><a name="FAQ">FAQ</a></h2>
251
252 <p>
253 <font color=red>Question</font>: Using <code>mod_wrap</code>, connections
254 from hosts that have broken reverse DNS mappings are refused. OpenSSH
255 uses the same <code>libwrap</code> library, and this doesn't happen. Is it
256 a bug in <code>mod_wrap</code>?<br>
257 <font color=blue>Answer</font>: No, it is not, strictly speaking, a bug
258 in <code>mod_wrap</code>.
259
260 <p>
261 Users who encounter this issue will usually find log messages that look
262 like the any/all of the following in their syslog:
263 <pre>
264 proftpd: warning: can't verify hostname: gethostbyname(<i>dns-name</i>) failed
265 proftpd: warning: can't verify hostname: getaddrinfo(anothername.net, AF_INET) failed
266 proftpd: warning: host name/name mismatch: somedomain.com != vs-23.somename.com
267 </pre>
268 These log messages do <b>not</b>, in fact, come from <code>proftpd</code>.
269 Instead, they come from the <code>libwrap</code> library, which is used by
270 the <code>mod_wrap</code> module. In particular, the <code>libwrap</code>
271 library emits these log messages when it has been compiled with the
272 <code>-DPARANOID</code> compile-time option (and most installations of the
273 <code>libwrap</code> library are compiled this way).
274
275 <p>
276 OpenSSH allows such connections because the OpenSSH code, when using the
277 <code>libwrap</code> library, does not check for paranoid/unknown results
278 from the <code>host_access()</code> function of the <code>libwrap</code>
279 library. The <code>mod_wrap</code> module for ProFTPD <i>does</i> check
280 for these values, thus why those connections are refused by
281 <code>mod_wrap</code> but not OpenSSH. This just demonstrates that not all
282 applications use the <code>libwrap</code> library the same way.
283
284 <p>
285 The solution, in most cases, is to switch to using the newer
286 <a href="mod_wrap2.html"><code>mod_wrap2</code></a> module, which does
287 <b>not</b> use the <code>libwrap</code> library (and thus does not encounter
288 this issue).
289
290 <p>
291 <hr>
292 <h2><a name="Installation">Installation</a></h2>
293 Use of <code>mod_wrap</code> is straightforward, with some minor caveats. If
294 you're using Solaris, you'll need to obtain and build the tcpwrappers library,
295 as this library does not come installed on stock Solaris systems. If you're
296 using FreeBSD or Mac OSX (and possibly other versions), you'll need to change
297 the following line in the header of <code>mod_wrap.c</code>:
298 <pre>
299 * $Libraries: -lwrap -lnsl$
300 </pre>
301 to be:
302 <pre>
303 * $Libraries: -lwrap$
304 </pre>
305 This line is needed on Linux and Solaris machines, to properly link against
306 the <code>libnsl.a</code> library, which implements the NIS/YP functions.
307 In FreeBSD and Mac OSX, these functions are implemented in <code>libc</code>.
308
309 <p>
310 Then, you need simply follow the normal steps for using third-party modules in
311 ProFTPD:
312 <pre>
313 $ ./configure --with-modules=mod_wrap
314 $ make
315 $ make install
316 </pre>
317
318 <p>
319 <hr>
320 <font size=2><b><i>
321 &copy; Copyright 2000-2009 TJ Saunders<br>
322 All Rights Reserved<br>
323 </i></b></font>
324 <hr>
325
326 </body>
327 </html>