SUMMARY: anonymous ftp on Solaris 2.1

From: S. Cowles (scowles@toolik.stanford.edu)
Date: Fri May 07 1993 - 04:35:13 CDT


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:
scowles@camis.stanford.edu
scowles@llnl.gov {backbone}!lll-winken!humpty!scowles

============================================================
#!/bin/sh
# script for assisting in setting up anonymous ftp under Solaris 2.1.
# original from ogpaik@caltech.edu (Oon-Gil Paik).
# modifications and additional comments added by scowles@scheffer.stanford.edu.
# sccsid: @(#)anonftpsetup 1.3 13:40:28 93/05/06
#
# From ogpaik@caltech.edu Wed May 5 22:46 PDT 1993
# Date: Wed, 5 May 93 22:34:08 PDT
# From: ogpaik@caltech.edu (Oon-Gil Paik)
# To: scowles@toolik.stanford.edu
# 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

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



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:49 CDT