Subject: Wu-FTPD under Solaris 2.4 ???

From: [email-masked]
Date: Fri, 29 Sep 1995 11:16:47 +0100 (MET)

Hello!

After using wu-ftpd for quite some time on a SunOS 4.x box, we are now
of necessity switching to a Solaris box.

Building wu-ftpd 2.4 for Solaris (with gcc 2.6.3) goes without a hitch (no
error messages, and then ftpd behaves just fine -- until you do anything
that requires it to open a socket back to the remote machine. Then it
reports,

	425 Can't create data socket (0.0.0.0,20): Bad file number.

Running it under truss  shows that this is due to an attempt to open /dev/tcp
for reading and writing, which under Solaris is a symlink to
/devices/pseudo/clone@0:tcp, which has permissions 0666, just as
/dev/tcp does under SunOS.

Any clues anybody?
-- 
W. N. Paul/KSRU * Alcatel Austria AG * Scheydgasse 41 * A-1210 Vienna, Austria 
[email-masked] * +43-1-277-22 x2523 (voice)/x118 (fax) * +43-1-774-1947 (h)
"Never attribute to malice that which can be adequately explained by stupidity."
"Wo Dummheit als Erklaerung ausreicht, sollte man nicht nach Bosheit suchen."

---

From: [email-masked] (Andy Wessels)
Date: Fri, 29 Sep 1995 09:20:42 -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: 47

----- Begin Included Message -----

Any clues anybody?

----- End Included Message -----

I had the same problem.   What I ended up doing was to remove the ~ftp tree and
started from groupnd zero.  After you compile the ftpd binaries and get them
installed, and make sure that you have an entry in the /etc/passwd file.

Do a man on in.ftpd--this will show the ftpd manpage from sun.  Look in there
for a script.  You can use this script to build the archive tree.  Note that
you may get an error that mknod cannot create for ticots and ticotsord.  Sun
has changed their names, at least on the US version of 2.4 (3/95 release).
The easiest way around this is to edit the script.  Look for the section where
the tcp, ticots, and ticotsord devices are made.   Copy this whole section.  I
believe it was about 10 lines or so.  Remove ticots and ticotsord from the first
section, change the basename in the second section, and delete tcp in the
second. Be sure to change the variable 'prefix' in the second part.  See the
attached script--this is straight from the man page.  I make no claim of writing
this except for the modification noted above.

You should be able to now do a 'ls' on the directory when you come in as
anonymous.  Now, here is where I am having problems.  ls works, but not ls -l.
I have traced the library calls, and ls -l is trying to open the libraries in
/usr/openwin/lib (?!?!?)  setting up a link from /usr/openwin/lib to /usr/lib
does not seem to help.  Any ideas??

andy.
[email-masked]

----------
X-Sun-Data-Type: shell-script
X-Sun-Data-Description: shell-script
X-Sun-Data-Name: setup.anon.ftp
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 149

#!/bin/sh
# script to setup SunOS 5.3 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} for SunOS 5.3

     # 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

     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.
     prefix="/devices/pseudo/mm@0:"

     for device in zero
     do
        line=`ls -l ${prefix}${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

    # This prefix does not work. need to change.
    prefix="/devices/pseudo/clone@0:"
    # prefix="/devices/pseudo/tl@0:"

     for device in tcp udp 
     do
        line=`ls -l ${prefix}${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
     
     prefix="/devices/pseudo/tl@0:"

     for device in ticotsord
     do
        line=`ls -l ${prefix}${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