1ftpd(n)                     Tcl FTP Server Package                     ftpd(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       ftpd - Tcl FTP server implementation
9

SYNOPSIS

11       package require Tcl  8.3
12
13       package require ftpd  ?1.3?
14
15       ::ftpd::server ?myaddr?
16
17       ::ftpd::config ?option value? ?option value ...?
18
19       fsCmd append path
20
21       fsCmd delete path channel
22
23       fsCmd dlist path style channel
24
25       fsCmd exists path
26
27       fsCmd mkdir path channel
28
29       fsCmd mtime path channel
30
31       fsCmd permissions path
32
33       fsCmd rename path newpath channel
34
35       fsCmd retr path
36
37       fsCmd rmdir path channel
38
39       fsCmd size path channel
40
41       fsCmd store path
42
43______________________________________________________________________________
44

DESCRIPTION

46       The  ftpd package provides a simple Tcl-only server library for the FTP
47       protocol    as    specified    in    RFC    959    (http://www.rfc-edi
48       tor.org/rfc/rfc959.txt).   It  works  by  listening on the standard FTP
49       socket.  Most server errors are returned as  error  messages  with  the
50       appropriate  code  attached to them.  Since the server code for the ftp
51       daemon is executed in the event loop, it is  possible  that  a  bgerror
52       will be thrown on the server if there are problems with the code in the
53       module.
54

COMMANDS

56       ::ftpd::server ?myaddr?
57              Open a listening socket to listen to and accept ftp connections.
58              myaddr is an optional argument.  myaddr is the domain-style name
59              or numerical IP address of the client-side network interface  to
60              use for the connection.
61
62       ::ftpd::config ?option value? ?option value ...?
63              The value is always the name of the command to call as the call‐
64              back. The option specifies which callback should be  configured.
65              See  section  CALLBACKS  for  descriptions  of the arguments and
66              return values for each of the callbacks.
67
68              -authIpCmd proc
69                     Callback to authenticate new connections based on the ip-
70                     address of the peer.
71
72              -authUsrCmd proc
73                     Callback  to  authenticate  new  connections based on the
74                     user logging in (and the users password).
75
76              -authFileCmd proc
77                     Callback to accept or deny a users  access  to  read  and
78                     write to a specific path or file.
79
80              -logCmd proc
81                     Callback for log information generated by the FTP engine.
82
83              -fsCmd proc
84                     Callback to connect the engine to the filesystem it oper‐
85                     ates on.
86
87              -closeCmd proc
88                     Callback to be called when a connection is  closed.  This
89                     allows  the  embedding  application  to  perform  its own
90                     cleanup operations.
91
92              -xferDoneCmd proc
93                     Callback for transfer completion notification.  In  other
94                     words,  it  is  called  whenever a transfer of data to or
95                     from the client has completed.
96

CALLBACKS

98       authIpCmd callback
99              The authIpCmd receives the ip-address of the peer attempting  to
100              connect  to  the  ftp  server as its argument. It returns a 1 to
101              allow users from the specified IP to attempt to login and a 0 to
102              reject the login attempt from the specified IP.
103
104       authUsrCmd callback
105              The  authUsrCmd  receives  the  username and password as its two
106              arguments. It returns a 1 to accept the attempted login  to  the
107              ftpd and a 0 to reject the attempted login.
108
109       authFileCmd callback
110              The authFileCmd receives the user (that is currently logged in),
111              the path or filename that is about to be read  or  written,  and
112              read  or  write as its three arguments.  It returns a 1 to allow
113              the path or filename to be read or written, and a  0  to  reject
114              the attempted read or write with a permissions error code.
115
116       logCmd callback
117              The  logCmd  receives  a severity and a message as its two argu‐
118              ments.  The severities used within the ftpd  package  are  note,
119              debug, and error. The logCmd doesn't return anything.
120
121       fsCmd callback
122              The  fsCmd  receives  a  subcommand,  a  filename  or  path, and
123              optional additional arguments (depending on the subcommand).
124
125              The subcommands supported by the fsCmd are:
126
127              fsCmd append path
128                     The append subcommand receives the filename to append  to
129                     as its argument. It returns a writable tcl channel as its
130                     return value.
131
132              fsCmd delete path channel
133                     The delete subcommand receives the  filename  to  delete,
134                     and a channel to write to as its two arguments.  The file
135                     specified is deleted and the appropriate ftp  message  is
136                     written to the channel that is passed as the second argu‐
137                     ment.  The delete subcommand returns nothing.
138
139              fsCmd dlist path style channel
140                     The dlist subcommand receives the  path  that  it  should
141                     list  the files that are in, the style in which the files
142                     should be listed which is either  nlst  or  list,  and  a
143                     channel to write to as its three arguments.  The files in
144                     the specified path are printed to the  specified  channel
145                     one  per line.  If the style is nlst only the name of the
146                     file is printed to the channel.  If  the  style  is  list
147                     then  the  file permissions, number of links to the file,
148                     the name of the user that owns the file, the name of  the
149                     group  that  owns  the  file,  the size (in bytes) of the
150                     file, the modify time of the file, and the  filename  are
151                     printed out to the channel in a formatted space separated
152                     format.  The dlist subcommand returns nothing.
153
154              fsCmd exists path
155                     The exists subcommand receives the  name  of  a  file  to
156                     check  the existence of as its only argument.  The exists
157                     subcommand returns a 1 if the path specified  exists  and
158                     the path is not a directory.
159
160              fsCmd mkdir path channel
161                     The  mkdir subcommand receives the path of a directory to
162                     create and a channel to write to as  its  two  arguments.
163                     The  mkdir  subcommand creates the specified directory if
164                     necessary and possible.  The mkdir subcommand then prints
165                     the  appropriate  success or failure message to the chan‐
166                     nel.  The mkdir subcommand returns nothing.
167
168              fsCmd mtime path channel
169                     The mtime subcommand receives the path of a file to check
170                     the  modify  time  on and a channel as its two arguments.
171                     If the file exists the mtime is printed to the channel in
172                     the  proper  FTP  format,  otherwise an appropriate error
173                     message and code are printed to the channel.   The  mtime
174                     subcommand returns nothing.
175
176              fsCmd permissions path
177                     The permissions subcommand receives the path of a file to
178                     retrieve the permissions of.  The permissions  subcommand
179                     returns the octal file permissions of the specified file.
180                     The file is expected to exist.
181
182              fsCmd rename path newpath channel
183                     The rename subcommand receives the path  of  the  current
184                     file, the new file path, and a channel to write to as its
185                     three arguments.  The rename subcommand renames the  cur‐
186                     rent  file  to  the  new file path if the path to the new
187                     file exists, and then prints out the appropriate  message
188                     to  the  channel.  If the new file path doesn't exist the
189                     appropriate error message is printed to the channel.  The
190                     rename subcommand returns nothing.
191
192              fsCmd retr path
193                     The  retr  subcommand receives the path of a file to read
194                     as its only argument.   The  retr  subcommand  returns  a
195                     readable  channel  that  the  specified  file can be read
196                     from.
197
198              fsCmd rmdir path channel
199                     The rmdir subcommand receives the path of a directory  to
200                     remove  and  a  channel to write to as its two arguments.
201                     The rmdir subcommand removes the specified directory  (if
202                     possible) and prints the appropriate message to the chan‐
203                     nel (which may be an error  if  the  specified  directory
204                     does  not  exist  or is not empty).  The rmdir subcommand
205                     returns nothing.
206
207              fsCmd size path channel
208                     The size subcommand receives the path of a  file  to  get
209                     the  size  (in bytes) of and a channel to write to as its
210                     two arguments.  The size subcommand prints the  appropri‐
211                     ate  code  and the size of the file if the specified path
212                     is a file, otherwise an appropriate error code  and  mes‐
213                     sage  are  printed  to  the channel.  The size subcommand
214                     returns nothing.
215
216              fsCmd store path
217                     The store subcommand receives the path of a file to write
218                     as  its  only  argument.   The store subcommand returns a
219                     writable channel.
220
221       closeCmd
222              The closeCmd receives no arguments when it is invoked,  and  any
223              return value it may generate is discarded.
224
225       xferDoneCmd sock sock2 file bytes filename err
226              The  xferDoneCmd receives six arguments when invoked. These are,
227              in this order, the channel handle of the control socket for  the
228              connection,  the  channel handle of the data socket used for the
229              transfer (already closed), the handle of the channel  containing
230              the transfered file, the number of bytes transfered, the path of
231              the file which was transfered, and a (possibly empty) error mes‐
232              sage.  Any return value it may generate is discarded.
233

VARIABLES

235       ::ftpd::cwd
236              The  current  working directory for a session when someone first
237              connects to the FTPD or when the REIN ftp command is received.
238
239       ::ftpd::contact
240              The e-mail address of the person that is the contact for the ftp
241              server.   This address is printed out as part of the response to
242              the FTP HELP command.
243
244       ::ftpd::port
245              The port that the ftp server should listen on.  If port is spec‐
246              ified as zero, the operating system will allocate an unused port
247              for use as a server socket; afterwards, the variable  will  con‐
248              tain the port number that was allocated.
249
250       ::ftpd::welcome
251              The  message that is printed out when the user first connects to
252              the ftp server.
253
254       ::ftpd::CurrentSocket
255              Accessible to all callbacks and all filesystem  commands  (which
256              are  a  special form of callback) and contains the handle of the
257              socket channel which was active when the callback was invoked.
258

BUGS, IDEAS, FEEDBACK

260       This document, and the package it describes, will  undoubtedly  contain
261       bugs  and  other  problems.  Please report such in the category ftpd of
262       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
263       also  report any ideas for enhancements you may have for either package
264       and/or documentation.
265
266       When proposing code changes, please provide unified diffs, i.e the out‐
267       put of diff -u.
268
269       Note  further  that  attachments  are  strongly  preferred over inlined
270       patches. Attachments can be made by going  to  the  Edit  form  of  the
271       ticket  immediately  after  its  creation, and then using the left-most
272       button in the secondary navigation bar.
273

KEYWORDS

275       ftp, ftpd, ftpserver, rfc 959, services
276

CATEGORY

278       Networking
279
280
281
282tcllib                                1.3                              ftpd(n)
Impressum