xref: /freebsd/libexec/tftpd/tftpd.8 (revision 79c342aaf86feb4efbd15383f54e4fe7bdc9da7b)
1ea022d16SRodney W. Grimes.\" Copyright (c) 1983, 1991, 1993
2ea022d16SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3ea022d16SRodney W. Grimes.\"
4ea022d16SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5ea022d16SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6ea022d16SRodney W. Grimes.\" are met:
7ea022d16SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8ea022d16SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9ea022d16SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10ea022d16SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11ea022d16SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
125efaea4cSChristian Brueffer.\" 3. Neither the name of the University nor the names of its contributors
13ea022d16SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14ea022d16SRodney W. Grimes.\"    without specific prior written permission.
15ea022d16SRodney W. Grimes.\"
16ea022d16SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17ea022d16SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18ea022d16SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19ea022d16SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20ea022d16SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21ea022d16SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22ea022d16SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23ea022d16SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24ea022d16SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25ea022d16SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26ea022d16SRodney W. Grimes.\" SUCH DAMAGE.
27ea022d16SRodney W. Grimes.\"
28*79c342aaSMark Johnston.Dd November 3, 2024
29ea022d16SRodney W. Grimes.Dt TFTPD 8
300efe23d6SRuslan Ermilov.Os
31ea022d16SRodney W. Grimes.Sh NAME
32ea022d16SRodney W. Grimes.Nm tftpd
33eb083802SRuslan Ermilov.Nd Internet Trivial File Transfer Protocol server
34ea022d16SRodney W. Grimes.Sh SYNOPSIS
35ff7e281dSYaroslav Tykhiy.Nm tftpd
36*79c342aaSMark Johnston.Op Fl bCcdlnoSw
37dba0fd30SEdwin Groothuis.Op Fl F Ar strftime-format
388ea31785SWarner Losh.Op Fl s Ar directory
39eff77877SMatthew N. Dodd.Op Fl U Ar umask
40816c4d3dSDag-Erling Smørgrav.Op Fl u Ar user
41ea022d16SRodney W. Grimes.Op Ar directory ...
42ea022d16SRodney W. Grimes.Sh DESCRIPTION
433f162cb8SPhilippe CharnierThe
443f162cb8SPhilippe Charnier.Nm
453f162cb8SPhilippe Charnierutility is a server which supports the
46ea022d16SRodney W. GrimesInternet Trivial File Transfer
47f62eaadfSGarrett WollmanProtocol
48f62eaadfSGarrett Wollman.Pq Tn RFC 1350 .
49ea022d16SRodney W. GrimesThe
50ea022d16SRodney W. Grimes.Tn TFTP
51ea022d16SRodney W. Grimesserver operates
52ea022d16SRodney W. Grimesat the port indicated in the
53ea022d16SRodney W. Grimes.Ql tftp
54ea022d16SRodney W. Grimesservice description;
55ea022d16SRodney W. Grimessee
56ea022d16SRodney W. Grimes.Xr services 5 .
57ea022d16SRodney W. GrimesThe server is normally started by
58ea022d16SRodney W. Grimes.Xr inetd 8 .
59ea022d16SRodney W. Grimes.Pp
60ea022d16SRodney W. GrimesThe use of
61ea022d16SRodney W. Grimes.Xr tftp 1
62ea022d16SRodney W. Grimesdoes not require an account or password on the remote system.
63ea022d16SRodney W. GrimesDue to the lack of authentication information,
64a8faeabcSPhilippe Charnier.Nm
65ea022d16SRodney W. Grimeswill allow only publicly readable files to be
66ea022d16SRodney W. Grimesaccessed.
67ff7e281dSYaroslav TykhiyFiles containing the string
68ff7e281dSYaroslav Tykhiy.Dq Li "/../"
69ff7e281dSYaroslav Tykhiyor starting with
70ff7e281dSYaroslav Tykhiy.Dq Li "../"
71ff7e281dSYaroslav Tykhiyare not allowed.
72273a307dSEugene GrosbeinFiles may be written only if they already exist (unless the
73273a307dSEugene Grosbein.Fl w
74273a307dSEugene Grosbeinoption is used) and are publicly writable (unless chrooted and the
75273a307dSEugene Grosbein.Fl S
76273a307dSEugene Grosbeinoption is used).
77ea022d16SRodney W. GrimesNote that this extends the concept of
78ea022d16SRodney W. Grimes.Dq public
79ea022d16SRodney W. Grimesto include
80ea022d16SRodney W. Grimesall users on all hosts that can be reached through the network;
81ea022d16SRodney W. Grimesthis may not be appropriate on all systems, and its implications
82ea022d16SRodney W. Grimesshould be considered before enabling tftp service.
83ea022d16SRodney W. GrimesThe server should have the user ID with the lowest possible privilege.
84ea022d16SRodney W. Grimes.Pp
85ea022d16SRodney W. GrimesAccess to files may be restricted by invoking
86a8faeabcSPhilippe Charnier.Nm
87ea022d16SRodney W. Grimeswith a list of directories by including up to 20 pathnames
88ea022d16SRodney W. Grimesas server program arguments in
89ff7e281dSYaroslav Tykhiy.Xr inetd.conf 5 .
90ea022d16SRodney W. GrimesIn this case access is restricted to files whose
91ea022d16SRodney W. Grimesnames are prefixed by the one of the given directories.
92ea022d16SRodney W. GrimesThe given directories are also treated as a search path for
93ea022d16SRodney W. Grimesrelative filename requests.
94ea022d16SRodney W. Grimes.Pp
95f62eaadfSGarrett WollmanThe
96a8faeabcSPhilippe Charnier.Fl s
97f62eaadfSGarrett Wollmanoption provides additional security by changing
98ff7e281dSYaroslav Tykhiythe root directory of
99ff7e281dSYaroslav Tykhiy.Nm ,
100ff7e281dSYaroslav Tykhiythereby prohibiting accesses to outside of the specified
101f62eaadfSGarrett Wollman.Ar directory .
102f62eaadfSGarrett WollmanBecause
103f62eaadfSGarrett Wollman.Xr chroot 2
104f62eaadfSGarrett Wollmanrequires super-user privileges,
105a8faeabcSPhilippe Charnier.Nm
106ff7e281dSYaroslav Tykhiymust be run as
107ff7e281dSYaroslav Tykhiy.Li root .
108f62eaadfSGarrett WollmanHowever, after performing the
109ff7e281dSYaroslav Tykhiy.Xr chroot 2
110ff7e281dSYaroslav Tykhiycall,
111a8faeabcSPhilippe Charnier.Nm
112ff7e281dSYaroslav Tykhiywill set its user ID to that of the specified
113f62eaadfSGarrett Wollman.Ar user ,
114f62eaadfSGarrett Wollmanor
115ff7e281dSYaroslav Tykhiy.Dq Li nobody
116f62eaadfSGarrett Wollmanif no
117f62eaadfSGarrett Wollman.Fl u
118f62eaadfSGarrett Wollmanoption is specified.
1198ea31785SWarner Losh.Pp
120ea022d16SRodney W. GrimesThe options are:
121ea022d16SRodney W. Grimes.Bl -tag -width Ds
122*79c342aaSMark Johnston.It Fl b
123*79c342aaSMark JohnstonBy default,
124*79c342aaSMark Johnston.Nm
125*79c342aaSMark Johnstonexpects an initial message to be available on its input socket.
126*79c342aaSMark JohnstonIf no data is available, the server exits immediately.
127*79c342aaSMark JohnstonIf
128*79c342aaSMark Johnston.Fl b
129*79c342aaSMark Johnstonis specified,
130*79c342aaSMark Johnston.Nm
131*79c342aaSMark Johnstonwill block waiting for the initial message.
1321ed0e5d2SBill Fumerola.It Fl c
133ff7e281dSYaroslav TykhiyChanges the default root directory of a connecting host via
134ff7e281dSYaroslav Tykhiy.Xr chroot 2
135ff7e281dSYaroslav Tykhiybased on the connecting IP address.
1361ed0e5d2SBill FumerolaThis prevents multiple clients from writing to the same file at the same time.
1371ed0e5d2SBill FumerolaIf the directory does not exist, the client connection is refused.
1381ed0e5d2SBill FumerolaThe
1391ed0e5d2SBill Fumerola.Fl s
1401ed0e5d2SBill Fumerolaoption is required for
1411ed0e5d2SBill Fumerola.Fl c
1421ed0e5d2SBill Fumerolaand the specified
1431ed0e5d2SBill Fumerola.Ar directory
1441ed0e5d2SBill Fumerolais used as a base.
1451ed0e5d2SBill Fumerola.It Fl C
1461ed0e5d2SBill FumerolaOperates the same as
1471ed0e5d2SBill Fumerola.Fl c
1481ed0e5d2SBill Fumerolaexcept it falls back to
1491ed0e5d2SBill Fumerola.Ar directory
150ff7e281dSYaroslav Tykhiyspecified via
151ff7e281dSYaroslav Tykhiy.Fl s
1521ed0e5d2SBill Fumerolaif a directory does not exist for the client's IP.
153dba0fd30SEdwin Groothuis.It Fl F
154dba0fd30SEdwin GroothuisUse this
155dba0fd30SEdwin Groothuis.Xr strftime 3
156dba0fd30SEdwin Groothuiscompatible format string for the creation of the suffix if
157dba0fd30SEdwin Groothuis.Fl W
158dba0fd30SEdwin Groothuisis specified.
159dba0fd30SEdwin GroothuisBy default the string "%Y%m%d" is used.
160a1aea88aSCraig Rodrigues.It Fl d, d Ar [value]
1615276e639SWarner LoshEnables debug output.
162a1aea88aSCraig RodriguesIf
163a1aea88aSCraig Rodrigues.Ar value
164a1aea88aSCraig Rodriguesis not specified, then the debug level is increased by one
165a1aea88aSCraig Rodriguesfor each instance of
166a1aea88aSCraig Rodrigues.Fl d
167a1aea88aSCraig Rodrigueswhich is specified.
168a1aea88aSCraig Rodrigues.Pp
169a1aea88aSCraig RodriguesIf
170a1aea88aSCraig Rodrigues.Ar value
171a1aea88aSCraig Rodriguesis specified, then the debug level is set to
172a1aea88aSCraig Rodrigues.Ar value .
173a1aea88aSCraig RodriguesThe debug level is a bitmask implemented in
174a1aea88aSCraig Rodrigues.Pa src/libexec/tftpd/tftp-utils.h .
175a1aea88aSCraig RodriguesValid values are 0 (DEBUG_NONE), 1 (DEBUG_PACKETS), 2, (DEBUG_SIMPLE),
176a1aea88aSCraig Rodrigues4 (DEBUG_OPTIONS), and 8 (DEBUG_ACCESS).  Multiple debug values can be combined
177a1aea88aSCraig Rodriguesin the bitmask by logically OR'ing the values.  For example, specifying
178a1aea88aSCraig Rodrigues.Fl d
179a1aea88aSCraig Rodrigues.Ar 15
180a1aea88aSCraig Rodrigueswill enable all the debug values.
181ea022d16SRodney W. Grimes.It Fl l
182a8faeabcSPhilippe CharnierLog all requests using
1833dead0b6SJoseph Koshy.Xr syslog 3
184f62eaadfSGarrett Wollmanwith the facility of
185f62eaadfSGarrett Wollman.Dv LOG_FTP .
186ff7e281dSYaroslav Tykhiy.Sy Note :
187ff7e281dSYaroslav TykhiyLogging of
188f62eaadfSGarrett Wollman.Dv LOG_FTP
189f62eaadfSGarrett Wollmanmessages
190f62eaadfSGarrett Wollmanmust also be enabled in the syslog configuration file,
1913dead0b6SJoseph Koshy.Xr syslog.conf 5 .
192ea022d16SRodney W. Grimes.It Fl n
193a8faeabcSPhilippe CharnierSuppress negative acknowledgement of requests for nonexistent
194ea022d16SRodney W. Grimesrelative filenames.
1955276e639SWarner Losh.It Fl o
1965276e639SWarner LoshDisable support for RFC2347 style TFTP Options.
1978ea31785SWarner Losh.It Fl s Ar directory
198a8faeabcSPhilippe CharnierCause
199a8faeabcSPhilippe Charnier.Nm
200f62eaadfSGarrett Wollmanto change its root directory to
201ff7e281dSYaroslav Tykhiy.Ar directory .
202ff7e281dSYaroslav TykhiyAfter doing that but before accepting commands,
203a8faeabcSPhilippe Charnier.Nm
204f62eaadfSGarrett Wollmanwill switch credentials to an unprivileged user.
205273a307dSEugene Grosbein.It Fl S
206273a307dSEugene GrosbeinIf
207273a307dSEugene Grosbein.Nm
208273a307dSEugene Grosbeinruns chrooted, the option allows write requests according to generic
209273a307dSEugene Grosbeinfile permissions, skipping requirement for files to be publicly writable.
210273a307dSEugene GrosbeinThe option is ignored for non-chrooted run.
211f62eaadfSGarrett Wollman.It Fl u Ar user
212f62eaadfSGarrett WollmanSwitch credentials to
213f62eaadfSGarrett Wollman.Ar user
214f62eaadfSGarrett Wollman(default
215ff7e281dSYaroslav Tykhiy.Dq Li nobody )
216f62eaadfSGarrett Wollmanwhen the
217f62eaadfSGarrett Wollman.Fl s
218f62eaadfSGarrett Wollmanoption is used.
219f62eaadfSGarrett WollmanThe user must be specified by name, not a numeric UID.
220eff77877SMatthew N. Dodd.It Fl U Ar umask
221eff77877SMatthew N. DoddSet the
222eff77877SMatthew N. Dodd.Ar umask
2232410103cSRuslan Ermilovfor newly created files.
2242410103cSRuslan ErmilovThe default is 022
225a3ec17dbSRuslan Ermilov.Pq Dv S_IWGRP | S_IWOTH .
226eff77877SMatthew N. Dodd.It Fl w
22741d05ce7SBjoern A. ZeebAllow write requests to create new files.
2282410103cSRuslan ErmilovBy default
229eff77877SMatthew N. Dodd.Nm
230eff77877SMatthew N. Doddrequires that the file specified in a write request exist.
231dba0fd30SEdwin GroothuisNote that this only works in directories writable by the user
232dba0fd30SEdwin Groothuisspecified with
233dba0fd30SEdwin Groothuis.Fl u
234dba0fd30SEdwin Groothuisoption
235dba0fd30SEdwin Groothuis.It Fl W
236dba0fd30SEdwin GroothuisAs
237dba0fd30SEdwin Groothuis.Fl w
238dba0fd30SEdwin Groothuisbut append a YYYYMMDD.nn sequence number to the end of the filename.
239b71d8e69SEdwin GroothuisNote that the string YYYYMMDD can be changed with the
240dba0fd30SEdwin Groothuis.Fl F
241dba0fd30SEdwin Groothuisoption.
242ea022d16SRodney W. Grimes.El
243ea022d16SRodney W. Grimes.Sh SEE ALSO
244ea022d16SRodney W. Grimes.Xr tftp 1 ,
245f62eaadfSGarrett Wollman.Xr chroot 2 ,
246ff7e281dSYaroslav Tykhiy.Xr syslog 3 ,
247ff7e281dSYaroslav Tykhiy.Xr inetd.conf 5 ,
248ff7e281dSYaroslav Tykhiy.Xr services 5 ,
249ff7e281dSYaroslav Tykhiy.Xr syslog.conf 5 ,
250ff7e281dSYaroslav Tykhiy.Xr inetd 8
251957af43fSCraig Rodrigues.Pp
252957af43fSCraig RodriguesThe following RFC's are supported:
253f62eaadfSGarrett Wollman.Rs
2549c282daaSJoel Dahl.%T RFC 1350: The TFTP Protocol (Revision 2)
255957af43fSCraig Rodrigues.Re
256957af43fSCraig Rodrigues.Rs
2579c282daaSJoel Dahl.%T RFC 2347: TFTP Option Extension
258957af43fSCraig Rodrigues.Re
259957af43fSCraig Rodrigues.Rs
2609c282daaSJoel Dahl.%T RFC 2348: TFTP Blocksize Option
261957af43fSCraig Rodrigues.Re
262957af43fSCraig Rodrigues.Rs
2639c282daaSJoel Dahl.%T RFC 2349: TFTP Timeout Interval and Transfer Size Options
264957af43fSCraig Rodrigues.Re
265fdf929ffSJohn Baldwin.Rs
266fdf929ffSJohn Baldwin.%T RFC 7440: TFTP Windowsize Option
267fdf929ffSJohn Baldwin.Re
268957af43fSCraig Rodrigues.Pp
269957af43fSCraig RodriguesThe non-standard
270957af43fSCraig Rodrigues.Cm rollover
271957af43fSCraig Rodriguesand
272957af43fSCraig Rodrigues.Cm blksize2
273957af43fSCraig RodriguesTFTP options are mentioned here:
274957af43fSCraig Rodrigues.Rs
275957af43fSCraig Rodrigues.%T Extending TFTP
276957af43fSCraig Rodrigues.%U http://www.compuphase.com/tftp.htm
277f62eaadfSGarrett Wollman.Re
278ea022d16SRodney W. Grimes.Sh HISTORY
279ea022d16SRodney W. GrimesThe
280ea022d16SRodney W. Grimes.Nm
2813f162cb8SPhilippe Charnierutility appeared in
28267c31d50SGarrett Wollman.Bx 4.2 ;
28367c31d50SGarrett Wollmanthe
28467c31d50SGarrett Wollman.Fl s
28567c31d50SGarrett Wollmanoption was introduced in
28667c31d50SGarrett Wollman.Fx 2.2 ,
2871ed0e5d2SBill Fumerolathe
28867c31d50SGarrett Wollman.Fl u
28967c31d50SGarrett Wollmanoption was introduced in
2901ed0e5d2SBill Fumerola.Fx 4.2 ,
291dba0fd30SEdwin Groothuisthe
2921ed0e5d2SBill Fumerola.Fl c
2931ed0e5d2SBill Fumerolaoption was introduced in
294dba0fd30SEdwin Groothuis.Fx 4.3 ,
295273a307dSEugene Grosbeinthe
296dba0fd30SEdwin Groothuis.Fl F
297dba0fd30SEdwin Groothuisand
298dba0fd30SEdwin Groothuis.Fl W
299dba0fd30SEdwin Groothuisoptions were introduced in
300273a307dSEugene Grosbein.Fx 7.4 ,
301273a307dSEugene Grosbeinand the
302273a307dSEugene Grosbein.Fl S
303273a307dSEugene Grosbeinoption was introduced in
304273a307dSEugene Grosbein.Fx 13.3 .
305dba0fd30SEdwin Groothuis.Pp
3065276e639SWarner LoshSupport for Timeout Interval and Transfer Size Options (RFC2349)
3075276e639SWarner Loshwas introduced in
3085276e639SWarner Losh.Fx 5.0 ,
3095276e639SWarner Loshsupport for the TFTP Blocksize Option (RFC2348) and the blksize2 option
3105276e639SWarner Loshwas introduced in
31186a04a0cSXin LI.Fx 7.4 .
312f6c506d9SCraig Rodrigues.Pp
313f6c506d9SCraig RodriguesEdwin Groothuis <edwin@FreeBSD.org> performed a major rewrite of the
314f6c506d9SCraig Rodrigues.Nm
315f6c506d9SCraig Rodriguesand
316f6c506d9SCraig Rodrigues.Xr tftp 1
317f6c506d9SCraig Rodriguescode to support RFC2348.
318fdf929ffSJohn Baldwin.Pp
319fdf929ffSJohn BaldwinSupport for the windowsize option (RFC7440) was introduced in
320fdf929ffSJohn Baldwin.Fx 13.0 .
321e5660633SCraig Rodrigues.Sh NOTES
32246d20cbcSCraig RodriguesFiles larger than 33,553,919 octets (65535 blocks, last one <512
32346d20cbcSCraig Rodriguesoctets) cannot be correctly transferred without client and server
32446d20cbcSCraig Rodriguessupporting blocksize negotiation (RFCs 2347 and 2348),
325e5660633SCraig Rodriguesor the non-standard TFTP rollover option.
32646d20cbcSCraig RodriguesAs a kludge,
32746d20cbcSCraig Rodrigues.Nm
32846d20cbcSCraig Rodriguesaccepts a sequence of block number which wrap to zero after 65535,
32946d20cbcSCraig Rodrigueseven if the rollover option is not specified.
33067034ac6SJeroen Ruigrok van der Werven.Pp
33146d20cbcSCraig RodriguesMany tftp clients will not transfer files over 16,776,703 octets
33246d20cbcSCraig Rodrigues(32767 blocks), as they incorrectly count the block number using
33346d20cbcSCraig Rodriguesa signed rather than unsigned 16-bit integer.
334