Subject: Anonymous FTP new problem

From: [email-masked] (Vibhavasu Vuppala)
Date: 30 Sep 1993 07:39:18 GMT

Hi,

I setup anonymous ftp on 2.2 (with mandatory patches). I followed the
method given in one of the sun-managers' summaries (see below).
When ftp'ing as anonymous user ls command returns the following,

ftp> ls
200 PORT command successful.
150 ASCII data connection for /bin/ls (35.8.60.47,33081) (0 bytes).
226 ASCII Transfer complete.
ftp> 

The dir is not empty, it has files (pub,dev,etc,bin etc.).
Strange thing is that ls command sometimes works (1 in 10) !

"chroot <ftp-dir> /bin/ls -l" works fine.

Has anybody seen this before ? Any suggestions ?

Thank you very much.

- vasu

I used this to setup ftp :

>From [email-masked] Fri May  7 02:43:40 1993
Sender: [email-masked]
Date: Thu, 6 May 93 13:42:26 PDT
From: [email-masked] (S. Cowles)
Reply-To: [email-masked] (S. Cowles)
Followup-To: junk
To: [email-masked]
Subject: SUMMARY:  anonymous ftp on Solaris 2.1
Content-Length: 4361
Status: RO

Earlier this week, I asked what I was missing in my setup of anonymous
ftp under Solaris 2.1.  Output of the ls(1) command showed uid's and
gid's with no resolution to user and group names.  Oon-Gil Paik sent me
a very nice script that covered all the basics.  I have taken the
liberty of modifying it and present it here.

Sid

S. Cowles 		 voice: +1 415 812 1917
internet:                uucp:
[email-masked]
[email-masked]         {backbone}!lll-winken!humpty!scowles

============================================================
#!/bin/sh
# script for assisting in setting up anonymous ftp under Solaris 2.1.
# original from [email-masked] (Oon-Gil Paik).
# modifications and additional comments added by [email-masked].
# sccsid:  @(#)anonftpsetup	1.3	13:40:28	93/05/06
#
# From [email-masked] Wed May  5 22:46 PDT 1993
# Date: Wed, 5 May 93 22:34:08 PDT
# From: [email-masked] (Oon-Gil Paik)
# To: [email-masked]
# Subject: Re: Solaris 2.1 anonymous ftp setup
#
# Use the above script to setup anonymous ftp.
# -OonGil
#
# Steps for setting up anonymous ftp under Solaris 2.1.
# 1. read the ftpd(1M) section for background.
# 2. create /etc/shells populated with your favourites.
# 3. establish the ftp user account and home directory.
# 4. run this script as root.
#
# Function of necessary files:
#
# Needed for 'dir' and 'ls' functionality.
# /bin/ls
#
# The following are needed for basic operation.
# /usr/lib/ld.so*
# /usr/lib/libc.so.1
# /usr/lib/libdl.so.1
# /usr/lib/libintl.so.1
# /usr/lib/libw.so.1
# /etc/passwd
# /etc/group
# /etc/netconfig
# /etc/nsswitch.conf
#
# The following are needed for 'ls' to resolve NIS names.
# /usr/lib/nsw*.so
# /usr/lib/libnsl.so.1
# /usr/lib/straddr.so

# OPERATIONS:
# a function for copying files:
filcopy(){
	f=$1
	ff=`basename $f`
	d1=`dirname $f`
	expr "$d1" : "/.*" >/dev/null 2>&1 && fd=`expr "$d1" : "/\(.*\)"`

	# for cleansing:
	/bin/rm -f ${FTP}/${fd}/$ff ] && cp $f ${FTP}/${fd}

	# for quicker operation:
	# [ ! -f ${FTP}/${fd}/$ff ] && cp $f ${FTP}/${fd}

	echo "cp $f ${FTP}/${fd}"
}

# greeting banner.
echo Fixing ${FTP} for SunOS 5.x

# the home ftp directory
FTP="/var/ftp"
[ ! -d $FTP ] && { echo "ftp home directory not established." >&2; exit 1; }

# necessary subdirectories.
[ ! -d ${FTP}/bin ] && mkdir ${FTP}/bin
[ ! -d ${FTP}/usr ] && mkdir ${FTP}/usr
[ ! -d ${FTP}/usr/lib ] && mkdir ${FTP}/usr/lib
[ ! -d ${FTP}/etc ] && mkdir ${FTP}/etc

# necessary files.
FILES="
/bin/ls
/usr/lib/ld.so*
/usr/lib/libc.so.1
/usr/lib/libdl.so.1
/usr/lib/libintl.so.1
/usr/lib/libw.so.1
/etc/passwd
/etc/group
/etc/netconfig
/etc/nsswitch.conf
/usr/lib/nsw*.so
/usr/lib/libnsl.so.1
/usr/lib/straddr.so
"

# do the file copy shuffle.
for FILE in $FILES
do
	filcopy $FILE
done

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

prefix="/devices/pseudo/mm:"
for device in zero
do
	[ -c ${FTP}/dev/$device ] && /bin/rm -f ${FTP}/dev/$device
	line=`ls -l ${prefix}${device} | sed -e 's/,//'`
	major=`echo $line | awk '{print $5}'`
	minor=`echo $line | awk '{print $6}'`
	mknod ${FTP}/dev/${device} c ${major} ${minor}
	echo "mknod ${FTP}/dev/${device} c ${major} ${minor}"
done

prefix="/devices/pseudo/clone:"
for device in tcp udp ticotsord
do
	[ -c ${FTP}/dev/$device ] && /bin/rm -f ${FTP}/dev/$device
	line=`ls -l ${prefix}${device} | sed -e 's/,//'`
	major=`echo $line | awk '{print $5}'`
	minor=`echo $line | awk '{print $6}'`
	mknod ${FTP}/dev/${device} c ${major} ${minor}
	echo "mknod ${FTP}/dev/${device} c ${major} ${minor}"
done

# set correct permissions.
chmod 666 ${FTP}/dev/*
chmod 555 ${FTP}/dev
chmod 111 ${FTP}/bin/ls
chmod 555 ${FTP}/bin
chmod 444 ${FTP}/etc/*
chmod 555 ${FTP}/etc
chmod 555 ${FTP}/usr/lib/lib*
chmod 555 ${FTP}/usr/lib
chmod 555 ${FTP}/usr
chown ftp ${FTP}
chmod 555 ${FTP}

exit 0

# OPTIONAL:  This is for the wuarchive ftp server.
[ ! -d etc/msgs ] && mkdir etc/msgs
echo Setting up wuarchive FTP server
cp -r /usr/local/etc/msgs ${FTP}/etc
chmod -R a+r ${FTP}/etc/msgs
chmod a+x ${FTP}/etc/msgs

cp -r /usr/local/etc/msgs /etc
chmod -R a+r /etc/msgs
chmod a+x /etc/msgs

if [ ! -f /usr/sbin/in.ftpd.orig ]; then
	mv /usr/sbin/in.ftpd /usr/sbin/in.ftpd.orig
fi
cp /export/local/etc/ftpd /usr/sbin/in.ftpd

============================================================