anon FTP: makefile to create and maintain directory

Doug Moran moran at warbucks.ai.sri.com
Wed May 9 08:51:54 AEST 1990


Below is a Makefile that incorporates the instructions for setting up a
directory for anonymous FTP under SunOS 4.0.x.  I use it to create the
directory and then have CROND run it weekly to update any changed binaries
or libraries.

-- Doug Moran, AI Center, SRI International

======================================================================
# 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
======================================================================



More information about the Comp.sys.sun mailing list