📄 upload.configuration.howto
字号:
Copyright (c) 1999,2000 WU-FTPD Development Group. All rights reserved. Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 The Regents of the University of California. Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. Portions Copyright (c) 1989 Massachusetts Institute of Technology. Portions Copyright (c) 1998 Sendmail, Inc. Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. Portions Copyright (c) 1997 Stan Barber. Portions Copyright (c) 1997 Kent Landfield. Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Use and distribution of this software and its source code are governed by the terms and conditions of the WU-FTPD Software License ("LICENSE"). If you did not receive a copy of the license, it may be obtained online at http://www.wu-ftpd.org/license.html. $Id: upload.configuration.HOWTO,v 1.2 2000/07/01 18:49:32 wuftpd Exp $ Upload Configuration HOW-TOThis document is available on-line at: ftp://ftp.wu-ftpd.org/pub/wu-ftpd/upload.configuration.HOWTOOne of the more powerfull, yet most often misused, features of WU-FTPD isthe upload clause. Historically, the problems with the upload clause stemfrom unclear documentation and poor implementation. This document is anattempt to address these issues. The features discussed in this documentapply to WU-FTPD Version 2.6.0. If you are not running 2.6.0, you arestrongly encouraged to upgrade; it includes a number of corrections, newfeatures and security enhancements not available with earlier versions ofWU-FTPD.Upload restrictions for anonymous FTP users-------------------------------------------For this example, we'll assume your system /etc/passwd file contains anentry for the anonymous FTP user as follows:ftp:*:95:95::/home/ftp:If your /etc/passwd file does not contain an entry for the user 'ftp' yoursite will not allow anonymous FTP. In addition, if the usernames 'ftp' or'anonymous' appear in the /etc/ftpusers file, anonymous FTP will not beallowed.In /etc/ftpaccess, we need a class which allows anonymous access. Thefollowing allows anonymous FTP from anywhere:class anonftp anonymous *To prevent anonymous FTP users attempting a Denial of Service (DoS) attackagainst your system, you should create a special filesystem to receivetheir uploads. This separate filesystem protects your server by limitingthe total size of all uploaded files while preventing those files fromconsuming all available space on the server. For this example, mount thefilesystem on /home/ftp/incomingBy default, the server will not allow uploads from anonymous FTP users.Just to be safe, and so we don't forget, let's add a clause saying that:upload /home/ftp * noWhat this says is, "For any user whose home directory is the anonymous FTParea, /home/ftp, do not allow any uploads." As I said, this is thedefault, but put it in anyway so you don't forget.Now, we want to allow uploads into the incoming filesystem. We MUST add aclause granting that privilege to anonymous users. Right now we don't wantto let anonymous users create directories. (I recommend NEVER allowing themto do it, but I'll show you how in a bit.) We want to ensure, however,the server is safe and cannot be used as a way-point for software pirates(warez traders). So we'll set the directory permissions for the incomingarea to prevent anyone seeing what's there and make the area write-only foranonymous users.First, we need an FTP site administrator, someone who owns the files, butisn't the root user or the anonymous user. Something like the following/etc/passwd entry will do:ftpadmin:*:96:96::/home/ftp:Set the incoming area permissions and ownership to safe values. Irecommend the following:chown ftpadmin /home/ftp/incomingchgrp ftpadmin /home/ftp/incomingchmod 3773 /home/ftp/incomingActually, ftpadmin should own more of the site, but I'm only talking aboutuploads right now.Finally, before we get into allowing uploads, one last thing. Whether youallow on-the-fly tar'ing of directories or not, you should make sure anend-run cannot be made and the incoming area downloaded using tar. To doso, create the special file '.notar' in both the FTP directory and theincoming area:touch /home/ftp/.notarchmod 0 /home/ftp/.notartouch /home/ftp/incoming/.notarchmod 0 /home/ftp/incoming/.notarThe zero-length .notar file can confuse some web clients and FTP proxies,so let's mark it unretrievable.noretrieve .notarTime to allow uploads, put the following in /etc/ftpaccess:upload /home/ftp /incoming yes ftpadmin ftpadmin 0440 nodirsNotice the target directory for the uploads is relative to the view theuser will have during the FTP session.What this says is, "For any user whose home directory is the anonymous FTParea, /home/ftp, allow uploads into the directory /incoming but do notallow the creation of new directories. Make all files uploaded owned bythe FTP administrator, mark them read-only so we don't allow them to bedownloaded." If uploaded files are to be made available for downloading,the safest thing to do is to tell the FTP administrator to move them into apublic area and modify the permissions after validating and approving them.I know this seems draconian but, in the long run, it's best.Some FTP sites like to live dangerously and allow anonymous users to createdirectories. I don't recommend this; it cannot be done with absolutesafety. If you insist, however, you can at least limit it to a singledirectory level. For example, replace the upload clause just added withthe following:upload /home/ftp /incoming yes ftpadmin ftpadmin 0440 dirs 3773upload /home/ftp /incoming/* yes ftpadmin ftpadmin 0440 nodirsThe first line allows directories to be created in the incoming area andenforces the use of safe permissions on them. The second prevents creationof deeper sub-directories. Notice one of the problems with allowingdirectory creation is there is no way to automatically create a '.notar' inthe new directory, so a crafty user may be able to make an end-run anddownload it anyway using on-the-fly tar'ing.One last thing: since the incoming area shouldn't allow downloads, andsince it's a file system, there will be a lost+found area; you will want toadd the following clause to make SURE no downloads occur:noretrieve /home/ftp/incomingor, at least, add the following to prevent downloading of the lost+foundfiles:noretrieve /home/ftp/incoming/lost+foundUpload restrictions for guest users-----------------------------------Setting up the FTP server for guest users is covered in the Guest HOWTO.It is not my purpose here to cover how to set up for guest access. If youhave not yet done so, review the information in that document at: ftp://ftp.fni.com/pub/wu-ftpd/guest-howtoFor this example, I'll assume you have entries similar to the following inyour system /etc/passwd file:dick:*:1010:1010::/home/users/./dick:/bin/shjane:*:1011:1011::/home/users/./jane:/bin/shBy default, the WU-FTPD server will grant upload privileges to all guestusers. The example users are chroot'd to /home/users and cannot access anyarea of the filesystem outside that directory structure. What we'reinterested in, then, is simply protecting the areas in the chroot directorystructure we want to keep the users out of.In a minimal installation, there will be bin, etc and dev, subdirectoriesin the /home/users directory. Other files and subdirectories may existdepending upon the requirements of your operating system. We don't wantusers being able to upload into these areas. In case something happens tothe permissions on them (you did set the permissions to safe values, didn'tyou?), you should deny upload privileges in your ftpaccess file. In ourcase, we'll say the following:upload /home/users/* / noupload /home/users/* /bin noupload /home/users/* /etc noupload /home/users/* /dev noWhile we're at it, we'll prevent downloads with noretrieve. Don't forgetto prevent end-runs by also creating .notar files in each directory.noretrieve /home/users/binnoretrieve /home/users/etcnoretrieve /home/users/devUpload restrictions for real users----------------------------------First off, let me say you shouldn't have any real users in your FTP site.Or, being more realistic, the only real user should be the siteadministrator. That being said, real users should be restricted touploading only into specific areas. Let's start with a real user in/etc/passwd:ftpadmin:*:109:109::/home/users/ftpadmin:/bin/shAgain, by default, the server will grant upload privileges everywhere, sowe have to start by revoking them and only allowing what we want to:upload /home/users/ftpadmin * noupload /home/users/ftpadmin /tmp yes nodirsupload /home/users/ftpadmin /home/users/ftpadmin yesupload /home/users/ftpadmin /home/users/ftpadmin/* yesupload /home/users/ftpadmin /home/ftp/incoming yes ftpadmin ftpadmin 0440 nodirsAbout matching rules--------------------Use extreme care when forming wildcard matching rules. It may be temptingto say, for instance:upload /home/users/ftpadmin /home/users/ftpadmin* yes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -