2013-03-27 13:40:10 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
|
|
WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
|
2013-08-26 15:47:15 +02:00
|
|
|
WPACLI=$DIR/../../wpa_supplicant/wpa_cli
|
2013-03-27 13:40:10 +01:00
|
|
|
HAPD=$DIR/../../hostapd/hostapd
|
2013-12-27 09:16:50 +01:00
|
|
|
HAPD_AS=$DIR/../../hostapd/hostapd
|
2014-12-25 12:30:54 +01:00
|
|
|
HAPDCLI=$DIR/../../hostapd/hostapd_cli
|
2013-03-27 13:40:10 +01:00
|
|
|
WLANTEST=$DIR/../../wlantest/wlantest
|
2013-09-29 18:14:16 +02:00
|
|
|
HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
|
2014-02-27 16:18:36 +01:00
|
|
|
DATE="$(date +%s)"
|
2013-03-27 13:40:10 +01:00
|
|
|
|
2013-10-30 14:55:58 +01:00
|
|
|
if [ -z "$LOGDIR" ] ; then
|
2013-10-31 13:27:57 +01:00
|
|
|
LOGDIR="$DIR/logs/$DATE"
|
2013-10-30 22:08:10 +01:00
|
|
|
mkdir -p $LOGDIR
|
2013-12-27 09:16:50 +01:00
|
|
|
else
|
|
|
|
if [ -e $LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_supplicant ]; then
|
|
|
|
WPAS=$LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_supplicant
|
2014-12-29 14:47:08 +01:00
|
|
|
WPACLI=$LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_cli
|
2014-12-14 11:24:15 +01:00
|
|
|
# extra code coverage
|
|
|
|
$WPAS > /dev/null 2>&1
|
|
|
|
$WPAS -efoo -Ifoo -mfoo -ofoo -Ofoo -pfoo -Pfoo -h > /dev/null 2>&1
|
|
|
|
$WPAS -bfoo -B -Cfoo -q -W -N -L > /dev/null 2>&1
|
|
|
|
$WPAS -T -v > /dev/null 2>&1
|
|
|
|
$WPAS -u -z > /dev/null 2>&1
|
2013-12-27 09:16:50 +01:00
|
|
|
fi
|
|
|
|
if [ -e $LOGDIR/alt-hostapd/hostapd/hostapd ]; then
|
|
|
|
HAPD=$LOGDIR/alt-hostapd/hostapd/hostapd
|
2014-12-29 14:47:08 +01:00
|
|
|
HAPDCLI=$LOGDIR/alt-hostapd/hostapd/hostapd_cli
|
2014-12-14 11:24:15 +01:00
|
|
|
# extra code coverage
|
|
|
|
$HAPD > /dev/null 2>&1
|
|
|
|
$HAPD -v > /dev/null 2>&1
|
|
|
|
$HAPD -B -efoo -Pfoo -T -bfoo -h > /dev/null 2>&1
|
|
|
|
$HAPD -ufoo > /dev/null 2>&1
|
|
|
|
$HAPD -u00:11:22:33:44:55 > /dev/null 2>&1
|
|
|
|
$HAPD -gfoo > /dev/null 2>&1
|
|
|
|
$HAPD -Gfoo-not-exists > /dev/null 2>&1
|
|
|
|
$HAPD -z > /dev/null 2>&1
|
2016-12-27 13:27:03 +01:00
|
|
|
$HAPD -i foo1,foo2,foo3 > /dev/null 2>&1
|
2013-12-27 09:16:50 +01:00
|
|
|
fi
|
|
|
|
if [ -e $LOGDIR/alt-hostapd-as/hostapd/hostapd ]; then
|
|
|
|
HAPD_AS=$LOGDIR/alt-hostapd-as/hostapd/hostapd
|
2014-02-15 16:07:35 +01:00
|
|
|
fi
|
|
|
|
if [ -e $LOGDIR/alt-hlr_auc_gw/hostapd/hlr_auc_gw ]; then
|
|
|
|
HLR_AUC_GW=$LOGDIR/alt-hlr_auc_gw/hostapd/hlr_auc_gw
|
2014-12-14 11:24:15 +01:00
|
|
|
# extra code coverage
|
|
|
|
$HLR_AUC_GW > /dev/null 2>&1
|
|
|
|
$HLR_AUC_GW -Dfoo -i7 -sfoo -h > /dev/null 2>&1
|
|
|
|
$HLR_AUC_GW -i100 > /dev/null 2>&1
|
|
|
|
$HLR_AUC_GW -z > /dev/null 2>&1
|
2013-12-27 09:16:50 +01:00
|
|
|
fi
|
2013-10-30 14:55:58 +01:00
|
|
|
fi
|
|
|
|
|
2014-02-27 16:18:36 +01:00
|
|
|
if test -w "$DIR/logs" ; then
|
|
|
|
rm -rf $DIR/logs/current
|
|
|
|
ln -sf $DATE $DIR/logs/current
|
|
|
|
fi
|
|
|
|
|
2013-09-29 15:41:17 +02:00
|
|
|
if groups | tr ' ' "\n" | grep -q ^admin$; then
|
|
|
|
GROUP=admin
|
|
|
|
else
|
|
|
|
GROUP=adm
|
|
|
|
fi
|
|
|
|
|
2013-11-08 08:13:14 +01:00
|
|
|
for i in 0 1 2; do
|
|
|
|
sed "s/ GROUP=.*$/ GROUP=$GROUP/" "$DIR/p2p$i.conf" > "$LOGDIR/p2p$i.conf"
|
|
|
|
done
|
|
|
|
|
2015-01-11 19:17:51 +01:00
|
|
|
sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%g" "$DIR/auth_serv/as.conf" > "$LOGDIR/as.conf"
|
|
|
|
sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%g" "$DIR/auth_serv/as2.conf" > "$LOGDIR/as2.conf"
|
2014-02-15 14:57:21 +01:00
|
|
|
|
2013-09-29 15:37:25 +02:00
|
|
|
if [ "$1" = "valgrind" ]; then
|
2013-08-24 19:33:21 +02:00
|
|
|
VALGRIND=y
|
2013-10-30 22:08:10 +01:00
|
|
|
VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
|
|
|
|
VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
|
2013-10-30 18:55:00 +01:00
|
|
|
chmod -f a+rx $WPAS
|
|
|
|
chmod -f a+rx $HAPD
|
2014-06-02 15:20:08 +02:00
|
|
|
chmod -f a+rx $HAPD_AS
|
|
|
|
HAPD_AS="valgrind --log-file=$LOGDIR/valgrind-auth-serv $HAPD_AS"
|
2013-09-29 15:37:25 +02:00
|
|
|
shift
|
2013-08-24 19:33:21 +02:00
|
|
|
else
|
|
|
|
unset VALGRIND
|
2013-10-30 18:43:59 +01:00
|
|
|
VALGRIND_WPAS=
|
|
|
|
VALGRIND_HAPD=
|
2013-08-24 19:33:21 +02:00
|
|
|
fi
|
|
|
|
|
2013-09-29 15:37:25 +02:00
|
|
|
if [ "$1" = "trace" ]; then
|
2013-09-28 09:36:56 +02:00
|
|
|
TRACE="T"
|
2013-09-29 15:37:25 +02:00
|
|
|
shift
|
2013-09-28 09:36:56 +02:00
|
|
|
else
|
|
|
|
TRACE=""
|
|
|
|
fi
|
|
|
|
|
2013-11-02 14:39:25 +01:00
|
|
|
$DIR/stop.sh
|
2014-06-10 19:50:29 +02:00
|
|
|
|
|
|
|
TMP=$1
|
|
|
|
if [ x${TMP%=[0-9]*} = "xchannels" ]; then
|
|
|
|
NUM_CH=${TMP#channels=}
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
NUM_CH=1
|
|
|
|
fi
|
|
|
|
|
2017-10-16 09:32:47 +02:00
|
|
|
test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=0 dyndbg=+p
|
2014-08-05 17:25:59 +02:00
|
|
|
|
2013-03-27 13:40:10 +01:00
|
|
|
sudo ifconfig hwsim0 up
|
2015-11-26 23:12:38 +01:00
|
|
|
sudo $WLANTEST -i hwsim0 -n $LOGDIR/hwsim0.pcapng -c -dtN -L $LOGDIR/hwsim0 &
|
2013-10-30 18:43:59 +01:00
|
|
|
for i in 0 1 2; do
|
2014-12-26 16:44:24 +01:00
|
|
|
DBUSARG=""
|
2017-06-06 10:13:29 +02:00
|
|
|
if [ $i = "0" ] && ([ -r /var/run/dbus/pid ] || [ -r /var/run/dbus/system_bus_socket ]); then
|
2014-12-26 16:44:24 +01:00
|
|
|
if $WPAS | grep -q -- -u; then
|
|
|
|
DBUSARG="-u"
|
|
|
|
fi
|
|
|
|
fi
|
2013-11-08 08:13:14 +01:00
|
|
|
sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $LOGDIR/p2p$i.conf \
|
2014-12-26 16:44:24 +01:00
|
|
|
-ddKt$TRACE -f $LOGDIR/log$i $DBUSARG &
|
2013-10-30 18:43:59 +01:00
|
|
|
done
|
2013-12-30 22:08:25 +01:00
|
|
|
sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \
|
|
|
|
-ddKt$TRACE -f $LOGDIR/log5 &
|
2015-08-03 16:53:52 +02:00
|
|
|
sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -f $LOGDIR/hostapd &
|
2016-12-26 23:56:46 +01:00
|
|
|
HPID=$!
|
|
|
|
echo $HPID > $LOGDIR/hostapd-test.pid
|
2013-10-30 18:43:59 +01:00
|
|
|
|
2013-09-29 18:14:16 +02:00
|
|
|
if [ -x $HLR_AUC_GW ]; then
|
2014-03-30 15:25:27 +02:00
|
|
|
cp $DIR/auth_serv/hlr_auc_gw.milenage_db $LOGDIR/hlr_auc_gw.milenage_db
|
|
|
|
sudo $HLR_AUC_GW -u -m $LOGDIR/hlr_auc_gw.milenage_db -g $DIR/auth_serv/hlr_auc_gw.gsm > $LOGDIR/hlr_auc_gw &
|
2013-09-29 18:14:16 +02:00
|
|
|
fi
|
|
|
|
|
2015-01-11 19:17:51 +01:00
|
|
|
openssl ocsp -index $DIR/auth_serv/index.txt \
|
|
|
|
-rsigner $DIR/auth_serv/ocsp-responder.pem \
|
|
|
|
-rkey $DIR/auth_serv/ocsp-responder.key \
|
|
|
|
-CA $DIR/auth_serv/ca.pem \
|
|
|
|
-issuer $DIR/auth_serv/ca.pem \
|
|
|
|
-verify_other $DIR/auth_serv/ca.pem -trust_other \
|
|
|
|
-ndays 7 \
|
|
|
|
-reqin $DIR/auth_serv/ocsp-req.der \
|
|
|
|
-respout $LOGDIR/ocsp-server-cache.der > $LOGDIR/ocsp.log 2>&1
|
|
|
|
if [ ! -r $LOGDIR/ocsp-server-cache.der ]; then
|
|
|
|
cp $DIR/auth_serv/ocsp-server-cache.der $LOGDIR/ocsp-server-cache.der
|
|
|
|
fi
|
2015-01-11 22:13:35 +01:00
|
|
|
|
2015-12-22 18:33:18 +01:00
|
|
|
cp $DIR/auth_serv/ocsp-multi-server-cache.der $LOGDIR/ocsp-multi-server-cache.der
|
|
|
|
|
2015-12-16 23:48:59 +01:00
|
|
|
openssl ocsp -index $DIR/auth_serv/index.txt \
|
|
|
|
-rsigner $DIR/auth_serv/ocsp-responder.pem \
|
|
|
|
-rkey $DIR/auth_serv/ocsp-responder.key \
|
|
|
|
-resp_key_id \
|
|
|
|
-CA $DIR/auth_serv/ca.pem \
|
|
|
|
-issuer $DIR/auth_serv/ca.pem \
|
|
|
|
-verify_other $DIR/auth_serv/ca.pem -trust_other \
|
|
|
|
-ndays 7 \
|
|
|
|
-reqin $DIR/auth_serv/ocsp-req.der \
|
|
|
|
-respout $LOGDIR/ocsp-server-cache-key-id.der > $LOGDIR/ocsp.log 2>&1
|
|
|
|
|
2015-01-11 22:13:35 +01:00
|
|
|
for i in unknown revoked; do
|
|
|
|
openssl ocsp -index $DIR/auth_serv/index-$i.txt \
|
|
|
|
-rsigner $DIR/auth_serv/ocsp-responder.pem \
|
|
|
|
-rkey $DIR/auth_serv/ocsp-responder.key \
|
|
|
|
-CA $DIR/auth_serv/ca.pem \
|
|
|
|
-issuer $DIR/auth_serv/ca.pem \
|
|
|
|
-verify_other $DIR/auth_serv/ca.pem -trust_other \
|
|
|
|
-ndays 7 \
|
|
|
|
-reqin $DIR/auth_serv/ocsp-req.der \
|
|
|
|
-respout $LOGDIR/ocsp-server-cache-$i.der >> $LOGDIR/ocsp.log 2>&1
|
|
|
|
done
|
2015-10-10 16:27:42 +02:00
|
|
|
|
|
|
|
openssl ocsp -reqout $LOGDIR/ocsp-req.der -issuer $DIR/auth_serv/ca.pem \
|
2017-12-19 07:40:44 +01:00
|
|
|
-sha256 -serial 0xD8D3E3A6CBE3CD12 -no_nonce >> $LOGDIR/ocsp.log 2>&1
|
2015-10-10 16:27:42 +02:00
|
|
|
for i in "" "-unknown" "-revoked"; do
|
|
|
|
openssl ocsp -index $DIR/auth_serv/index$i.txt \
|
|
|
|
-rsigner $DIR/auth_serv/ca.pem \
|
|
|
|
-rkey $DIR/auth_serv/ca-key.pem \
|
|
|
|
-CA $DIR/auth_serv/ca.pem \
|
|
|
|
-ndays 7 \
|
|
|
|
-reqin $LOGDIR/ocsp-req.der \
|
|
|
|
-resp_no_certs \
|
|
|
|
-respout $LOGDIR/ocsp-resp-ca-signed$i.der >> $LOGDIR/ocsp.log 2>&1
|
|
|
|
done
|
|
|
|
openssl ocsp -index $DIR/auth_serv/index.txt \
|
|
|
|
-rsigner $DIR/auth_serv/server.pem \
|
|
|
|
-rkey $DIR/auth_serv/server.key \
|
|
|
|
-CA $DIR/auth_serv/ca.pem \
|
|
|
|
-ndays 7 \
|
|
|
|
-reqin $LOGDIR/ocsp-req.der \
|
|
|
|
-respout $LOGDIR/ocsp-resp-server-signed.der >> $LOGDIR/ocsp.log 2>&1
|
|
|
|
|
2014-05-11 00:06:00 +02:00
|
|
|
touch $LOGDIR/hostapd.db
|
|
|
|
sudo $HAPD_AS -ddKt $LOGDIR/as.conf $LOGDIR/as2.conf > $LOGDIR/auth_serv &
|
2013-09-29 18:14:16 +02:00
|
|
|
|
2013-08-26 15:47:15 +02:00
|
|
|
# wait for programs to be fully initialized
|
2014-12-22 18:22:42 +01:00
|
|
|
for i in 0 1 2 3 4 5 6 7 8 9; do
|
|
|
|
if [ -e /tmp/wpas-wlan0 ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 0.05
|
|
|
|
done
|
2013-08-26 15:47:15 +02:00
|
|
|
for i in 0 1 2; do
|
|
|
|
for j in `seq 1 10`; do
|
|
|
|
if $WPACLI -g /tmp/wpas-wlan$i ping | grep -q PONG; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ $j = "10" ]; then
|
|
|
|
echo "Could not connect to /tmp/wpas-wlan$i"
|
2013-09-28 17:19:38 +02:00
|
|
|
exit 1
|
2013-08-26 15:47:15 +02:00
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
for j in `seq 1 10`; do
|
|
|
|
if $WPACLI -g /var/run/hostapd-global ping | grep -q PONG; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ $j = "10" ]; then
|
|
|
|
echo "Could not connect to /var/run/hostapd-global"
|
2013-09-28 17:19:38 +02:00
|
|
|
exit 1
|
2013-08-26 15:47:15 +02:00
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
2013-09-28 17:19:38 +02:00
|
|
|
|
2014-12-25 12:30:54 +01:00
|
|
|
for j in `seq 1 10`; do
|
|
|
|
if $HAPDCLI -i as ping | grep -q PONG; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ $j = "10" ]; then
|
|
|
|
echo "Could not connect to hostapd-as-RADIUS-server"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2014-12-22 18:22:42 +01:00
|
|
|
if [ $USER = "0" -o $USER = "root" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 0.75
|
|
|
|
sudo chown -f $USER $LOGDIR/hwsim0.pcapng $LOGDIR/hwsim0 $LOGDIR/log* $LOGDIR/hostapd
|
|
|
|
if [ "x$VALGRIND" = "xy" ]; then
|
|
|
|
sudo chown -f $USER $LOGDIR/*valgrind*
|
|
|
|
fi
|
|
|
|
|
2013-09-28 17:19:38 +02:00
|
|
|
exit 0
|