Remove dependence on 'which'

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@2421 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2005-07-27 20:30:16 +00:00
parent 91fb066029
commit 6c8b63bfe0
5 changed files with 48 additions and 17 deletions

View File

@ -1,4 +1,10 @@
Changes in 2.5.1ex
Changes in 2.5.1
1) Make "shorewall add" work with 'ipsec' in hosts file.
2) Remove dependence on 'which'
Changes in 2.5.1ex/2.5.0
1) Clean up handling of zones

View File

@ -1734,7 +1734,7 @@ disable_ipv6() {
local foo="$(ip -f inet6 addr ls 2> /dev/null)"
if [ -n "$foo" ]; then
if qt which ip6tables; then
if qt mywhich ip6tables; then
save_progress_message "Disabling IPV6..."
ip6tables -P FORWARD DROP && save_command ip6tables -P FORWARD DROP
ip6tables -P INPUT DROP && save_command ip6tables -P INPUT DROP
@ -1749,7 +1749,7 @@ disable_ipv6_1() {
local foo="$(ip -f inet6 addr ls 2> /dev/null)"
if [ -n "$foo" ]; then
if qt which ip6tables; then
if qt mywhich ip6tables; then
progress_message "Disabling IPV6..."
ip6tables -P FORWARD DROP
ip6tables -P INPUT DROP
@ -2084,7 +2084,7 @@ clear_firewall() {
echo 1 > /proc/sys/net/ipv4/ip_forward
if qt which ip6tables; then
if qt mywhich ip6tables; then
ip6tables -P INPUT ACCEPT 2> /dev/null
ip6tables -P OUTPUT ACCEPT 2> /dev/null
ip6tables -P FORWARD ACCEPT 2> /dev/null
@ -6627,6 +6627,8 @@ add_ip_aliases()
ensure_and_save_command ip addr add ${external}${val} dev $interface $label
fi
qt mywhich arping && run_and_save_command qt arping -U -c 2 -I $interface $external
echo "$external $interface" >> /var/lib/shorewall/nat
[ -n "$label" ] && label="with $label"
progress_message " IP Address $external added to interface $interface $label"
@ -6741,7 +6743,7 @@ determine_capabilities() {
qt $IPTABLES -t mangle -X fooX1234
if qt which ipset; then
if qt mywhich ipset; then
qt ipset -X fooX1234 # Just in case something went wrong the last time
if qt ipset -N fooX1234 iphash ; then
@ -8519,7 +8521,7 @@ do_initialize() {
load_kernel_modules
if [ -z "$IPTABLES" ]; then
IPTABLES=$(which iptables 2> /dev/null)
IPTABLES=$(mywhich iptables 2> /dev/null)
[ -z "$IPTABLES" ] && startup_error "Can't find iptables executable"
else

View File

@ -223,7 +223,7 @@ loadmodule() # $1 = module name, $2 - * arguments
local suffix
moduleloader=modprobe
if ! qt which modprobe; then
if ! qt mywhich modprobe; then
moduleloader=insmod
fi
@ -282,7 +282,7 @@ mutex_on()
[ -d /var/lib/shorewall ] || mkdir -p /var/lib/shorewall
if qt which lockfile; then
if qt mywhich lockfile; then
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
@ -316,7 +316,7 @@ mutex_off()
# STD - mktemp.org mktemp
#
find_mktemp() {
local mktemp=`which mktemp 2> /dev/null`
local mktemp=`mywhich mktemp 2> /dev/null`
if [ -n "$mktemp" ]; then
if qt mktemp -V ; then
@ -784,3 +784,19 @@ find_interface_addresses() # $1 = interface
{
ip -f inet addr show $1 | grep inet | sed 's/inet //;s/\/.*//;s/ peer.*//'
}
#
# Internal version of 'which'
#
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
echo $dir/$1
return 0
fi
done
return 2
}

View File

@ -1,6 +1,13 @@
Shorewall 2.5.0
Shorewall 2.5.1
Problems Corrected:
Problems Corrected in 2.5.1:
1) Shorewall is no longer dependent on the 'which' utility.
2) "shorewall add" no longer fails when the 'ipsec' option has appeared
in /etc/shorewall/hosts.
Problems Corrected in 2.5.0:
1) The behavior of CONTINUE policies has been improved. Shorewall no
longer generates a useless policy chain corresponding to these

View File

@ -150,7 +150,7 @@ showchain() # $1 = name of chain
iptablesbug()
{
if qt which awk ; then
if qt mywhich awk ; then
awk 'BEGIN {sline=""; };\
/^-j/ { print sline $0; next };\
/-m policy.*-j/ { print $0; next };\
@ -209,7 +209,7 @@ get_config() {
exit 2
fi
else
IPTABLES=$(which iptables 2> /dev/null)
IPTABLES=$(mywhich iptables 2> /dev/null)
if [ -z "$IPTABLES" ] ; then
echo " ERROR: Can't find iptables executable" >&2
exit 2
@ -355,7 +355,7 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
timeout=$1
fi
qt which awk && haveawk=Yes || haveawk=
qt mywhich awk && haveawk=Yes || haveawk=
while true; do
clear_term
@ -747,7 +747,7 @@ case "$1" in
esac
if [ -n "$FAST" ]; then
if qt which make; then
if qt mywhich make; then
make -qf /etc/shorewall/Makefile || FAST=
fi
@ -934,7 +934,7 @@ case "$1" in
echo
ip -stat link ls
if qt which brctl; then
if qt mywhich brctl; then
echo
echo "Bridges"
echo
@ -979,7 +979,7 @@ case "$1" in
echo
arp -na
if qt which lsmod; then
if qt mywhich lsmod; then
echo
echo "Modules"
echo