0148-0150.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 468 行
HTML
468 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:FTP</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=08 //-->
<!-- PAGES=0131-0152 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0145-0147.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0151-0152.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-148"><P>Page 148</P></A>
<P>Confused? Don't be. Each of these options is actually quite simple. In the following
sections, I describe them one at a time.
</P>
<H4><A NAME="ch08_ 37">
The Strip Prefix
</A></H4>
<P>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.
</P>
<H4><A NAME="ch08_ 38">
The Strip Postfix
</A></H4>
<P>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.
</P>
<H4><A NAME="ch08_ 39">
The Add-on Prefix
</A></H4>
<P>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.
</P>
<H4><A NAME="ch08_ 40">
The Add-on Postfix
</A></H4>
<P>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.
</P>
<H4><A NAME="ch08_ 41">
The External Command
</A></H4>
<P>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:
</P>
<!-- CODE SNIP //-->
<PRE>
gzip _dc %s
</PRE>
<!-- END CODE SNIP //-->
<P>The %s in the line tells the server to substitute in the filename being requested by the user.
</P>
<H4><A NAME="ch08_ 42">
The Type of File
</A></H4>
<P>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,
</P>
<A NAME="PAGENUM-149"><P>Page 149</P></A>
<P>T_ASCII, and T_DIR, which represent regular files, ASCII files, and directories, respectively.
An example of this entry is T_REG|T_ASCII.
</P>
<H4><A NAME="ch08_ 43">
Options
</A></H4>
<P>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.
</P>
<H4><A NAME="ch08_ 44">
The Description
</A></H4>
<P>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.
</P>
<H4><A NAME="ch08_ 45">
Example of an /etc/ftpconversions Entry
</A></H4>
<P>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:
</P>
<!-- CODE SNIP //-->
<PRE>
: : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP
</PRE>
<!-- END CODE SNIP //-->
<P>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.
</P>
<P>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.
</P>
<H4><A NAME="ch08_ 46">
Configuring Host Access—The /etc/ftphosts File
</A></H4>
<P>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.
</P>
<A NAME="PAGENUM-150"><P>Page 150</P></A>
<P>Each line in the file can be one of two commands:
</P>
<!-- CODE SNIP //-->
<PRE>
allow <username> <addrglob>
</PRE>
<!-- END CODE SNIP //-->
<P>or
</P>
<!-- CODE SNIP //-->
<PRE>
deny <username> <addrglob>
</PRE>
<!-- END CODE SNIP //-->
<P>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.
</P>
<P>The deny command explicitly denies the specified user
<username> from the sites listed in
<addrglob>. You can list multiple sites.
</P>
<H4><A NAME="ch08_ 47">
The FTP Log File—/var/log/xferlog
</A></H4>
<P>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:
</P>
<HR>
<TABLE WIDTH="360">
<TR><TD>
current-time
</TD><TD>
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
</TD></TR>
<TR><TD>
transfer-time
</TD><TD>
The total time in seconds spent transferring the file
</TD></TR>
<TR><TD>
remote-host
</TD><TD>
The hostname of the client that initiated the transfer
</TD></TR>
<TR><TD>
file-size
</TD><TD>
The size of the file that was transferred
</TD></TR>
<TR><TD>
filename
</TD><TD>
The name of the file that was transferred
</TD></TR>
<TR><TD>
transfer-type
</TD><TD>
The type of transfer done, where
a is an ASCII transfer and b is a binary transfer
</TD></TR>
<TR><TD>
special-action-flag
</TD><TD>
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
</TD></TR>
<TR><TD>
direction
</TD><TD>
A flag indicating whether the file was outgoing or
incoming, represented by an o or i, respectively
</TD></TR>
<TR><TD>
access-mode
</TD><TD>
The type of user who performed the action, where
a is anonymous, g is a guest, and r is a real user
</TD></TR>
<TR><TD>
username
</TD><TD>
The local username if the user was of type
real
</TD></TR>
<TR><TD>
service-name
</TD><TD>
The name of the service being invoked (most often FTP)
</TD></TR>
<TR><TD>
authentication-method
</TD><TD>
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
</TD></TR>
<TR><TD>
authenticated-user-id
</TD><TD>
The username by which this transfer was authenticated
</TD></TR>
</TABLE>
<P><CENTER>
<a href="0145-0147.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0151-0152.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?