Subject: Re: wuftpd on solaris 2.5

From: [email-masked] (William E. Diego)
Date: Thu, 13 Mar 1997 10:19:27 -0500

----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 51

Ok, I will send two files as attachments; let me know if you cannot
save them as manual pages.

The first file is 'ftpd.1m' and is a short one that refers to the
second file, 'in.ftpd.1n; which is the actual manual page.  Both of
these belong in:

	/usr/share/man/man1m

Let me know how it goes.

Cheers,
-bd

> From [email-masked] Thu Mar 13 07:40:34 1997
> Date: Thu, 13 Mar 1997 06:28:28 -0600
> Reply-To: [email-masked]
> Sender: [email-masked]
> From: "Steven K. Buehler" <[email-masked]>
> To: [email-masked]
> Subject: Re: wuftpd on solaris 2.5
> Mime-Version: 1.0
> X-Sender: [email-masked]
> X-Mailer: Windows Eudora Pro Version 3.0.1 (32)
> X-Listprocessor-Version: 8.0 -- ListProcessor(tm) by CREN
> 
> I guess that you will need to ask you to send it to me (please).  I read thru the one that came with Solaris 2.5 and the one that came with wuftpd and neither one said a thing about it.  
> 
> Thanks
> Steve
> 
> At 11:54 PM 3/12/97 -0500, you wrote:
> >Read the in.ftpd manual page that came **with Solaris 2.5**
> >not the one that wuftpd installs.  If the installation has written
> >over the original, I will be glad to forward an original to you.
> >The manual page tells you about additional libraries and devices
> >you need to add/create (more than there were in SunOS 4.x).
> >
> >Cheers,
> >-bd
> >
> >
> 
> ======================================================
> Steven K. Buehler
> S & B Computers
> Rockford Illinois, USA
> Phone: 815-398-7169
> Fax: 815-398-7266
> ======================================================
> 
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: ftpd.1m
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 2

.so man1m/in.ftpd.1m
.\" @(#)ftpd.1m 1.0 93/10/11 SMI;
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: in.ftpd.1m
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 623

