From da1857777c45d0e69a8f109d2a756e56857a5ebe Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Tue, 11 Feb 2025 09:04:10 -0500 Subject: [PATCH] Starting to have chkspf script working --- Makefile | 2 +- data-tst/spf.tst | 5 ++--- lib/subrou.c | 2 +- shell/test-spf.sh | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) mode change 100644 => 100755 shell/test-spf.sh diff --git a/Makefile b/Makefile index a37a63b..00a84e0 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ clean : #test procedure #-------------------------------------------------------------------- test : clean debug - @ bin/valide data-tst/spf.tst + @ shell/test-spf.sh data-tst/spf.tst #-------------------------------------------------------------------- #Installation procedure diff --git a/data-tst/spf.tst b/data-tst/spf.tst index 15b0e0e..fdf459f 100644 --- a/data-tst/spf.tst +++ b/data-tst/spf.tst @@ -1,9 +1,8 @@ #======================================================== #data to check if SPF are properly seen -chkmx.spf.example.com#NOTE: this test rely on the fact -#"spf.example.com" is accessible via DNS request. +#NOTE: this test rely on the fact +#"spf.example.com" is accessible via a DNS request. #======================================================== -#-------------------------------------------------------- #Checking MX #Acceptable IP number spf_pass chkmx.spf.example.com 127.0.0.255 diff --git a/lib/subrou.c b/lib/subrou.c index 5994aa9..4ff8ccd 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.4.2" -#define RELEASE "34" +#define RELEASE "35" //Public variables PUBLIC int debug=0; //debug level diff --git a/shell/test-spf.sh b/shell/test-spf.sh old mode 100644 new mode 100755 index 7211144..0bfafe7 --- a/shell/test-spf.sh +++ b/shell/test-spf.sh @@ -2,3 +2,25 @@ #--------------------------------------------------------------------- #shell script to test SPF directive #--------------------------------------------------------------------- +while [ $# -gt 0 ] + do + filename=$1 + numline=0 + echo "scanning \"$1\" test file" + cat $1 | while read line + do + numline=$((numline+1)) + data=`echo $line | grep -o '^[^#]*'` + if [ -z "$data" ] ; then + continue; + fi + expect=`echo $data | cut -d ' ' -f1` + domain=`echo $data | cut -d ' ' -f2` + ipnum=`echo $data | cut -d ' ' -f3` + result=`bin/chkspf $domain $ipnum` + if [ "$result" != "$expect" ] ; then + echo "error: line $numline, Expected:=$expect Result:=$result" + fi + done + shift + done -- 2.47.3