[comp.unix.internals] anonymous ftp problem

beig%FRULM63.BITNET%CUNYVM.CUNY.EDU@vm1.nodak.edu (Jacques Beigbeder) (11/29/90)

The message is clear enough: you have no file /usr/lib/ld.so
To be more explicit, the anonymous ftp put you in a new / (with a chroot)
and you must find from this new root all the softwares: for instance ls.
But ls is dynamically linked, so it uses /usr/lib/ld.so, /dev/zero, etc.

Here is a shell which sets up an anonymous ftp.

  --Jacques Beigbeder
----------------------------------------
# Usage:
#       "make" ("make all") creates/updates the anonymous FTP directory tree.
#       "make PubList" to see the list of files in your "public" directories.
#               (included in "make all").
# Suggested that this makefile be invoked periodically by cron.
#   For example, use the following as a _single_ line entry in crontab.
#       0 6 * * 2 if ypmatch ftp passwd > /dev/null 2>&1 ; then
#               csh -c 'cd ~ftp ; set MF=/usr/local/etc/anon_ftp.mk;
#               make -f $MF MAKEFILE=$MF all |&
#               /usr/ucb/mail -s "~FTP maintenance" MOPER2' ; fi
#
# WARNING: the most natural place to put this makefile is in ~ftp, but don't.
#       Since it is run by crond as root, do not have it accessible to
#       anonymous FTP (ie, don't trust file protections in ~ftp to protect it).
#
# Author: Douglas B. Moran, Artificial Intelligence Center, SRI International
# Date Last Mod: $Date: 90/05/08 15:49:41 $

SHELL=/bin/sh

all : bin/ls UpdateEtc DynamicLibs PubDirs PubList

DynamicLibs : usr/lib/ld.so dev/zero libc

#       Update the files in ~ftp/bin when the corresponding files change
#               in the real system directories
#       NOTE: symbolic links cannot be used to the files in the system
#               directories because FTP (release 1.2) does NOT
#               follow symbolic links.
#       However, it does follow symbolic links for passwords and groups
#               (i.e. local functions??).

UpdateEtc: etc/passwd etc/group
PubDirs : incoming pub

bin etc dev usr usr/lib :
        @echo 'Creating directory ~ftp/$@'
        @mkdir -p $@
        @chmod 555 $@
usr/lib : usr

#               Having lib as symbolic link to usr/lib may not be necessary,
#               but it seems that having libc.so.* in usr/lib (as opposed
#               to being in lib) is necessary.
lib : usr/lib
        @echo 'Creating directory ~ftp/$@ as symbolic link to ~ftp/usr/lib'
        @ln -s usr/lib lib

incoming :
        @echo 'Creating directory ~ftp/$@'
        @mkdir $@
        @chown ftp $@
        @chmod 777 $@
pub :
        @echo 'Creating directory ~ftp/$@'
        @mkdir $@
        @chown ftp $@
        @chmod 755 $@

bin/ls : bin /bin/ls
        @echo 'Installing updated/new LS command'
        @/bin/rm -f $@
        @cp -p /$@ $@
        @chmod 111 $@

dev/zero : dev
        @echo 'Creating device' $@
        @mknod $@ c 3 12  ; chmod 666 $@

usr/lib/ld.so : usr/lib /usr/lib/ld.so
        @echo 'Installing updated/new' $@
        @cp -p /$@ $@
        @chmod 555 $@

libc : lib
        @LIBC=`ldd /bin/ls | sed 's;^.*=> /;;'| tr -d '\015' ` ; \
          make -f $$MAKEFILE LIBC_CUR=$$LIBC $$LIBC
#           "tail -1" works in most cases.  Exceptions: when libc.so.N.10
#           supercedes libc.so.N.9, and when the current version libc.so.N.I
#           but /bin/ls uses libc.so.M.J (M < N).  Using "sort" instead
#           would handle the former, but not the latter.
#       @LIBC=`cd / ; ls lib/libc.so* | tail -1` ;  make ...

$$LIBC_CUR : /$$LIBC_CUR
        @echo 'Installing updated/new LIBC shared library: ' $@
        @cp -p /$@ $@
        @chmod 555 $@

#       The real tables should include the minimum info need by anonymous ftp
#       (eg, do not give away user names and encrypted passwds).
#       Note: Created but not updated (these entries are rarely changed).
etc/passwd : etc
        @echo 'Creating $@ file'
        @egrep '^(root|bin|ftp):' /$@ | sed 's;^\([^:]*\):[^:]*:;\1:*:;' > $@
        @chmod 444 $@

etc/group : etc
        @echo 'Creating $@ file'
        @egrep '^(wheel|bin|ftp):' /$@.yp > $@
        @chmod 444 $@

# notify operator of any files in pub
PubList :
        @-for D in pub incoming ; do \
            echo '' ; \
            if [ -d $$D ] ; then \
                echo "The files in ~ftp/$$D are:" ; \
                ls -lAR $$D ; \
            fi ; \
        done

dnb@meshugge.media.mit.edu (David N. Blank) (11/30/90)

Howdy-

> Here is a shell which sets up an anonymous ftp.

It took myslef and someone else quite a bit of head-scratching to make
your shell work under SunOS 4.1 entirely.  Specifically, the line:

> $$LIBC_CUR : /$$LIBC_CUR

which contains the variable target for the copying of the current shared
library does not work until changed to:

 $(LIBC_CUR) : /$(LIBC_CUR)

I hope this helps others who were equally stymied.  Please pass this
change on to the author (Douglas B. Moran, Artificial Intelligence
Center, SRI International).  Thanks.

         Peace,
            dNb