#! /bin/sh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # tcpip720 src/tcpip/usr/samples/tcpip/anon.users.ftp 1.2 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2002 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG * @(#)08 1.2 src/tcpip/usr/samples/tcpip/anon.users.ftp, tcpfilexfr, tcpip720 10/18/02 14:23:03 # # COMPONENT_NAME: TCPIP anon.users.ftp # # FUNCTIONS: # # ORIGINS: 27 # # (C) COPYRIGHT International Business Machines Corp. 1985, 1989 # All Rights Reserved # Licensed Materials - Property of IBM # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # # NOTICE TO FTPUSERS OF THE SOURCE CODE EXAMPLES # # INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE # EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT # WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT # LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE # OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, # IS WITH YOU. SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE # DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION # DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR # CORRECTION. # # RISC System/6000 is a trademark of International Business Machines # Corporation. # # # # Shell script to create login account for anonymous ftp users: # use any name that you want and that user will be set up similar # to the user 'anonymous'. # # Syntax: anon.users.ftp # CMD=`basename $0` PATH=/etc:/bin:/usr/bin export PATH TERM=ibm6153 export TERM umask 0 FTPUSER=$1 if [ $# -lt 1 ]; then echo "$CMD: Insufficient parameters" echo "\nusage: ${CMD} username" exit 1 fi if [ -z "`/usr/bin/id | /bin/grep 'uid=0'`" ] then echo 'sorry, you must be root to run this script.' exit fi if [ -n "`/bin/grep \^$FTPUSER: /etc/passwd`" ] then echo "Warning: user \"$FTPUSER\" already exists, proceeding anyway." fi echo "Creating $FTPUSER as an anonymous ftp user." # Now run the mkuser command to create user. /bin/mkuser $FTPUSER 1>/dev/null echo "Added user $FTPUSER." # get the home directory of ftp user from /etc/passwd. FTPHOME=`/bin/grep "^$FTPUSER:" /etc/passwd | /usr/bin/cut -d: -f6` # # make sure that FTPHOME is reasonable, to protect against # outherwise disastrous results. # if [ -z "$FTPHOME" ]; then echo "$FTPUSER login directory not set." exit 1; fi if [ ! -d "$FTPHOME" ]; then echo "$FTPHOME: not a directory." exit 1 fi case $FTPHOME in /|/etc|/bin|/usr|/usr/bin|/dev) echo "$FTPHOME: not a wise choice." exit 1 ;; *) /bin/echo "Are you sure you want to modify $FTPHOME? " read answer case x$answer in x[Yy]*) ;; *) exit 1 ;; esac ;; esac # make $FTPHOME/bin directory cd $FTPHOME mkdir bin chown root bin cp /bin/ls $FTPHOME/bin/ls chmod 111 $FTPHOME/bin/ls chmod 555 $FTPHOME/bin chgrp system $FTPHOME/bin echo "Made $FTPHOME/bin directory." # make $FTPHOME/etc directory mkdir etc chown root etc chmod 555 etc chgrp system $FTPHOME/etc if [ -f /etc/nls/ctab/default ] then mkdir etc/nls mkdir etc/nls/ctab cp /etc/nls/ctab/default etc/nls/ctab/default chmod 2755 $FTPHOME/etc/nls chmod 2755 $FTPHOME/etc/nls/ctab chown root $FTPHOME/etc/nls chgrp system $FTPHOME/etc/nls chown root $FTPHOME/etc/nls/ctab chgrp system $FTPHOME/etc/nls/ctab chown root $FTPHOME/etc/nls/ctab/default chgrp system $FTPHOME/etc/nls/ctab/default fi echo "Made $FTPHOME/etc directory." # make $FTPHOME/pub directory mkdir pub chmod 777 pub chgrp system $FTPHOME/pub echo "Made $FTPHOME/pub directory." # make $FTPHOME/lib directory mkdir lib chmod 555 lib chgrp system $FTPHOME/lib cp /lib/libc.a lib/libc.a cp /lib/libcurses.a lib/libcurses.a cp /lib/libcrypt.a lib/libcrypt.a echo "Made $FTPHOME/lib directory." # make $FTPHOME dev/null entry mkdir dev #do equiv of mknod dev/null c 2 2 /usr/sbin/mknod dev/null c $(ls -l /dev/null | awk '{print $5, $6}' | tr -d ,) chmod 555 dev chown root dev chgrp system dev echo "Made $FTPHOME/dev/null entry." # make $FTPHOME message catalog directory mkdir usr mkdir usr/lpp mkdir usr/lpp/msg mkdir usr/lpp/msg/$LANG chmod 555 usr chown root usr chgrp system usr chmod 555 usr/lpp chown root usr/lpp chgrp system usr/lpp chmod 555 usr/lpp/msg chown root usr/lpp/msg chgrp system usr/lpp/msg chmod 555 usr/lpp/msg/$LANG chown root usr/lpp/msg/$LANG chgrp system usr/lpp/msg/$LANG if [ -f /usr/lpp/msg/$LANG/ls.cat ] then cp /usr/lpp/msg/$LANG/ls.cat usr/lpp/msg/$LANG/ls.cat fi echo "Made $FTPHOME/usr/lpp/msg/$LANG directory." # fix up ftp's root directory chmod 555 $FTPHOME chown root $FTPHOME