'\" t
.\" @(#)in.ftpd.1m 1.32 95/08/21 SMI; from SVr4
.\" Copyright 1989 AT&T
.TH in.ftpd 1M "10 Aug 1995"
.SH NAME
in.ftpd, ftpd \- file transfer protocol server
.SH SYNOPSIS
.B in.ftpd
[
.B \-dl
] [
.BI \-t timeout
]
.SH AVAILABILITY
SUNWcsu
.SH DESCRIPTION
.IX  "in.ftpd command"  ""  "\fLin.ftpd\fP \(em File Transfer Protocol daemon on remote host"
.IX  "File Transfer Protocol" "server" "" "server \(em \fLin.ftpd\fP" 
.IX  "FTP" "daemon on remote host" "" "daemon on remote host \(em \fLin.ftpd\fP"
.IX  "Internet" "File Transfer Protocol daemon on remote host" "" "File Transfer Protocol daemon on remote host \(em \fLin.ftpd\fP"
.IX  "TCP/IP" "File Transfer Protocol daemon on remote host" "" "File Transfer Protocol daemon on remote host \(em \fLin.ftpd\fP"
.B in.ftpd
is the Internet File Transfer Protocol (\c
.SM FTP\c
) server process.
The server is invoked by the Internet daemon
.BR inetd (1M)
each time a connection to the
.SM FTP
service (see
.BR services (4))
is made.
.SH OPTIONS
.TP 12
.B \-d
Debugging information is logged to the system log daemon
.BR syslogd (1M).
.TP
.B \-l
Each
.SM FTP
session is logged to the system log daemon
.BR syslogd (1M).
.TP
.BI \-t timeout
Set the inactivity timeout period to
.IR timeout seconds.
The
.SM FTP
server will timeout an inactive session after 15 minutes.
.SS Requests
.LP
The
.SM FTP
server currently supports the following
.SM FTP
requests;
case is not distinguished.
.TP 12
.SB ABOR
abort previous command
.TP
.SB ACCT
specify account (ignored)
.TP
.SB ALLO
allocate storage (vacuously)
.TP
.SB APPE
append to a file
.TP
.SB CDUP
change to parent of current working directory
.TP
.SB CWD
change working directory
.TP
.SB DELE
delete a file
.TP
.SB HELP
give help information
.TP
.SB LIST
give list files in a directory
.RB ( "ls \-lg" )
.TP
.SB MKD
make a directory
.TP
.SB MODE
specify data transfer
.I mode
.TP
.SB NLST
give name list of files in directory
.RB ( ls )
.TP
.SB NOOP
do nothing
.TP
.SB PASS
specify password
.TP
.SB PASV
prepare for server-to-server transfer
.TP
.SB PORT
specify data connection port
.TP
.SB PWD
print the current working directory
.TP
.SB QUIT
terminate session
.TP
.SB RETR
retrieve a file
.TP
.SB RMD
remove a directory
.TP
.SB RNFR
specify rename-from file name
.TP
.SB RNTO
specify rename-to file name
.TP
.SB STOR
store a file
.TP
.SB STOU
store a file with a unique name
.TP
.SB STRU
specify data transfer
.I structure
.TP
.SB TYPE
specify data transfer
.I type
.TP
.SB USER
specify user name
.TP
.SB XCUP
change to parent of current working directory
.TP
.SB XCWD
change working directory
.TP
.SB XMKD
make a directory
.TP
.SB XPWD
print the current working directory
.TP
.SB XRMD
remove a directory
.LP
The remaining
.SM FTP
requests specified in
.SM RFC
959 are recognized, but not implemented.
.LP
The
.SM FTP
server will abort an active file transfer only when the
.SB ABOR
command is preceded by a Telnet \*(lqInterrupt Process\*(rq (IP)
signal and a Telnet \*(lqSynch\*(rq signal in the command Telnet stream,
as described in
.SM RFC
959.
.LP
.B in.ftpd
interprets file names according to the \*(lqglobbing\*(rq
conventions used by
.BR sh (1).
This allows users to utilize the metacharacters:
\f3* ? [ ] { } ~\f1
.LP
.B in.ftpd
authenticates users according to four rules.
.RS 6
.TP 6
1)
The user name must be in the password data base,
.BR /etc/passwd ,
and have a password that is not null.  A password
must always be provided by the client before any file operations
may be performed.
.TP
2)
If the user name appears in the file
.BR /etc/ftpusers ,
.B ftp
access is denied.
.br
.ne 5
.TP
3)
.B ftp
access is denied if the user's shell (from
.BR /etc/passwd )
is not listed in the file 
.BR /etc/shells.
If the file
.BR /etc/shells
does not exist, then the user's shell must be one of the following:
.sp 1n
.RS 12
.TS
tab(:);
lb1 lb1 lb1.
/usr/bin/sh:/usr/bin/csh:/usr/bin/ksh
/usr/bin/jsh:/bin/sh:/bin/csh
/bin/ksh:/bin/jsh:/sbin/sh
/sbin/jsh
.TE
.RE
.sp 1n
.TP
4)
If the user name is \*(lqanonymous\*(rq or \*(lqftp\*(rq,
an entry for the user name \f2ftp\f1 must be present in the
password and shadow files.
The user is then allowed
to log in by specifying any password \(em by convention this
is given as the user's e-mail address (such as
.BR [email-masked] ).
Do not specify a valid shell in the password entry of the
\f2ftp\f1 user, and do not give it a valid password (use NP in the
encrypted password field of the shadow file).
.RE
.LP
For anonymous ftp users,
.B in.ftpd
takes special measures to restrict the client's access privileges.
The server performs a
.BR chroot (2)
command to the home directory of the \*(lqftp\*(rq user.
In order that system security is not breached, it is recommended
that the \*(lqftp\*(rq subtree be constructed with care;  the following
rules are suggested.
.sp 1n
.TP 12
.B ~ftp
Make the home directory owned by
.B root
and unwritable by anyone.  This directory should not be on a file
system mounted with the
.B nosuid
option.
.br
.ne 5
.TP
.B ~ftp/bin
Make this directory owned by the super-user and unwritable by
anyone.  Make this a symbolic link to
.B ~ftp/usr/bin
The program
.BR ls (1)
must be present to support the list commands.  This
program should have mode 111.
.br
.ne 10
.TP
.B ~ftp/usr/lib
Make this directory owned by the super-user and unwritable by
anyone.
Copy the following shared libraries from
.B /usr/lib
into this directory.:
.sp 1n
.RS 12
.B ld.so*
.br
.B libc.so*
.br
.B libdl.so*
.br
.B libintl.so*
.br
.B libw.so*
.br
.B libnsl.so*
.br
.B libsocket.so*
.br
.B nss_nis.so*
.br
.B nss_nisplus.so*
.br
.B nss_dns.so*
.br
.B nss_files.so*
.br
.B straddr.so*
.RE
.sp 1n
.TP
.B ~ftp/etc
Make this directory owned by the super-user and unwritable by
anyone.  Copies of the files
.BR passwd (4),
.BR group (4),
and
.BR netconfig (4)
must be present for the
.BR ls (1)
command to work properly.  These files should be mode 444.
.TP
.B ~ftp/pub
Make this directory mode 777 and owned by
.BR ftp .
Users should then place files which are to be accessible via the
anonymous account in this directory.
.TP
.B ~ftp/dev
Make this directory owned by the super-user and unwritable
by anyone.  First perform
.B ls \-lL
on the device files listed below to determine their major and minor
numbers, then use
.B mknod
to create them in this directory.
.sp 1n
.RS 12
.B /dev/zero
.br
.B /dev/tcp
.br
.B /dev/udp
.br
.B /dev/ticotsord
.br
.RE
.TP
.B ~ftp/usr/share/lib/zoneinfo
Make this directory mode 555 and owned by the super-user.
Copy its contents from
.BR /usr/share/lib/zoneinfo .
This enables 
.B ls \-l
to display time and date stamps correctly.
.sp 1n
.ne 10
.SH EXAMPLES
.LP
To set up anonymous ftp, add the following entry to the
.B /etc/passwd
file. In this case,
.B /export/ftp
was chosen to be the anonymous ftp
area, and the shell is the non-existent file
.BR /nosuchshell .
This prevents users from logging in as the ftp user.
.in +4n
.B ftp:x:30000:30000:Anonymous FTP:/export/ftp:/nosuchshell
.in -4n
Add the following entry to /etc/shadow:
.in +4n
.B "ftp:NP:6445::::::"
.in -4n
.LP
The following is a shell script that will set up the anonymous ftp area.
It presumes that names are resolved using \s-1NIS\s0.
.LP
.nf
.ft 3
#!/bin/sh
# script to setup anonymous ftp area
#
# handle the optional command line argument
case $# in

   # the default location for the anon ftp comes from the passwd file
   0) ftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`"
      ;;

   1) if [ "$1" = "start" ]; then
         ftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`"
      else
         ftphome=$1
      fi
      ;;

   *) echo "Usage: $0 [anon-ftp-root]"
      exit 1
      ;;
esac

if [ -z "${ftphome}" ]; then
   echo "$0: ftphome must be non-null"
   exit 2
fi

# This script assumes that ftphome is neither / nor /usr so ...
if [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; then
   echo "$0: ftphome must not be / or /usr"
   exit 2
fi

# If ftphome does not exist but parent does, create ftphome
if [ ! -d ${ftphome} ]; then
    # lack of -p below is intentional
    mkdir ${ftphome}

fi
echo Setting up anonymous ftp area ${ftphome}

# Ensure that the /usr/bin directory exists
if [ ! -d ${ftphome}/usr/bin ]; then
    mkdir -p ${ftphome}/usr/bin
fi

cp /usr/bin/ls ${ftphome}/usr/bin
chmod 111 ${ftphome}/usr/bin/ls

# Now set the ownership and modes to match the man page
chown root ${ftphome}/usr/bin
chmod 555 ${ftphome}/usr/bin

# this may not be the right thing to do
# but we need the bin -> usr/bin link
if [ -r ${ftphome}/bin ]; then
    mv -f ${ftphome}/bin ${ftphome}/Obin
fi
ln -s usr/bin ${ftphome}

# Ensure that the /usr/lib and /etc directories exist
if [ ! -d ${ftphome}/usr/lib ]; then
    mkdir -p ${ftphome}/usr/lib
fi
if [ ! -d ${ftphome}/etc ]; then
    mkdir -p ${ftphome}/etc
fi

#Most of the following are needed for basic operation, except
#for libnsl.so, nss_nis.so, libsocket.so, and straddr.so which are
#needed to resolve NIS names.

cp /usr/lib/ld.so /usr/lib/ld.so.1 ${ftphome}/usr/lib

for lib in libc libdl libintl libw libnsl libsocket \\
   nss_nis nss_nisplus nss_dns nss_files
do
   cp /usr/lib/${lib}.so.1 ${ftphome}/usr/lib
   rm -f ${ftphome}/usr/lib/${lib}.so
   ln -s ./${lib}.so.1 ${ftphome}/usr/lib/${lib}.so
done

cp /usr/lib/straddr.so.2 ${ftphome}/usr/lib
rm -f ${ftphome}/usr/lib/straddr.so
ln -s ./straddr.so.2 ${ftphome}/usr/lib/straddr.so

cp /etc/passwd /etc/group /etc/netconfig ${ftphome}/etc

# Copy timezone database
mkdir -p ${ftphome}/usr/share/lib/zoneinfo
(cd ${ftphome}/usr/share/lib/zoneinfo
  (cd /usr/share/lib/zoneinfo; find . -print | cpio -o) | cpio -imdu
  find . -print | xargs chmod 555
  find . -print | xargs chown root
)

chmod 555 ${ftphome}/usr/lib/*
chmod 444 ${ftphome}/etc/*

# Now set the ownership and modes
chown root ${ftphome}/usr/lib ${ftphome}/etc
chmod 555 ${ftphome}/usr/lib ${ftphome}/etc

# Ensure that the /dev directory exists
if [ ! -d ${ftphome}/dev ]; then
    mkdir -p ${ftphome}/dev
fi

# make device nodes. ticotsord and udp are necessary for
# 'ls' to resolve NIS names.

for device in zero tcp udp ticotsord
do
   line=`ls -lL /dev/${device} | sed -e 's/,//'`
   major=`echo $line | awk '{print $5}'`
   minor=`echo $line | awk '{print $6}'`
   rm -f ${ftphome}/dev/${device}
   mknod ${ftphome}/dev/${device} c ${major} ${minor}
done

chmod 666 ${ftphome}/dev/*

## Now set the ownership and modes
chown root ${ftphome}/dev
chmod 555 ${ftphome}/dev

if [ ! -d ${ftphome}/pub ]; then
   mkdir -p ${ftphome}/pub
fi
chown ftp ${ftphome}/pub
chmod 777 ${ftphome}/pub
.fi
.ft 1
.SH SEE ALSO
.BR ftp (1),
.BR ls (1),
.BR aset (1M),
.BR inetd (1M),
.BR mknod (1M),
.BR syslogd (1M),
.BR chroot (2),
.BR getsockopt (3N),
.BR group (4),
.BR inetd.conf (4),
.BR netconfig (4),
.BR netrc (4),
.BR passwd (4),
.BR services (4)
.LP
Postel, Jon, and Joyce Reynolds,
.I File Transfer Protocol (
.SM FTP
),
.SM RFC
959, Network Information Center,
.SM SRI
International, Menlo Park, Calif.,
October 1985.
.SH DIAGNOSTICS
.B in.ftpd
logs various errors to
.BR syslogd ,
with a facility code of
.BR daemon .
.SS Info Severity
These messages are logged only if the
.B \-l
flag is specified.
.HP 12
.B "\s-1FTPD\s0: connection from"
.I host
.B at
.I time
.br
A connection was made to
.B ftpd
from the host
.I host
at the date and time
.IR time .
.HP 12
.B "\s-1FTPD\s0: User"
.I user
.B "timed out after"
.I timeout
.B "seconds at"
.I time
.br
The user
.I user
was logged out because they had not entered any commands after
.I timeout
seconds; the logout occurred at the date and time
.IR time .
.br
.ne 5
.SS Debug Severity
These messages are logged only if the
.B \-d
flag is specified.
.HP 12
.B "\s-1FTPD\s0: command:"
.I command
.br
A command line containing
.I command
was read from the
.SM FTP
client.
.TP 12
.B "lost connection"
The
.SM FTP
client dropped the connection.
.br
.ne 5
.TP 12
<\-\-\- \f2replycode\f1
.PD 0
.TP 12
<\-\-\- \f2replycode\-\f1
A reply was sent to the
.SM FTP
client with the reply code
.IR replycode .
The next message logged will include the message associated with the
reply.  If a
.B \-
follows the reply code, the reply is continued on later lines.
.PD
.br
.ne 6
.SH NOTES
The anonymous account is inherently dangerous
and should be avoided when possible.
.LP
The server must run as the super-user to
create sockets with privileged
port numbers.  It maintains an effective
user id of the logged in user,
reverting to the super-user only when binding
addresses to sockets.
The possible security holes have been
extensively scrutinized, but are
possibly incomplete.
.LP
.B /etc/ftpusers
contains a list of users 
who cannot access the system; the format of the file is
one user name per line.