| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD module mod_quotatab</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center> |
| 11 | <h2><b>ProFTPD module <code>mod_quotatab</code></b></h2> |
| 12 | </center> |
| 13 | <hr><br> |
| 14 | |
| 15 | This module is contained in the <code>mod_quotatab.c</code>, |
| 16 | <code>mod_quotatab.h</code>, and in its submodule source files, for |
| 17 | ProFTPD 1.2.<i>x</i>/1.3.<i>x</i>, and is not compiled by default. |
| 18 | Installation instructions can be found <a href="#Installation">here</a>. |
| 19 | |
| 20 | <p> |
| 21 | This module is designed to impose quotas, both byte- and file-based, on |
| 22 | FTP accounts, based on user, group, class, or for all accounts. It is based |
| 23 | on the ideas contained in Eric Estabrook's <code>mod_quota</code>; however, |
| 24 | this module has been written from scratch to implement quotas in a very |
| 25 | different manner. A more detailed explanation of the <a href="#Usage">usage</a> |
| 26 | of this module follows the directive explanations. |
| 27 | |
| 28 | <p> |
| 29 | The most current version of <code>mod_quotatab</code>'s submodules supports |
| 30 | storage of quota table information in various formats: |
| 31 | <a name="submodules"></a> |
| 32 | <ul> |
| 33 | <li><a href="mod_quotatab_file.html"><code>mod_quotatab_file</code></a> for file-based quota tables<br> |
| 34 | <li><a href="mod_quotatab_ldap.html"><code>mod_quotatab_ldap</code></a> for LDAP-based quota limit tables<br> |
| 35 | <li><a href="mod_quotatab_radius.html"><code>mod_quotatab_radius</code></a> for RADIUS-based quota tables<br> |
| 36 | <li><a href="mod_quotatab_sql.html"><code>mod_quotatab_sql</code></a> for SQL-based quota tables<br> |
| 37 | </ul> |
| 38 | |
| 39 | <p> |
| 40 | The most current version of <code>mod_quotatab</code> is distributed with the |
| 41 | ProFTPD source code. |
| 42 | |
| 43 | <h2>Author</h2> |
| 44 | <p> |
| 45 | Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any |
| 46 | questions, concerns, or suggestions regarding this module. |
| 47 | |
| 48 | <h2>Thanks</h2> |
| 49 | <p> |
| 50 | <i>2002-01-12</i>: Thanks to SupaFly <ntlfy <i>at</i> ntlworld.com> for |
| 51 | helping debug an issue with a missing tally table. |
| 52 | |
| 53 | <p> |
| 54 | <i>2002-03-30</i>: Thanks to Kai Langheim <kl <i>at</i> q-nic.de> for |
| 55 | pointing out several small bugs affecting users with no quota entries. |
| 56 | |
| 57 | <p> |
| 58 | <i>2003-01-24</i>: Thanks to Arne Blankerts <Blankerts <i>at</i> tow.de> |
| 59 | for noting small bug with the file upload counter being incorrectly incremented |
| 60 | for overwritten files. |
| 61 | |
| 62 | <h2>Directives</h2> |
| 63 | <ul> |
| 64 | <li><a href="#QuotaDefault">QuotaDefault</a> |
| 65 | <li><a href="#QuotaDirectoryTally">QuotaDirectoryTally</a> |
| 66 | <li><a href="#QuotaDisplayUnits">QuotaDisplayUnits</a> |
| 67 | <li><a href="#QuotaEngine">QuotaEngine</a> |
| 68 | <li><a href="#QuotaExcludeFilter">QuotaExcludeFilter</a> |
| 69 | <li><a href="#QuotaLimitTable">QuotaLimitTable</a> |
| 70 | <li><a href="#QuotaLock">QuotaLock</a> |
| 71 | <li><a href="#QuotaLog">QuotaLog</a> |
| 72 | <li><a href="#QuotaOptions">QuotaOptions</a> |
| 73 | <li><a href="#QuotaShowQuotas">QuotaShowQuotas</a> |
| 74 | <li><a href="#QuotaTallyTable">QuotaTallyTable</a> |
| 75 | </ul> |
| 76 | |
| 77 | <p> |
| 78 | <h2><code>SITE</code> Commands</h2> |
| 79 | <ul> |
| 80 | <li><a href="#SITE_QUOTA">SITE QUOTA</a> |
| 81 | </ul> |
| 82 | |
| 83 | <hr> |
| 84 | <h3><a name="QuotaDefault">QuotaDefault</a></h3> |
| 85 | <strong>Syntax:</strong> QuotaDefault <em>quota-type per-session limit-type bytes-avail-in bytes-avail-out bytes-avail-xfer files-avail-in files-avail-out files-avail-xfer</em><br> |
| 86 | <strong>Default:</strong> None<br> |
| 87 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 88 | <strong>Module:</strong> mod_quotatab<br> |
| 89 | <strong>Compatibility:</strong> 1.3.5rc1 and later |
| 90 | |
| 91 | <p> |
| 92 | The <code>QuotaDefault</code> directive configures a "default" quota limit, |
| 93 | to be used when a limit is not found for the current user (<i>e.g.</i> a limit |
| 94 | has not yet been configured for the user via one of the mod_quotatab backends). |
| 95 | Since this "default" needs to provide all of the limit information required |
| 96 | by <code>mod_quotatab</code>, there are quite a few required parameters: |
| 97 | <ul> |
| 98 | <li><em>quota-type</em> |
| 99 | <li><em>per-session</em> |
| 100 | <li><em>limit-type</em> |
| 101 | <li><em>bytes-avail-in</em> |
| 102 | <li><em>bytes-avail-out</em> |
| 103 | <li><em>bytes-avail-xfer</em> |
| 104 | <li><em>files-avail-in</em> |
| 105 | <li><em>files-avail-out</em> |
| 106 | <li><em>files-avail-xfer</em> |
| 107 | </ul> |
| 108 | The meaning of these parameters is discussed in more detail |
| 109 | <a href="#QuotaLookup">here</a>. |
| 110 | |
| 111 | <p> |
| 112 | For example, you might use: |
| 113 | <pre> |
| 114 | QuotaDefault user false hard 10485760 0 0 0 0 0 |
| 115 | </pre> |
| 116 | |
| 117 | <p> |
| 118 | <hr> |
| 119 | <h3><a name="QuotaDirectoryTally">QuotaDirectoryTally</a></h3> |
| 120 | <strong>Syntax:</strong> QuotaDirectoryTally <em>on|off</em><br> |
| 121 | <strong>Default:</strong> QuotaDirectoryTally off<br> |
| 122 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 123 | <strong>Module:</strong> mod_quotatab<br> |
| 124 | <strong>Compatibility:</strong> 1.2.5rc2 and later |
| 125 | |
| 126 | <p> |
| 127 | The <code>QuotaDirectoryTally</code> directive configures |
| 128 | <code>mod_quotatab</code> to take directory operations (<i>e.g.</i> creating |
| 129 | a directory, removing a directory) into account when tallying. |
| 130 | |
| 131 | <p> |
| 132 | <hr> |
| 133 | <h3><a name="QuotaDisplayUnits">QuotaDisplayUnits</a></h3> |
| 134 | <strong>Syntax:</strong> QuotaDisplayUnits <em>"b"|"Kb"|"Mb"|"Gb"</em><br> |
| 135 | <strong>Default:</strong> None<br> |
| 136 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 137 | <strong>Module:</strong> mod_quotatab<br> |
| 138 | <strong>Compatibility:</strong> 1.2.5rc2 and later |
| 139 | |
| 140 | <p> |
| 141 | This directive configures how the user's current byte quota values will be |
| 142 | reported to them. Note that this directive does not affect how the quota |
| 143 | values are stored in the quota table, only their presentation to the user. |
| 144 | |
| 145 | <p> |
| 146 | <em>"b"</em> causes quotas to be displayed in bytes; |
| 147 | <em>"Kb"</em>, kilobytes; <em>"Mb"</em>, megabytes; and |
| 148 | <em>"Gb"</em>, gigabytes. |
| 149 | |
| 150 | <p> |
| 151 | Example: |
| 152 | <pre> |
| 153 | # display quota information in megabytes |
| 154 | QuotaDisplayUnits Mb |
| 155 | </pre> |
| 156 | |
| 157 | <p> |
| 158 | <hr> |
| 159 | <h3><a name="QuotaEngine">QuotaEngine</a></h3> |
| 160 | <strong>Syntax:</strong> QuotaEngine <em>on|off</em><br> |
| 161 | <strong>Default:</strong> None<br> |
| 162 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 163 | <strong>Module:</strong> mod_quotatab<br> |
| 164 | <strong>Compatibility:</strong> 1.2.5rc2 and later</a> |
| 165 | |
| 166 | <p> |
| 167 | The <code>QuotaEngine</code> directive enables or disables the module's runtime |
| 168 | quota engine. If it is set to <em>off</em> this module does no runtime |
| 169 | processing at all. Use this directive to disable the module instead of |
| 170 | commenting out all <code>mod_quotatab</code> directives. |
| 171 | |
| 172 | <p> |
| 173 | <hr> |
| 174 | <h3><a name="QuotaExcludeFilter">QuotaExcludeFilter</a></h3> |
| 175 | <strong>Syntax:</strong> QuotaExcludeFilter <em>regex|"none"</em><br> |
| 176 | <strong>Default:</strong> None<br> |
| 177 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 178 | <strong>Module:</strong> mod_quotatab<br> |
| 179 | <strong>Compatibility:</strong> 1.3.1rc1 and later</a> |
| 180 | |
| 181 | <p> |
| 182 | The <code>QuotaExcludeFilter</code> directive configures a regular expression |
| 183 | filter that is applied to every file handled by <code>mod_quotatab</code>; |
| 184 | this includes files that are scanned if: |
| 185 | <pre> |
| 186 | QuotaOptions ScanOnLogin |
| 187 | </pre> |
| 188 | is in effect. Any file which matches the configured regular expression is |
| 189 | ignored by <code>mod_quotatab</code>, and will not affect the tally updates. |
| 190 | |
| 191 | <p> |
| 192 | Note that the regular expression is applied to the <i>absolute path</i> of |
| 193 | the file being handled. This allows for a regular expression which can |
| 194 | exclude particular directories, or just certain filenames. |
| 195 | |
| 196 | <p> |
| 197 | <hr> |
| 198 | <h3><a name="QuotaLimitTable">QuotaLimitTable</a></h3> |
| 199 | <strong>Syntax:</strong> QuotaLimitTable <em>source-type:source-info</em><br> |
| 200 | <strong>Default:</strong> None<br> |
| 201 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 202 | <strong>Module:</strong> mod_quotatab<br> |
| 203 | <strong>Compatibility:</strong> 1.2.5rc2 and later</a> |
| 204 | |
| 205 | <p> |
| 206 | This directive configures the information necessary for the module to locate |
| 207 | and use the table containing the quota <i>limit</i>, the maximum number |
| 208 | of bytes and/or files defined for use by specific users, groups, classes, |
| 209 | <i>etc</i>, and is <b>required</b> for <code>mod_quotatab</code> to function. |
| 210 | Note that "groups" here refers to the groups of which the user |
| 211 | is a member, the same groups as used for filesystem permissions; |
| 212 | "classes" refers to connection |
| 213 | <a href="../howto/Classes.html">classes</a>. |
| 214 | |
| 215 | <p> |
| 216 | Please consult the relevant <a href="#submodule">submodule</a> documentation |
| 217 | for details on that module's syntax for this configuration directive. |
| 218 | |
| 219 | <p> |
| 220 | See also: <a href="#QuotaTallyTable">QuotaTallyTable</a> |
| 221 | |
| 222 | <p> |
| 223 | <hr> |
| 224 | <h3><a name="QuotaLock">QuotaLock</a></h3> |
| 225 | <strong>Syntax:</strong> QuotaLock <em>file</em><br> |
| 226 | <strong>Default:</strong> None<br> |
| 227 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 228 | <strong>Module:</strong> mod_quotatab<br> |
| 229 | <strong>Compatibility:</strong> 1.2.9rc1 and later</a> |
| 230 | |
| 231 | <p> |
| 232 | The <code>QuotaLock</code> directive sets the filename for a synchronization |
| 233 | lockfile which <code>mod_quotatab</code> needs when communicating with |
| 234 | some submodules, such as for SQL-based tables, which have trouble providing |
| 235 | the needed synchronization/locking semantics. Use of <code>QuotaLock</code> |
| 236 | is recommended, but not required. |
| 237 | |
| 238 | <p> |
| 239 | If <code>QuotaLock</code> is used, it is <b>strongly advised</b> that the |
| 240 | configured lock file <b>not</b> be on an NFS (or any other network) filesystem. |
| 241 | |
| 242 | <p> |
| 243 | <hr> |
| 244 | <h3><a name="QuotaLog">QuotaLog</a></h3> |
| 245 | <strong>Syntax:</strong> QuotaLog <em>file|"none"</em><br> |
| 246 | <strong>Default:</strong> None<br> |
| 247 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 248 | <strong>Module:</strong> mod_quotatab<br> |
| 249 | <strong>Compatibility:</strong> 1.2.5rc2 and later</a> |
| 250 | |
| 251 | <p> |
| 252 | The <code>QuotaLog</code> directive is used to specify a log file for |
| 253 | <code>mod_quotatab</code> reporting, and can be done a per-server basis. |
| 254 | The <em>file</em> parameter must be the full path to the file to use for |
| 255 | logging. Note that this path must <b>not</b> be to a world-writeable |
| 256 | directory and, unless <code>AllowLogSymlinks</code> is explicitly set to |
| 257 | <em>on</em> (generally a bad idea), the path must <b>not</b> be a symbolic |
| 258 | link. |
| 259 | |
| 260 | <p> |
| 261 | If <em>file</em> is "none", no logging will be done at all; this |
| 262 | setting can be used to override a <code>QuotaLog</code> setting inherited from |
| 263 | a <code><Global></code> context. |
| 264 | |
| 265 | <p> |
| 266 | <hr> |
| 267 | <h3><a name="QuotaOptions">QuotaOptions</a></h3> |
| 268 | <strong>Syntax:</strong> QuotaOptions <em>opt1 ...</em><br> |
| 269 | <strong>Default:</strong> None<br> |
| 270 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 271 | <strong>Module:</strong> mod_quotatab<br> |
| 272 | <strong>Compatibility:</strong> 1.3.1rc1 and later |
| 273 | |
| 274 | <p> |
| 275 | The <code>QuotaOptions</code> directive is used to configure various optional |
| 276 | behavior of <code>mod_quotatab</code>. |
| 277 | |
| 278 | <p> |
| 279 | Example: |
| 280 | <pre> |
| 281 | QuotaOptions ScanOnLogin |
| 282 | </pre> |
| 283 | |
| 284 | <p> |
| 285 | The currently implemented options are: |
| 286 | <ul> |
| 287 | <li><code>ScanOnLogin</code><br> |
| 288 | <p> |
| 289 | If configured, this causes <code>mod_quotatab</code> to recursively |
| 290 | scan the user's home directory when the user logs in, and to update |
| 291 | the tally entry for that user, if any, with the number of bytes and |
| 292 | files found. <b>Note</b> that these scans <i>will</i> cause a longer |
| 293 | login time for the user, depending on the size of their home directory. |
| 294 | |
| 295 | <p> |
| 296 | Note that this scanning will <b>only</b> happen <i>if</i> the configured |
| 297 | limits for the user have either a bytes-in value greater than zero or |
| 298 | a files-in value greater than zero. (These are the only two limits |
| 299 | related to upload, hence why <code>ScanOnLogin</code> only goes into |
| 300 | effect based on them.) |
| 301 | </li> |
| 302 | </ul> |
| 303 | |
| 304 | <p> |
| 305 | <hr> |
| 306 | <h3><a name="QuotaShowQuotas">QuotaShowQuotas</a></h3> |
| 307 | <strong>Syntax:</strong> QuotaShowQuotas <em>on|off</em><br> |
| 308 | <strong>Default:</strong> on<br> |
| 309 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 310 | <strong>Module:</strong> mod_quotatab<br> |
| 311 | <strong>Compatibility:</strong> 1.2.5rc2 and later</a> |
| 312 | |
| 313 | <p> |
| 314 | The <code>QuotaShowQuotas</code> directive can be used to enable/disable |
| 315 | <code>mod_quotatab</code>'s response to a <code>SITE QUOTA</code> request. |
| 316 | For some sites, revealing the current quota information may be considered |
| 317 | an unnecessary, perhaps even detrimental, information leak; other sites |
| 318 | may consider this a definite feature. |
| 319 | |
| 320 | <p> |
| 321 | <hr> |
| 322 | <h3><a name="QuotaTallyTable">QuotaTallyTable</a></h3> |
| 323 | <strong>Syntax:</strong> QuotaTallyTable <em>source-type:source-info</em><br> |
| 324 | <strong>Default:</strong> None<br> |
| 325 | <strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br> |
| 326 | <strong>Module:</strong> mod_quotatab<br> |
| 327 | <strong>Compatibility:</strong> 1.2.5rc2 and later</a> |
| 328 | |
| 329 | <p> |
| 330 | This directive configures the information necessary for the module to locate |
| 331 | and use the table containing the quota <i>tally</i>, or the current byte/file |
| 332 | counts for users, groups, classes, <i>etc</i>, and is <b>required</b> for |
| 333 | <code>mod_quotatab</code> to function. Note that "groups" here |
| 334 | refers to the groups of which the user is a member, the same groups as used |
| 335 | for filesystem permissions; "classes" refers to connection |
| 336 | <a href="../howto/Classes.html">classes</a>. |
| 337 | |
| 338 | <p> |
| 339 | Please consult the relevant <a href="#submodule">submodule</a> documentation |
| 340 | for details on that module's syntax for this configuration directive. |
| 341 | |
| 342 | <p> |
| 343 | See also: <a href="#QuotaLimitTable">QuotaLimitTable</a> |
| 344 | |
| 345 | <p> |
| 346 | <hr><br> |
| 347 | |
| 348 | <p> |
| 349 | <h3><a name="SITE_QUOTA">SITE QUOTA</a></h3> |
| 350 | <p> |
| 351 | The <code>SITE QUOTA</code> command will display the quota, both the limit |
| 352 | and the current tally, to the client. This <code>SITE</code> command accepts |
| 353 | no parameters, and can only be used once the client has successfully logged |
| 354 | in. |
| 355 | |
| 356 | <p> |
| 357 | Example: |
| 358 | <pre> |
| 359 | ftp> quote SITE QUOTA |
| 360 | 200-The current quota for this session are [current/limit]: |
| 361 | Name: tj |
| 362 | Quota Type: User |
| 363 | Per Session: True |
| 364 | Limit Type: Hard |
| 365 | Uploaded Kb: unlimited |
| 366 | Downloaded Kb: unlimited |
| 367 | Transferred Kb: unlimited |
| 368 | Uploaded files: 1/1 |
| 369 | Downloaded files: unlimited |
| 370 | Transferred files: unlimited |
| 371 | 200 Please contact [email protected] if these entries are inaccurate |
| 372 | ftp> |
| 373 | </pre> |
| 374 | Use of this <code>SITE</code> command can be controlled via |
| 375 | <code><Limit></code>, <i>e.g.</i>: |
| 376 | <pre> |
| 377 | <Limit SITE_QUOTA> |
| 378 | AllowUser tj |
| 379 | DenyAll |
| 380 | </Limit> |
| 381 | </pre> |
| 382 | |
| 383 | <p> |
| 384 | Like many <code>SITE</code> commands, the FTP client will probably not |
| 385 | recognize or support <code>SITE QUOTA</code>. Hopefully the client <i>does</i> |
| 386 | have the ability to send arbitrary commands to the server, as the common |
| 387 | <code>ftp(1)</code> client does via <code>quote</code>. |
| 388 | |
| 389 | <p> |
| 390 | The email address displayed in the <code>SITE QUOTA</code> output can be |
| 391 | configured via the <a href="http://www.proftpd.org/docs/modules/mod_core.html#ServerAdmin"><code>ServerAdmin</code></a> directive. |
| 392 | |
| 393 | <p> |
| 394 | <hr><br> |
| 395 | |
| 396 | <p> |
| 397 | <h2><a name="Usage">Usage</a></h2> |
| 398 | <p> |
| 399 | To use <code>mod_quotatab</code>'s functionality, you must first define the |
| 400 | tables that together contain the quota information. |
| 401 | |
| 402 | <p><a name="QuotaTables"></a> |
| 403 | There are two such quota tables: one table, called the <b>limit table</b> for |
| 404 | providing quota information about the absolute byte/file <i>limits</i> for |
| 405 | users, groups, and classes, and a separate table, called the <b>tally table</b> |
| 406 | for maintaining the current <i>tally</i>, or number of bytes/files used, for |
| 407 | those same users, groups, and classes. (Note that "groups" here |
| 408 | refers to the groups of which the user is a member, the same groups as used |
| 409 | for filesystem permissions; "classes" refers to connection |
| 410 | <a href="../howto/Classes.html">classes</a>.) This separation of information |
| 411 | allows for a configuration such as using LDAP to efficiently distribute the |
| 412 | limit information, and local SQL databases for efficiently storing the tally. |
| 413 | The limit table is considered a read-only table, and is only accessed at the |
| 414 | start of session in order to determine what the session limits should be. The |
| 415 | tally table is accessed in read-write mode, and is updated after the relevant |
| 416 | FTP commands have been processed. |
| 417 | |
| 418 | <p> |
| 419 | This module was not explicitly designed for easy interaction with other |
| 420 | applications, but rather for other criteria: |
| 421 | <ul> |
| 422 | <li>Efficient lookups and updates |
| 423 | <li>No need for <code>~/.quota</code> files |
| 424 | <li>No need of requirement for root privileges to access quotas |
| 425 | <li>Easy support for an abstraction layer for storing quota information in |
| 426 | other formats |
| 427 | <li>Support for a <code>SITE</code> command that allows users to view their current quotas |
| 428 | </ul> |
| 429 | |
| 430 | <p> |
| 431 | This module maintains its quotas based solely on FTP commands - it does not |
| 432 | enforce quotas based on files that may have been added, deleted, or moved |
| 433 | via shell access or any mechanism other than through the <code>proftpd</code> |
| 434 | server. |
| 435 | |
| 436 | <p><a name="QuotaLookup"></a> |
| 437 | When a client logs in, assuming <code>QuotaEngine</code> is <em>on</em>, |
| 438 | <code>mod_quotatab</code> will check the limit table for the record most |
| 439 | appropriate for that client. This check first examines the table for records |
| 440 | of type <code>user</code> that match the client's login name. |
| 441 | |
| 442 | <p> |
| 443 | If no such matching records are found, it checks for records of type |
| 444 | <code>group</code> that match any of the user's groups (both primary and |
| 445 | supplemental). If there are multiple <code>group</code>-type limits |
| 446 | available and applicable to the user's groups, which one is used? The |
| 447 | <code>mod_quotatab</code> module first checks for a quota limit for the |
| 448 | user's <i>primary</i> group. If there is a <code>group</code> limit for |
| 449 | the user's primary group, that limit is used. Otherwise, the supplemental |
| 450 | groups for the user are checked, in the order returned by the authenticating |
| 451 | module (<i>e.g.</i> <code>mod_auth_unix</code>, <code>mod_sql</code>, |
| 452 | <code>mod_ldap</code>, <i>etc</i>). |
| 453 | |
| 454 | <p> |
| 455 | If no such matching <code>group</code> quotas are found, the |
| 456 | <code>mod_quotatab</code> will check for records of type <code>class</code> |
| 457 | that belong to the class (if enabled) from which the client is connecting. |
| 458 | The order of classes matched is the order in which the classes are defined |
| 459 | in the <code>proftpd.conf</code> file. |
| 460 | |
| 461 | <p> |
| 462 | If still no matching records are found, the table will be searched for a |
| 463 | record of type <code>all</code>; if absent, the module will assume that no |
| 464 | quotas apply to the client. |
| 465 | |
| 466 | <p> |
| 467 | <b>Note</b> that there is only <b>one</b> type of limit in effect at a given |
| 468 | time; <code>mod_quotatab</code> does <b>not</b> combine multiple |
| 469 | user/group/class/all limits for the same client. The module was designed |
| 470 | such that only one limit (and its corresponding tally) would be enforced/used |
| 471 | for a given session. In the case of multiple applicable <code>group</code> |
| 472 | or <code>class</code> type quotas, only the <i>matching</i> quota limit and |
| 473 | tally will be used and updated. Currently, there is no support for multiple |
| 474 | simultaneous (or "layered") limits/tallies. |
| 475 | |
| 476 | <p> |
| 477 | Once the limits for the current session have been established, |
| 478 | <code>mod_quotatab</code> examines the tally table to see what the current |
| 479 | numbers in the matching tally record are. Should the client have an |
| 480 | applicable limit record but no matching tally record, the module will |
| 481 | initialize a new record in the tally table. If the limit record specifies |
| 482 | that quotas are per-session, <code>mod_quotatab</code> will ignore any |
| 483 | existing tally records, and will not update the tallies. |
| 484 | |
| 485 | <p> |
| 486 | For the purposes of tracking the number of <i>uploaded</i> bytes/files, |
| 487 | the tally will be adjusted accordingly upon use of the following FTP commands: |
| 488 | <code>APPE</code> (bytes only), <code>DELE</code>, <code>STOR</code>, and |
| 489 | <code>STOU</code>. The number of bytes used for the calculation will be |
| 490 | determined from the difference in file size of the file in question. |
| 491 | |
| 492 | <p> |
| 493 | For the purposes of tracking the number of <i>downloaded</i> bytes/files, |
| 494 | the tally will be adjusted accordingly upon use of the following FTP commands: |
| 495 | <code>RETR</code>. The number of bytes used for the calculation will be |
| 496 | determined from the number of bytes sent to the client. |
| 497 | |
| 498 | <p> |
| 499 | For the purposes of tracking the number of <i>transferred</i> bytes/files, |
| 500 | the tally will be adjusted accordingly upon use of the following FTP commands: |
| 501 | <code>APPE</code> (bytes only), <code>DELE</code>, <code>RETR</code>, |
| 502 | <code>STOR</code>, and <code>STOU</code>. The number of bytes used for |
| 503 | the calculation will be determined from the number of bytes sent to the |
| 504 | client. This type of limit allows for byte/file limits to be set that |
| 505 | encompass both uploads and downloads. |
| 506 | |
| 507 | <p> |
| 508 | Note that if all three types of quotas are set (upload, download, and |
| 509 | transfer), any quota reached will cause denial of FTP commands. This means |
| 510 | that a high upload quota will never be reached if a low transfer quota is |
| 511 | in effect. This holds true for bytes and files quota. For example, if |
| 512 | a user has a limited number of both bytes and files to be uploaded in their |
| 513 | limit record, the first limit reached (bytes or files) is the effective |
| 514 | limit. <i>Caveat emptor</i>. |
| 515 | |
| 516 | <p> |
| 517 | For any quota limit that is set as "unlimited", |
| 518 | <code>mod_quotatab</code> will not keep the tally. Many site administrators |
| 519 | might want this ability, for accounting purposes. However, that ability is |
| 520 | outside of the intended design of this module; other logging modules are |
| 521 | much better suited for accounting purposes (<i>e.g.</i> <code>mod_sql</code>'s |
| 522 | <code>SQLLog</code> directive). |
| 523 | |
| 524 | <p><a name="QuotaLimits"></a> |
| 525 | <b>Quota Limit Enforcement</b><br> |
| 526 | A "hard" limit type means that a user's tally will <b>never</b> |
| 527 | be allowed to exceed the limit; any file uploaded that exceeds the user's |
| 528 | quota limit will be deleted, and the tally will not be incremented. A |
| 529 | "soft" limit type, on the other hand, is a little less strict, |
| 530 | for it will allow a user to exceed the quota limit by one file only. For |
| 531 | example, assume a user's tally is close their limit. That user uploads |
| 532 | a large file, one that pushes the tally up over the quota limit. If their |
| 533 | limit type is "hard", the large file will be deleted once uploaded, |
| 534 | and a message returned to the client informing them of this. If the user's |
| 535 | limit type is "soft", the large file will be allowed, but any |
| 536 | other uploads are denied (until the user deletes some files, and brings |
| 537 | their tally back down below the quota limit). |
| 538 | |
| 539 | <p> |
| 540 | <b>Note</b> that the enforcement of "hard" limits, by deleting the |
| 541 | uploaded file, can cause unpleasant surprises for users (and site |
| 542 | administrators). In order to <b>not</b> lose large or important files because |
| 543 | of hard limits, I recommend using the <a href="../modules/mod_xfer.html#HiddenStores"><code>HiddenStores</code></a> directive with your |
| 544 | <code>mod_quotatab</code> configuration. If <code>HiddenStores</code> is |
| 545 | enabled, then when the hard upload limit is exceeded, it will be the temporary |
| 546 | <code>HiddenStores</code> file, and <b>not</b> the destination/target file, |
| 547 | that will be deleted. This way, the quota-exceeding upload will fail, but |
| 548 | users should not be surprised with unexpectedly deleted files. |
| 549 | |
| 550 | <p> |
| 551 | <b>Quota Internals</b><br> |
| 552 | If any developers wish to make use of <code>mod_quotatab</code>'s quota |
| 553 | information, or to develop a new submodule, there is developer documentation |
| 554 | available <a href="http://www.castaglia.org/proftpd/doc/devel-guide/advanced/Quotatab/">here</a>. |
| 555 | |
| 556 | <p><a name="QuotaDisplay"></a> |
| 557 | <b><code>Display</code> Variables</b><br> |
| 558 | The following variables are provided by <code>mod_quotatab</code>, and |
| 559 | can be used in any <code>Display</code> file (<i>e.g.</i> |
| 560 | <code>DisplayLogin</code>) other than <code>DisplayConnect</code>. The |
| 561 | values for the variables are not known when the client connects to the |
| 562 | daemon, hence why the variables are not useful in a <code>DisplayConnect</code> |
| 563 | file. |
| 564 | <pre> |
| 565 | %{mod_quotatab.limit.bytes_in} |
| 566 | %{mod_quotatab.limit.bytes_out} |
| 567 | %{mod_quotatab.limit.bytes_xfer} |
| 568 | %{mod_quotatab.limit.files_in} |
| 569 | %{mod_quotatab.limit.files_out} |
| 570 | %{mod_quotatab.limit.files_xfer} |
| 571 | %{mod_quotatab.tally.bytes_in} |
| 572 | %{mod_quotatab.tally.bytes_out} |
| 573 | %{mod_quotatab.tally.bytes_xfer} |
| 574 | %{mod_quotatab.tally.files_in} |
| 575 | %{mod_quotatab.tally.files_out} |
| 576 | %{mod_quotatab.tally.files_xfer} |
| 577 | </pre> |
| 578 | Note that the values for the various byte variables honor any |
| 579 | <a href="#QuotaDisplayUnits"><code>QuotaDisplayUnits</code></a> setting. |
| 580 | |
| 581 | <p> |
| 582 | <hr> |
| 583 | <h2><a name="Installation">Installation</a></h2> |
| 584 | Follow the usual steps for using third-party modules in ProFTPD: |
| 585 | <pre> |
| 586 | $ ./configure --with-modules=<i>mod_quotatab:...</i> |
| 587 | $ make |
| 588 | $ make install |
| 589 | </pre> |
| 590 | where the list of modules, including <code>mod_quotatab</code>, will depend on |
| 591 | the types of quota tables you wish to support. |
| 592 | |
| 593 | <p> |
| 594 | For using file-based quota tables, include the <code>mod_quotatab_file</code> |
| 595 | submodule, <i>e.g.</i>: |
| 596 | <pre> |
| 597 | --with-modules=mod_quotatab:mod_quotatab_file |
| 598 | </pre> |
| 599 | or: |
| 600 | <pre> |
| 601 | --enable-dso --with-shared=mod_quotatab:mod_quotatab_file |
| 602 | </pre> |
| 603 | |
| 604 | <p> |
| 605 | For using LDAP-based quota limit tables, include <code>mod_quotatab_ldap</code> |
| 606 | in addition to either <code>mod_quotatab_file</code> or |
| 607 | <code>mod_quotatab_sql</code>: |
| 608 | <pre> |
| 609 | --with-modules=mod_quotatab:mod_quotatab_file:mod_quotatab_ldap |
| 610 | </pre> |
| 611 | or: |
| 612 | <pre> |
| 613 | --enable-dso --with-shared=mod_quotatab:mod_quotatab_file:mod_quotatab_ldap |
| 614 | </pre> |
| 615 | Note that file- or SQL-based tally tables are needed since |
| 616 | <code>mod_quotatab_ldap</code> cannot handle tally tables, only limit tables. |
| 617 | <code>mod_quotatab_ldap</code> also requires a correct installation of the |
| 618 | <code>mod_ldap</code> module. |
| 619 | |
| 620 | <p> |
| 621 | For using SQL-based quota tables, include the <code>mod_quotatab_sql</code> |
| 622 | submodule, <i>e.g.</i>: |
| 623 | <pre> |
| 624 | --with-modules=mod_quotatab:mod_quotatab_sql |
| 625 | </pre> |
| 626 | or: |
| 627 | <pre> |
| 628 | --enable-dso --with-shared=mod_quotatab:mod_quotatab_sql |
| 629 | </pre> |
| 630 | And, if you wish to support file- <b>and</b> SQL-based quota tables: |
| 631 | <pre> |
| 632 | --with-modules=mod_quotatab:mod_quotatab_file:mod_quotatab_sql |
| 633 | </pre> |
| 634 | or: |
| 635 | <pre> |
| 636 | --enable-dso --with-shared=mod_quotatab:mod_quotatab_file:mod_quotatab_sql |
| 637 | </pre> |
| 638 | Note that SQL tables require that a correct installation of |
| 639 | <code>mod_sql</code> (and any of its backend modules) also be used. |
| 640 | Consult the <code>mod_sql</code> documentation for installation instructions |
| 641 | for that module. |
| 642 | |
| 643 | <p> |
| 644 | <hr> |
| 645 | <font size=2><b><i> |
| 646 | © Copyright 2000-2021 The ProFTPD Project<br> |
| 647 | All Rights Reserved<br> |
| 648 | </i></b></font> |
| 649 | <hr> |
| 650 | |
| 651 | </body> |
| 652 | </html> |