These seven fields are all integer fields that follow the shell field in the password database. A zero in any field (or missing the field entirely) means no limit. For example, a user record without quotas might look like:
mmgleason:unUuvgMaz/h76:696:33,31:Michelle:/home/mmgleason:/bin/kshAdding a 3 megabyte (3072 kB) disk usage hard limit, a 2800 kB soft limit, a 500 file hard limit, a 450 file soft limit, a zero for quota options, a zero for no download bandwidth limit, and a zero for no upload bandwidth limit to the record would cause the user record to appear like:
mmgleason:unUuvgMaz/h76:696:33,31:Michelle:/home/mmgleason:/bin/ksh:3072:2800:500:450:0:0:0Essentially all you need to do when creating your user records is to append
There are two modes to the program. The first is setting a single user's quota by explicitly inputting the values. Here's an example that sets the quota for the waldo user in the password database local.db. I typed "7600" and "800" as new values for the quotas:
As with OS quotas (and the "edquota" program), a value of zero means no limit. The values shown in brackets are the existing settings, and if you just hit return, that value will not be changed.# ./ncftpd_edquota -f local.db waldo Hard quota, kB [7500] : 7600 Hard quota, files [500] : 800 Download bandwidth limit, in kB/sec [0 (no limit)] : 12 Upload bandwidth limit, in kB/sec [0 (no limit)] : 0 Quotas changed for user waldo.
Note: This example also shows how to set indivudal bandwidth limits for users, in kilobytes per second. Although a bandwidth limit is a slightly different concept than a disk quota, this configuration information is managed as a part of the quota system. If you want only bandwidth limits and no quotas, you would simply leave the quota fields at 0.
The second mode is modeled after the "edquota" program's prototype mode, where you can use one user's quota settings as a template and copy those settings to other users. For example, if you wanted to replicate waldo's configuration for the users huey, duey, and louie, you could do that like this:
# ./ncftpd_edquota -f local.db -p waldo huey duey louie Quotas changed for user huey. Quotas changed for user duey. Quotas changed for user louie.
Since a "du -k -s" is done for each user in the database, be
aware that this could impact system performance.
Here is some sample text that could be used as a login message:
Notice how this example did not use the %qbu or %qfu. While these are useful, those cookies would require that the disk usage calculations be performed at login time, instead of being postponed until really needed. The quota-related cookies can be used anywhere NcFTPd expands cookies, which includes the change-of-directory .message files and u-goodbye-message. Unfortunately there is no standard behavior which requires FTP clients to display any of these messages to the user.Welcome to ftp.example.com! All actions are logged; if you don't like this, disconnect now. Your disk usage quota is %qbh bytes. The maximum number of files you are allotted is %qfh.
Another way a user can find out their quota status is to have the FTP client program issue a "SITE QUOTA" command. Here's an example using the standard bare-bones command-line FTP client:
ftp> site quota 200-Quota report: 200- Bytes: 6660649 Limit: 7680000 200- Files: 647 Limit: 650 200 Done (0.03 seconds used initially to compute quota). ftp>
Here is what happens when using the bare-bones command line FTP client, to illustrate the error returned:
(This example also shows that the hard limit is really not a firm, to-the-exact-byte limit. In fact, the user could exceed the limit by as much as 4095 bytes. This behavior is required for optimal performance at the expense of a small amount of bytes.)ftp> put myfile.zip local: myfile.zip remote: myfile.zip 200 PORT command successful. 450 Disk quota exceeded (7682249 bytes; limit: 7680000). ftp>
A. You will need to create a NcFTPd password database by importing your existing /etc/passwd. If you only want quotas for a few users, you can create an "override" database, where the users you want to have quotas exist in both /etc/passwd and a password database, and users that don't have quotas only exist in /etc/passwd. You would then set "passwd=/path/to/the/override.db,/etc/passwd" in the domain.cf to specify that both a database and /etc/passwd are checked for users.
Q. Users complain that their FTP client times out when they login (or try and upload).
A. The user may have a very deep and complex directory structure. NcFTPd may need a significant amount of time to calculate the disk quota, and the FTP client may have gotten impatient and assumed the server connection had been lost. Have the user try a different FTP client.
Q. Users complain that uploads fail.
A. By design, the quota system doesn't allow any more bytes uploaded when the user reaches their quota. Show the user how to check their quota and perhaps suggest a different FTP client which can show the quota statistics in your login or goodbye message. Ideally this client program should also display the error message from the server, so when this happens, the user will see "disk quota exceeded" message text.
Q. Users complain that uploads are corrupted.
A. Some FTP clients don't report that the upload was not successful! Others display an error, but not prominently enough for the user to notice.
Q. Does NcFTPd track when the disk usage goes down in a session, or only up?
A. File and directory removals are reflected in the disk usage, so amount of disk used should go down when the user deletes files in the session.
Q. Do directories and links count as "files" in the file limit?
A. Yes. They do not, however, count towards the byte usage limit.
Q. Can I set a system-wide defaults for quotas and bandwidth limits?
A. Disk quotas must be set per-user, but you can set
a domain-wide bandwidth limit which would let you use bandwidth limits
without using NcFTPd password databases.
See the documentation for
download-bandwidth-per-user.