2 # dump assorted information of use in debugging
3 # Copyright (C) 1998, 1999 Henry Spencer.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # RCSID $Id: barf,v 1.65 2002/03/26 17:49:42 henry Exp $
17 KERNSRC=${KERNSRC-/usr/src/linux}
19 CONFS=${IPSEC_CONFS-/etc}
22 # message patterns that start relevant parts of logs
23 fstart='Starting FreeS.WAN'
24 pstart='Starting Pluto subsystem'
27 --help) echo "Usage: ipsec barf" ; exit 0 ;;
28 --version) echo "$me $IPSEC_VERSION" ; exit 0 ;;
31 # make sure output is in English
32 unset LANG LANGUAGE LC_ALL LC_MESSAGES
34 # log-location guesser, results in $findlog_file and $findlog_startline
35 # Fine point: startline is the *last* line containing "string", or
36 # failing that, the *first* line containing "fallbackstring".
37 findlog() { # findlog string fallbackstring possiblefile ...
42 # try the suggested files first
45 if test -r $LOGS/$f -a ! -d $LOGS/$f && egrep -q "$s" $LOGS/$f
47 # aha, this one has it
49 findlog_startline=`egrep -n "$s" $LOGS/$f |
56 if test -r $LOGS/$f -a ! -d $LOGS/$f && egrep -q "$t" $LOGS/$f
58 # aha, this one has it
60 findlog_startline=`egrep -n "$t" $LOGS/$f |
65 # nope, resort to a search, newest first, of uncompressed logs
66 for f in `ls -t $LOGS | | egrep -v '^mail' | egrep -v '\.(gz|Z)$'`
68 if test -r $LOGS/$f -a ! -d $LOGS/$f && egrep -q "$s" $LOGS/$f
72 findlog_startline=`egrep -n "$s" $LOGS/$f |
77 for f in `ls -t $LOGS | egrep -v '^mail' | egrep -v '\.(gz|Z)$'`
79 if test -r $LOGS/$f -a ! -d $LOGS/$f && egrep -q "$t" $LOGS/$f
83 findlog_startline=`egrep -n "$t" $LOGS/$f |
88 echo "$0: unable to find $LOGS/$1 or local equivalent" >&2
89 findlog_file=/dev/null
90 findlog_startline=1 # arbitrary
93 # try to guess where logs are
94 findlog "$fstart" "klips" messages syslog
96 kline=$findlog_startline
97 findlog "$pstart" "Pluto" secure auth.log debug
99 pline=$findlog_startline
101 # /lib/modules examiner
104 for d in `ls /lib/modules`
106 if test -d /lib/modules/$d
111 nm -g $f | egrep "$2"
120 # advanced shell deviousness to get dividers into output
121 _________________________() {
122 $2 # something to do nothing and not echo anything
125 exec 2>&1 # stderr on stdout, so errors go into main output
129 _________________________ version
131 _________________________ proc/version
133 _________________________ proc/net/ipsec_eroute
134 sort +3 /proc/net/ipsec_eroute || cat /proc/net/ipsec_eroute
135 _________________________ proc/net/ipsec_spi
136 cat /proc/net/ipsec_spi
137 _________________________ proc/net/ipsec_spigrp
138 cat /proc/net/ipsec_spigrp
139 _________________________ netstart-rn
141 _________________________ proc/net/ipsec_tncfg
142 cat /proc/net/ipsec_tncfg
143 _________________________ proc/net/pf_key
145 _________________________ proc/net/pf_key-star
146 ( cd /proc/net ; egrep '^' pf_key_* )
147 _________________________ proc/sys/net/ipsec-star
148 ( cd /proc/sys/net/ipsec ; egrep '^' * )
149 _________________________ ipsec/status
151 _________________________ ifconfig-a
153 _________________________ ipsec/directory
155 _________________________ hostname/fqdn
157 _________________________ hostname/ipaddress
158 hostname --ip-address
159 _________________________ uptime
161 _________________________ ps
162 # -i ppid picks up the header
163 ps alxwf | egrep -i 'ppid|pluto|ipsec|klips'
164 _________________________ ipsec/showdefaults
166 _________________________ ipsec/conf
167 ipsec _include $CONFS/ipsec.conf | ipsec _keycensor
168 _________________________ ipsec/secrets
169 ipsec _include $CONFS/ipsec.secrets | ipsec _secretcensor
170 _________________________ ipsec/ls-dir
171 ls -l ${IPSEC_DIR-/usr/local/lib/ipsec}
172 _________________________ ipsec/updowns
173 for f in `ls ${IPSEC_DIR-/usr/local/lib/ipsec} | egrep updown`
175 cat ${IPSEC_DIR-/usr/local/lib/ipsec}/$f
177 _________________________ proc/net/dev
179 _________________________ proc/net/route
181 _________________________ proc/sys/net/ipv4/ip_forward
182 cat /proc/sys/net/ipv4/ip_forward
183 _________________________ proc/sys/net/ipv4/conf/star-rp_filter
184 ( cd /proc/sys/net/ipv4/conf ; egrep '^' */rp_filter )
185 _________________________ uname-a
187 _________________________ redhat-release
188 if test -r /etc/redhat-release
190 cat /etc/redhat-release
192 _________________________ proc/net/ipsec_version
193 cat /proc/net/ipsec_version
194 _________________________ iptables/list
196 _________________________ ipchains/list
198 _________________________ ipfwadm/forward
200 _________________________ ipfwadm/input
202 _________________________ ipfwadm/output
204 _________________________ iptables/nat
205 iptables -t nat -L -v -n
206 _________________________ ipchains/masq
208 _________________________ ipfwadm/masq
210 _________________________ iptables/mangle
211 iptables -t mangle -L -v -n
212 _________________________ proc/modules
214 _________________________ proc/meminfo
216 _________________________ dev/ipsec-ls
218 _________________________ proc/net/ipsec-ls
219 ls -l /proc/net/ipsec_*
220 _________________________ usr/src/linux/.config
221 if test -f $KERNSRC/.config
223 egrep 'IP|NETLINK' $KERNSRC/.config
225 _________________________ etc/syslog.conf
227 _________________________ lib/modules-ls
229 _________________________ proc/ksyms-netif_rx
230 egrep netif_rx /proc/ksyms
231 _________________________ lib/modules-netif_rx
232 modulegoo kernel/net/ipv4/ipip.o netif_rx
233 _________________________ kern.debug
234 if test -f $LOGS/kern.debug
236 tail -100 $LOGS/kern.debug
238 _________________________ klog
239 sed -n $kline,'$'p $klog |
240 egrep -i 'ipsec|klips|pluto' |
242 --short) tail -500 ;;
245 _________________________ plog
246 sed -n $pline,'$'p $plog |
249 --short) tail -500 ;;
252 _________________________ date