Merge branch 'vendor/OPENRESOLV'
[dragonfly.git] / libexec / ftpd / ftpd.8
1 .\" Copyright (c) 1985, 1988, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)ftpd.8      8.2 (Berkeley) 4/19/94
29 .\" $FreeBSD: src/libexec/ftpd/ftpd.8,v 1.74 2007/04/20 09:08:20 trhodes Exp $
30 .\" $DragonFly: src/libexec/ftpd/ftpd.8,v 1.7 2008/05/02 02:05:04 swildner Exp $
31 .\"
32 .Dd April 20, 2007
33 .Dt FTPD 8
34 .Os
35 .Sh NAME
36 .Nm ftpd
37 .Nd Internet File Transfer Protocol server
38 .Sh SYNOPSIS
39 .Nm
40 .Op Fl 468ADdEhMmOoRrSUvW
41 .Op Fl l Op Fl l
42 .Op Fl a Ar address
43 .Op Fl H Ar host
44 .Op Fl P Ar port
45 .Op Fl p Ar file
46 .Op Fl T Ar maxtimeout
47 .Op Fl t Ar timeout
48 .Op Fl u Ar umask
49 .Sh DESCRIPTION
50 The
51 .Nm
52 utility is the
53 Internet File Transfer Protocol
54 server process.
55 The server uses the
56 .Tn TCP
57 protocol
58 and listens at the port specified with the
59 .Fl P
60 option or in the
61 .Dq ftp
62 service specification; see
63 .Xr services 5 .
64 .Pp
65 Available options:
66 .Bl -tag -width indent
67 .It Fl 4
68 When
69 .Fl D
70 is specified, accept connections via
71 .Dv AF_INET
72 socket.
73 .It Fl 6
74 When
75 .Fl D
76 is specified, accept connections via
77 .Dv AF_INET6
78 socket.
79 .It Fl 8
80 Enable transparent UTF-8 mode.
81 RFC\ 2640 compliant clients will be told that the character encoding
82 used by the server is UTF-8, which is the only effect of the option.
83 .Pp
84 This option does not enable any encoding conversion for server file names;
85 it implies instead that the names of files on the server are encoded
86 in UTF-8.
87 As for files uploaded via FTP, it is the duty of the RFC\ 2640 compliant
88 client to convert their names from the client's local encoding to UTF-8.
89 FTP command names and own
90 .Nm
91 messages are always encoded in ASCII, which is a subset of UTF-8.
92 Hence no need for server-side conversion at all.
93 .It Fl A
94 Allow only anonymous ftp access.
95 .It Fl a
96 When
97 .Fl D
98 is specified, accept connections only on the specified
99 .Ar address .
100 .It Fl D
101 With this option set,
102 .Nm
103 will detach and become a daemon, accepting connections on the FTP port and
104 forking children processes to handle them.
105 This is lower overhead than starting
106 .Nm
107 from
108 .Xr inetd 8
109 and is thus useful on busy servers to reduce load.
110 .It Fl d
111 Debugging information is written to the syslog using
112 .Dv LOG_FTP .
113 .It Fl E
114 Disable the EPSV command.
115 This is useful for servers behind older firewalls.
116 .It Fl h
117 Disable printing host-specific information, such as the
118 server software version or hostname, in server messages.
119 .It Fl H
120 Advertise the hostname as
121 .Ar host
122 instead of using the value of
123 .Xr gethostname 3 .
124 .It Fl l
125 Each successful and failed
126 .Xr ftp 1
127 session is logged using syslog with a facility of
128 .Dv LOG_FTP .
129 If this option is specified twice, the retrieve (get), store (put), append,
130 delete, make directory, remove directory and rename operations and
131 their filename arguments are also logged.
132 By default,
133 .Xr syslogd 8
134 logs these to
135 .Pa /var/log/xferlog .
136 .It Fl M
137 Prevent anonymous users from creating directories.
138 .It Fl m
139 Permit anonymous users to overwrite or modify
140 existing files if allowed by file system permissions.
141 By default, anonymous users cannot modify existing files;
142 in particular, files to upload will be created under a unique name.
143 .It Fl O
144 Put server in write-only mode for anonymous users only.
145 RETR is disabled for anonymous users, preventing anonymous downloads.
146 This has no effect if
147 .Fl o
148 is also specified.
149 .It Fl o
150 Put server in write-only mode.
151 RETR is disabled, preventing downloads.
152 .It Fl P
153 When
154 .Fl D
155 is specified, accept connections at
156 .Ar port ,
157 specified as a numeric value or service name, instead of at the default
158 .Dq ftp
159 port.
160 .It Fl p
161 When
162 .Fl D
163 is specified, write the daemon's process ID to
164 .Ar file
165 instead of the default pid file,
166 .Pa /var/run/ftpd.pid .
167 .It Fl R
168 With this option set,
169 .Nm
170 will revert to historical behavior with regard to security checks on
171 user operations and restrictions on PORT requests.
172 Currently,
173 .Nm
174 will only honor PORT commands directed to unprivileged ports on the
175 remote user's host (which violates the FTP protocol specification but
176 closes some security holes).
177 .It Fl r
178 Put server in read-only mode.
179 All commands which may modify the local file system are disabled.
180 .It Fl S
181 With this option set,
182 .Nm
183 logs all anonymous file downloads to the file
184 .Pa /var/log/ftpd
185 when this file exists.
186 .It Fl T
187 A client may also request a different timeout period;
188 the maximum period allowed may be set to
189 .Ar timeout
190 seconds with the
191 .Fl T
192 option.
193 The default limit is 2 hours.
194 .It Fl t
195 The inactivity timeout period is set to
196 .Ar timeout
197 seconds (the default is 15 minutes).
198 .It Fl U
199 This option instructs ftpd to use data ports in the range of
200 .Dv IP_PORTRANGE_DEFAULT
201 instead of in the range of
202 .Dv IP_PORTRANGE_HIGH .
203 Such a change may be useful for some specific firewall configurations;
204 see
205 .Xr ip 4
206 for more information.
207 .Pp
208 Note that option is a virtual no-op in
209 .Fx 5.0
210 and above; both port
211 ranges are identical by default.
212 .It Fl u
213 The default file creation mode mask is set to
214 .Ar umask ,
215 which is expected to be an octal numeric value.
216 Refer to
217 .Xr umask 2
218 for details.
219 This option may be overridden by
220 .Xr login.conf 5 .
221 .It Fl v
222 A synonym for
223 .Fl d .
224 .It Fl W
225 Do not log FTP sessions to
226 .Pa /var/log/wtmp .
227 .El
228 .Pp
229 The file
230 .Pa /var/run/nologin
231 can be used to disable ftp access.
232 If the file exists,
233 .Nm
234 displays it and exits.
235 If the file
236 .Pa /etc/ftpwelcome
237 exists,
238 .Nm
239 prints it before issuing the
240 .Dq ready
241 message.
242 If the file
243 .Pa /etc/ftpmotd
244 exists,
245 .Nm
246 prints it after a successful login.
247 Note the motd file used is the one
248 relative to the login environment.
249 This means the one in
250 .Pa ~ftp/etc
251 in the anonymous user's case.
252 .Pp
253 The ftp server currently supports the following ftp requests.
254 The case of the requests is ignored.
255 Requests marked [RW] are
256 disabled if
257 .Fl r
258 is specified.
259 .Bl -column "Request" -offset indent
260 .It Sy Request Ta Sy "Description"
261 .It ABOR Ta "abort previous command"
262 .It ACCT Ta "specify account (ignored)"
263 .It ALLO Ta "allocate storage (vacuously)"
264 .It APPE Ta "append to a file [RW]"
265 .It CDUP Ta "change to parent of current working directory"
266 .It CWD Ta "change working directory"
267 .It DELE Ta "delete a file [RW]"
268 .It EPRT Ta "specify data connection port, multiprotocol"
269 .It EPSV Ta "prepare for server-to-server transfer, multiprotocol"
270 .It FEAT Ta "give information on extended features of server"
271 .It HELP Ta "give help information"
272 .It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA"
273 .It LPRT Ta "specify data connection port, multiprotocol"
274 .It LPSV Ta "prepare for server-to-server transfer, multiprotocol"
275 .It MDTM Ta "show last modification time of file"
276 .It MKD Ta "make a directory [RW]"
277 .It MODE Ta "specify data transfer" Em mode
278 .It NLST Ta "give name list of files in directory"
279 .It NOOP Ta "do nothing"
280 .It PASS Ta "specify password"
281 .It PASV Ta "prepare for server-to-server transfer"
282 .It PORT Ta "specify data connection port"
283 .It PWD Ta "print the current working directory"
284 .It QUIT Ta "terminate session"
285 .It REST Ta "restart incomplete transfer"
286 .It RETR Ta "retrieve a file"
287 .It RMD Ta "remove a directory [RW]"
288 .It RNFR Ta "specify rename-from file name [RW]"
289 .It RNTO Ta "specify rename-to file name [RW]"
290 .It SITE Ta "non-standard commands (see next section)"
291 .It SIZE Ta "return size of file"
292 .It STAT Ta "return status of server"
293 .It STOR Ta "store a file [RW]"
294 .It STOU Ta "store a file with a unique name [RW]"
295 .It STRU Ta "specify data transfer" Em structure
296 .It SYST Ta "show operating system type of server system"
297 .It TYPE Ta "specify data transfer" Em type
298 .It USER Ta "specify user name"
299 .It XCUP Ta "change to parent of current working directory (deprecated)"
300 .It XCWD Ta "change working directory (deprecated)"
301 .It XMKD Ta "make a directory (deprecated) [RW]"
302 .It XPWD Ta "print the current working directory (deprecated)"
303 .It XRMD Ta "remove a directory (deprecated) [RW]"
304 .El
305 .Pp
306 The following non-standard or
307 .Ux
308 specific commands are supported
309 by the
310 SITE request.
311 .Bl -column Request -offset indent
312 .It Sy Request Ta Sy Description
313 .It UMASK Ta change umask, e.g. ``SITE UMASK 002''
314 .It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60''
315 .It CHMOD Ta "change mode of a file [RW], e.g. ``SITE CHMOD 755 filename''"
316 .It MD5 Ta "report the files MD5 checksum, e.g. ``SITE MD5 filename''"
317 .It HELP Ta give help information
318 .El
319 .Pp
320 Note: SITE requests are disabled in case of anonymous logins.
321 .Pp
322 The remaining ftp requests specified in Internet RFC 959
323 are
324 recognized, but not implemented.
325 MDTM and SIZE are not specified in RFC 959, but will appear in the
326 next updated FTP RFC.
327 To avoid possible denial-of-service attacks, SIZE requests against
328 files larger than 10240 bytes will be denied if the current transfer
329 type is ASCII.
330 .Pp
331 The ftp server will abort an active file transfer only when the
332 ABOR
333 command is preceded by a Telnet "Interrupt Process" (IP)
334 signal and a Telnet "Synch" signal in the command Telnet stream,
335 as described in Internet RFC 959.
336 If a
337 STAT
338 command is received during a data transfer, preceded by a Telnet IP
339 and Synch, transfer status will be returned.
340 .Pp
341 The
342 .Nm
343 utility interprets file names according to the
344 .Dq globbing
345 conventions used by
346 .Xr csh 1 .
347 This allows users to utilize the metacharacters
348 .Dq Li \&*?[]{}~ .
349 .Pp
350 The
351 .Nm
352 utility authenticates users according to six rules.
353 .Bl -enum -offset indent
354 .It
355 The login name must be in the password data base
356 and not have a null password.
357 In this case a password must be provided by the client before any
358 file operations may be performed.
359 If the user has an OPIE key, the response from a successful USER
360 command will include an OPIE challenge.
361 The client may choose to respond with a PASS command giving either
362 a standard password or an OPIE one-time password.
363 The server will automatically determine which type of
364 password it has been given and attempt to authenticate accordingly.
365 See
366 .Xr opie 4
367 for more information on OPIE authentication.
368 .It
369 The login name must not appear in the file
370 .Pa /etc/ftpusers .
371 .It
372 The login name must not be a member of a group specified in the file
373 .Pa /etc/ftpusers .
374 Entries in this file interpreted as group names are prefixed by an "at"
375 .Ql \&@
376 sign.
377 .It
378 The user must have a standard shell returned by
379 .Xr getusershell 3 .
380 .It
381 If the user name appears in the file
382 .Pa /etc/ftpchroot ,
383 or the user is a member of a group with a group entry in this file,
384 i.e., one prefixed with
385 .Ql \&@ ,
386 the session's root will be changed to the directory specified
387 in this file or to the user's login directory by
388 .Xr chroot 2
389 as for an
390 .Dq anonymous
391 or
392 .Dq ftp
393 account (see next item).
394 See
395 .Xr ftpchroot 5
396 for a detailed description of the format of this file.
397 This facility may also be triggered by enabling the boolean "ftp-chroot"
398 capability in
399 .Xr login.conf 5 .
400 However, the user must still supply a password.
401 This feature is intended as a compromise between a fully anonymous
402 account and a fully privileged account.
403 The account should also be set up as for an anonymous account.
404 .It
405 If the user name is
406 .Dq anonymous
407 or
408 .Dq ftp ,
409 an
410 anonymous ftp account must be present in the password
411 file (user
412 .Dq ftp ) .
413 In this case the user is allowed
414 to log in by specifying any password (by convention an email address for
415 the user should be used as the password).
416 When the
417 .Fl S
418 option is set, all transfers are logged as well.
419 .El
420 .Pp
421 In the last case,
422 .Nm
423 takes special measures to restrict the client's access privileges.
424 The server performs a
425 .Xr chroot 2
426 to the home directory of the
427 .Dq ftp
428 user.
429 As a special case if the
430 .Dq ftp
431 user's home directory pathname contains the
432 .Pa /./
433 separator,
434 .Nm
435 uses its left-hand side as the name of the directory to do
436 .Xr chroot 2
437 to, and its right-hand side to change the current directory to afterwards.
438 A typical example for this case would be
439 .Pa /usr/local/ftp/./pub .
440 In order that system security is not breached, it is recommended
441 that the
442 .Dq ftp
443 subtree be constructed with care, following these rules:
444 .Bl -tag -width "~ftp/pub" -offset indent
445 .It Pa ~ftp
446 Make the home directory owned by
447 .Dq root
448 and unwritable by anyone.
449 .It Pa ~ftp/etc
450 Make this directory owned by
451 .Dq root
452 and unwritable by anyone (mode 555).
453 The files pwd.db (see
454 .Xr passwd 5 )
455 and
456 .Xr group 5
457 must be present for the
458 .Xr ls 1
459 command to be able to produce owner names rather than numbers.
460 The password field in
461 .Xr passwd 5
462 is not used, and should not contain real passwords.
463 The file
464 .Pa ftpmotd ,
465 if present, will be printed after a successful login.
466 These files should be mode 444.
467 .It Pa ~ftp/pub
468 This directory and the subdirectories beneath it should be owned
469 by the users and groups responsible for placing files in them,
470 and be writable only by them (mode 755 or 775).
471 They should
472 .Em not
473 be owned or writable by
474 .Dq ftp
475 or its group, otherwise guest users
476 can fill the drive with unwanted files.
477 .El
478 .Pp
479 If the system has multiple IP addresses,
480 .Nm
481 supports the idea of virtual hosts, which provides the ability to
482 define multiple anonymous ftp areas, each one allocated to a different
483 internet address.
484 The file
485 .Pa /etc/ftphosts
486 contains information pertaining to each of the virtual hosts.
487 Each host is defined on its own line which contains a number of
488 fields separated by whitespace:
489 .Bl -tag -offset indent -width hostname
490 .It hostname
491 Contains the hostname or IP address of the virtual host.
492 .It user
493 Contains a user record in the system password file.
494 As with normal anonymous ftp, this user's access uid, gid and group
495 memberships determine file access to the anonymous ftp area.
496 The anonymous ftp area (to which any user is chrooted on login)
497 is determined by the home directory defined for the account.
498 User id and group for any ftp account may be the same as for the
499 standard ftp user.
500 .It statfile
501 File to which all file transfers are logged, which
502 defaults to
503 .Pa /var/log/ftpd .
504 .It welcome
505 This file is the welcome message displayed before the server ready
506 prompt.
507 It defaults to
508 .Pa /etc/ftpwelcome .
509 .It motd
510 This file is displayed after the user logs in.
511 It defaults to
512 .Pa /etc/ftpmotd .
513 .El
514 .Pp
515 Lines beginning with a '#' are ignored and can be used to include
516 comments.
517 .Pp
518 Defining a virtual host for the primary IP address or hostname
519 changes the default for ftp logins to that address.
520 The 'user', 'statfile', 'welcome' and 'motd' fields may be left
521 blank, or a single hyphen '-' used to indicate that the default
522 value is to be used.
523 .Pp
524 As with any anonymous login configuration, due care must be given
525 to setup and maintenance to guard against security related problems.
526 .Pp
527 The
528 .Nm
529 utility has internal support for handling remote requests to list
530 files, and will not execute
531 .Pa /bin/ls
532 in either a chrooted or non-chrooted environment.
533 The
534 .Pa ~/bin/ls
535 executable need not be placed into the chrooted tree, nor need the
536 .Pa ~/bin
537 directory exist.
538 .Sh FILES
539 .Bl -tag -width ".Pa /var/run/ftpd.pid" -compact
540 .It Pa /etc/ftpusers
541 List of unwelcome/restricted users.
542 .It Pa /etc/ftpchroot
543 List of normal users who should be chroot'd.
544 .It Pa /etc/ftphosts
545 Virtual hosting configuration file.
546 .It Pa /etc/ftpwelcome
547 Welcome notice.
548 .It Pa /etc/ftpmotd
549 Welcome notice after login.
550 .It Pa /var/run/ftpd.pid
551 Default pid file for daemon mode.
552 .It Pa /var/run/nologin
553 Displayed and access refused.
554 .It Pa /var/log/ftpd
555 Log file for anonymous transfers.
556 .It Pa /var/log/xferlog
557 Default place for session logs.
558 .El
559 .Sh SEE ALSO
560 .Xr ftp 1 ,
561 .Xr umask 2 ,
562 .Xr getusershell 3 ,
563 .Xr opie 4 ,
564 .Xr ftpchroot 5 ,
565 .Xr login.conf 5 ,
566 .Xr inetd 8 ,
567 .Xr syslogd 8
568 .Sh HISTORY
569 The
570 .Nm
571 utility appeared in
572 .Bx 4.2 .
573 IPv6 support was added in WIDE Hydrangea IPv6 stack kit.
574 .Sh BUGS
575 The server must run as the super-user
576 to create sockets with privileged port numbers.
577 It maintains
578 an effective user id of the logged in user, reverting to
579 the super-user only when binding addresses to sockets.
580 The
581 possible security holes have been extensively
582 scrutinized, but are possibly incomplete.