@@ -1443,6 +1443,7 @@ fileout() {
14431443
14441444
14451445json_header() {
1446+ local fname_date="$1"
14461447 local fname_prefix
14471448 local filename_provided=false
14481449
@@ -1471,9 +1472,9 @@ json_header() {
14711472 fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
14721473 fi
14731474 if [[ -z "$JSONFILE" ]]; then
1474- JSONFILE="$fname_prefix-$(date +"%Y%m%d-%H%M" .json) "
1475+ JSONFILE="$fname_prefix-${fname_date} .json"
14751476 elif [[ -d "$JSONFILE" ]]; then
1476- JSONFILE="$JSONFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M" .json) "
1477+ JSONFILE="$JSONFILE/${fname_prefix}-${fname_date} .json"
14771478 fi
14781479 # Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
14791480 if "$APPEND" && [[ ! -s "$JSONFILE" ]]; then
@@ -1494,6 +1495,7 @@ json_header() {
14941495
14951496
14961497csv_header() {
1498+ local fname_date="$1"
14971499 local fname_prefix
14981500 local filename_provided=false
14991501
@@ -1519,9 +1521,9 @@ csv_header() {
15191521 fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
15201522 fi
15211523 if [[ -z "$CSVFILE" ]]; then
1522- CSVFILE="${fname_prefix}-$(date +"%Y%m%d-%H%M" .csv) "
1524+ CSVFILE="${fname_prefix}-${fname_date} .csv"
15231525 elif [[ -d "$CSVFILE" ]]; then
1524- CSVFILE="$CSVFILE/${fname_prefix}-$(date +"%Y%m%d-%H%M" .csv) "
1526+ CSVFILE="$CSVFILE/${fname_prefix}-${fname_date} .csv"
15251527 fi
15261528 # Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
15271529 if "$APPEND" && [[ ! -s "$CSVFILE" ]]; then
@@ -1548,6 +1550,7 @@ csv_header() {
15481550################# END JSON file functions. START HTML functions ####################
15491551
15501552html_header() {
1553+ local fname_date="$1"
15511554 local fname_prefix
15521555 local filename_provided=false
15531556
@@ -1576,9 +1579,9 @@ html_header() {
15761579 fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
15771580 fi
15781581 if [[ -z "$HTMLFILE" ]]; then
1579- HTMLFILE="$fname_prefix-$(date +"%Y%m%d-%H%M" .html) "
1582+ HTMLFILE="$fname_prefix-${fname_date} .html"
15801583 elif [[ -d "$HTMLFILE" ]]; then
1581- HTMLFILE="$HTMLFILE/$fname_prefix-$(date +"%Y%m%d-%H%M" .html) "
1584+ HTMLFILE="$HTMLFILE/$fname_prefix-${fname_date} .html"
15821585 fi
15831586 # Silently reset APPEND var if the file doesn't exist as otherwise it won't be created
15841587 if "$APPEND" && [[ ! -s "$HTMLFILE" ]]; then
@@ -1626,8 +1629,9 @@ html_footer() {
16261629################# END HTML file functions ####################
16271630
16281631prepare_logging() {
1629- # arg1: for testing mx records name we put a name of logfile in here, otherwise we get strange file names
1630- local fname_prefix="$1"
1632+ local fname_date="$1"
1633+ # arg2: for testing mx records name we put a name of logfile in here, otherwise we get strange file names
1634+ local fname_prefix="$2"
16311635 local filename_provided=false
16321636
16331637 if [[ -n "$PARENT_LOGFILE" ]]; then
@@ -1644,10 +1648,10 @@ prepare_logging() {
16441648 [[ -z "$fname_prefix" ]] && fname_prefix="${FNAME_PREFIX}${NODE}_p${PORT}"
16451649
16461650 if [[ -z "$LOGFILE" ]]; then
1647- LOGFILE="$fname_prefix-$(date +"%Y%m%d-%H%M" .log) "
1651+ LOGFILE="$fname_prefix-${fname_date} .log"
16481652 elif [[ -d "$LOGFILE" ]]; then
16491653 # actually we were instructed to place all files in a DIR instead of the current working dir
1650- LOGFILE="$LOGFILE/$fname_prefix-$(date +"%Y%m%d-%H%M" .log) "
1654+ LOGFILE="$LOGFILE/$fname_prefix-${fname_date} .log"
16511655 else
16521656 : # just for clarity: a log file was specified, no need to do anything else
16531657 fi
@@ -23098,25 +23102,26 @@ draw_line() {
2309823102
2309923103
2310023104run_mx_all_ips() {
23105+ local fname_date="$1"
2310123106 local mxs mx
2310223107 local mxport
2310323108 local -i ret=0
2310423109 local word=""
2310523110
2310623111 STARTTLS_PROTOCOL="smtp"
2310723112 # test first higher priority servers
23108- mxs=$(get_mx_record "$1 " | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
23113+ mxs=$(get_mx_record "$2 " | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
2310923114 if [[ $CMDLINE_IP == one ]]; then
2311023115 word="as instructed one" # with highest priority
2311123116 mxs=${mxs%% *}
2311223117 else
2311323118 word="the only"
2311423119 fi
23115- mxport=${2 :-25}
23120+ mxport=${3 :-25}
2311623121 if [[ -n "$LOGFILE" ]] || [[ -n "$PARENT_LOGFILE" ]]; then
23117- prepare_logging
23122+ prepare_logging "${fname_date}"
2311823123 else
23119- prepare_logging "${FNAME_PREFIX}mx-$1"
23124+ prepare_logging "${fname_date}" "${ FNAME_PREFIX}mx-$1"
2312023125 fi
2312123126 if [[ -n "$mxs" ]] && [[ "$mxs" != ' ' ]]; then
2312223127 [[ $(count_words "$mxs") -gt 1 ]] && MULTIPLE_CHECKS=true
@@ -24990,22 +24995,23 @@ lets_roll() {
2499024995################# main #################
2499124996
2499224997
24993- RET=0 # this is a global as we can have a function main(), see #705. Should we toss then all local $ret?
24994- ip=""
24998+ RET=0 # this is a global as a function main() is problematic, see #705. Should we toss then all local $ret?
2499524999 stopwatch start
25000+ FNAME_DATE="$(date +"%Y%m%d-%H%M")" # a global var, and a definition via local doesn't work here. Omitting definition above
25001+ IP="" # see previous line, global used only here
2499625002
2499725003 lets_roll init
2499825004 initialize_globals
24999- check_base_requirements # needs to come after $do_html is defined
25005+ check_base_requirements # needs to come after $do_html is defined
2500025006 parse_cmd_line "$@"
2500125007 # CMDLINE_PARSED has been set now. Don't put a function immediately after this which calls fatal().
2500225008 # Rather put it after csv_header below.
2500325009 # html_header() needs to be called early! Otherwise if html_out() is called before html_header() and the
2500425010 # command line contains --htmlfile <htmlfile> or --html, it'll make problems with html output, see #692.
2500525011 # json_header and csv_header could be called later but for context reasons we'll leave it here
25006- html_header
25007- json_header
25008- csv_header
25012+ html_header "${FNAME_DATE}"
25013+ json_header "${FNAME_DATE}"
25014+ csv_header "${FNAME_DATE}"
2500925015 get_install_dir
2501025016 # see #705, we need to source TLS_DATA_FILE here instead of in get_install_dir(), see #705
2501125017 [[ -r "$TLS_DATA_FILE" ]] && . "$TLS_DATA_FILE"
@@ -25030,7 +25036,7 @@ lets_roll() {
2503025036 fileout_banner
2503125037
2503225038 if "$do_mass_testing"; then
25033- prepare_logging
25039+ prepare_logging "${FNAME_DATE}"
2503425040 if [[ "$MASS_TESTING_MODE" == parallel ]]; then
2503525041 run_mass_testing_parallel
2503625042 else
@@ -25043,13 +25049,13 @@ lets_roll() {
2504325049 #TODO: there shouldn't be the need for a special case for --mx, only the ip addresses we would need upfront and the do-parser
2504425050 if "$do_mx_all_ips"; then
2504525051 #FIXME: do we need this really here?
25046- count_do_variables # if we have just 1x "do_*" --> we do a standard run -- otherwise just the one specified
25052+ count_do_variables # if we have just 1x "do_*" --> we do a standard run -- otherwise just the one specified
2504725053 [[ $? -eq 1 ]] && set_scanning_defaults
25048- run_mx_all_ips "${URI}" $PORT # we should reduce run_mx_all_ips to what's necessary as below we have similar code
25054+ run_mx_all_ips "${FNAME_DATE}" "${ URI}" $PORT # we should reduce run_mx_all_ips to what's necessary as below we have similar code
2504925055 exit $?
2505025056 fi
2505125057
25052- [[ -z "$NODE" ]] && parse_hn_port "${URI}" # NODE, URL_PATH, PORT, IPADDRs and IP46ADDR is set now
25058+ [[ -z "$NODE" ]] && parse_hn_port "${URI}" # NODE, URL_PATH, PORT, IPADDRs and IP46ADDR is set now
2505325059 prepare_logging
2505425060
2505525061 if [[ -n "$PROXY" ]] && $DNS_VIA_PROXY; then
@@ -25066,10 +25072,10 @@ lets_roll() {
2506625072 pr_bold "Testing all IPv4 addresses (port $PORT): "
2506725073 fi
2506825074 outln "$IPADDRs"
25069- for ip in $IPADDRs; do
25075+ for IP in $IPADDRs; do
2507025076 draw_line "-" $((TERM_WIDTH * 2 / 3))
2507125077 outln
25072- NODEIP="$ip "
25078+ NODEIP="$IP "
2507325079 lets_roll "${STARTTLS_PROTOCOL}"
2507425080 RET=$((RET + $?)) # RET value per IP address
2507525081 done
0 commit comments