Subject: Re: Wrong Time Zone (Solaris)

From: [email-masked]
Date: Wed, 24 Apr 1996 12:21:39 -0700

> From: [email-masked]
> To: [email-masked]
> Subject: Wrong Time Zone (Solaris)
 
> 
> Probably not.  You need to read the original man page for ftpd on Solaris. 
> It details the time zone database that needs to be copied to the ftp root. 
> You will need the information in /usr/share/lib/zoneinfo to be duplicated
> in ~ftp.  Once you have whatever is necessary in this directory, you will
> get local time and date stamps correctly on an ls -l or dir command.  

Well, unfortunately, the man page for Solaris 2.4/in.ftpd, while it
mentions all sorts of things, it does not mention /etc/TIMEZONE, nor
does it mention /usr/lib/share/zoneinfo at all.  I have copied both
/etc/TIMEZONE and /usr/lib/share/zoneinfo/* into the anonymous
area, and made sure they were readable, but still can not get it
to work.

Help???

>>Ericw

---

From: [email-masked]
Date: Wed, 24 Apr 96 19:42:15 0500

>> Probably not.  You need to read the original man page for ftpd on Solari
>> It details the time zone database that needs to be copied to the ftp roo
>> You will need the information in /usr/share/lib/zoneinfo to be duplicate
>> in ~ftp.  Once you have whatever is necessary in this directory, you wil

>mentions all sorts of things, it does not mention /etc/TIMEZONE, nor does
>it mention /usr/lib/share/zoneinfo at all.  I have copied both
>/etc/TIMEZONE and /usr/lib/share/zoneinfo/* into the anonymous area, and
>made sure they were readable, but still can not get it to work.

Oops.  Maybe I read it somewhere else.  I appologize for making the
reference without checking (I destroyed the original man page with the
installation of wu-ftpd :-)).  Anyway, here's the (Korn) shell script we
use to create the environment on our virtual Web servers for wu-ftp.  It
does the trick.  (We have a script for adding virtual ftp users on the
same servers, if you're interested.)  It may be possible to cut down on
the shared libraries and the timezone database, but I didn't bother
researching that.  The reference to the timezone database is at the end.  

I hope this helps.  

Garry Williams
America Net, Inc.

#!/bin/ksh
#
#	Create the anonymous ftp environment for WU-FTPD
#
#	Usage:
#		ftp-config [-v]
#
#       This script creates the directory structure necessary for the #      
anonymous ftp server.  The essence of the problem is that the #      
anonymous ftp server needs to perform a chroot to some #       directory
to insure that the ftp accesses are secured from the #       system's file
system.  This means that certain directories #       that are normally
available to programs cannot be reached #       after the chroot. 
Specifically, /usr/bin, /usr/lib, /dev, #       and /etc are recreated
under the virtual root along with #       certain files that need to be
there.

#       Input:
#		/etc/passwd
#               /etc/group
#		/bin/{ls,compress}
#		/usr/local/bin/gtar
#		/dev/{tcp,zero,udp,ticotsord}
#		/usr/lib{ld,libc,libdl,libintl,libw,libnsl,libsocket,
#			nss_nis,nss_nisplus,nss_dns,nss_files,straddr}
#			.so.*

#       Output:
#               anonymous ftp directory structure

#       Exits:
#               0 - Normal
#		1 - Syntax error
#		2 - The ftp group ${FTPGROUP} dosn't exist
#		3 - The path for the home directory is invalid
#		4 - Cannot create ftp user
#		5 - The ftp administrator user doesn't exist

#	Changes:
#		Version 1 4/7/96 -- GTW
#		4/11/96 -- Generalized passwd and group file creations

#VERBOSE=TRUE
FTPADMIN=garry			# ftp administrator 
FTPGROUP=misc			# ftp user's group
BASE=/var			# Where to put ftp home directory
PGM=$(basename $0)		# This command's name

#	Process the command line

if [ $# -eq 0 ]
then
	:
elif [ "$1" = "-v" -o "$1" = "v" ]
then
	VERBOSE=TRUE
else
	echo "${PGM}: Invalid parameter"
	echo "${PGM}: Usage: ${PGM} [-v]"
	exit 1
fi

#	Check if ftp group exists

if grep ${FTPGROUP} /etc/group > /dev/null
then
	:
else
	echo "${PGM}: The ftp group (${FTPGROUP}) does not exist"
	exit 2
fi

#	Check if path for ftp home directory exists

if [ ! -d ${BASE} ]
then
	echo "${PGM}: ${BASE} does not exist - cannot create ftp home directory"
	exit 3
fi

#	Check to make sure ${FTPADMIN} exists

if grep "^${FTPADMIN}:" /etc/passwd > /dev/null
then
	:
else
	echo "${PGM}: The ftp administrator login ${FTPADMIN} does not exist"
	echo "${PGM}: Either add the ${FTPADMIN} user to this system or "
	echo "${PGM}:   edit the script $0 to set another user ID"
	exit 5
fi

#	Create the ftp user's home directory

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: Creating ftp home directory in ${BASE}"
fi
cd ${BASE}
mkdir ftp
chown root:${FTPGROUP} ftp
chmod 555 ftp

#	Create the ftp user

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: Creating ftp user with home=${BASE}/ftp, shell=/bin/false"
fi
if useradd -g $FTPGROUP -c "Anonymous FTP" -d ${BASE}/ftp -s /bin/false
ftp then
	:
else
	echo "${PGM}: useradd failed for user ftp"
	rmdir ${BASE}/ftp
	exit 4
fi
passwd -l ftp

#	Create the ftp user's home directory structure

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: Creating ftp directory structure in ${BASE}/ftp" fi

cd ~ftp
for dirs in \
	usr usr/bin usr/lib etc pub dev \
	usr/share usr/share/lib usr/share/lib/zoneinfo
do
	mkdir ${dirs}
	chown root:${FTPGROUP} ${dirs}
	chmod 111 ${dirs}
done

#       Copy programs we need

cp /bin/ls /bin/compress /usr/local/bin/gtar usr/bin
chmod 111 usr/bin/*
ln -s usr/bin bin

#	Set up the pub directory
chown ${FTPADMIN}:${FTPGROUP} pub
chmod 2755 pub

# make device nodes. ticotsord and udp are necessary for
# 'ls' to resolve NIS names.

# I got this from the Solaris ftpd man page.  The idea is to create #
copies of the existing special files and insure that the node # numbers
are correct.  Look at an ls -lL of stuff in /dev to see # what's happening
here.

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: making necessary device nodes in ${BASE}/ftp/dev" fi

for device in zero tcp udp ticotsord
do
        line=$(ls -lL /dev/${device} | sed -e 's/,//')
        major=$(echo $line | awk '{print $5}')
        minor=$(echo $line | awk '{print $6}')
        rm -f ${BASE}/ftp/dev/${device}
        mknod ${BASE}/ftp/dev/${device} c ${major} ${minor}
done

chmod 666 ${BASE}/ftp/dev/*

## Now set the ownership and modes
chown root:root ${BASE}/ftp/dev
chmod 555 ${BASE}/ftp/dev

#	Create the ~ftp/etc/passwd and ~ftp/etc/group files

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: creating etc/passwd and etc/group files"
fi

cd ~ftp
ftpentry=$(grep '^ftp:' /etc/passwd)
rootentry=$(grep '^root:' /etc/passwd)
daemonentry=$(grep '^daemon:' /etc/passwd)
binentry=$(grep '^bin:' /etc/passwd)
sysentry=$(grep '^sys:' /etc/passwd)
admentry=$(grep '^adm:' /etc/passwd)
uucpentry=$(grep '^uucp:' /etc/passwd)
adminentry=$(grep "^${FTPADMIN}:" /etc/passwd)

echo "$rootentry
$daemonentry
$binentry
$sysentry
$admentry
$uucpentry
$adminentry
$ftpentry
" > etc/passwd

rootentry=$(grep '^root:' /etc/group)
otherentry=$(grep '^other:' /etc/group)
binentry=$(grep '^bin:' /etc/group)
sysentry=$(grep '^sys:' /etc/group)
admentry=$(grep '^adm:' /etc/group)
uucpentry=$(grep '^uucp:' /etc/group)
miscentry=$(grep "^${FTPGROUP}:" /etc/group)
wwwentry=$(grep '^www:' /etc/group)
staffentry=$(grep '^staff:' /etc/group)
daemonentry=$(grep '^daemon:' /etc/group)

echo "$rootentry
$otherentry
$binentry
$sysentry
$admentry
$uucpentry
${staffentry}
$daemonentry
${wwwentry}
${miscentry}
" > etc/group

chmod 444 ~ftp/etc/passwd ~ftp/etc/group
chown root:${FTPGROUP} ~ftp/etc/passwd ~ftp/etc/group

#	Create ftpaccess file and associated files

echo "loginfails 3
class   all     real,guest,anonymous    *

limit   all     20      Any     /etc/msgs/ftp.full

readme  README* login
readme  README* cwd=*

message /welcome.msg    login
message .message        cwd=*

compress        yes     local   remote
tar             yes     local   remote

log     commands        real
log     transfers       anonymous,real  inbound,outbound

#shutdown       /etc/msgs/ftp-shut-message

deny    !nameserved     /etc/msgs/ftp-deny-notnameserved

passwd-check    rfc822  warn

# all the following default to yes for everybody
delete          no      anonymous       # delete permission?
overwrite       no      anonymous       # overwrite permission? rename         
no      anonymous       # rename permissions?
chmod           no      anonymous       # chmod permission?
umask           no      anonymous       # umask permission?

# Upload directory
upload  /var/ftp   *            no
upload  /var/ftp   /incoming    yes     ftp     daemon  0643

# path-filter...
path-filter     anonymous  /etc/msgs/pathmsg  ^[-A-Za-z0-9_\.]*$  ^\.  ^-
path-filter     guest      /etc/msgs/pathmsg  ^[-A-Za-z0-9_\.]*$  ^\.  ^-

email   [email-masked]
" > /etc/ftpaccess

if [ ! -d /etc/msgs ]
then
	mkdir /etc/msgs
fi
echo "Too many ftp users at this time.  There are %M users allowed. Please
try again later." > /etc/msgs/ftp.full

echo "This is %L (America Net, Inc.) ftp Server -- Welcome.
You are user number %N and logged in from %R.
You logged in as %U (%T).
All files are found in the /pub directory.
Send all comments or reports of problems to %E." > ~ftp/welcome.msg

echo "1999 11 31 08 00 0015 0001 
The line above indicates the scheduled time of shutdown for the server.
The year (any year > 1970) month (0-11) day (0-31) hour (0-23) minute
(0-59) deny-offset (HHMM) and disconnect-offset (HHMM).
This text will be displayed and the following will be substituted:
	%s	time system is going to be shut down
	%r	time new connections will be denied
	%d	time current connections will be dropped
Edit this file to something more appropriate and then uncomment the 
shutdown statement in the /etc/ftpaccess file to activate the shutdown
warnings to ftp users." > /etc/msgs/ftp-shut-message

chmod 444 /etc/ftpaccess \
	/etc/msgs/ftp.full \
	/etc/msgs/ftp-shut-message \
	~ftp/welcome.msg

#	Create the shared libraries ls needs after chroot

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: Creating shared libraries"
fi

cd ~ftp
chown bin:bin usr/lib
chmod 555 usr usr/lib

cd ~ftp/usr/lib
for lib in\
	ld libc libdl libintl libw libnsl libsocket\
	nss_nis nss_nisplus nss_dns nss_files straddr 
do
	cp /usr/lib/${lib}.so* .
	chown bin:bin ${lib}.so*
	chmod 555 ${lib}.so*
done

#	Create timezone database

if [ "${VERBOSE}" = "TRUE" ]
then
	echo "${PGM}: Creating timezone database"
fi

cd ~ftp
chown root:root usr/share usr/share/lib usr/share/lib/zoneinfo chmod 555
usr/share usr/share/lib usr/share/lib/zoneinfo
cp -r /usr/share/lib/zoneinfo/* usr/share/lib/zoneinfo
chmod -R -w usr/share/lib/zoneinfo/*

#	Finished

echo "${PGM}: $(date) -- Anonymous ftp environment set up"
exit 0