-->

Previous | Table of Contents | Next

Page 148

Confused? Don't be. Each of these options is actually quite simple. In the following sections, I describe them one at a time.

The Strip Prefix

The strip prefix is the string at the beginning of a filename that should be removed when the file is fetched. For example, if you want a special action taken on files beginning with discography., where that prefix is removed after the action, you would specify .discography for this option. When the clients specify filenames, they should not include the strip prefix. That is, if a file is called discography.orb and a client issues the command get orb, the server performs the optional command on the file and then transfers the results back to the client.

The Strip Postfix

The strip postfix is the string at the end of the filename that should be removed when the file is fetched. The strip postfix is typically used to remove the trailing .gz from a gzipped file that is being decompressed before being transferred back to the client.

The Add-on Prefix

An add-on prefix is the string inserted before the filename when a file is transferred either to or from the server. For example, say you want to insert the string uppercase. to all files being pulled from the server that are getting converted to uppercase.

The Add-on Postfix

An add-on postfix is the string appended to a filename after an operation on it is complete. This type of postfix is commonly used when the client issues the command get largefile.gz, where the actual filename is only largefile; in this case, the server compresses the file using gzip and then performs the transfer.

The External Command

The key component of each line is the external command. This entry specifies the program to be run when a file is transferred to or from the server. As the file is transferred, it is filtered through the program where downloads (files sent to the client) need to be sent to the standard out and uploads (files sent to the server) will be coming from the standard in. For example, if you want to provide decompression with gzip for files being downloaded, the entry would look like the following:


gzip _dc %s

The %s in the line tells the server to substitute in the filename being requested by the user.

The Type of File

The type of file field for /etc/ftpconversions is a list of possible kinds of files that can be acted on, each type name separated by a pipe symbol (|). The three file types recognized are T_REG,

Page 149

T_ASCII, and T_DIR, which represent regular files, ASCII files, and directories, respectively. An example of this entry is T_REG|T_ASCII.

Options

The options field of /etc/ftpconversions is similar to the type of file field in that it is composed of a list of names separated by a pipe symbol (|). The three types of options supported are O_COMPRESS, O_UNCOMPRESS, and O_TAR, which specify whether the command compresses files, decompresses files, or uses the tar command. A sample entry is O_COMPRESS|O_TAR, which says that the file is both compressed and tarred.

The Description

The last parameter of /etc/ftpconversions, the description of the conversion, is a free-form entry in which you can describe what kind of conversion is done.

Example of an /etc/ftpconversions Entry

The following is a sample entry that compresses files using gzip on demand. This would allow someone who wants to get the file orb_discography.tar to instead request the file orb_discrography.tar.gz and have the server compress the file using gzip before sending it him. The configuration line that does this is as follows:


: : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP

The first two parameters are not necessary because you don't want to remove anything from the filename before sending it to the requester. The third parameter is empty because you don't want to add any strings to the beginning of the filename before sending it. The fourth parameter, though, does have the string .gz, which will result in the file having the .gz suffix added before being sent. The fifth parameter is the actual command used to compress the file, where the _9 option tells gzip to compress the file as much as it can, -c results in the compressed file being sent to the standard output, and %s is replaced by the server with the filename being requested (for example, orb_discography.tar). T_REG in the sixth parameter tells the server to treat the file being handled as a normal file rather than an ASCII file or directory. The second-to-last parameter, O_COMPRESS, tells the server that the action being taken is file compression, and finally, the last parameter is simply a comment for the administrator so that she can determine the action being taken at a glance.

A bit daunting, isn't it? Don't worry, examine the sample /etc/ftpconversions file that came with the wu-ftpd RPM package to see additional examples of using tar and gzip. In fact, most sites never need to add to this file because it covers the most popular conversion requests made.

Configuring Host Access—The /etc/ftphosts File

The /etc/ftphosts file establishes rules on a per-user basis defining whether users are allowed to log in from certain hosts or whether users are denied access when they try to log in from other hosts.

Page 150

Each line in the file can be one of two commands:


allow <username> <addrglob>

or


deny <username> <addrglob>

where the allow command allows the user specified in <username> to connect via FTP from the explicitly listed addresses in <addrglob>. You can list multiple addresses.

The deny command explicitly denies the specified user <username> from the sites listed in <addrglob>. You can list multiple sites.

The FTP Log File—/var/log/xferlog

Although /var/log/xferlog isn't a configuration file, it is important nonetheless. In this file, all the logs generated by the FTP server are stored. Each line of the log consists of the following:


current-time The current time in DDD MMM dd hh:mm:ss YYYY format, where DDD is the day of the week, MMM is the month, dd is the day of the month, hh:mm:ss is the time in military format, and YYYY is the year
transfer-time The total time in seconds spent transferring the file
remote-host The hostname of the client that initiated the transfer
file-size The size of the file that was transferred
filename The name of the file that was transferred
transfer-type The type of transfer done, where a is an ASCII transfer and b is a binary transfer
special-action-flag A list of actions taken on the file by the server, where C means the file was compressed, U means the file was uncompressed, T means the file was tarred, and - means that no action was taken
direction A flag indicating whether the file was outgoing or incoming, represented by an o or i, respectively
access-mode The type of user who performed the action, where a is anonymous, g is a guest, and r is a real user
username The local username if the user was of type real
service-name The name of the service being invoked (most often FTP)
authentication-method The type of authentication used; 0 means no authentication was done (anonymous user), and 1 means the user was validated with RFC 931 Authentication Server Protocol
authenticated-user-id The username by which this transfer was authenticated

Previous | Table of Contents | Next