| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ftpquota: tool for ProFTPD mod_quotatab</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center> |
| 11 | <h2><b><code>ftpquota</code>: tool for ProFTPD module <code>mod_quotatab</code></b></h2> |
| 12 | </center> |
| 13 | <hr><br> |
| 14 | |
| 15 | <p> |
| 16 | This program is distributed with the |
| 17 | <a href="./mod_quotatab.html"><code>mod_quotatab</code></a> module for |
| 18 | ProFTPD 1.2. It is used to create and manage quota tables of type |
| 19 | "file". |
| 20 | |
| 21 | <p> |
| 22 | The most current version of <code>ftpquota</code> is distributed with the |
| 23 | ProFTPD source code. |
| 24 | |
| 25 | <h2>Author</h2> |
| 26 | <p> |
| 27 | Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any |
| 28 | questions, concerns, or suggestions regarding this program. |
| 29 | |
| 30 | <p> |
| 31 | <hr><br> |
| 32 | <h2><a name="Usage">Usage</a></h2> |
| 33 | The following describes the common usage of the <code>ftpquota</code> tool. |
| 34 | The options supported are described in more detail |
| 35 | <a href="#Options">later</a>. |
| 36 | |
| 37 | <p> |
| 38 | <b>Creating Tables</b><br> |
| 39 | To start using <code>mod_quotatab</code>, the two required tables are required. |
| 40 | Tables of type "file" have identifying magic headers such that |
| 41 | <code>ftpquota</code> is needed to initially create both tables. It is an |
| 42 | error to attempt to create a table that already exists: |
| 43 | <pre> |
| 44 | $ ftpquota --create-table --type=limit |
| 45 | ftpquota: cannot create existing table |
| 46 | </pre> |
| 47 | |
| 48 | <p> |
| 49 | To create the initial limit table: |
| 50 | <pre> |
| 51 | $ ftpquota --create-table --type=limit |
| 52 | </pre> |
| 53 | To create the initial tally table: |
| 54 | <pre> |
| 55 | $ ftpquota --create-table --type=tally |
| 56 | </pre> |
| 57 | The population of a tally table file with the tally for <code>user</code>s, |
| 58 | <code>group</code>s, <code>class</code>es, and <code>all</code> is done |
| 59 | automatically by <code>mod_quotatab</code>. |
| 60 | |
| 61 | <p> |
| 62 | For both of these operations, the <code>--table-path</code> can be used to |
| 63 | create a table in a non-default location. |
| 64 | |
| 65 | <p> |
| 66 | <b>Updating Tables</b><br> |
| 67 | Now that you have the initial tables created, but blank, you need to add |
| 68 | records (to the limit table) for the users, groups, classes, etc on which |
| 69 | you, as the administrator, wish to impose quotas. |
| 70 | |
| 71 | <p> |
| 72 | To a basic limit record for a user <code>bob</code> using the default quotas |
| 73 | (which are all "unlimited" by default): |
| 74 | <pre> |
| 75 | $ ftpquota --add-record --type=limit --name=bob --quota-type=user |
| 76 | </pre> |
| 77 | Similarly for quotas of type <code>group</code> or <code>class.</code> Note |
| 78 | that for quotas of type <code>all</code>, the <code>--name</code> option |
| 79 | is not necessary; the <code>all</code> record applies to everyone, regardless |
| 80 | of name or group or class membership. If no byte or file limits are |
| 81 | specified, the default settings (<b>unlimited</b> numbers of bytes/files) |
| 82 | are used. |
| 83 | |
| 84 | <p> |
| 85 | It is an error to add a record that already exists. Note, however, that it |
| 86 | is possible to have multiple records of the same name, but different |
| 87 | quota types. The record to use for a given session is identified by the |
| 88 | combination of name and quota type. |
| 89 | |
| 90 | <p> |
| 91 | An example of creating a limit record with more complex quotas for a class |
| 92 | named "browsers" |
| 93 | <pre> |
| 94 | $ ftpquota --add-record --type=limit --name=browsers --quota-type=class \ |
| 95 | --files-upload=0 --files-download=25 --table-path=/usr/local/etc/ftplimit.tab |
| 96 | </pre> |
| 97 | or, another way: |
| 98 | <pre> |
| 99 | $ ftpquota --add-record --type=limit --name=browsers --quota-type=class \ |
| 100 | --bytes-upload=0 --bytes-download=2 --units=Gb --table-path=/usr/local/etc/ftplimit.tab |
| 101 | </pre> |
| 102 | In general, it is a good idea to use either byte quotas or file quotas, but |
| 103 | not both, unless you know what you are doing. In these examples, the |
| 104 | <code>--table-path</code> option is used to add the record to a limit table in |
| 105 | a non-default location. |
| 106 | |
| 107 | <p> |
| 108 | Another option available when creating limit records is the |
| 109 | <code>--per-session</code> option. By default, quotas are persistent, and |
| 110 | apply to the user (or group, class, or everyone) across all sessions. Using |
| 111 | this option means the limits will be enforced only for the duration of |
| 112 | the client's session, and that the limits will apply only to that client. |
| 113 | In other words, using this option for <code>group</code>, <code>class</code>, |
| 114 | or <code>all</code> quotas is not a good idea. |
| 115 | |
| 116 | <p> |
| 117 | Similarly, for removing records from the limit table (effectively removing |
| 118 | quotas from affecting that <code>user/group/class/all</code>) or from the |
| 119 | tally table (effectively resetting the quotas to zero for that |
| 120 | <code>user/group/class/all</code>), there is the |
| 121 | <code>--delete-record</code> option: |
| 122 | <pre> |
| 123 | $ ftpquota --delete-record --type=limit --name=browsers --quota-type=class |
| 124 | </pre> |
| 125 | |
| 126 | <p> |
| 127 | In addition to adding and removing records, an administrator may want to |
| 128 | simply change the quotas in a given record, either in the limit or tally |
| 129 | tables. In this case, use <code>--update-record</code>: |
| 130 | <pre> |
| 131 | $ ftpquota --update-record --type=tally --name=bob --quota-type=user \ |
| 132 | --bytes-download=100 --files-download=1 |
| 133 | </pre> |
| 134 | This example command manually sets user <code>bob</code>'s download tally to |
| 135 | 100 bytes, 1 file. It is an error to update a record that does not exist. |
| 136 | |
| 137 | <p> |
| 138 | There are some administrators who wish to impose quotas on a daily basis, that |
| 139 | is, to have a per-day quota. At present, the easiest way to do this is to |
| 140 | have a cron job that, once a day, does the following: |
| 141 | <pre> |
| 142 | $ ftpquota --update-record --type=tally --name=<i>name</i> --quota-type=<i>quotatype</i> |
| 143 | </pre> |
| 144 | This command will "reset" the matching tally record. By default, if |
| 145 | no byte or file quotas are set, the default values are used: <b>unlimited</b> |
| 146 | if updating a limit record, zero if updating a tally record. |
| 147 | |
| 148 | <p> |
| 149 | When editing the tables, <code>ftpquota</code> will obtain read or write |
| 150 | locks as necessary. If those tables are being used by a running server, which |
| 151 | also performs locking, the script will wait until it is able to obtain a lock. |
| 152 | Changing of in-use table information is ideally done while the server is |
| 153 | quiescent. This locking is to avoid data synchronization and corruption |
| 154 | issues. |
| 155 | |
| 156 | <p> |
| 157 | <b>Showing Tables</b><br> |
| 158 | Having tables in binary format makes it difficult to easily see what |
| 159 | the current records are, to double-check limits or simply to view the |
| 160 | current tally. <code>ftpquota</code> thus supports the dumping out of |
| 161 | table contents in human-legible form via the <code>--show-records</code> |
| 162 | option: |
| 163 | <pre> |
| 164 | $ ftpquota --show-records --type=limit |
| 165 | </pre> |
| 166 | or, for a tally table not in the location where the scripts expects it to |
| 167 | be: |
| 168 | <pre> |
| 169 | $ ftpquota --show-records --type=tally --table-path=/usr/local/etc/ftpd/quota-tally.tab |
| 170 | </pre> |
| 171 | When viewing tables this way, the <code>--units</code> option can be used |
| 172 | to display byte quotas in other units (<i>e.g.</i> Kb, Mb, etc). |
| 173 | |
| 174 | <p> |
| 175 | <hr><br> |
| 176 | <h2><a name="Options">Options</a></h2> |
| 177 | The following is the output from running <code>ftpquota --help</code>: |
| 178 | <pre> |
| 179 | usage: ftpquota [options] |
| 180 | |
| 181 | The following options describe the type of operation to be performed: |
| 182 | |
| 183 | --add-record Create a new record with the specified limits. Any |
| 184 | limits left unspecified with have their default |
| 185 | values. This option requires the --name and |
| 186 | --quota-type options. |
| 187 | |
| 188 | --create-table Create the table if not present. Used to initialize |
| 189 | a table. The default limit table path is |
| 190 | "./ftpquota.limittab". The default tally table path is |
| 191 | "./ftpquota.tallytab". |
| 192 | |
| 193 | --delete-record Deletes a quota record from the table. This option |
| 194 | requires the --name and --quote-type options. |
| 195 | |
| 196 | --show-records Prints out all of the quota records in the table in |
| 197 | a legible format. |
| 198 | |
| 199 | --update-record Updates a quota record with the specified limits. Any |
| 200 | limits left unspecified will be updated with their |
| 201 | default value. This option requires the --name and |
| 202 | --quota-type options. |
| 203 | |
| 204 | The following option describes the type of table on which to operate: |
| 205 | |
| 206 | --type Specifies a table type to use. The allowable options |
| 207 | are: "limit" or "tally". This is required. |
| 208 | |
| 209 | The following options are used to specify specific quota limits: |
| 210 | |
| 211 | --Bu Specifies the limit of the number of bytes that may be |
| 212 | --bytes-upload uploaded. Defaults to -1 (unlimited). |
| 213 | |
| 214 | --Bd Specifies the limit of the number of bytes that may be |
| 215 | --bytes-download downloaded. Defaults to -1 (unlimited). |
| 216 | |
| 217 | --Bx Specifies the limit of the number of bytes that may be |
| 218 | --bytes-xfer transferred. Note that this total includes uploads, |
| 219 | downloads, AND directory listings. Defaults to |
| 220 | -1 (unlimited). |
| 221 | |
| 222 | --Fu Specifies the limit of the number of files that may be |
| 223 | --files-upload uploaded. Defaults to -1 (unlimited). |
| 224 | |
| 225 | --Fd Specifies the limit of the number of files that may be |
| 226 | --files-download downloaded. Defaults to -1 (unlimited). |
| 227 | |
| 228 | --Fx Specifies the limit of the number of files that may be |
| 229 | --files-xfer transferred, including uploads and downloads. Defaults |
| 230 | to -1 (unlimited). |
| 231 | |
| 232 | -L Specifies the type of limit, "hard" or "soft", of |
| 233 | --limit-type the bytes limits. If "hard", any uploaded files that |
| 234 | push the bytes used counter past the limit will be |
| 235 | automatically deleted; if "soft", those extra bytes |
| 236 | will be allowed, but future uploads will be denied. |
| 237 | This option only makes sense if --type is "limit". |
| 238 | |
| 239 | -N Specifies a name for the quota record. This name |
| 240 | --name will be the user/login name, group name, or class |
| 241 | name, depending on the quota type. This option |
| 242 | is ignored if the quota type specified is "all". |
| 243 | |
| 244 | -P |
| 245 | --per-session Specifies that the quota limit is to be applied only |
| 246 | to each session, rather than persisting across |
| 247 | sessions. By default, quotas are persistent. |
| 248 | |
| 249 | -Q Specifies a "quota type" for this record, where |
| 250 | --quota-type the type means to which category of FTP users this |
| 251 | quota will apply. The quota type must be one of: |
| 252 | "user", "group", "class", or "all". |
| 253 | |
| 254 | The following options are miscellaneous: |
| 255 | |
| 256 | --help Displays this message. |
| 257 | |
| 258 | --table-path Specifies the path to a quota table file to use. |
| 259 | |
| 260 | --units Specifies whether to treats bytes as is, in kilobytes, |
| 261 | megabytes, or gigabytes. Allowable options are: |
| 262 | "B" or "byte", "Kb" or "kilo", "Mb" or "mega", |
| 263 | and "Gb" or "giga". Defaults to "byte". |
| 264 | |
| 265 | --verbose Toggles more verbose information about the doings of |
| 266 | the tool as it works. |
| 267 | </pre> |
| 268 | |
| 269 | <p> |
| 270 | <hr> |
| 271 | <font size=2><b><i> |
| 272 | © Copyright 2000-2002 TJ Saunders<br> |
| 273 | All Rights Reserved<br> |
| 274 | </i></b></font> |
| 275 | <hr> |
| 276 | |
| 277 | </body> |
| 278 | </html> |