First complete implementation.
1 parent a2e065f commit e51ef4739c235443e64ba24fec963db440aa9932
@tundra tundra authored on 28 Apr 2006
Showing 1 changed file
View
78
rebuild-hosts.allow.sh 0 → 100755
#!/bin/sh
# rebuild-hosts.allow.sh
# Rebuild /etc/hosts.allow From Standard And User-Requested Entries
# Part Of The 'tperimeter' Package
#
# Copyright (c) 2006 TundraWare Inc., Des Plaines, IL USA
# All Rights Reserved
# $Id: rebuild-hosts.allow.sh,v 1.100 2006/04/28 23:04:53 tundra Exp $
 
BASE="/usr/local/etc/tperimeter"
EPILOGUE=${BASE}/epilogue
PROLOGUE=${BASE}/prologue
STANDARD=${BASE}/allow
USERREQUESTS="/www/cgi-bin/perimeter/requests"
 
#####
# Function To Scan A Directory Structure To Build
# "Allow" Entries In Proper /etc/hosts.allow Format
#####
 
BuildAllowEntries()
{
if [ -d $1 ] # Only attempt this if the target directory exists
then
cd $1
for x in *
do
echo -n $x": "
cd $x
for y in *
do
echo -n $y" "
done
echo " :ALLOW"
cd ..
done
fi
}
# End Of 'BuildAllowEntries()'
 
#####
# Rebuild /etc/hosts-allow
#####
 
# Timestamp it
 
echo "# Built On: `date`"
echo ""
 
# First, the standard prologue
 
cat ${PROLOGUE}
 
 
# Add any user-requested temporary additions
 
echo "# Access Requested Via The 'tperimeter' Interface"
echo ""
 
BuildAllowEntries ${USERREQUESTS}
 
 
# Delete the user requests
 
rm -rf ${USERREQUESTS}
 
 
# Now include the standard set of access definitions
 
echo ""
echo "# Standard 'Allow' Entries"
echo ""
 
BuildAllowEntries ${STANDARD}
 
# Finally, add the epilogue
 
cat ${EPILOGUE}