Debian Codegraph @

doc/contrib/mod_ifsession.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD module mod_ifsession</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center>
11 <h2><b>ProFTPD module <code>mod_ifsession</code></b></h2>
12 </center>
13 <hr><br>
14
15 The purpose of <code>mod_ifsession</code> is to provide a flexible way of
16 specifying that certain configuration directives only apply to certain sessions,
17 based on credentials such as connection class, user, or group membership.
18
19 <p>
20 For class-based qualifications, <code>mod_ifsession</code> will apply
21 configuration directives to the current session as soon as the client has
22 connected to the server; for user- and group-based qualifications,
23 <code>mod_ifsession</code> applies configuration directives to the current
24 session, if applicable, only after the client has successfully authenticated.
25 This means that <code>mod_ifsession</code> cannot change the effect of some
26 user- and group-qualified configuration directives, particularly those that
27 influence the session prior to authentication. These directives include:
28 <pre>
29 AccessDenyMsg
30 AccessGrantMsg
31 AnonRequirePassword
32 &lt;Anonymous&gt;
33 AuthGroupFile
34 AuthUserFile
35 CreateHome
36 DefaultChdir
37 DefaultRoot
38 DefaultTransferMode
39 DisplayConnect
40 ExtendedLog
41 MaxInstances
42 RequireValidShell
43 RootLogin
44 ServerIdent
45 ServerName
46 ShowSymlinks
47 TransferLog
48 UseFtpUsers
49 WtmpLog
50 </pre>
51 and the directives from the <code>mod_auth_pam</code> module. All of these
52 <b>can</b> set on based on class qualifications, however.
53
54 <p>
55 While the above list of configuration directives is daunting, there <b>are</b>
56 still valid uses for this module, <i>e.g.</i> configuring
57 <code>&lt;Directory&gt;</code> and/or <code>&lt;Limit&gt;</code> for certain
58 sessions, <code>Filter</code> directives, transfer rates, maximum file sizes,
59 etc. Plus, some of the above directives (<i>e.g.</i> <code>DefaultChdir</code>,
60 <code>DefaultRoot</code>) already have their own configurable restrictions
61 (group expressions in the case of <code>DefaultChdir</code> and
62 <code>DefaultRoot</code>), so all is not entirely lost.
63
64 <p>
65 This module is contained in the <code>contrib/mod_ifsession.c</code> file for
66 ProFTPD 1.2.<i>x</i>/1.3.<i>x</i>, and is not compiled by default.
67 Installation instructions are discussed <a href="#Installation">here</a>.
68
69 <p>
70 The most current version of <code>mod_ifsession</code> is distributed with
71 the ProFTPD source.
72
73 <h2>Author</h2>
74 <p>
75 Please contact TJ Saunders &lt;tj <i>at</i> castaglia.org&gt; with any
76 questions, concerns, or suggestions regarding this module.
77
78 <h2>Directives</h2>
79 <ul>
80 <li><a href="#IfAuthenticated">&lt;IfAuthenticated&gt;</a>
81 <li><a href="#IfClass">&lt;IfClass&gt;</a>
82 <li><a href="#IfGroup">&lt;IfGroup&gt;</a>
83 <li><a href="#IfSessionOptions">IfSessionOptions</a>
84 <li><a href="#IfUser">&lt;IfUser&gt;</a>
85 </ul>
86
87 <hr>
88 <h3><a name="IfAuthenticated">&lt;IfAuthenticated&gt;</a></h3>
89 <strong>Syntax:</strong> &lt;IfAuthenticated&gt;<br>
90 <strong>Default:</strong> None<br>
91 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
92 <strong>Module:</strong> mod_ifsession<br>
93 <strong>Compatibility:</strong> 1.3.5rc1 and later
94
95 <p>
96 The <code>&lt;IfAuthenticated&gt;</code> context should contain any
97 configuration directives that should be in effect for any sessions where
98 the client has successfully authenticated.
99
100 <p>
101 Examples:
102 <pre>
103 # Only configure SQL logging for authenticated users, to avoid cluttering
104 # database tables with fail login data
105 &lt;IfAuthenticated&gt;
106 SQLLog ...
107 &lt;/IfAuthenticated&gt;
108 </pre>
109
110 <p>
111 See also: <a href="#IfGroup">&lt;IfGroup&gt;</a>, <a href="#IfUser">&lt;IfUser&gt;</a>
112
113 <hr>
114 <h3><a name="IfClass">&lt;IfClass&gt;</a></h3>
115 <strong>Syntax:</strong> &lt;IfClass <em>[&quot;AND&quot;|&quot;OR&quot;] class-expression|&quot;regex&quot; regexp</em>&gt;<br>
116 <strong>Default:</strong> None<br>
117 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
118 <strong>Module:</strong> mod_ifsession<br>
119 <strong>Compatibility:</strong> 1.2.8rc1 and later
120
121 <p>
122 The <code>&lt;IfClass&gt;</code> context should contain any configuration
123 directives that should be in effect for any sessions that match the
124 <em>class-expression</em>. <code>Classes</code> must be enabled for this
125 context to work properly; the connecting client must be in any of the classes
126 listed in the expression for the directives contained to be applied. Note
127 that <code>!</code> notation in front of a class name in the expression is
128 supported.
129
130 <p>
131 The given <em>class-expression</em> may optionally be prefixed
132 with either the &quot;AND&quot; or &quot;OR&quot; keywords, which affect how
133 the expression is evaluated: if &quot;AND&quot; is used, then <b>all</b>
134 portions of the expression must evaluate to TRUE for the configuration context
135 to be applied to the current session; if &quot;OR&quot; is used, then <b>any</b>
136 portion of the expression must be TRUE for the context to be applied. The
137 default setting for <code>&lt;IfClass&gt;</code> is &quot;OR&quot;.
138
139 <p>
140 If the &quot;regex&quot; keyword is used, the <em>regexp</em> should be a
141 regular expression to match class names.
142
143 <p>
144 Examples:
145 <pre>
146 # Give friends, and local users, better transfer rates
147 &lt;IfClass local, friends&gt;
148 TransferRate RETR 8192
149 &lt;/IfClass&gt;
150
151 TransferRate RETR 4096
152 </pre>
153
154 <p>
155 See also: <a href="#IfGroup">&lt;IfGroup&gt;</a>, <a href="#IfUser">&lt;IfUser&gt;</a>
156
157 <p>
158 <hr>
159 <h3><a name="IfGroup">&lt;IfGroup&gt;</a></h3>
160 <strong>Syntax:</strong> &lt;IfGroup <em>[&quot;AND&quot;|&quot;OR&quot;] group-expression|&quot;regex&quot; regexp</em>&gt;<br>
161 <strong>Default:</strong> None<br>
162 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
163 <strong>Module:</strong> mod_ifsession<br>
164 <strong>Compatibility:</strong> 1.2.8rc1 and later
165
166 <p>
167 The <code>&lt;IfGroup&gt;</code> context should contain any configuration
168 directives that should be in effect for any sessions that match the
169 <em>group-AND-expression</em>. The authenticated user must be in <b>all</b> of
170 the groups listed in the expression for the directives contained to be
171 applied. Note that <code>!</code> notation in front of a group name in the
172 expression is supported.
173
174 <p>
175 The given <em>group-expression</em> may optionally be prefixed
176 with either the &quot;AND&quot; or &quot;OR&quot; keywords, which affect how
177 the expression is evaluated: if &quot;AND&quot; is used, then <b>all</b>
178 portions of the expression must evaluate to TRUE for the configuration context
179 to be applied to the current session; if &quot;OR&quot; is used, then <b>any</b>
180 portion of the expression must be TRUE for the context to be applied. The
181 default setting for <code>&lt;IfGroup&gt;</code> is &quot;AND&quot;.
182
183 <p>
184 If the &quot;regex&quot; keyword is used, the <em>regexp</em> should be a
185 regular expression to match group names.
186
187 <p>
188 Example:
189 <pre>
190 # Only members of group webusers can upload/download HTML files
191 &lt;IfGroup !webusers&gt;
192 PathDenyFilter \.htm$|\.html$
193 &lt;/IfGroup&gt;
194 </pre>
195
196 <p>
197 See also: <a href="#IfClass">&lt;IfClass&gt;</a>, <a href="#IfUser">&lt;IfUser&gt;</a>
198
199 <p>
200 <hr>
201 <h3><a name="IfSessionOptions">IfSessionOptions</a></h3>
202 <strong>Syntax:</strong> IfSessionOptions <em>opt1 ...</em><br>
203 <strong>Default:</strong> None<br>
204 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
205 <strong>Module:</strong> mod_ifsession<br>
206 <strong>Compatibility:</strong> 1.3.9rc1 and later
207
208 <p>
209 The <code>IfSessionOptions</code> directive is used to configure various
210 optional behavior of <code>mod_ifsession</code>.
211
212 <p>
213 Example:
214 <pre>
215 IfSessionOptions PerUnauthenticatedUser
216 </pre>
217
218 <p>
219 The currently implemented options are:
220 <ul>
221 <li><code>PerUnauthenticatedUser</code><br>
222 <p>
223 By default, <code>mod_ifsession</code> will only use the
224 <i>authenticated</i> identify of the remote client for conditional
225 configurations, <i>i.e.</i> after the client has successfully
226 authenticated.
227
228 <p>
229 However, some sites need to use different <i>authentication-related</i>
230 conditional configurations, which means using the <i>unauthenticated</i>
231 identity (usually the username requested). For such cases, use this
232 option. <b>Not recommended</b>, as such conditional configurations can
233 lead to timing differences, which can then be used to determine/test which
234 usernames are valid for the site.
235 </li>
236 </ul>
237
238 <p>
239 <hr>
240 <h3><a name="IfUser">&lt;IfUser&gt;</a></h3>
241 <strong>Syntax:</strong> &lt;IfUser <em>[&quot;AND&quot;|&quot;OR&quot;] user-expression|&quot;regex&quot; regexp</em>&gt;<br>
242 <strong>Default:</strong> None<br>
243 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
244 <strong>Module:</strong> mod_ifsession<br>
245 <strong>Compatibility:</strong> 1.2.8rc1 and later
246
247 <p>
248 The <code>&lt;IfUser&gt;</code> context should contain any configuration
249 directives that should be in effect for any sessions that match the
250 <em>user-OR-expression</em>. The authenticated user must be one of the users
251 listed in the expression for the directives contained to be applied. Note
252 that <code>!</code> notation in front of a user name in the expression is
253 supported.
254
255 <p>
256 The given <em>user-expression</em> may optionally be prefixed
257 with either the &quot;AND&quot; or &quot;OR&quot; keywords, which affect how
258 the expression is evaluated: if &quot;AND&quot; is used, then <b>all</b>
259 portions of the expression must evaluate to TRUE for the configuration context
260 to be applied to the current session; if &quot;OR&quot; is used, then <b>any</b>
261 portion of the expression must be TRUE for the context to be applied. The
262 default setting for <code>&lt;IfUser&gt;</code> is &quot;OR&quot;.
263
264 <p>
265 If the &quot;regex&quot; keyword is used, the <em>regexp</em> should be a
266 regular expression to match user names.
267
268 <p>
269 Example:
270 <pre>
271 # Alter the view of files for everyone except the admin
272 &lt;IfUser !ftpadm&gt;
273 &lt;Directory /&gt;
274 DirFakeUser on ~
275 DirFakeGroup on ~
276 DirFakeMode 0440
277 &lt;/Directory&gt;
278 &lt;/IfUser&gt;
279
280 # Impose a PathDenyFilter on ftp users
281 &lt;IfUser regex ^ftp&gt;
282 PathDenyFilter \.conf$
283 &lt;/IfUser&gt;
284 </pre>
285
286 <p>
287 See also: <a href="#IfClass">&lt;IfClass&gt;</a>, <a href="#IfGroup">&lt;IfGroup&gt;</a>
288
289 <p>
290 <hr>
291 <h2><a name="Usage">Usage</a></h2>
292
293 <p>
294 <b>As a Shared Module</b><br>
295 If your <code>proftpd</code> is compiled with <code>mod_ifsession</code>
296 as a shared module, then you <b>must</b> make sure that
297 <code>mod_ifsession</code> is loaded <b>last</b>:
298 <pre>
299 &lt;IfModule mod_dso.c&gt;
300 LoadModule mod_sql.c
301 LoadModule mod_sql_mysql.c
302 LoadModule mod_tls.c
303 LoadModule mod_rewrite.c
304 <b>LoadModule mod_ifsession.c</b>
305 &lt;/IfModule&gt;
306 </pre>
307 Failure to ensure that <code>mod_ifsession</code> is loaded last will mean
308 that the per-user/group/class functionality will not work as you expect.
309
310 <p>
311 <i>Todo</i><br>
312 Expressions, AND vs OR
313
314 <p>
315 <hr>
316 <h2><a name="Installation">Installation</a></h2>
317 The <code>mod_ifsession</code> module is distributed with ProFTPD. Follow the
318 usual steps for using third-party modules in ProFTPD:
319 <pre>
320 $ ./configure --with-modules=mod_ifsession
321 $ make
322 $ make install
323 </pre>
324 Note that <code>mod_ifsession</code> should be the <b>last</b> module
325 in the <code>--with-modules</code> list, if multiple modules are listed.
326 This makes sure that <code>mod_ifsession</code>'s changes will be seen
327 properly by other modules.
328
329 <p>
330 To build <code>mod_ifsession</code> as a DSO module:
331 <pre>
332 $ ./configure --enable-dso --with-shared=mod_ifsession
333 </pre>
334 Then follow the usual steps:
335 <pre>
336 $ make
337 $ make install
338 </pre>
339
340 <p>
341 Alternatively, if your <code>proftpd</code> was compiled with DSO support, you
342 can use the <code>prxs</code> tool to build <code>mod_ifsession</code> as a
343 shared module:
344 <pre>
345 $ prxs -c -i -d mod_ifsession.c
346 </pre>
347
348 <p>
349 <b>Logging</b><br>
350 The <code>mod_ifsession</code> module supports <a href="../howto/Tracing.html">trace logging</a>, via the module-specific log channels:
351 <ul>
352 <li>ifsession
353 </ul>
354 Thus for trace logging, to aid in debugging, you would use the following in
355 your <code>proftpd.conf</code>:
356 <pre>
357 TraceLog /path/to/ftpd/trace.log
358 Trace ifsession:20
359 </pre>
360 This trace logging can generate large files; it is intended for debugging use
361 only, and should be removed from any production configuration.
362
363 <p>
364 <hr>
365 <font size=2><b><i>
366 &copy; Copyright 2000-2023 TJ Saunders<br>
367 All Rights Reserved<br>
368 </i></b></font>
369 <hr>
370
371 </body>
372 </html>