\chapter{FTP server}\label{cha:ftpd} \begin{description} \item[Used files:] ftpd.scm \item[Name of the package:] ftpd \end{description} \section{What users want to know} \section{Entry points} \defun {ftpd} {options} {\noreturn} \begin{defundescx}{ftp-inetd} {anonymous-home} {\noreturn} \ex{ftpd} starts the server, using \semvar{anonymous-home} as the root directory of the server. Usage of relative paths is not encouraged. \semvar{port} specifies the port the server is listening for connections. It defaults to 21. \ex{ftpd} makes a log entry for each file sent or retrieved. These logs are written to \semvar{logfile}, if given. If \semvar{dns-lookup?} is \sharpt, the logfile will contain the host names instead of their IP addresses. If \semvar{dns-lookup?} is not specified or \sharpf, the IP addresses are stored. The log format of \ex{ftpd} is the same as the one of \ex{wuftpd}. The fields are seperated by spaces and contain following informations: \codex{Fri Apr 19 17:08:14 2002 4 134.2.2.171 56881 /files.lst b \_ i a nop@ssword ftp 0 *} \begin{enumerate} \item Current date and time. This field contains spaces and is 24 characters long. \item Transfer time in seconds. \item Remote host IP (wuftpd puts the name here). \item File size in bytes \item Name of file (spaces are converted to underscores) \item Transfer type: \underline{a}scii or \underline{b}inary (image type). \item Special action flags. As \ex{ftpd} does not support any special action, we are always `\ex{\_}' here. \item File was sent to user (\underline{o}utgoing) or received from user (\underline{i}ncoming) \item \underline{A}nonymous access \item Anonymous ftp password. We do not use anyone. \item Service name - always \ex{ftp}. \item Authentication mode (always none = `\ex{0}'). \item Authenticated user ID (always not available = `\ex{*}') \end{enumerate} As the procedure does not return, you have to do a \ex{fork} in order to have a ``real'' daemon: \codex{(fork (lambda () (ftpd "/data/ftp" 8080)))} \ex{ftpd-inetd} is the version to be used with a daemon like \ex{inetd}. If the server is started this way, it handles the connection through the current standard output and input ports. \end{defundescx} \subsubsection*{Examples} To start the server with the current home directory as root directory and listening on port 8080, use \codex{(ftpd (cwd) 8080)} This is how the ftp server at the computing faculty of the university of Tuebingen\footnote{\texttt{archive.informatik.uni-tuebingen.de}} is started: \begin{alltt} #!/bin/sh /scsh-0.6-alpha/bin/scsh <